NonZero#

NonZero - 13#

Version

  • name: NonZero (GitHub)

  • domain: main

  • since_version: 13

  • function: False

  • support_level: SupportType.COMMON

  • shape inference: True

This version of the operator has been available since version 13.

Summary

Returns the indices of the elements that are non-zero (in row-major order - by dimension). NonZero behaves similar to numpy.nonzero: https://docs.scipy.org/doc/numpy/reference/generated/numpy.nonzero.html

Inputs

  • X (heterogeneous) - T: input

Outputs

  • Y (heterogeneous) - tensor(int64): output

Type Constraints

  • T in ( tensor(bfloat16), tensor(bool), tensor(complex128), tensor(complex64), tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8) ): Constrain to all tensor types.

Examples

Differences

00Returns the indices of the elements that are non-zeroReturns the indices of the elements that are non-zero
11(in row-major order - by dimension).(in row-major order - by dimension).
22NonZero behaves similar to numpy.nonzero:NonZero behaves similar to numpy.nonzero:
33https://docs.scipy.org/doc/numpy/reference/generated/numpy.nonzero.htmlhttps://docs.scipy.org/doc/numpy/reference/generated/numpy.nonzero.html
44
55**Inputs****Inputs**
66
77* **X** (heterogeneous) - **T**:* **X** (heterogeneous) - **T**:
88 input input
99
1010**Outputs****Outputs**
1111
1212* **Y** (heterogeneous) - **tensor(int64)**:* **Y** (heterogeneous) - **tensor(int64)**:
1313 output output
1414
1515**Type Constraints****Type Constraints**
1616
1717* **T** in (* **T** in (
18 tensor(bfloat16),
1819 tensor(bool), tensor(bool),
1920 tensor(complex128), tensor(complex128),
2021 tensor(complex64), tensor(complex64),
2122 tensor(double), tensor(double),
2223 tensor(float), tensor(float),
2324 tensor(float16), tensor(float16),
2425 tensor(int16), tensor(int16),
2526 tensor(int32), tensor(int32),
2627 tensor(int64), tensor(int64),
2728 tensor(int8), tensor(int8),
2829 tensor(string), tensor(string),
2930 tensor(uint16), tensor(uint16),
3031 tensor(uint32), tensor(uint32),
3132 tensor(uint64), tensor(uint64),
3233 tensor(uint8) tensor(uint8)
3334 ): ):
3435 Constrain to all tensor types. Constrain to all tensor types.

NonZero - 9#

Version

  • name: NonZero (GitHub)

  • domain: main

  • since_version: 9

  • function: False

  • support_level: SupportType.COMMON

  • shape inference: True

This version of the operator has been available since version 9.

Summary

Returns the indices of the elements that are non-zero (in row-major order - by dimension). NonZero behaves similar to numpy.nonzero: https://docs.scipy.org/doc/numpy/reference/generated/numpy.nonzero.html

Inputs

  • X (heterogeneous) - T: input

Outputs

  • Y (heterogeneous) - tensor(int64): output

Type Constraints

  • T in ( tensor(bool), tensor(complex128), tensor(complex64), tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8) ): Constrain to all tensor types.