GetDataTypeLength

Function Usage

Obtains the memory size occupied by the data type.

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

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

Prototype

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

Constraints

None

Examples

1
2
3
4
5
6
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) {
  // ...
}