Constructor
Function Usage
Constructs a specified tensor object. The Tensor class is used to describe the information and behavior of a tensor object, including the shape, format, datatype, and tensor data.
Prototype
1 2 3 4 | Tensor() //Default constructor Tensor (const StorageShape &storage_shape, const StorageFormat &storage_format, const TensorPlacement placement, const ge::DataType data_type, TensorAddress addr) Tensor(const StorageShape &storage_shape, const StorageFormat &storage_format, ge::DataType data_type) Tensor(const StorageShape &storage_shape, const StorageFormat &storage_format, const TensorPlacement placement, const ge::DataType data_type, TensorAddress addr, TensorAddrManager manager) |
Parameters
Parameter |
Input/Output |
Description |
||
|---|---|---|---|---|
storage_shape |
Input |
Shape information of a specified tensor. It is of the StorageShape type. |
||
storage_format |
Input |
Format information of a specified tensor. It is of the StorageFormat type. |
||
placement |
Input |
Location of the device where the actual tensor data is stored. It is of the TensorPlacement type. |
||
data_type |
Input |
Data type of a specified tensor. It is of the ge::DataType. |
||
addr |
Input |
Memory address that stores the actual tensor data. It is of the TensorAddress type, which is defined as follows:
|
||
manager |
Input |
Management function of the tensor data. If the value of manager is empty, addr is considered as the tensor data address and the data does not need to be deallocated.
|
Returns
An initialized tensor object
Constraints
The values of the members (such as format and shape) in the tensor must be configured explicitly. Otherwise, the values are undefined.
Examples
1 2 3 4 5 | Tensor tensor{{{8, 3, 224, 224}, {16, 3, 224, 224}}, // shape {ge::FORMAT_ND, ge::FORMAT_FRACTAL_NZ, {}}, // format kFollowing, // placement ge::DT_FLOAT16, //dt nullptr}; |