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