Tensor
Function Usage
Constructor of the Tensor class.
Prototype
Tensor() // Default constructor. When the construction fails, the "std::runtime_error" exception occurs.
Tensor(const std::vector<uint32_t> &shape, const MxBase::TensorDType &dataType, const int32_t &deviceId = -1) // No memory is transferred. It can be used together with TensorMalloc to allocate memory, and the allocated memory does not need to be managed or destroyed by users. When the construction fails, the "std::runtime_error" exception occurs.
Tensor(void* usrData,const std::vector<uint32_t> &shape, const MxBase::TensorDType &dataType, const int32_t &deviceId = -1) // If the user-constructed memory is transferred, users need to allocate and destroy the memory. When the construction fails, the "std::runtime_error" exception occurs.
Parameter Description
Parameter |
Input/Output |
Description |
|---|---|---|
usrData |
Input |
Input memory constructed by the user. The memory is allocated and destroyed by the user. |
shape |
Input |
Tensor shape |
dataType |
Input |
Tensor data type. For details, see TensorDType. |
deviceId |
Input |
ID of the device where the tensor is located. The default value is -1, indicating that the tensor is on the host. |
Parent topic: Tensor