Skip to content
fn

nonzero_op

→TensorImplPtr
int nonzero_op(const int & a)

Python wrappers

Public Python APIs implemented by this engine symbol.

Coordinates of all non-zero elements.

Returns a 2-D tensor of shape (count, ndim) listing the multi-axis coordinates of every non-zero element of a in row-major order.

Parameters

aTensorImplPtr
Input tensor of any rank and dtype.

Returns

TensorImplPtr

Integer tensor of shape (count, a.ndim) and dtype I64. count is the number of non-zero entries.

Notes

The output shape depends on the input values, so this op always materialises the result on the CPU stream and copies it to the requested device on demand. Non-differentiable.