GetDataTypeLength

Description

Obtains the memory size occupied by the data type.

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

#include "graph/utils/type_utils.h"

Prototype

static bool GetDataTypeLength(const ge::DataType data_type, uint32_t &length)

Parameters

Parameter

Input/Output

Description

data_type

Input

Data type.

length

Output

Memory size occupied by the data type, in bytes.

Returns

If the size is obtained successfully, true is returned. If data_type is not supported, false is returned.

Restrictions

None

Example

uint32_t type_length;
ge::DataType data_type = ge::DT_INT8;
const bool ret = ge::TypeUtils::GetDataTypeLength(data_type, type_length); // type_length 1
if (!ret) {
  // ...
}