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

Finds the indices of maximum 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

Finds the indices of maximum values along an axis.

Output dtype is always int64. The reduced axis is removed by default (keepdim=false).

Example:

Tensor X = {{3, 1, 4},
{1, 5, 9}}; // shape(2, 3)
Tensor Y = argmax(X, 0); // Reduce axis 0 (rows)
std::cout << Y << std::endl;
// Y = [0, 1, 1] // Indexes of max values per column
Tensor Z = argmax(X, 1, /*keepdim=* /true); // Reduce axis 1 (columns), keep dims
std::cout << Z << std::endl;
// Z = [[2],
// [2]] // Indexes of max values per row
A multidimensional, strided tensor data structure.
Definition: tensor.hpp:105

Member Function Documentation

◆ forward()

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

◆ reduce() [1/2]

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

◆ reduce() [2/2]

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

Member Data Documentation

◆ axis

int tannic::expression::Argmax::axis

◆ keepdim

bool tannic::expression::Argmax::keepdim

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