maxElement

Computes a max reduction along the specified axes.

maxElement
(
,
size_t[] axes = []
,
string mod = __MODULE__
,
size_t line = __LINE__
)

Parameters

op
Type: Operation

The input to the reduction.

axes
Type: size_t[]

The axes the reduction should be performed along.

Return Value

Type: Operation

The resulting operation.

Examples

1 import dopt.core : evaluate;
2 
3 auto a = float32([2, 2],[
4     1.0f, 4.0f,
5     3.0f, 6.0f
6 ]);
7 
8 assert(a.maxElement.evaluate().as!float == [6.0f]); //Max value in the entire tensor
9 assert(a.maxElement([0]).evaluate().as!float == [3.0f, 6.0f]); //Max of each column
10 assert(a.maxElement([1]).evaluate().as!float == [4.0f, 6.0f]); //Max of each row

Meta