Compress

Compress - 11

版本

  • 名称: Compress (GitHub)

  • : main

  • 起始版本: 11

  • 函数: False

  • 支持级别: SupportType.COMMON

  • 形状推断: True

此版本的算子自版本 11 起可用。

摘要

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

属性

  • axis - INT :

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

输入

  • 输入 (异构) - T

    秩 r >= 1 的张量。

  • condition (异构) - T1

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

输出

  • 输出 (异构) - T

    如果指定了 axis,则为秩 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 起可用。

摘要

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

属性

  • axis - INT :

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

输入

  • 输入 (异构) - T

    秩 r >= 1 的张量。

  • condition (异构) - T1

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

输出

  • 输出 (异构) - T

    如果指定了 axis,则为秩 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) ) 中

    限制为布尔张量。