![]() |
Signet Forge 0.1.0
C++20 Parquet library with AI-native extensions
|
DEMO |
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. | |
| BatchTensorBuilder & | add_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< OwnedTensor > | build (TensorDataType output_dtype=TensorDataType::FLOAT32) |
| Build the final batch tensor. | |
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.
|
default |
Default constructor: creates an empty builder with no columns.
|
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.
| name | Human-readable column name (for diagnostics). |
| tensor | View of the column data. |
Definition at line 1038 of file tensor_bridge.hpp.
|
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().
| output_dtype | Desired element type of the output tensor (default: FLOAT32). |
Definition at line 1075 of file tensor_bridge.hpp.
|
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.
|
inlinenoexcept |
Number of feature sources (columns) added.
Definition at line 1060 of file tensor_bridge.hpp.