Tannic
A C++ Tensor Library
|
Expression template for mathematical function operations. More...
#include <functions.hpp>
Public Member Functions | |
constexpr | Function (Functor functor, typename Trait< Argument >::Reference argument) |
Constructs a Function expression. | |
constexpr type | dtype () const |
Returns the data type of the result. | |
constexpr Shape const & | shape () const |
Returns the shape of the result. | |
constexpr Strides const & | strides () const |
Returns the strides of the result. | |
auto | offset () const |
Returns the offset of the result. | |
Tensor | forward () const |
Public Attributes | |
Functor | functor |
Trait< Argument >::Reference | argument |
Expression template for mathematical function operations.
Represents a lazily evaluated unary function that takes a functor as argument and maps it to an argument. The actual computation is deferred until forward()
is called.
Functor | A mathematical functor satisfying the Functional concept |
Argument | An expression type satisfying the Expression concept |
|
inlineconstexpr |
|
inlineconstexpr |
Returns the data type of the result.
Functors in this expression template system are type-preserving — applying them element-wise does not change the scalar type (e.g., applying exp()
to a float32
tensor produces float32
output). Therefore, we can directly query and return the argument's dtype.
|
inline |
|
inline |
Returns the offset of the result.
Since element-wise functors do not change the memory location of the data, the offset is taken directly from the argument.
|
inlineconstexpr |
Returns the shape of the result.
The shape is returned as const&
to avoid copying the shape object, and because element-wise functors do not alter tensor dimensions.
|
inlineconstexpr |
Returns the strides of the result.
Strides describe memory layout, and for pure element-wise operations they remain identical to those of the input tensor. Returning const&
avoids copying and preserves the original stride information.
Trait<Argument>::Reference tannic::function::Function< Functor, Argument >::argument |
Functor tannic::function::Function< Functor, Argument >::functor |