CreateConst
Applicability
Product |
Supported or Not |
|---|---|
√ |
|
√ |
|
√ |
|
√ |
|
√ |
Function Usage
Creates a Const operator.
Prototype
- Create a Const operator of the int64 type.
1EsTensorHolder CreateConst(const std::vector<int64_t> &value, const std::vector<int64_t> dims)
- Create a Const operator of the int32 type.
1EsTensorHolder CreateConst(const std::vector<int32_t> &value, const std::vector<int64_t> dims)
- Create a Const operator of the uint64 type.
1EsTensorHolder CreateConst(const std::vector<uint64_t> &value, const std::vector<int64_t> dims)
- Creates a Const operator of the uint32 type.
1EsTensorHolder CreateConst(const std::vector<uint32_t> &value, const std::vector<int64_t> dims)
- Create a Const operator of the float type.
1EsTensorHolder CreateConst(const std::vector<float> &value, const std::vector<int64_t> dims)
- Create a Const operator of a specified type, format, and dimension (using a general template).
1 2
template <typename T> EsTensorHolder CreateConst(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. |
Constraints
None
Examples
- Create a Const operator of the int64 type.
1 2 3 4
EsGraphBuilder builder("test_graph"); std::vector<int64_t> dims = {3}; std::vector<int64_t> vec64 = {1, 2, 3}; auto c1 = builder.CreateConst(vec64, dims);
- Create a Const operator of a specified type, format, and dimension.
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.CreateConst<float>(vecf, dims, ge::DT_FLOAT);
Parent topic: EsGraphBuilder