EsCreateConstV2
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) using an ABI-safe API.
Prototype
1 2 | template <typename T> EsCTensorHolder *EsCreateConstV2(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
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 EsCreateConst.
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::EsCreateConstV2<int64_t>(graph, data.data(), dims.data(), dims.size(), ge::DT_INT64); |