SerialStringToFormat

Function Usage

Converts a string into a value of the Format type.

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 AscendStringToFormat.

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

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

Prototype

1
static Format SerialStringToFormat(const std::string &str)

Parameters

Parameter

Input/Output

Description

str

Input

Format string to be converted

Returns

If the input is valid, the Format enum value after conversion is returned. For details about the enumeration definition, see Format. If the input is invalid, FORMAT_RESERVED is returned and an error message is printed.

Constraints

None

Examples

1
2
std::string format_str = "NHWC";
auto format = ge::TypeUtils::SerialStringToFormat(format_str); // 1