Constructor and Destructor
Function Usage
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
- Constructor
1 2 3 4
explicit TensorData(TensorAddress addr = nullptr, const TensorAddrManager manager = nullptr) explicit TensorData(TensorAddress addr, const TensorAddrManager manager, size_t size, TensorPlacement placement) TensorData(TensorData &&other) noexcept TensorData(const TensorData &) = delete
- Destructor
1~TensorData
Parameters
Parameter |
Input/Output |
Description |
||
|---|---|---|---|---|
addr |
Input |
Address of the tensor data.
|
||
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.
|
||
size |
Input |
Memory occupied by the tensor data. |
||
placement |
Input |
Location of the device where the tensor data is located. |
Returns
Initialized TensorData object
Constraints
None.
Examples
1 2 | auto addr = reinterpret_cast<void *>(0x10); TensorData td(addr, HostAddrManager, 100U, kOnHost); |