![]() |
Signet Forge 0.1.0
C++20 Parquet library with AI-native extensions
|
DEMO |
A lightweight, non-owning view into a contiguous block of typed memory, interpreted as a multi-dimensional tensor. More...
#include <tensor_bridge.hpp>
Public Member Functions | |
| TensorView ()=default | |
| Default constructor: creates an invalid (null) view. | |
| TensorView (void *data, TensorShape shape, TensorDataType dtype, size_t byte_stride=0) noexcept | |
| Construct a view over existing memory. | |
| TensorView (const void *data, TensorShape shape, TensorDataType dtype, size_t byte_stride=0) noexcept | |
| Construct a const view (stores as void* internally, constness enforced by the const overloads of data()/typed_data()). | |
| void * | data () noexcept |
| Raw mutable pointer to the underlying data buffer. | |
| const void * | data () const noexcept |
| Raw const pointer to the underlying data buffer. | |
| template<typename T > | |
| T * | typed_data () noexcept |
| Reinterpret the data pointer as a typed mutable pointer. | |
| template<typename T > | |
| const T * | typed_data () const noexcept |
| Reinterpret the data pointer as a typed const pointer. | |
| const TensorShape & | shape () const noexcept |
| The shape of this tensor view. | |
| TensorDataType | dtype () const noexcept |
| The element data type. | |
| size_t | element_size () const noexcept |
| Bytes per element. | |
| int64_t | num_elements () const noexcept |
| Total number of elements. | |
| size_t | byte_size () const noexcept |
| Total byte size of the tensor data (num_elements * element_size). | |
| size_t | effective_byte_stride () const noexcept |
| Effective stride in bytes along the first dimension. | |
| template<typename T > | |
| T & | at (int64_t i) |
| Access a single element in a 1D tensor (mutable). | |
| template<typename T > | |
| const T & | at (int64_t i) const |
| Access a single element in a 1D tensor (const). | |
| template<typename T > | |
| T & | at (int64_t row, int64_t col) |
| Access a single element in a 2D tensor by (row, col) (mutable). | |
| template<typename T > | |
| const T & | at (int64_t row, int64_t col) const |
| Access a single element in a 2D tensor by (row, col) (const). | |
| bool | is_contiguous () const noexcept |
| True if the data is densely packed (no stride gaps). | |
| bool | is_valid () const noexcept |
| True if the view points to valid data. | |
| TensorView | slice (int64_t start, int64_t count) const |
| Slice along the first dimension: returns a view over rows [start, start+count). | |
| expected< TensorView > | reshape (TensorShape new_shape) const |
| Reshape the view to a new shape with the same total number of elements. | |
A lightweight, non-owning view into a contiguous block of typed memory, interpreted as a multi-dimensional tensor.
This is the core zero-copy type: wrapping existing Parquet column data as a TensorView involves no allocation or data movement. The caller is responsible for ensuring the underlying data remains valid for the lifetime of the view.
The optional byte_stride parameter supports non-contiguous views (e.g. a single column extracted from a row-major matrix). When byte_stride is 0 (the default), the data is assumed to be densely packed.
Definition at line 274 of file tensor_bridge.hpp.
|
default |
Default constructor: creates an invalid (null) view.
|
inlinenoexcept |
Construct a view over existing memory.
| data | Pointer to the start of the data buffer. |
| shape | Shape of the tensor. |
| dtype | Element data type. |
| byte_stride | Stride in bytes between consecutive elements along the first axis. 0 means contiguous (dense packing). |
Definition at line 286 of file tensor_bridge.hpp.
|
inlinenoexcept |
Construct a const view (stores as void* internally, constness enforced by the const overloads of data()/typed_data()).
Definition at line 295 of file tensor_bridge.hpp.
|
inline |
Access a single element in a 1D tensor (mutable).
| T | Element type (must match dtype()). |
| i | Zero-based element index. |
| std::out_of_range | if index is invalid or data is null. |
Definition at line 370 of file tensor_bridge.hpp.
|
inline |
Access a single element in a 1D tensor (const).
| T | Element type (must match dtype()). |
| i | Zero-based element index. |
| std::out_of_range | if index is invalid or data is null. |
Definition at line 391 of file tensor_bridge.hpp.
|
inline |
Access a single element in a 2D tensor by (row, col) (mutable).
| T | Element type (must match dtype()). |
| row | Zero-based row index. |
| col | Zero-based column index. |
| std::out_of_range | if indices are invalid or data is null. |
Definition at line 413 of file tensor_bridge.hpp.
|
inline |
Access a single element in a 2D tensor by (row, col) (const).
| T | Element type (must match dtype()). |
| row | Zero-based row index. |
| col | Zero-based column index. |
| std::out_of_range | if indices are invalid or data is null. |
Definition at line 438 of file tensor_bridge.hpp.
|
inlinenoexcept |
Total byte size of the tensor data (num_elements * element_size).
Returns 0 if num_elements() is non-positive (empty or error shape).
Definition at line 343 of file tensor_bridge.hpp.
|
inlinenoexcept |
Raw const pointer to the underlying data buffer.
Definition at line 307 of file tensor_bridge.hpp.
|
inlinenoexcept |
Raw mutable pointer to the underlying data buffer.
Definition at line 305 of file tensor_bridge.hpp.
|
inlinenoexcept |
The element data type.
Definition at line 329 of file tensor_bridge.hpp.
|
inlinenoexcept |
Effective stride in bytes along the first dimension.
If byte_stride_ is 0 (contiguous), computes the dense stride.
Definition at line 351 of file tensor_bridge.hpp.
|
inlinenoexcept |
Bytes per element.
Definition at line 332 of file tensor_bridge.hpp.
|
inlinenoexcept |
True if the data is densely packed (no stride gaps).
Definition at line 459 of file tensor_bridge.hpp.
|
inlinenoexcept |
True if the view points to valid data.
Definition at line 464 of file tensor_bridge.hpp.
|
inlinenoexcept |
Total number of elements.
Definition at line 337 of file tensor_bridge.hpp.
|
inline |
Reshape the view to a new shape with the same total number of elements.
Only valid for contiguous views. Returns an error if:
Definition at line 501 of file tensor_bridge.hpp.
|
inlinenoexcept |
The shape of this tensor view.
Definition at line 327 of file tensor_bridge.hpp.
|
inline |
Slice along the first dimension: returns a view over rows [start, start+count).
Zero-copy: the returned view's data pointer is offset into this view's buffer. No data is copied.
| start | First row index (inclusive). |
| count | Number of rows. |
Definition at line 478 of file tensor_bridge.hpp.
|
inlinenoexcept |
Reinterpret the data pointer as a typed const pointer.
| T | Element type (e.g. float, double, int32_t). |
Definition at line 320 of file tensor_bridge.hpp.
|
inlinenoexcept |
Reinterpret the data pointer as a typed mutable pointer.
The caller is responsible for ensuring T matches dtype().
| T | Element type (e.g. float, double, int32_t). |
Definition at line 313 of file tensor_bridge.hpp.