Class GXFTensor

Clara Holoscan v0.4.0

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

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.


tensorTensor to wrap.

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

Construct a new GXFTensor object.


dl_ctxDLManagedTensorCtx object to wrap.

DLDevice device() const

Get DLDevice object from the GXF Tensor.


DLDevice object.

DLDataType dtype() const

Get DLDataType object from the GXF Tensor.


DLDataType object.

std::shared_ptr<holoscan::Tensor> as_tensor()

Convert GXF Tensor to Holoscan Tensor.


holoscan::Tensor object converted from GXF Tensor.

inline std::shared_ptr<DLManagedTensorCtx> &dl_ctx()

Get the internal DLManagedTensorCtx of the GXFTensor.


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.


tensor – Holoscan Tensor object to convert.


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, NVIDIA. Last updated on Jun 28, 2023.