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

Builds a single contiguous 2D tensor from multiple column tensors, suitable for passing to an ML inference engine (ONNX Runtime, etc.). More...

#include <tensor_bridge.hpp>

Public Member Functions

 BatchTensorBuilder ()=default
 Default constructor: creates an empty builder with no columns.
 
BatchTensorBuilderadd_column (const std::string &name, const TensorView &tensor)
 Add a column tensor as a feature source.
 
TensorShape expected_shape () const
 Compute the expected output shape based on currently added columns.
 
size_t num_features () const noexcept
 Number of feature sources (columns) added.
 
expected< OwnedTensorbuild (TensorDataType output_dtype=TensorDataType::FLOAT32)
 Build the final batch tensor.
 

Detailed Description

Builds a single contiguous 2D tensor from multiple column tensors, suitable for passing to an ML inference engine (ONNX Runtime, etc.).

Each added column contributes one or more feature columns to the output. For 1D numeric columns (shape {N}), each adds 1 column to the batch. For 2D vector columns (shape {N, D}), each adds D columns.

All input columns must have the same number of rows. The output is a single {rows, total_cols} tensor with the requested element type.

Usage: BatchTensorBuilder builder; builder.add_column("price", price_view); // {1000} builder.add_column("volume", volume_view); // {1000} builder.add_column("embedding", embed_view); // {1000, 128} auto batch = builder.build(TensorDataType::FLOAT32); // batch.shape() == {1000, 130}

Definition at line 1024 of file tensor_bridge.hpp.

Constructor & Destructor Documentation

◆ BatchTensorBuilder()

signet::forge::BatchTensorBuilder::BatchTensorBuilder ( )
default

Default constructor: creates an empty builder with no columns.

Member Function Documentation

◆ add_column()

BatchTensorBuilder & signet::forge::BatchTensorBuilder::add_column ( const std::string &  name,
const TensorView tensor 
)
inline

Add a column tensor as a feature source.

For 1D tensors: contributes 1 feature column per row. For 2D tensors: contributes dims[1] feature columns per row. Higher-dimensional tensors are not supported.

Parameters
nameHuman-readable column name (for diagnostics).
tensorView of the column data.
Returns
Reference to this builder for chaining.

Definition at line 1038 of file tensor_bridge.hpp.

◆ build()

expected< OwnedTensor > signet::forge::BatchTensorBuilder::build ( TensorDataType  output_dtype = TensorDataType::FLOAT32)
inline

Build the final batch tensor.

Allocates a single contiguous output tensor of shape {rows, total_cols} and copies each column's data into the appropriate column positions.

Currently requires all input columns to be contiguous. Mixed source types are handled via ColumnToTensor::cast().

Parameters
output_dtypeDesired element type of the output tensor (default: FLOAT32).
Returns
OwnedTensor on success, Error on failure.

Definition at line 1075 of file tensor_bridge.hpp.

◆ expected_shape()

TensorShape signet::forge::BatchTensorBuilder::expected_shape ( ) const
inline

Compute the expected output shape based on currently added columns.

Returns {rows, total_cols} where rows is taken from the first column and total_cols is the sum of per-column widths.

Definition at line 1048 of file tensor_bridge.hpp.

◆ num_features()

size_t signet::forge::BatchTensorBuilder::num_features ( ) const
inlinenoexcept

Number of feature sources (columns) added.

Definition at line 1060 of file tensor_bridge.hpp.


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