
MakeLayout产品支持情况产品是否支持Ascend 950PR/Ascend 950DTxAtlas A3 训练系列产品 / Atlas A3 推理系列产品√Atlas A2 训练系列产品 / Atlas A2 推理系列产品√Atlas 200I/500 A2 推理产品xAtlas 推理系列产品 AI CorexAtlas 推理系列产品 Vector CorexAtlas 训练系列产品x功能说明将传入的Shape和Stride数据打包成Layout数据结构。函数原型template typename ShapeType, typename StrideType __aicore__ inline constexpr auto MakeLayout(const ShapeType shape, const StrideType stride)参数说明参数名输入/输出描述shape输入Std::tuple结构类型用于定义数据的逻辑形状例如二维矩阵的行数和列数或多维张量的各维度大小。stride输入Std::tuple结构类型用于定义各维度在内存中的步长即同维度相邻元素在内存中的间隔间隔的单位为元素与Shape的维度信息一一对应。返回值说明返回Layout对象。约束说明构造Layout对象时传入的Shape和Stride结构需是Std::tuple结构类型且满足Std::tuple结构类型的使用约束。调用示例// 初始化Layout数据结构获取对应数值 AscendC::Shapeint,int,int shape AscendC::MakeShape(10, 20, 30); AscendC::Strideint,int,int stride AscendC::MakeStride(1, 100, 200); auto layoutMake AscendC::MakeLayout(shape, stride); AscendC::LayoutAscendC::Shapeint, int, int, AscendC::Strideint, int, int layoutInit(shape, stride); int value AscendC::Std::get0(layoutMake.GetShape()); // value 10 value AscendC::Std::get1(layoutMake.GetShape()); // value 20 value AscendC::Std::get2(layoutMake.GetShape()); // value 30 value AscendC::Std::get0(layoutInit.GetStride()); // value 1 value AscendC::Std::get1(layoutInit.GetStride()); // value 100 value AscendC::Std::get2(layoutInit.GetStride()); // value 200创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考