> This page is for version 5.0 (Latest) (default).
> For other versions, use one of these documentation indexes:
> - 5.0 (Latest) (default): https://docs.nvidia.com/holoscan/sdk-user-guide/5-0-latest/llms.txt
> - ltsb-2.0: https://docs.nvidia.com/holoscan/sdk-user-guide/ltsb-2-0/llms.txt
> - 4.6: https://docs.nvidia.com/holoscan/sdk-user-guide/4-6/llms.txt
> - 4.5: https://docs.nvidia.com/holoscan/sdk-user-guide/4-5/llms.txt
> - 4.4: https://docs.nvidia.com/holoscan/sdk-user-guide/4-4/llms.txt
> - 4.3: https://docs.nvidia.com/holoscan/sdk-user-guide/4-3/llms.txt
> - Archives: https://docs.nvidia.com/holoscan/sdk-user-guide/archives/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/holoscan/sdk-user-guide/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/holoscan/sdk-user-guide/_mcp/server.

# holoscan::DLManagedTensorContext

> Context object holding a versioned DLPack tensor and a reference to its backing memory.

Context object holding a versioned DLPack tensor and a reference to its backing memory.

The [Tensor](../classes/tensor) class wraps this struct. The wrapped tensor is a DLManagedTensorVersioned so the [Tensor](../classes/tensor) can carry DLPack version and flags (e.g. read-only / copied). `memory_reference` keeps the data alive for as long as the context exists; it typically holds a [DLManagedMemoryBuffer](../classes/dlmanagedmemorybuffer) / [DLManagedMemoryBufferVersioned](../classes/dlmanagedmemorybufferversioned) whose destructor invokes the source tensor's DLPack deleter, or a Holoscan-owned stream-aware reference. `dl_shape` / `dl_strides` own the shape/stride arrays the wrapped DLTensor points at. A private control block makes authority and transient read-lease state common to every [Tensor](../classes/tensor) wrapper over this context.

Vendored from nvidia::gxf::DLManagedTensorContext to remove the GXF dependency.

```cpp showLineNumbers={false}
#include <holoscan/dlpack.hpp>
```

---

## Constructors

### DLManagedTensorContext \[#dlmanagedtensorcontext]

```cpp showLineNumbers={false}
HOLOSCAN_CORE_EXPORT holoscan::DLManagedTensorContext::DLManagedTensorContext()
```

Create a context with a private local-writable access-authority control block.

---

## Member variables

| Name               | Type                                           | Description                                                            |
| ------------------ | ---------------------------------------------- | ---------------------------------------------------------------------- |
| `tensor`           | `DLManagedTensorVersioned`                     | The versioned tensor to wrap.                                          |
| `memory_reference` | `std::shared_ptr< TensorMemoryReference >`     | Native Holoscan lifetime/stream hook keeping the backing memory alive. |
| `dl_shape`         | `std::vector< int64_t >`                       | Shape of the DLTensor (owned).                                         |
| `dl_strides`       | `std::vector< int64_t >`                       | Strides of the DLTensor in elements (owned).                           |
| `access_state_`    | `std::shared_ptr< detail::TensorAccessState >` |                                                                        |