Skip to main content

TensorBuffer Struct

Storage handle for a tensor — opaque container for one of four backing memory kinds. More...

Declaration

struct simaai::neat::TensorBuffer { ... }

Included Headers

#include <TensorCore.h>

Public Member Functions Index

Mappingmap (MapMode mode) const

Map the buffer for read/write access; returns a scoped Mapping. More...

Public Member Attributes Index

StorageKindkind = StorageKind::Unknown

How the storage was acquired (CPU-owned, external, GstSample, device). More...

Devicedevice {}

Where the buffer is accessible. More...

std::size_tsize_bytes = 0

Total backing-memory size in bytes. More...

std::shared_ptr< void >holder

Lifetime guard (shared_ptr that owns/refcounts the underlying memory). More...

void *data = ...

Optional direct pointer (some storage kinds set this; others rely on map_fn). More...

std::function< Mapping(MapMode)>map_fn

Custom map function (set for non-trivial storage kinds). More...

std::uint64_tsima_mem_target_flags = ...

SIMA memory target flags (advanced; for accelerator-aware allocators). More...

std::uint64_tsima_mem_flags = 0

SIMA memory flags (cache, alignment, etc.). More...

std::vector< Segment >sima_segments

Named segments for multi-region buffers (composite formats, packed outputs). More...

Description

Storage handle for a tensor — opaque container for one of four backing memory kinds.

TensorBuffer is the abstraction over the four StorageKinds. The map_fn callback unifies the access path: regardless of where the bytes live (CPU heap, GStreamer pool, accelerator scratch), map(mode) returns a Mapping you can read or write. The holder shared_ptr keeps the underlying memory alive for the lifetime of the buffer (and any Mapping derived from it).

Multi-segment buffers (sima_segments) carry several named regions in one allocation — used for composite formats like NV12 (Y + UV) and packed multi-tensor MLA outputs.

Definition at line 448 of file TensorCore.h.

Public Member Functions

map()

Mapping simaai::neat::TensorBuffer::map (MapMode mode)
inline

Map the buffer for read/write access; returns a scoped Mapping.

If the storage has a custom map_fn, calls it. Otherwise, returns a Mapping wrapping the bare data pointer. Always sets keepalive to the buffer's holder so the Mapping safely outlives buffer destruction.

Definition at line 472 of file TensorCore.h.

472 Mapping map(MapMode mode) const {
473 Mapping mapping;
474 if (map_fn) {
475 mapping = map_fn(mode);
476 } else {
477 mapping.data = data;
478 mapping.size_bytes = size_bytes;
479 }
480 if (!mapping.keepalive) {
481 mapping.keepalive = holder;
482 }
483 return mapping;
484 }

Public Member Attributes

data

void* simaai::neat::TensorBuffer::data

Optional direct pointer (some storage kinds set this; others rely on map_fn).

Initialiser
= nullptr

Definition at line 455 of file TensorCore.h.

455 void* data =

device

Device simaai::neat::TensorBuffer::device {}

Where the buffer is accessible.

Definition at line 451 of file TensorCore.h.

holder

std::shared_ptr<void> simaai::neat::TensorBuffer::holder

Lifetime guard (shared_ptr that owns/refcounts the underlying memory).

Definition at line 454 of file TensorCore.h.

kind

StorageKind simaai::neat::TensorBuffer::kind = StorageKind::Unknown

How the storage was acquired (CPU-owned, external, GstSample, device).

Definition at line 449 of file TensorCore.h.

map_fn

std::function<Mapping(MapMode)> simaai::neat::TensorBuffer::map_fn

Custom map function (set for non-trivial storage kinds).

Definition at line 458 of file TensorCore.h.

sima_mem_flags

std::uint64_t simaai::neat::TensorBuffer::sima_mem_flags = 0

SIMA memory flags (cache, alignment, etc.).

Definition at line 461 of file TensorCore.h.

461 std::uint64_t sima_mem_flags = 0;

sima_mem_target_flags

std::uint64_t simaai::neat::TensorBuffer::sima_mem_target_flags

SIMA memory target flags (advanced; for accelerator-aware allocators).

Initialiser
= 0

Definition at line 459 of file TensorCore.h.

459 std::uint64_t sima_mem_target_flags =

sima_segments

std::vector<Segment> simaai::neat::TensorBuffer::sima_segments

Named segments for multi-region buffers (composite formats, packed outputs).

Definition at line 462 of file TensorCore.h.

462 std::vector<Segment> sima_segments;

size_bytes

std::size_t simaai::neat::TensorBuffer::size_bytes = 0

Total backing-memory size in bytes.

Definition at line 452 of file TensorCore.h.

452 std::size_t size_bytes = 0;

The documentation for this struct was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.