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

Describes the shape of a tensor as a vector of dimension sizes. More...

#include <tensor_bridge.hpp>

Public Member Functions

 TensorShape ()=default
 Default constructor: scalar shape (empty dims).
 
 TensorShape (std::vector< int64_t > d)
 Construct from a vector of dimensions.
 
 TensorShape (std::initializer_list< int64_t > il)
 Construct from an initializer list (e.g.
 
int64_t num_elements () const noexcept
 Total number of elements (product of all dimensions).
 
size_t ndim () const noexcept
 Number of dimensions.
 
bool is_scalar () const noexcept
 True if this is a scalar (no dimensions, or a single dimension of 1).
 
bool is_vector () const noexcept
 True if this is a 1D vector.
 
bool is_matrix () const noexcept
 True if this is a 2D matrix.
 
bool operator== (const TensorShape &other) const
 Equality comparison (element-wise dimension match).
 
bool operator!= (const TensorShape &other) const
 Inequality comparison.
 

Public Attributes

std::vector< int64_t > dims
 Dimension sizes (e.g. {32, 768} for a 32x768 matrix)
 

Detailed Description

Describes the shape of a tensor as a vector of dimension sizes.

Examples: {} — scalar {100} — 1D vector of 100 elements {32, 768} — 2D matrix (32 rows, 768 columns) {4,3,3} — 3D tensor (e.g. batch of 3x3 matrices)

Definition at line 207 of file tensor_bridge.hpp.

Constructor & Destructor Documentation

◆ TensorShape() [1/3]

signet::forge::TensorShape::TensorShape ( )
default

Default constructor: scalar shape (empty dims).

◆ TensorShape() [2/3]

signet::forge::TensorShape::TensorShape ( std::vector< int64_t >  d)
inlineexplicit

Construct from a vector of dimensions.

Parameters
dDimension sizes.

Definition at line 215 of file tensor_bridge.hpp.

◆ TensorShape() [3/3]

signet::forge::TensorShape::TensorShape ( std::initializer_list< int64_t >  il)
inline

Construct from an initializer list (e.g.

TensorShape{100} for 1D, TensorShape{32, 768} for 2D).

Note
Use single-brace syntax: TensorShape{n}, not TensorShape{{n}}.

Definition at line 219 of file tensor_bridge.hpp.

Member Function Documentation

◆ is_matrix()

bool signet::forge::TensorShape::is_matrix ( ) const
inlinenoexcept

True if this is a 2D matrix.

Definition at line 246 of file tensor_bridge.hpp.

◆ is_scalar()

bool signet::forge::TensorShape::is_scalar ( ) const
inlinenoexcept

True if this is a scalar (no dimensions, or a single dimension of 1).

Definition at line 238 of file tensor_bridge.hpp.

◆ is_vector()

bool signet::forge::TensorShape::is_vector ( ) const
inlinenoexcept

True if this is a 1D vector.

Definition at line 243 of file tensor_bridge.hpp.

◆ ndim()

size_t signet::forge::TensorShape::ndim ( ) const
inlinenoexcept

Number of dimensions.

Definition at line 235 of file tensor_bridge.hpp.

◆ num_elements()

int64_t signet::forge::TensorShape::num_elements ( ) const
inlinenoexcept

Total number of elements (product of all dimensions).

Returns 1 for a scalar (empty dims), consistent with ML frameworks.

Definition at line 223 of file tensor_bridge.hpp.

◆ operator!=()

bool signet::forge::TensorShape::operator!= ( const TensorShape other) const
inline

Inequality comparison.

Definition at line 254 of file tensor_bridge.hpp.

◆ operator==()

bool signet::forge::TensorShape::operator== ( const TensorShape other) const
inline

Equality comparison (element-wise dimension match).

Definition at line 249 of file tensor_bridge.hpp.

Member Data Documentation

◆ dims

std::vector<int64_t> signet::forge::TensorShape::dims

Dimension sizes (e.g. {32, 768} for a 32x768 matrix)

Definition at line 208 of file tensor_bridge.hpp.


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