ttnn.prod

ttnn.prod = Operation(python_fully_qualified_name='ttnn.prod', function=<ttnn._ttnn.operations.reduction.prod_t object>, preprocess_golden_function_inputs=<function default_preprocess_golden_function_inputs>, golden_function=None, postprocess_golden_function_outputs=<function default_postprocess_golden_function_outputs>, is_cpp_operation=True, is_experimental=False)

Computes the product of all elements on specified dim of the input tensor.

If no dim is provided (or dim is set to None), it will compute the product of all elements in the input tensor. If keepdim is True, the resulting tensor will have a similar shape as the input tensor, but with the specified dim reduced to 1. This is not supported when taking the product across all dimensions. Otherwise, the target dim will be squeezed, resulting in an output tensor with one less dimension than the input tensor.

Parameters:

input_tensor (ttnn.Tensor) – the input tensor.

Keyword Arguments:
  • dim (int, optional) – Dimension to perform prod. Defaults to None.

  • keepdim (bool, optional) – keep original dimension size. Defaults to False.

  • memory_config (ttnn.MemoryConfig, optional) – Memory configuration for the operation. Defaults to None.

Returns:

List of ttnn.Tensor – the output tensor.

Example:

>>> tensor = ttnn.from_torch(torch.tensor((1, 2), dtype=torch.bfloat16), device=device)
>>> output = ttnn.prod(tensor, dim=0)
>>> output_all_dims = ttnn.prod(tensor)