SerialStringToDataType

Description

Converts a DataType string into a DataType value.

In GCC 5.1 and later versions, libstdc++ changes some APIs of std::string and std::list to better implement C++11 specifications. As a result, the ABI of the old and new versions are incompatible. Therefore, it is recommended that this API should be replaced with AscendStringToDataType.

To use this API, the type_utils.h header file must be included.

#include "graph/utils/type_utils.h"

Prototype

static DataType SerialStringToDataType(const std::string &str)

Parameters

Parameter

Input/Output

Description

str

Input

DataType string to be converted.

Returns

If the input is valid, the DataType enum value after conversion is returned. For details about the enumeration definition, see DataType. If the input is invalid, DT_UNDEFINED is returned and error logs are printed.

Restrictions

None

Example

std::string type_str = "DT_UINT32";
auto data_type = ge::TypeUtils::SerialStringToDataType(type_str); // 8