Signet Forge 0.1.0
C++20 Parquet library with AI-native extensions
DEMO
Loading...
Searching...
No Matches
signet::forge::OnnxTensorInfo Struct Reference

Contains all information needed to create an OrtValue externally. More...

#include <onnx_bridge.hpp>

Public Member Functions

bool is_valid () const
 Check whether this info is ready to be used with OrtApi::CreateTensorWithDataAsOrtValue.
 

Public Attributes

void * data = nullptr
 Pointer to contiguous tensor data (non-owning unless is_owner)
 
std::vector< int64_t > shape
 ONNX shape dimensions (e.g. {batch, features})
 
OnnxTensorType element_type = OnnxTensorType::UNDEFINED
 ONNX element data type.
 
size_t byte_size = 0
 Total data size in bytes (product of shape * element size)
 
bool is_owner = false
 If true, the data was allocated by the bridge and the caller must free it.
 

Detailed Description

Contains all information needed to create an OrtValue externally.

This struct aggregates the data pointer, shape, element type, and byte size that OrtApi::CreateTensorWithDataAsOrtValue requires. No ONNX Runtime headers are needed to populate or consume this struct.

auto info = *prepare_for_onnx(tensor);
OrtValue* ort_val = nullptr;
OrtMemoryInfo* mem_info = nullptr;
ort_api->CreateCpuMemoryInfo(OrtArenaAllocator, OrtMemTypeDefault, &mem_info);
ort_api->CreateTensorWithDataAsOrtValue(
mem_info,
info.data,
info.byte_size,
info.shape.data(),
info.shape.size(),
static_cast<ONNXTensorElementDataType>(info.element_type),
&ort_val);
expected< OnnxTensorInfo > prepare_for_onnx(const TensorView &tensor)
Prepare a TensorView for ONNX Runtime consumption (zero-copy).
See also
prepare_for_onnx, OnnxInputSet

Definition at line 138 of file onnx_bridge.hpp.

Member Function Documentation

◆ is_valid()

bool signet::forge::OnnxTensorInfo::is_valid ( ) const
inline

Check whether this info is ready to be used with OrtApi::CreateTensorWithDataAsOrtValue.

Returns
true if data is non-null, byte_size > 0, shape is non-empty, and element_type is not UNDEFINED.

Definition at line 150 of file onnx_bridge.hpp.

Member Data Documentation

◆ byte_size

size_t signet::forge::OnnxTensorInfo::byte_size = 0

Total data size in bytes (product of shape * element size)

Definition at line 142 of file onnx_bridge.hpp.

◆ data

void* signet::forge::OnnxTensorInfo::data = nullptr

Pointer to contiguous tensor data (non-owning unless is_owner)

Definition at line 139 of file onnx_bridge.hpp.

◆ element_type

OnnxTensorType signet::forge::OnnxTensorInfo::element_type = OnnxTensorType::UNDEFINED

ONNX element data type.

Definition at line 141 of file onnx_bridge.hpp.

◆ is_owner

bool signet::forge::OnnxTensorInfo::is_owner = false

If true, the data was allocated by the bridge and the caller must free it.

Definition at line 143 of file onnx_bridge.hpp.

◆ shape

std::vector<int64_t> signet::forge::OnnxTensorInfo::shape

ONNX shape dimensions (e.g. {batch, features})

Definition at line 140 of file onnx_bridge.hpp.


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