CreateConstV2

Applicable Products

All processors

Header File/Library File

  • Header file: #include <ge/es_graph_builder.h>
  • Library files: libeager_style_graph_builder_base.so and libeager_style_graph_builder_base_static.a

Function Usage

Creates a Const operator using an ABI-safe API.

Prototype

1
2
template <typename T> 
EsTensorHolder CreateConstV2(const std::vector<T> &value, const std::vector<int64_t> &dims, ge::DataType dt, ge::Format format = FORMAT_ND)

Parameters

Parameter

Input/Output

Description

value

Input

Tensor data vector.

dims

Input

Tensor dimension vector.

T

Input

Tensor data type.

dt

Input

Tensor data type.

format

Input

Tensor format. The default value is FORMAT_ND.

Returns

Parameter

Type

Description

-

EsTensorHolder

Tensor holder operator of the created Const. If the operation fails, an invalid EsTensorHolder is returned.

Restrictions

This API uses the CompliantNodeBuilder V2 API to construct a Const node, avoiding the risk of std::string transfer across the C++ ABIs in the old IR definition structure.

To use this API, the runtime software package must support CompliantNodeBuilder V2 symbols. To be compatible with old software packages that do not contain V2 symbols, use CreateConst.

Example

1
2
3
4
EsGraphBuilder builder("test_graph");
std::vector<float> vecf = {1.1, 2.0, 3.2, 4.4};
std::vector<int64_t> dims = {4};
auto c1 = builder.CreateConstV2<float>(vecf, dims, ge::DT_FLOAT);