Compress

Compress - 11

版本

  • 名称: Compress (GitHub)

  • : main

  • 起始版本: 11

  • 函数: False

  • 支持级别: SupportType.COMMON

  • 形状推断: True

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

摘要

沿给定轴从输入张量中选择切片,其中条件对每个轴索引都评估为 True。如果未提供轴,则在选择元素之前将输入展平。Compress 的行为类似于 numpy.compress: https://docs.scipy.org.cn/doc/numpy/reference/generated/numpy.compress.html

属性

  • 轴 - INT :

    (可选) 沿其进行切片的轴。如果未指定,则在选择元素之前将输入展平。负值表示从后向前计算维度。接受的范围是 [-r, r-1],其中 r = rank(input)。

输入

  • 输入 (异构) - T

    秩 r >= 1 的张量。

  • 条件 (异构) - T1

    布尔值的秩 1 张量,用于指示要选择哪些切片或数据元素。如果未指定轴,其长度可以小于沿轴的输入长度或展平的输入大小。在这种情况下,超出条件长度的数据切片或元素将被丢弃。

输出

  • 输出 (异构) - T

    如果指定了轴,则输出为秩 r 的张量。否则输出为秩 1 的张量。

类型约束

  • 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) )

    将输入和输出类型限制为所有张量类型。

  • T1 在 ( tensor(bool) )

    限制为布尔张量。

Compress - 9

版本

  • 名称: Compress (GitHub)

  • : main

  • 起始版本: 9

  • 函数: False

  • 支持级别: SupportType.COMMON

  • 形状推断: False

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

摘要

沿给定轴从输入张量中选择切片,其中条件对每个轴索引都评估为 True。如果未提供轴,则在选择元素之前将输入展平。Compress 的行为类似于 numpy.compress: https://docs.scipy.org.cn/doc/numpy/reference/generated/numpy.compress.html

属性

  • 轴 - INT :

    (可选) 沿其进行切片的轴。如果未指定,则在选择元素之前将输入展平。

输入

  • 输入 (异构) - T

    秩 r >= 1 的张量。

  • 条件 (异构) - T1

    布尔值的秩 1 张量,用于指示要选择哪些切片或数据元素。如果未指定轴,其长度可以小于沿轴的输入长度或展平的输入大小。在这种情况下,超出条件长度的数据切片或元素将被丢弃。

输出

  • 输出 (异构) - T

    如果指定了轴,则输出为秩 r 的张量。否则输出为秩 1 的张量。

类型约束

  • 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) )

    将输入和输出类型限制为所有张量类型。

  • T1 在 ( tensor(bool) )

    限制为布尔张量。