Class GXFTensor

Base Type

  • public nvidia::gxf::Tensor

class GXFTensor : public nvidia::gxf::Tensor

Class to wrap GXF Tensor holding DLPack tensor structure.

Public Functions

GXFTensor() = default

explicit GXFTensor(nvidia::gxf::Tensor &tensor)

Construct a new GXFTensor object.

This constructor is used to wrap a GXF Tensor object. The given nvidia::gxf::Tensor object is modified to point to the shared memory buffer so that the memory buffer is shared between the GXF’s Tensor object and the GXFTensor object.

Parameters

tensorTensor to wrap.

explicit GXFTensor(std::shared_ptr<DLManagedTensorCtx> &dl_ctx)

Construct a new GXFTensor object.

Parameters

dl_ctxDLManagedTensorCtx object to wrap.

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

static std::shared_ptr<GXFTensor> from_tensor(std::shared_ptr<holoscan::Tensor> tensor)

Create GXF Tensor object from Holoscan Tensor.

Parameters

tensor – Holoscan Tensor object to convert.

Returns

The shared pointer object to the GXFTensor object that is created from the given Holoscan Tensor object.

Protected Attributes

std::shared_ptr<DLManagedTensorCtx> dl_ctx_

© Copyright 2022-2023, NVIDIA. Last updated on Feb 9, 2024.