MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Kakshya::TensorImport Class Reference

Owns a DLPack tensor received from another library. More...

#include <TensorDLPack.hpp>

Collaboration diagram for MayaFlux::Kakshya::TensorImport:

Public Member Functions

std::optional< TensorAccess > access () const
 Borrow the producer's memory.
std::optional< TensorData > copy () const
 Dense owning copy, independent of the producer.
TensorImport & operator= (const TensorImport &)=delete
TensorImport & operator= (TensorImport &&other) noexcept
bool read_only () const noexcept
 Whether the producer marked the tensor read-only.
const TensorSpec & spec () const noexcept
 Layout described by the producer.
 TensorImport (const TensorImport &)=delete
 TensorImport (TensorImport &&other) noexcept
 ~TensorImport ()

Static Public Member Functions

static std::optional< TensorImport > take (DLManagedTensor *managed)
 Take ownership of a legacy, unversioned DLPack tensor.
static std::optional< TensorImport > take (DLManagedTensorVersioned *managed)
 Take ownership of a versioned DLPack tensor.

Private Member Functions

 TensorImport (TensorSpec spec, const std::byte *data, size_t size, bool read_only, std::function< void()> release) noexcept

Private Attributes

const std::byte * m_data {}
bool m_read_only {}
std::function< void()> m_release
size_t m_size {}
TensorSpec m_spec

Detailed Description

Owns a DLPack tensor received from another library.

Takes the producer's tensor, validates it, and exposes it as a TensorAccess without copying. The producer's deleter runs when this object is destroyed or when the tensor is rejected.

Usage:

auto imported = TensorImport::take(managed);
auto view = imported->access();
auto owned = imported->copy();
static std::optional< TensorImport > take(DLManagedTensorVersioned *managed)
Take ownership of a versioned DLPack tensor.
Note
The data is borrowed from the producer. Its extent is derived from the shape, strides and offset, which cannot be checked against the producer's allocation.

Definition at line 40 of file TensorDLPack.hpp.


The documentation for this class was generated from the following files: