Class GXFTensor
Defined in File gxf_tensor.hpp
Base Type
public nvidia::gxf::Tensor
-
class GXFTensor : public nvidia::gxf::Tensor
Class to wrap GXF Tensor holding DLPack tensor structure.
This class inherits nvidia::gxf::Tensor and is used with DLManagedTensorCtx class to wrap the GXF Tensor.
Public Functions
- GXFTensor() = default
Construct a new GXFTensor object.
- Parameters
dl_ctx – DLManagedTensorCtx object to wrap.
-
explicit GXFTensor(nvidia::gxf::Tensor &tensor, int64_t id = 0)
Construct a new GXFTensor object from a GXF Tensor.
This constructor wraps a GXF Tensor object. When the GXF Tensor object is modified to point to a shared memory buffer, updates should be protected using a mutex. To mitigate thread contention when different threads access different tensors, this method uses hash-selected mutexes.
A set of mutexes is allocated in a static array. To select which mutex to lock, this method uses a simple hash function based on the provided ID. The selected mutex ensures safe access to the Tensor’s data pointer across multiple threads.
For the ID (
id
), the GXF component’s ID can be used to indicate a specific GXF Tensor object. If no ID is provided, the mutex associated with ID 0 is used. If the ID is -1, no mutex is utilized.
-
DLDevice device() const
Get DLDevice object from the GXF Tensor.
- Returns
DLDevice object.
-
DLDataType dtype() const
Get DLDataType object from the GXF Tensor.
- Returns
DLDataType object.
-
std::shared_ptr<holoscan::Tensor> as_tensor()
Convert GXF Tensor to Holoscan Tensor.
- Returns
holoscan::Tensor object converted from GXF Tensor.
-
inline std::shared_ptr<DLManagedTensorCtx> &dl_ctx()
Get the internal DLManagedTensorCtx of the GXFTensor.
- Returns
A shared pointer to the Tensor’s DLManagedTensorCtx.
Public Static Functions
Protected Attributes
- std::shared_ptr<DLManagedTensorCtx> dl_ctx_