asc2.reduce_max

asc2.reduce_max(input: LocalTensor, *dims: int, keep_dims: bool = False) LocalTensor
asc2.reduce_max(input: LocalTensor) PlainValue

Returns the maximum value of each row of the input tensor in the given dimensions dims.

Dimensions dims are squeezed, resulting the output tensor having fewer dimensions than input, unless keep_dims=True is provided. When dimension is not specified, the entire tensor is reduced to a single scalar value.

The supported data types for the input are: int8, int16, int32, int64, float16, bfloat16, float32. When reducing to a single scalar value, the supported data types are: int16, int32, int64, float16, float32.

Parameters:
  • input – The input tensor

  • dims – Optional, dimensions to reduce, should be in range of [0..len(input.shape)-1]

  • keep_dims – If set to True, then reduced dimensions are kept in the result shape with size of 1

Raises:
  • TypeError – If input is not a LocalTensor, keep_dims is not a bool, or dims contains non-integer values

  • RuntimeError – If input dtype is not supported, or if dims explicitly lists all dimensions

Examples

Reduce tensor by first (outermost) dimension, resulting tensor having the shape [256], each element is a maximum value between 128 elements in corresponding column:

input = asc2.copy_in(x, [0, 0], [128, 256])
result = asc2.reduce_max(input, 0)

Compute the maximum value between all tensor elements, returns single scalar value:

input = asc2.copy_in(x, [0, 0], [256, 256])
result = asc2.reduce_max(input)

This function can also be called as a member function on LocalTensor, as input.max(...) instead of reduce_max(input, ...).