Coordinate Overview
Coordinate is essentially a tuple used to represent the position information of a tensor in different dimensions, that is, the coordinate value. Coordinate is closely related to Layout and Index (memory location index).
- Conversion from Coordinate to Index: Layout defines the shape of a tensor and the stride of each dimension. Based on the information and the given Coordinate, the index of the coordinate in the memory can be calculated.
- Conversion from Index to Coordinate: Based on the shape and stride information defined in the Layout, the coordinate corresponding to a known memory location index can be obtained through calculation.
Template parameter
Parameter |
Description |
|---|---|
Coords |
Indicates the formal parameter pack of the input data type. The number of parameters ranges from 0 to 64. The supported input data types are size_t and Std::Int. |
Related APIs
// Coord structure construction method template <typename... Ts> __aicore__ inline constexpr Coord<Ts...> MakeCoord(Ts const&... t) // Layout input, converting Coordinate to the memory location index template <typename CoordType, typename ShapeType, typename StrideType> __aicore__ inline constexpr auto Crd2Idx(const CoordType& coord, const Layout<ShapeType, StrideType>& layout) // Shape and stride input, converting Coordinate to the memory location index. template <typename CoordType, typename ShapeType, typename StrideType> __aicore__ inline constexpr auto Crd2Idx(const CoordType& coord, const ShapeType& shape, const StrideType& stride)
Parent topic: Coordinate