在指定维度上求和、取最大值或最小值,并消除这个维度。
相当于pytorch中
intensor.amax(axis)
x shape: [2,3], axis: [0]
x: tensor([[ 1, 18, 17], [16, 10, 1]]) output: tensor([16, 18, 17])
x shape: [2,3,2], axis: [0,1]
x: tensor([[[17, 3], [19, 6], [ 1, 18]], [[ 4, 5], [ 8, 1], [14, 18]]]) output: tensor([19, 18])
相当于pytorch中
intensor.amin(axis)
x shape: [2,3], axis: [0]
x: tensor([[16, 2, 7], [18, 16, 17]]) output: tensor([16, 2, 7])
x shape: [2,3,2], axis: [0,1]
x: tensor([[[ 9, 4], [11, 0], [ 2, 6]], [[ 2, 7], [ 8, 16], [ 5, 3]]]) output: tensor([2, 0])
相当于pytorch中
torch.sum(intensor, axis)
x shape: [2,3], axis: [0]
x: tensor([[-0.9701, -0.8059, 0.2919], [-0.1444, -2.3023, 1.2257]]) output: tensor([-1.1145, -3.1082, 1.5176])
x shape: [2,3,2], axis: [0,1]
x: tensor([[[ 1.4630, -0.3619], [-0.4526, -1.0142], [-0.2883, 0.9334]], [[ 0.7801, -0.1580], [ 0.4843, 1.8145], [ 0.9706, -1.8114]]]) output: tensor([ 2.9571, -0.5976])
struct ReduceParam { enum ReduceType { REDUCE_UNDEFINED = 0, REDUCE_MAX, REDUCE_MIN, REDUCE_SUM, }; ReduceType reduceType = REDUCE_UNDEFINED; SVector<int64_t> axis; };
成员名称 |
类型 |
默认值 |
描述 |
---|---|---|---|
reduceType |
ReduceType |
REDUCE_UNDEFINED |
计算类型,支持以下参数:
|
axis |
SVector<int64_t> |
{} |
指定轴(维度)。
|
参数 |
维度 |
数据类型 |
格式 |
描述 |
---|---|---|---|---|
x |
[dim_0,dim_1,... ,dim_n] |
|
ND |
输入tensor。 |
参数 |
维度 |
数据类型 |
格式 |
描述 |
---|---|---|---|---|
output |
基于输入“x”的维度,消除axis要求的维度。 |
|
ND |
输出tensor。 |