CreateTensorFromFile
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
√ |
|
√ |
|
√ |
|
√ |
|
√ |
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 tensor of the specified data type and tensor shape from a binary file.
Prototype
1 2 | template <typename T> std::unique_ptr<Tensor> CreateTensorFromFile(const char *data_file_path, const std::vector<int64_t> &dims, DataType dt, Format format = FORMAT_ND); |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
T |
Input |
Tensor data type. |
data_file_path |
Input |
Path of the binary file. |
dims |
Input |
Tensor dimension vector. |
dt |
Input |
Tensor data type. |
format |
Input |
Tensor format. The default value is FORMAT_ND. |
Returns
Parameter |
Type |
Description |
|---|---|---|
- |
std::unique_ptr<Tensor> |
Smart pointer to the created tensor. If the operation fails, nullptr is returned. |
Restrictions
None
Example
1 2 | std::vector<int64_t> dims = {1}; auto tensor = CreateTensorFromFile<int64_t>(file_path.c_str(), dims, ge::DT_INT64, ge::FORMAT_ALL); |
Parent topic: EsGraphBuilder