ttnn.nonzero
- ttnn.nonzero = Operation(python_fully_qualified_name='ttnn.nonzero', function=<ttnn._ttnn.operations.data_movement.nonzero_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)
-
Returns the number of elements (N) that are non-zero as well as a tensor of the same shape as input where the first N elements are the indices of non-zero elements.
- Parameters:
-
input_tensor (ttnn.Tensor) – Input Tensor should be 1D and in row major layout.
- Keyword Arguments:
-
memory_config (ttnn.MemoryConfig, optional) – Memory configuration for the operation. Defaults to None.
queue_id (int, optional) – command queue id. Defaults to 0.
- Returns:
-
List of ttnn.Tensor – the output tensors.
Example
>>> tensor = ttnn.to_device(ttnn.from_torch(torch.zeros((1, 1, 1, 32), dtype=torch.bfloat16)), device) >>> output = ttnn.nonzero(tensor)