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 421 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 445 of file TensorCore.h.

445 Mapping map(MapMode mode) const {
446 Mapping mapping;
447 if (map_fn) {
448 mapping = map_fn(mode);
449 } else {
450 mapping.data = data;
451 mapping.size_bytes = size_bytes;
452 }
453 if (!mapping.keepalive) {
454 mapping.keepalive = holder;
455 }
456 return mapping;
457 }

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 428 of file TensorCore.h.

428 void* data =

device

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

Where the buffer is accessible.

Definition at line 424 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 427 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 422 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 431 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 434 of file TensorCore.h.

434 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 432 of file TensorCore.h.

432 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 435 of file TensorCore.h.

435 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 425 of file TensorCore.h.

425 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.