非零

非零 - 13

版本

  • 名称: NonZero (GitHub)

  • 域名: main

  • since_version: 13

  • 函数: False

  • support_level: SupportType.COMMON

  • 形状推断: True

此版本的运算符自版本13起可用。

摘要

返回非零元素的索引(按行主序 - 按维度)。 NonZero 的行为类似于 numpy.nonzero: https://docs.scipy.org/doc/numpy/reference/generated/numpy.nonzero.html, 但对于标量输入,NonZero 生成的输出形状为 (0, N) 而不是 (1, N),这与 Numpy 的行为不同。

输入

  • X (异构) - T:

    输入

输出

  • Y (异构) - tensor(int64):

    输出

类型约束

  • T 在 ( 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) ):

    限制为所有张量类型。

非零 - 9

版本

  • 名称: NonZero (GitHub)

  • 域名: main

  • since_version: 9

  • 函数: False

  • support_level: SupportType.COMMON

  • 形状推断: True

此版本的运算符自版本9起可用。

摘要

返回非零元素的索引(按行主序 - 按维度)。 NonZero 的行为类似于 numpy.nonzero: https://docs.scipy.org/doc/numpy/reference/generated/numpy.nonzero.html, 但对于标量输入,NonZero 生成的输出形状为 (0, N) 而不是 (1, N),这与 Numpy 的行为不同。

输入

  • X (异构) - T:

    输入

输出

  • Y (异构) - tensor(int64):

    输出

类型约束

  • T 在 ( 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) ):

    约束所有张量类型。