AscendStringToDataType

Function Usage

Converts a DataType string into a DataType value.

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

1
#include "graph/utils/type_utils.h"

Prototype

1
static DataType AscendStringToDataType(const AscendString &str)

Parameters

Parameter

Input/Output

Description

str

Input

DataType string to be converted, which is of the AscendString type.

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.

Constraints

None

Examples

1
2
ge::AscendString type_str("DT_UINT32");
auto data_type = ge::TypeUtils::AscendStringToDataType(type_str); // 8