Slice¶
Slice - 13¶
版本¶
名称: Slice (GitHub)
域:
main
起始版本:
13
函数:
False
支持级别:
SupportType.COMMON
Shape 推断:
True
此版本的运算符自版本 13 起可用。
摘要¶
沿多个轴生成输入张量的切片。类似于 numpy:https://numpy.com.cn/doc/stable/user/basics.indexing.html?highlight=slice#slicing-and-striding
Slice 使用 starts
、ends
、axes
和 steps
输入来选择其输入 data
张量的子张量。
对于 [0, ... r-1]
中的每个 i
(其中 r = rank(input)
),必须按如下方式计算有效的 starts[i]
、ends[i]
和 steps[i]
如果省略 axes
,则将其设置为 [0, ..., r-1]
。如果省略 steps
,则将其设置为长度为 len(starts)
的 [1, ..., 1]
有效值初始化为 start[i] = 0
,ends[i] = dims[i]
(其中 dims
是 input
的维度),并且 steps[i] = 1
。
axes
的所有负元素都通过加上 r
变为非负,其中 r =rank(input)
。
starts[i]
和 ends[i]
中的所有负值都加上 dims[axes[i]]
,其中 dims
是 input
的维度。然后,调整后的 starts[i]
即 start[axes[i]]
,对于正步进被限制在 [0, dims[axes[i]]]
范围内,对于负步进被限制在 [0, dims[axes[i]]-1]
范围内。
调整后的 ends[i]
的限制取决于 steps[i]
的符号,并且必须适应复制 0 到 dims[axes[i]]
个元素,因此对于正步进,ends[axes[i]]
被限制在 [0, dims[axes[i]]]
,而对于负步进,它被限制在 [-1, dims[axes[i]]-1]
。
最后,steps[axes[i]] = steps[i]
。
对于切片到未知大小维度的末尾,建议向前切片时传递 INT_MAX
,向后切片时传递 'INT_MIN'。
示例 1
data = [
[1, 2, 3, 4],
[5, 6, 7, 8],
]
axes = [0, 1]
starts = [1, 0]
ends = [2, 3]
steps = [1, 2]
result = [
[5, 7],
]
示例 2
data = [
[1, 2, 3, 4],
[5, 6, 7, 8],
]
starts = [0, 1]
ends = [-1, 1000]
result = [
[2, 3, 4],
]
输入¶
3 到 5 个输入之间。
data (异构) - T
从中提取切片的数据张量。
starts (异构) - Tind
1-D 张量,对应
axes
中各轴的起始索引ends (异构) - Tind
1-D 张量,对应
axes
中各轴的结束索引(不包含)axes (可选, 异构) - Tind
1-D 张量,表示
starts
和ends
应用于的轴。负值表示从末尾计数维度。接受的范围是 [-r, r-1],其中 r = rank(data)。如果轴重复,则行为未定义。steps (可选, 异构) - Tind
1-D 张量,对应
axes
中各轴的切片步长。负值表示向后切片。'steps' 不能为 0。默认为 1。
输出¶
output (异构) - T
切片后的数据张量。
类型约束¶
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)
) 中的一种。约束输入和输出类型为所有张量类型。
Tind 为 (
tensor(int32)
,tensor(int64)
) 中的一种。约束索引为整数类型。
Slice - 11¶
版本¶
名称: Slice (GitHub)
域:
main
起始版本:
11
函数:
False
支持级别:
SupportType.COMMON
Shape 推断:
True
此版本的运算符自版本 11 起可用。
摘要¶
沿多个轴生成输入张量的切片。类似于 numpy:https://numpy.com.cn/doc/stable/reference/routines.indexing.html Slices 使用 starts
、ends
、axes
和 steps
输入为轴列表中的每个轴指定起始和结束维度以及步长,它使用此信息来切片输入 data
张量。如果为任何起始或结束索引传递负值,则表示该维度末尾前的元素数量。如果传递给起始或结束的值大于该维度的元素数量 n
,则表示 n
。对于切片到未知大小维度的末尾,建议向前切片时传递 INT_MAX
,向后切片时传递 'INT_MIN'。如果为步长传递负值,则表示向后切片。但是步长值不能为 0。如果省略 axes
,则将其设置为 [0, ..., ndim-1]
。如果省略 steps
,则将其设置为长度为 len(starts)
的 [1, ..., 1]
。示例 1:data = [ [1, 2, 3, 4], [5, 6, 7, 8], ] axes = [0, 1] starts = [1, 0] ends = [2, 3] steps = [1, 2] result = [ [5, 7], ] 示例 2:data = [ [1, 2, 3, 4], [5, 6, 7, 8], ] starts = [0, 1] ends = [-1, 1000] result = [ [2, 3, 4], ]
输入¶
3 到 5 个输入之间。
data (异构) - T
从中提取切片的数据张量。
starts (异构) - Tind
1-D 张量,对应
axes
中各轴的起始索引ends (异构) - Tind
1-D 张量,对应
axes
中各轴的结束索引(不包含)axes (可选, 异构) - Tind
1-D 张量,表示
starts
和ends
应用于的轴。负值表示从末尾计数维度。接受的范围是 [-r, r-1],其中 r = rank(data)。steps (可选, 异构) - Tind
1-D 张量,对应
axes
中各轴的切片步长。负值表示向后切片。'steps' 不能为 0。默认为 1。
输出¶
output (异构) - T
切片后的数据张量。
类型约束¶
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)
) 中的一种。约束输入和输出类型为所有张量类型。
Tind 为 (
tensor(int32)
,tensor(int64)
) 中的一种。约束索引为整数类型。
Slice - 10¶
版本¶
名称: Slice (GitHub)
域:
main
起始版本:
10
函数:
False
支持级别:
SupportType.COMMON
Shape 推断:
True
此版本的运算符自版本 10 起可用。
摘要¶
沿多个轴生成输入张量的切片。类似于 numpy:https://numpy.com.cn/doc/stable/reference/routines.indexing.html Slices 使用 starts
、ends
、axes
和 steps
输入为轴列表中的每个轴指定起始和结束维度以及步长,它使用此信息来切片输入 data
张量。如果为任何起始或结束索引传递负值,则表示该维度末尾前的元素数量。如果传递给起始或结束的值大于该维度的元素数量 n
,则表示 n
。对于切片到未知大小维度的末尾,建议传递 INT_MAX
。如果为步长传递负值,则表示向后切片。如果省略 axes
,则将其设置为 [0, ..., ndim-1]
。如果省略 steps
,则将其设置为长度为 len(starts)
的 [1, ..., 1]
。示例 1:data = [ [1, 2, 3, 4], [5, 6, 7, 8], ] axes = [0, 1] starts = [1, 0] ends = [2, 3] steps = [1, 2] result = [ [5, 7], ] 示例 2:data = [ [1, 2, 3, 4], [5, 6, 7, 8], ] starts = [0, 1] ends = [-1, 1000] result = [ [2, 3, 4], ]
输入¶
3 到 5 个输入之间。
data (异构) - T
从中提取切片的数据张量。
starts (异构) - Tind
1-D 张量,对应
axes
中各轴的起始索引ends (异构) - Tind
1-D 张量,对应
axes
中各轴的结束索引(不包含)axes (可选, 异构) - Tind
1-D 张量,表示
starts
和ends
应用于的轴。steps (可选, 异构) - Tind
1-D 张量,对应
axes
中各轴的切片步长。默认为 1。
输出¶
output (异构) - T
切片后的数据张量。
类型约束¶
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)
) 中的一种。约束输入和输出类型为所有张量类型。
Tind 为 (
tensor(int32)
,tensor(int64)
) 中的一种。约束索引为整数类型。
Slice - 1¶
版本¶
名称: Slice (GitHub)
域:
main
起始版本:
1
函数:
False
支持级别:
SupportType.COMMON
Shape 推断:
True
此版本的运算符自版本 1 起可用。
摘要¶
沿多个轴生成输入张量的切片。类似于 numpy:https://numpy.com.cn/doc/stable/reference/routines.indexing.html Slices 使用 axes
、starts
和 ends
属性为轴列表中的每个轴指定起始和结束维度,它使用此信息来切片输入 data
张量。如果为任何起始或结束索引传递负值,则表示该维度末尾前的元素数量。如果传递给起始或结束的值大于该维度的元素数量 n
,则表示 n
。对于切片到未知大小维度的末尾,建议传递 INT_MAX
。如果省略 axes
,则将其设置为 [0, ..., ndim-1]
。示例 1:data = [ [1, 2, 3, 4], [5, 6, 7, 8], ] axes = [0, 1] starts = [1, 0] ends = [2, 3] result = [ [5, 6, 7], ] 示例 2:data = [ [1, 2, 3, 4], [5, 6, 7, 8], ] starts = [0, 1] ends = [-1, 1000] result = [ [2, 3, 4], ]
属性¶
axes - INTS :
表示
starts
和ends
应用于的轴。它是可选的。如果不存在,将视为 [0, 1, …, len(starts
) - 1]。ends - INTS (必需)
对应 axes 中各轴的结束索引(不包含)
starts - INTS (必需)
对应
axes
中各轴的起始索引
输入¶
data (异构) - T
从中提取切片的数据张量。
输出¶
output (异构) - T
切片后的数据张量。
类型约束¶
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)
) 中的一种。约束输入和输出类型为所有张量类型。