37 #include <unordered_map>
384 std::shared_ptr<NpuTensorPriv> priv_;
This class represents a tensor in the VART API.
Definition: vart_npu_tensor.hpp:225
const void * get_buffer() const
Retrieves a pointer to the tensor's buffer.
friend class NpuTensorPrivAccess
Definition: vart_npu_tensor.hpp:383
void * get_buffer()
Retrieves a pointer to the tensor's buffer.
int export_buffer() const
Export the tensor buffer as a dma-buf file descriptor.
NpuTensor(const NpuTensorInfo &info, const void *buffer, MemoryType mem_type)
Construct a NpuTensor from a user-supplied constant buffer.
NpuTensor(const NpuTensorInfo &info, void *buffer, MemoryType mem_type)
Construct a NpuTensor from a user-supplied buffer.
NpuTensor()
Default-constructs an empty NpuTensor with no buffer or metadata.
MemoryType get_memory_type() const
Get the memory type of the tensor.
uint64_t get_physical_address() const
Returns the physical address of the tensor buffer.
void print_info() const
Prints the metadata of the tensor.
const void * get_virtual_address() const
Returns the virtual address of the tensor buffer.
void * get_virtual_address()
Returns the virtual address of the tensor buffer.
const NpuTensorInfo & get_info() const
Returns the NpuTensorInfo metadata of the tensor.
void sync_buffer() const
Synchronizes the tensor buffer between CPU and AIE.
VART (Vitis AI Runtime) ML inference API namespace.
MemoryType
Enumerates the various memory types utilized for tensors in the VART API.
Definition: vart_npu_tensor.hpp:116
@ USER_POINTER_NON_CMA
User-provided pointer without contiguous memory guarantee (e.g. new, malloc).
@ DMA_FD
File descriptor used for Direct Memory Access (DMA).
@ UNKNOWN
Memory type is not specified or recognized.
@ XRT_BO
Buffer object associated with XRT.
@ USER_POINTER_CMA
User-provided pointer to a contiguous physical memory block.
TensorType
Specifies the tensor types supported in the VART API.
Definition: vart_npu_tensor.hpp:146
@ CPU
Tensor metadata from the ONNX model, as defined for standard CPU execution.
@ HW
AMD hardware-specific tensor metadata, formatted for direct execution on AMD AI engines.
DataType
Enumerates the supported data types for tensors in the VART API.
Definition: vart_npu_tensor.hpp:62
@ UINT32
32-bit unsigned integer.
@ UINT16
16-bit unsigned integer.
@ INT64
64-bit signed integer.
@ INT16
16-bit signed integer.
@ INT32
32-bit signed integer.
@ UNKNOWN
Unknown data type.
@ UINT64
64-bit unsigned integer.
@ FLOAT32
32-bit floating point.
@ FP16
16-bit floating point.
@ UINT8
8-bit unsigned integer.
@ INT8
8-bit signed integer.
@ BF16
16-bit Brain Floating Point format.
TensorDirection
Enumerates the supported tensor directions in the VART API.
Definition: vart_npu_tensor.hpp:131
@ OUTPUT
Output tensor direction.
@ INPUT
Input tensor direction.
MemoryLayout
Enumerates the supported memory layouts for tensors in the VART API.
Definition: vart_npu_tensor.hpp:89
@ NWC
Model batch, Width, Channels (packed format).
@ NCH
Model batch, Channels (packed format), Height.
@ NHWC8
Model batch, Height, Width, Channel groups of 8.
@ HCWNC4
Height, Channels / 4, Width, N = 1, Channel groups of 4.
@ NC4HW4
Model batch, Channels / 4, Height, Width, Channel groups of 4.
@ NC8HW8
Model batch, Channels / 8, Height, Width, Channel groups of 8.
@ NHWC4
Model batch, Height, Width, Channel groups of 4 (e.g. RGBA).
@ HCWNC16
Height, Channels / 16, Width, N = 1, Channel groups of 16.
@ NHC
Model batch, Height, Channels (packed format).
@ UNKNOWN
Unknown memory layout.
@ NCHW
Model batch, Channels, Height, Width (planar format).
@ HCWNC8
Height, Channels / 8, Width, N = 1, Channel groups of 8.
@ NC
Model batch, Channels (packed format).
@ NHW
Model batch, Height, Width.
@ NHW16C4WC
Model batch, Height, Width / 16, Channels / 4, Width groups of 16, Channel groups of 4.
@ GENERIC
Generic layout. See NpuTensorInfo::memory_layout_order for more info.
@ NHW16WC4C
Model batch, Height, Width / 16, Width groups of 16, Channels / 4, Channel groups of 4.
@ NHWC
Model batch, Height, Width, Channels (packed format).
Metadata structure describing a tensor used in VART.
Definition: vart_npu_tensor.hpp:195
MemoryLayout memory_layout
Definition: vart_npu_tensor.hpp:200
std::vector< uint32_t > shape
Definition: vart_npu_tensor.hpp:204
TensorType tensor_type
Definition: vart_npu_tensor.hpp:199
size_t size
Definition: vart_npu_tensor.hpp:202
std::vector< uint32_t > memory_layout_order
Definition: vart_npu_tensor.hpp:201
TensorDirection direction
Definition: vart_npu_tensor.hpp:198
std::vector< uint32_t > strides
Definition: vart_npu_tensor.hpp:205
std::string name
Definition: vart_npu_tensor.hpp:196
size_t size_in_bytes
Definition: vart_npu_tensor.hpp:203
DataType data_type
Definition: vart_npu_tensor.hpp:197