|
Tannic
A C++ Tensor Library
|
Classes | |
| struct | Argmax |
| Finds the indices of maximum values along an axis. More... | |
| struct | Argmean |
| Computes the mean along an axis. More... | |
| struct | Argmin |
| Finds the indexes of minimum values along an axis. More... | |
| struct | Argsum |
| Sums tensor values along an axis. More... | |
| struct | Cartesian |
| Tag type for Cartesian (real/imaginary) complex number representation. More... | |
| class | Comparison |
| Expression template for element-wise tensor comparisons. More... | |
| class | Complexification |
| Creates a complex tensor view from real components. More... | |
| class | Complexification< Coordinates, Real, Imaginary > |
| class | Complexification< Coordinates, Source > |
| struct | EQ |
| class | Expansion |
| Expression template for expanding (broadcasting) singleton dimensions of a tensor. More... | |
| class | Flatten |
| Expression template for flattening a contiguous range of dimensions. More... | |
| struct | GE |
| struct | GT |
| struct | LE |
| struct | LT |
| struct | NE |
| class | Permutation |
| Expression template for reordering tensor dimensions according to a specified permutation. More... | |
| struct | Polar |
| Tag type for Polar (magnitude/angle) complex number representation. More... | |
| class | Realification |
| Creates a real-valued view of complex tensor data. More... | |
| class | Reduction |
| Lazy reduction expression. More... | |
| class | Slice |
| Expression template representing a tensor slice or subview. More... | |
| class | Squeeze |
| Expression template for removing singleton dimensions from a tensor. More... | |
| class | Transpose |
| Expression template for transposing two dimensions of a tensor. More... | |
| class | Unsqueeze |
| Expression template for inserting singleton dimensions into a tensor. More... | |
| class | View |
| Expression template for viewing a tensor with a new shape. More... | |
Functions | |
| template<Expression First, Expression Second> | |
| constexpr auto | operator== (First &&lhs, Second &&rhs) |
| template<Expression First, Expression Second> | |
| constexpr auto | operator!= (First &&lhs, Second &&rhs) |
| template<Expression First, Expression Second> | |
| constexpr auto | operator< (First &&lhs, Second &&rhs) |
| template<Expression First, Expression Second> | |
| constexpr auto | operator<= (First &&lhs, Second &&rhs) |
| template<Expression First, Expression Second> | |
| constexpr auto | operator> (First &&lhs, Second &&rhs) |
| template<Expression First, Expression Second> | |
| constexpr auto | operator>= (First &&lhs, Second &&rhs) |
| bool | allclose (Tensor const &first, Tensor const &second, double rtol=1e-5f, double atol=1e-8f) |
| Determine whether two tensors are element-wise equal within a tolerance. | |
| template<Expression Real> | |
| constexpr auto | complexify (Real &&real) |
| Creates a complex tensor view from interleaved real/imaginary data. | |
| template<Expression Real, Expression Imaginary> | |
| constexpr auto | complex (Real &&real, Imaginary &&imaginary) |
| Creates complex tensor from separate real and imaginary tensors | |
| template<Expression Magnitude, Expression Angle> | |
| constexpr auto | polar (Magnitude &&rho, Angle &&theta) |
| Creates complex tensor from polar coordinates (magnitude/angle) | |
| template<Expression Complex> | |
| constexpr auto | realify (Complex &&complex) |
| Creates a real-valued view of complex tensor data. | |
| template<Expression Source> | |
| constexpr auto | argmax (Source &&source, int axis, bool keepdim=false) |
| Creates an Argmax reduction. | |
| template<Expression Source> | |
| constexpr auto | argmin (Source &&source, int axis, bool keepdim=false) |
| Creates an Argmin reduction. | |
| template<Expression Source> | |
| constexpr auto | sum (Source &&source, int axis, bool keepdim=false) |
| Creates a sum reduction. | |
| template<Expression Source> | |
| constexpr auto | mean (Source &&source, int axis, bool keepdim=false) |
| Creates a mean reduction. | |
| template<typename T > | |
| std::byte const * | tobytes (T const &reference) |
| template<Expression Source, Integral ... Indexes> | |
| constexpr auto | view (Source &&source, Indexes ... indexes) |
| Creates a reshaped view of a tensor or expression. | |
| template<Expression Source> | |
| constexpr auto | transpose (Source &&source, int first, int second) |
| Creates a transposed view of a tensor or expression by swapping two dimensions. | |
| template<Expression Source, Integral ... Indexes> | |
| constexpr auto | permute (Source &&source, Indexes... indexes) |
| Creates a permuted view of a tensor or expression. | |
| template<Expression Source, Integral... Sizes> | |
| constexpr auto | expand (Source &&source, Sizes... sizes) |
| Creates an expanded view of a tensor, broadcasting singleton dimensions. | |
| template<Expression Source> | |
| constexpr auto | squeeze (Source &&source) |
| Removes all singleton dimensions from a tensor (squeeze). | |
| template<Expression Source, Integral... Axes> | |
| constexpr auto | unsqueeze (Source &&source, Axes... axes) |
| Inserts singleton dimensions at the specified axes (unsqueeze). | |
| template<Expression Source> | |
| constexpr auto | flatten (Source &&source, int start=0, int end=-1) |
| Flattens dimensions of a tensor into a single dimension. | |
| bool tannic::expression::allclose | ( | Tensor const & | first, |
| Tensor const & | second, | ||
| double | rtol = 1e-5f, |
||
| double | atol = 1e-8f |
||
| ) |
Determine whether two tensors are element-wise equal within a tolerance.
This function checks whether all elements of two tensors are close to each other, within a relative tolerance (rtol) and an absolute tolerance (atol).
| first | The first tensor to compare. |
| second | The second tensor to compare. |
| rtol | Relative tolerance. Default = 1e-5. The allowable difference grows with the magnitude of the values. |
| atol | Absolute tolerance. Default = 1e-8. The minimum absolute tolerance for small values. |
first and second satisfy the condition:
, false otherwise.| tannic::Exception | if the tensors have mismatched shapes or incompatible environments. |
|
constexpr |
Creates an Argmax reduction.
| axis | Axis to reduce (-1 for last axis). |
| keepdim | If true, keeps reduced axis as size 1. |
|
constexpr |
Creates an Argmin reduction.
| axis | Axis to reduce (-1 for last axis). |
| keepdim | If true, keeps reduced axis as size 1. |
|
constexpr |
|
constexpr |
Creates a complex tensor view from interleaved real/imaginary data.
| real | Tensor with shape [...,2N] containing N real/imaginary pairs |
|
constexpr |
Creates an expanded view of a tensor, broadcasting singleton dimensions.
This function returns an Expansion expression that allows a tensor to be “expanded” along dimensions of size 1 without copying data. Expansion is only allowed along singleton dimensions; other dimensions must match the requested size.
| Source | The tensor or expression type to expand. |
| Sizes | Integral dimension sizes for the expanded view. |
| source | The source tensor or expression. |
| sizes | The target shape for the expanded view. |
Expansion object representing the broadcasted view.| Exception | if:
|
Example usage:
|
constexpr |
Flattens dimensions of a tensor into a single dimension.
| Source | The expression or tensor type. |
| source | The source tensor or expression. |
| start_dim | First dimension to flatten (default = 0). |
| end_dim | Last dimension to flatten (default = -1, meaning last dim). |
Flatten view expression.Example:
|
constexpr |
Creates a mean reduction.
| axis | Axis to reduce. |
| keepdim | If true, keeps reduced axis as size 1. |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
Creates a permuted view of a tensor or expression.
| Source | The expression or tensor type. |
| Indexes | Integral indices specifying the permutation order. |
| source | The source expression. |
| indexes | Sequence of dimension indices indicating the new axis order. |
Permutation view expression.Example:
|
constexpr |
Creates complex tensor from polar coordinates (magnitude/angle)
|
constexpr |
Creates a real-valued view of complex tensor data.
| complex | Complex tensor to reinterpret |
|
constexpr |
Removes all singleton dimensions from a tensor (squeeze).
This function returns a Squeeze expression that reinterprets the source tensor without its size-1 dimensions.
| Source | The expression or tensor type. |
| source | The source tensor or expression. |
Squeeze view expression.Example:
|
constexpr |
Creates a sum reduction.
| axis | Axis to reduce (-1 for last axis). |
| keepdim | If true, keeps reduced axis as size 1. |
|
inline |
|
constexpr |
Creates a transposed view of a tensor or expression by swapping two dimensions.
| Source | The expression or tensor type. |
| source | The source expression. |
| first | First dimension index to swap. |
| second | Second dimension index to swap. |
Transpose view expression.
|
constexpr |
Inserts singleton dimensions at the specified axes (unsqueeze).
This function returns an Unsqueeze expression that reinterprets the source tensor with new dimensions of size 1 added.
| Source | The expression or tensor type. |
| Axes | One or more integral indices where new dimensions will be inserted. |
| source | The source tensor or expression. |
| axes | Axis indices (negative indices allowed). |
Unsqueeze view expression.Example:
|
constexpr |
Creates a reshaped view of a tensor or expression.
| Source | The expression or tensor type. |
| Indexes | New shape dimensions (integral values). |
| source | The source expression. |
| indexes | Dimension sizes for the new shape. |
View view expression.