Tannic
A C++ Tensor Library
Loading...
Searching...
No Matches
tannic::operation::Exponentiation Struct Reference

Binary element-wise exponentiation of two tensor expressions. More...

#include <operations.hpp>

Public Member Functions

void forward (Tensor const &, Tensor const &, Tensor &) const
 

Static Public Member Functions

static constexpr type promote (type first, type second)
 
static constexpr Shape broadcast (Shape const &first, Shape const &second)
 

Detailed Description

Binary element-wise exponentiation of two tensor expressions.

Used to build a lazily evaluated Binary<Exponentiation, Base, Exponent> expression. The result shape is determined via broadcasting rules, and the result type is chosen according to type promotion rules between the base and exponent.

Computation is deferred until forward() is called or the expression is assigned to a Tensor, meaning it can be composed into larger expression graphs without incurring immediate cost.

Example: Exponentiation

Tensor A(float32, {2, 2}); A.initialize();
A[0, 0] = 2; A[0, 1] = 3;
A[1, 0] = 4; A[1, 1] = 5;
Tensor B(float32, {2, 2}); B.initialize();
B[0, 0] = 3; B[0, 1] = 2;
B[1, 0] = 1; B[1, 1] = 0;
auto C = A ^ B;
std::cout << C.forward();
// Output: [[8, 9], [4, 1]]
A multidimensional, strided tensor data structure.
Definition: tensor.hpp:105
void initialize(Environment environment=Host{}) const
Allocates the memory buffer for the tensor.

Member Function Documentation

◆ broadcast()

static constexpr Shape tannic::operation::Exponentiation::broadcast ( Shape const &  first,
Shape const &  second 
)
inlinestaticconstexpr

◆ forward()

void tannic::operation::Exponentiation::forward ( Tensor const &  ,
Tensor const &  ,
Tensor  
) const

◆ promote()

static constexpr type tannic::operation::Exponentiation::promote ( type  first,
type  second 
)
inlinestaticconstexpr

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