EsCreateConst

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 of a specified type (original pointer version).

Prototype

1
2
template <typename T>
EsCTensorHolder *EsCreateConst(EsCGraphBuilder *graph, const T *value, const int64_t *dims, int64_t dim_num, ge::DataType dt, ge::Format format = FORMAT_ND) 

Parameters

Parameter

Input/Output

Description

T

Input

Tensor data type.

graph

Input

Pointer to the graph builder.

value

Input

Pointer to the tensor data.

dims

Input

Pointer to the tensor dimension array.

dim_num

Input

Number of dimensions.

dt

Input

Tensor data type.

format

Input

Tensor format. The default value is FORMAT_ND.

Returns

Parameter

Type

Description

-

EsCTensorHolder *

Tensor holder operator of the created Const. If the operation fails, nullptr is returned.

Restrictions

EsCreateConst uses the IrDefOutputs or IrDefAttrs API internally. The IR definition structure contains the std::string field, and the compatibility between different C++ ABI configurations is not guaranteed. This API is reserved for compatibility with old GE packages.

If ABI security is required, use EsCreateConstV2 (see EsCreateConstV2). To use EsCreateConstV2, the runtime software package must support the CompliantNodeBuilder V2 API.

Example

1
2
3
4
EsCGraphBuilder *graph = EsCreateGraphBuilder("graph_name");
std::vector<int64_t> data = {1, 2, 3};
std::vector<int64_t> dims = {3};
auto const_tensor = ge::es::EsCreateConst<int64_t>(graph, data.data(), dims.data(), dims.size(), ge::DT_INT64);