110 "OnnxTensorType has no Signet TensorDataType equivalent"};
151 return data !=
nullptr
179 "cannot prepare invalid tensor for ONNX"};
184 "non-contiguous tensors cannot be exported to ONNX; "
185 "call clone() first to produce a contiguous copy"};
192 "ONNX tensor dimensions must be positive"};
200 info.
data =
const_cast<void*
>(tensor.
data());
208 "tensor dtype maps to UNDEFINED ONNX type"};
245 for (
const auto& t :
tensors) {
246 if (!t.is_valid())
return false;
265 const std::vector<std::pair<std::string, TensorView>>& inputs)
267 if (inputs.empty()) {
269 "cannot prepare empty input set for ONNX"};
273 result.
names.reserve(inputs.size());
274 result.
tensors.reserve(inputs.size());
276 for (
const auto& [name, tensor] : inputs) {
280 "failed to prepare ONNX input '" + name +
"': "
281 + info.error().message};
283 result.
names.push_back(name);
284 result.
tensors.push_back(std::move(*info));
315 default:
return "UNKNOWN";
An owning tensor that manages its own memory via a std::vector<uint8_t> buffer.
TensorView view()
Get a mutable non-owning view.
A lightweight, non-owning view into a contiguous block of typed memory, interpreted as a multi-dimens...
bool is_valid() const noexcept
True if the view points to valid data.
bool is_contiguous() const noexcept
True if the data is densely packed (no stride gaps).
size_t byte_size() const noexcept
Total byte size of the tensor data (num_elements * element_size).
const TensorShape & shape() const noexcept
The shape of this tensor view.
TensorDataType dtype() const noexcept
The element data type.
void * data() noexcept
Raw mutable pointer to the underlying data buffer.
A lightweight result type that holds either a success value of type T or an Error.
expected< OnnxTensorInfo > prepare_for_onnx(const TensorView &tensor)
Prepare a TensorView for ONNX Runtime consumption (zero-copy).
const char * onnx_type_name(OnnxTensorType t)
Return a human-readable string for an OnnxTensorType value.
OnnxTensorType
ONNX tensor element data types, mirroring OrtTensorElementDataType.
@ UNDEFINED
No type (invalid / uninitialized)
@ UINT32
32-bit unsigned integer
@ UINT16
16-bit unsigned integer
@ INT64
64-bit signed integer
@ INT16
16-bit signed integer
@ STRING
Variable-length string.
@ INT32
32-bit signed integer
@ UINT64
64-bit unsigned integer
@ BFLOAT16
Brain floating-point (bfloat16)
@ FLOAT16
16-bit IEEE float (float16)
@ FLOAT
32-bit IEEE float (float32)
@ UINT8
8-bit unsigned integer
@ INT8
8-bit signed integer
@ DOUBLE
64-bit IEEE float (float64)
OnnxTensorType to_onnx_type(TensorDataType dtype)
Convert a Signet TensorDataType to the corresponding OnnxTensorType.
expected< TensorDataType > from_onnx_type(OnnxTensorType ort_type)
Convert an OnnxTensorType back to a Signet TensorDataType.
@ UNSUPPORTED_TYPE
The file contains a Parquet physical or logical type that is not implemented.
@ INTERNAL_ERROR
An unexpected internal error that does not fit any other category.
@ INVALID_ARGUMENT
A caller-supplied argument is outside the valid range or violates a precondition.
expected< OnnxInputSet > prepare_inputs_for_onnx(const std::vector< std::pair< std::string, TensorView > > &inputs)
Prepare a batch of named TensorViews for ONNX Runtime inference.
TensorDataType
Element data type for tensor storage, mapping to ONNX/PyTorch/TF type enums.
@ FLOAT64
IEEE 754 double-precision (8 bytes)
@ INT64
Signed 64-bit integer.
@ INT16
Signed 16-bit integer.
@ INT32
Signed 32-bit integer.
@ FLOAT32
IEEE 754 single-precision (4 bytes)
@ FLOAT16
IEEE 754 half-precision (2 bytes)
@ UINT8
Unsigned 8-bit integer.
@ INT8
Signed 8-bit integer.
Lightweight error value carrying an ErrorCode and a human-readable message.
ErrorCode code
The machine-readable error category.
Contains all information needed to create an OrtValue externally.
bool is_valid() const
Check whether this info is ready to be used with OrtApi::CreateTensorWithDataAsOrtValue.
OnnxTensorType element_type
ONNX element data type.
size_t byte_size
Total data size in bytes (product of shape * element size)
bool is_owner
If true, the data was allocated by the bridge and the caller must free it.
void * data
Pointer to contiguous tensor data (non-owning unless is_owner)
std::vector< int64_t > shape
ONNX shape dimensions (e.g. {batch, features})
std::vector< int64_t > dims
Dimension sizes (e.g. {32, 768} for a 32x768 matrix)
Zero-copy tensor bridge: maps Parquet column data directly into ML-framework-compatible tensor views ...