asc.language.tile.reduction_ops.reduce_sum

asc.language.tile.reduction_ops.reduce_sum(input: Tile, *dims: int, keep_dims: bool = False) Tile
asc.language.tile.reduction_ops.reduce_sum(input: Tile) PlainValue

Returns the sum of each row of the input tile in the given dimensions dims.

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

Parameters:
  • input – the input tile

  • 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

Examples

Reduce tile by first (outermost) dimension, resulting tile having the shape [256], each element is sum of 128 elements in corresponding column:

input = asc2.load(x, [128, 256], offsets=[0, 0])
result = asc2.reduce_sum(input, 0)

Compute total sum of all numbers in tile, returns single scalar value:

input = asc2.load(x, [256, 256], offsets=[0, 0])
result = asc2.reduce_sum(input)

This function can also be called as a member function on Tile, as x.sum(...) instead of reduce_sum(x, ...).