产品 |
是否支持(仅获取最值的原型) |
是否支持(获取最值和索引的原型) |
|---|---|---|
Ascend 950PR/Ascend 950DT |
x |
√ |
x |
√ |
|
x |
√ |
|
x |
x |
|
√ |
x |
|
x |
x |
|
x |
x |
参数名 |
描述 |
|---|---|
T |
ReduceMax/ReduceMin指令的数据类型,支持half/float。 |
参数名 |
输入/输出 |
描述 |
|---|---|---|
maxMinValue |
输出 |
ReduceMax/ReduceMin指令的最大值/最小值。 |
maxMinIndex |
输出 |
ReduceMax/ReduceMin指令的最值对应的索引值。 |
无
1 2 3 4 5 | AscendC::LocalTensor<float> src; AscendC::LocalTensor<float> work; AscendC::LocalTensor<float> dst; int32_t mask = 64; AscendC::ReduceMax(dst, src, work, mask, 1, 8, true); // 连续场景,srcRepStride = 8,且calIndex = true |
1 2 3 4 5 6 7 | AscendC::LocalTensor<float> src; AscendC::LocalTensor<float> dst; int32_t mask = 64; AscendC::WholeReduceMax(dst, src, mask, 1, 1, 1, 8); float val = 0; // 最大值 float idx = 0; // 最大值的索引值,与ReduceMax的结果相同,保证和WholeReduceMax的调动次序,而且要配对调用 AscendC::GetReduceRepeatMaxMinSpr<float>(val, idx); |
1 2 3 4 5 6 7 | AscendC::LocalTensor<float> src; AscendC::LocalTensor<float> dst; int32_t mask = 64; AscendC::WholeReduceMax(dst, src, mask, 1, 1, 1, 8); float val = 0; // 最大值 float idx = 0; // 最大值的索引值,与ReduceMax的结果相同,保证和WholeReduceMax的调动次序,而且要配对调用 AscendC::GetReduceRepeatMaxMinSpr<float>(val, idx); |
1 2 3 4 5 6 7 | AscendC::LocalTensor<float> src; AscendC::LocalTensor<float> work; AscendC::LocalTensor<float> dst; int32_t mask = 64; AscendC::ReduceMax(dst, src, work, mask, 1, 8, true); float val = 0; // 最大值 AscendC::GetReduceRepeatMaxMinSpr<float>(val); // 保证和WholeReduceMax的调动次序,而且要配对调用 |
1 2 3 4 5 6 7 | AscendC::LocalTensor<float> src; AscendC::LocalTensor<float> dst; int32_t mask = 64; float val = 0; // 最大值 float idx = 0; // 最大值的索引值,与ReduceMax的结果相同 AscendC::WholeReduceMax(dst, src, mask, 1, 1, 1, 8); AscendC::GetReduceRepeatMaxMinSpr<float>(val, idx); // 保证和WholeReduceMax的调动次序,而且要配对调用 |