MakeLayout
Supported Products
Product |
Supported (√/x) |
|---|---|
√ |
|
√ |
|
x |
|
x |
|
x |
|
x |
Functions
Packs the input shape and stride data into the layout data structure.
Prototype
1 2 | template <typename ShapeType, typename StrideType> __aicore__ inline constexpr auto MakeLayout(const ShapeType& shape, const StrideType& stride) |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
shape |
Input |
Std::tuple structure type, which is used to define the logical shape of data, for example, the number of rows and columns of a two-dimensional matrix or the size of each dimension of a multi-dimensional tensor. |
stride |
Input |
Std::tuple structure type, which is used to define the stride of each dimension in the memory, that is, the interval between adjacent elements in the same dimension in the memory. The unit of the interval is element, and the interval corresponds to the dimension information of the shape. |
Returns
Returns the layout object.
Restrictions
The Shape and Stride structures passed to the constructor of the Layout object must be of the Std::tuple structure type and meet the usage restrictions of the Std::tuple structure type.
Examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | // Initialize the layout data structure and obtain the corresponding value. AscendC::Shape<int,int,int> shape = AscendC::MakeShape(10, 20, 30); AscendC::Stride<int,int,int> stride = AscendC::MakeStride(1, 100, 200); auto layoutMake = AscendC::MakeLayout(shape, stride); AscendC::Layout<AscendC::Shape<int, int, int>, AscendC::Stride<int, int, int>> layoutInit(shape, stride); int value = AscendC::Std::get<0>(layoutMake.GetShape()); // value = 10 value = AscendC::Std::get<1>(layoutMake.GetShape()); // value = 20 value = AscendC::Std::get<2>(layoutMake.GetShape()); // value = 30 value = AscendC::Std::get<0>(layoutInit.GetStride()); // value = 1 value = AscendC::Std::get<1>(layoutInit.GetStride()); // value = 100 value = AscendC::Std::get<2>(layoutInit.GetStride()); // value = 200 |