Tannic
A C++ Tensor Library
Loading...
Searching...
No Matches
tannic::expression::Argsum Struct Reference

Sums tensor values along an axis. More...

#include <reductions.hpp>

Public Member Functions

constexpr type reduce (type dtype) const
 
constexpr Shape reduce (Shape const &shape) const
 
void forward (Tensor const &input, Tensor &output) const
 

Public Attributes

int axis
 
bool keepdim
 

Detailed Description

Sums tensor values along an axis.

Preserves input dtype. Use keepdim=true to maintain shape for broadcasting.

Example (NumPy/PyTorch behavior):

Tensor X = {{1, 2},
{3, 4}}; // shape(2, 2)
Tensor Y = sum(X, 0); // Sum over rows
// Y = [4, 6] // 1+3=4, 2+4=6
Tensor Z = sum(X, 1, /*keepdim=* /true);
// Z = [[3], // 1+2=3
// [7]] // 3+4=7
A multidimensional, strided tensor data structure.
Definition: tensor.hpp:105

Member Function Documentation

◆ forward()

void tannic::expression::Argsum::forward ( Tensor const &  input,
Tensor output 
) const

◆ reduce() [1/2]

constexpr Shape tannic::expression::Argsum::reduce ( Shape const &  shape) const
inlineconstexpr

◆ reduce() [2/2]

constexpr type tannic::expression::Argsum::reduce ( type  dtype) const
inlineconstexpr

Member Data Documentation

◆ axis

int tannic::expression::Argsum::axis

◆ keepdim

bool tannic::expression::Argsum::keepdim

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