Select
产品支持情况
- Ascend 950PR/Ascend 950DT:支持
- Atlas A3 训练系列产品/Atlas A3 推理系列产品:不支持
- Atlas A2 训练系列产品/Atlas A2 推理系列产品:不支持
- Atlas 200I/500 A2 推理产品:不支持
- Atlas 推理系列产品AI Core:不支持
- Atlas 推理系列产品Vector Core:不支持
- Atlas 训练系列产品:不支持
功能说明
选择Layout的shape和stride指定维度组成新的layout对象并返回。
函数原型
C++
template <size_t... Is, typename Shape, typename Stride>
__aicore__ inline constexpr auto Select(const Layout<Shape, Stride>& layout)
参数说明
表1 模板参数说明
| 参数名 | 类型 | 描述 |
|---|---|---|
| Shape | 输入 | 组成Layout的shape的类型,即元组(tuple)类型。 |
| Stride | 输入 | 组成Layout的stride的类型,即元组(tuple)类型。 |
| Is... | size_t | 索引序列,用于编译时递归选择shape和stride的子结构。 |
表2 参数说明
| 参数名 | 类型 | 描述 |
|---|---|---|
| layout | 输入 | Layout用于描述张量的布局。 |
返回值说明
返回子Layout对象。
约束说明
索引Is...必须在有效范围内。
调用示例
C++
using namespace AscendC::Te;
auto shape = MakeShape(10, 20, 30);
auto layout = MakeLayout(shape);
// 选择第0和第1维度
auto subLayout = Select<0, 1>(layout);