asc2.reduce_prod

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

Returns the product 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.

The supported data types for the input are: float32. Reduction to a single scalar value is not supported.

Parameters:
  • input – The input tensor

  • dims – 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, if dims explicitly lists all dimensions, or if reducing to a scalar (no dims provided)

Examples

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

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

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