CreateTensorFromFile
Applicability
Product |
Supported or Not |
|---|---|
√ |
|
√ |
|
√ |
|
√ |
|
√ |
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. |
Constraints
None
Examples
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