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

Unary element-wise negation of a tensor expression. More...

#include <operations.hpp>

Public Member Functions

void forward (Tensor const &, Tensor &) const
 

Detailed Description

Unary element-wise negation of a tensor expression.

Used to build a lazily evaluated Unary<Negation, Operand> expression. The computation is not performed immediately, but deferred until forward() is called or the expression is assigned to a Tensor object.

Example: Unary negation

Tensor A(float32, {2, 2}); A.initialize();
A[0, 0] = 1; A[0, 1] = -2;
A[1, 0] = 3; A[1, 1] = -4;
auto B = -A; // Lazy negation (Unary<Negation, Tensor>)
Tensor C = B.forward(); // Triggers computation
Tensor D = -A; // Computation triggered when assigned to Tensor
std::cout << D;
// Output: [[-1, 2], [-3, 4]]
A multidimensional, strided tensor data structure.
Definition: tensor.hpp:105
Tensor & forward()
Returns a reference to this tensor (const-qualified).
Definition: tensor.hpp:220
void initialize(Environment environment=Host{}) const
Allocates the memory buffer for the tensor.

Member Function Documentation

◆ forward()

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

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