Constructor and Destructor
Description
Constructs a TensorData.
Method 1: The address of the tensor data and the manager used to manage the tensor data are specified.
Method 2: The address of the tensor data, the manager used to manage the tensor data, the memory occupied by the tensor data, and the location (host or device) of the tensor data are specified.
Method 3: move constructor.
Note: If the manager is nullptr, addr is the address of the tensor data. Otherwise, the address of the tensor data is provided by the manager.
Prototype
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
addr |
Input |
Address of the tensor data. using TensorAddress = void *; |
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. using TensorAddrManager = ge::graphStatus (*)(TensorAddress addr, TensorOperateType operate_type, void **out);
enum TensorOperateType {
kGetTensorAddress, ///< Obtain the address of the tensor.
kFreeTensor, ///< Free the tensor.
kPlusShareCount, ///< Share the tensor.
kTensorOperateType
};
|
size |
Input |
Memory occupied by the tensor data. |
placement |
Input |
Location of the device where the tensor data is located. |
Returns
Initialized TensorData object
Restrictions
None
Example
auto addr = reinterpret_cast<void *>(0x10); TensorData td(addr, HostAddrManager, 100U, kOnHost);