Txeo v0.1
A Developer-Friendly TensorFlow C++ Wrapper
|
The shape of a tensor is an ordered collection of dimensions of mathematical vector spaces. More...
#include <TensorShape.h>
Public Member Functions | |
TensorShape (const TensorShape &shape) | |
TensorShape (TensorShape &&shape) noexcept | |
~TensorShape () | |
TensorShape & | operator= (const TensorShape &shape) |
TensorShape & | operator= (TensorShape &&shape) noexcept |
bool | operator== (const TensorShape &shape) const |
bool | operator!= (const TensorShape &shape) const |
TensorShape (int number_of_axes, size_t dim) | |
Constructs a tensor shape with axes having the same dimension. | |
TensorShape (const std::vector< size_t > &shape) | |
Constructs a tensor shape from a std::vector. | |
TensorShape (std::vector< size_t > &&shape) | |
Constructs a tensor shape from a std::vector. | |
TensorShape (const std::initializer_list< size_t > &shape) | |
Constructs a tensor shape from an initializer list. | |
int | number_of_axes () const noexcept |
Returns the size of the tensor shape. | |
int | size () const noexcept |
Synonym for txeo::TensorShape::number_of_axes() | |
int64_t | axis_dim (int axis) const |
Returns the dimension of the specified axis. | |
const std::vector< size_t > & | stride () const |
Returns the stride of each dimension in the tensor. | |
std::vector< int64_t > | axes_dims () const noexcept |
Returns the collection of tensor shape dimensions. | |
bool | is_fully_defined () const noexcept |
Indicates whether the tensor shape has any negative(undefined) dimensions or not. | |
void | push_axis_back (size_t dim) |
Inserts a dimension after the last axis. | |
void | insert_axis (int axis, size_t dim) |
Inserts a dimension at the specified axis. | |
void | remove_axis (int axis) |
Removes a specified axis. | |
void | remove_all_axes () |
Removes all axes from this shape, resulting an empty shape. | |
void | set_dim (int axis, size_t dim) |
Sets a dimension in a specified axis. | |
size_t | calculate_capacity () const noexcept |
Calculates the number of available tensor elements specified by the tensor shape. | |
TensorShape | clone () const |
Returns a clone of this tensor. | |
Friends | |
template<typename T > | |
class | Tensor |
template<typename T > | |
class | Predictor |
template<typename T > | |
class | TensorAgg |
class | txeo::detail::TensorHelper |
std::ostream & | operator<< (std::ostream &os, const TensorShape &shape) |
The shape of a tensor is an ordered collection of dimensions of mathematical vector spaces.
Each position of the tensor shape is an "axis", labeled starting from zero, and the value in this position is a "dimension". An empty tensor shape is the shape of a scalar value. In some some conditions, a negative dimension represents an undefined dimension, but this attribution is reserved to TensorFlow C++.
Definition at line 30 of file TensorShape.h.
txeo::TensorShape::TensorShape | ( | const TensorShape & | shape | ) |
|
noexcept |
txeo::TensorShape::~TensorShape | ( | ) |
|
explicit |
Constructs a tensor shape with axes having the same dimension.
number_of_axes | Number of axes of the tensor |
dim | dimension in each axis |
txeo::TensorShapeError |
Example Usage:
|
explicit |
Constructs a tensor shape from a std::vector.
shape | vector of dimensions |
Example Usage:
|
explicit |
Constructs a tensor shape from a std::vector.
shape | vector of dimensions
|
|
inlineexplicit |
Constructs a tensor shape from an initializer list.
shape | vector of dimensions
|
Definition at line 123 of file TensorShape.h.
|
noexcept |
Returns the collection of tensor shape dimensions.
int64_t txeo::TensorShape::axis_dim | ( | int | axis | ) | const |
Returns the dimension of the specified axis.
axis | Axis whose dimension is to be returned |
txeo::TensorShapeError |
|
noexcept |
Calculates the number of available tensor elements specified by the tensor shape.
TensorShape txeo::TensorShape::clone | ( | ) | const |
Returns a clone of this tensor.
void txeo::TensorShape::insert_axis | ( | int | axis, |
size_t | dim | ||
) |
Inserts a dimension at the specified axis.
axis | Specified axis |
dim | Specified dimension |
txeo::TensorShapeError |
Example Usage:
|
noexcept |
Indicates whether the tensor shape has any negative(undefined) dimensions or not.
|
noexcept |
Returns the size of the tensor shape.
bool txeo::TensorShape::operator!= | ( | const TensorShape & | shape | ) | const |
TensorShape & txeo::TensorShape::operator= | ( | const TensorShape & | shape | ) |
|
noexcept |
bool txeo::TensorShape::operator== | ( | const TensorShape & | shape | ) | const |
void txeo::TensorShape::push_axis_back | ( | size_t | dim | ) |
Inserts a dimension after the last axis.
dim | Specified dimension |
Example Usage:
void txeo::TensorShape::remove_all_axes | ( | ) |
Removes all axes from this shape, resulting an empty shape.
void txeo::TensorShape::remove_axis | ( | int | axis | ) |
Removes a specified axis.
axis | Specified axis |
txeo::TensorShapeError |
Example Usage:
void txeo::TensorShape::set_dim | ( | int | axis, |
size_t | dim | ||
) |
Sets a dimension in a specified axis.
axis | Axis whose dimension will be changed |
dim | New dimension |
txeo::TensorShapeError |
Example Usage:
|
inlinenoexcept |
Synonym for txeo::TensorShape::number_of_axes()
Definition at line 138 of file TensorShape.h.
const std::vector< size_t > & txeo::TensorShape::stride | ( | ) | const |
Returns the stride of each dimension in the tensor.
The stride represents the step size needed to move along each dimension of the tensor in memory layout. It is useful for operations requiring efficient indexing.
Example Usage:
|
friend |
|
friend |
Definition at line 314 of file TensorShape.h.
|
friend |
Definition at line 311 of file TensorShape.h.
|
friend |
Definition at line 317 of file TensorShape.h.
|
friend |
Definition at line 319 of file TensorShape.h.