| 1 | /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ |
| 2 | |* *| |
| 3 | |* Interface Definitions *| |
| 4 | |* *| |
| 5 | |* Automatically generated file, do not edit! *| |
| 6 | |* *| |
| 7 | \*===----------------------------------------------------------------------===*/ |
| 8 | |
| 9 | |
| 10 | /// Check the availability of workgroup level layouts |
| 11 | bool mlir::xegpu::DistributeLayoutAttr::isForWorkgroup() const { |
| 12 | return getImpl()->isForWorkgroup(getImpl(), *this); |
| 13 | } |
| 14 | |
| 15 | /// Check the availability of subgroup level layouts |
| 16 | bool mlir::xegpu::DistributeLayoutAttr::isForSubgroup() const { |
| 17 | return getImpl()->isForSubgroup(getImpl(), *this); |
| 18 | } |
| 19 | |
| 20 | /// Check the availability of lane level layouts |
| 21 | bool mlir::xegpu::DistributeLayoutAttr::isForLane() const { |
| 22 | return getImpl()->isForLane(getImpl(), *this); |
| 23 | } |
| 24 | |
| 25 | /// Get the rank of attribute |
| 26 | int64_t mlir::xegpu::DistributeLayoutAttr::getRank() const { |
| 27 | return getImpl()->getRank(getImpl(), *this); |
| 28 | } |
| 29 | |
| 30 | /// Get the num of effective subgroups |
| 31 | int64_t mlir::xegpu::DistributeLayoutAttr::getNumSubgroups() const { |
| 32 | return getImpl()->getNumSubgroups(getImpl(), *this); |
| 33 | } |
| 34 | |
| 35 | /// Get the order of the layout attribute |
| 36 | DenseI32ArrayAttr mlir::xegpu::DistributeLayoutAttr::getOrder() const { |
| 37 | return getImpl()->getOrder(getImpl(), *this); |
| 38 | } |
| 39 | |
| 40 | /// Get the effective SgLayout of the layout attribute as integer array |
| 41 | SmallVector<int64_t> mlir::xegpu::DistributeLayoutAttr::getEffectiveSgLayoutAsInt() const { |
| 42 | return getImpl()->getEffectiveSgLayoutAsInt(getImpl(), *this); |
| 43 | } |
| 44 | |
| 45 | /// Get the effective SgData of the layout attribute as integer array |
| 46 | SmallVector<int64_t> mlir::xegpu::DistributeLayoutAttr::getEffectiveSgDataAsInt() const { |
| 47 | return getImpl()->getEffectiveSgDataAsInt(getImpl(), *this); |
| 48 | } |
| 49 | |
| 50 | /// Get the effective InstData of the layout attribute as integer array |
| 51 | SmallVector<int64_t> mlir::xegpu::DistributeLayoutAttr::getEffectiveInstDataAsInt() const { |
| 52 | return getImpl()->getEffectiveInstDataAsInt(getImpl(), *this); |
| 53 | } |
| 54 | |
| 55 | /// Get the effective LaneLayout of the layout attribute as integer array |
| 56 | SmallVector<int64_t> mlir::xegpu::DistributeLayoutAttr::getEffectiveLaneLayoutAsInt() const { |
| 57 | return getImpl()->getEffectiveLaneLayoutAsInt(getImpl(), *this); |
| 58 | } |
| 59 | |
| 60 | /// Get the effective LaneData of the layout attribute as integer array |
| 61 | SmallVector<int64_t> mlir::xegpu::DistributeLayoutAttr::getEffectiveLaneDataAsInt() const { |
| 62 | return getImpl()->getEffectiveLaneDataAsInt(getImpl(), *this); |
| 63 | } |
| 64 | |
| 65 | /// Get the effective order of the layout attribute as integer array |
| 66 | SmallVector<int64_t> mlir::xegpu::DistributeLayoutAttr::getEffectiveOrderAsInt() const { |
| 67 | return getImpl()->getEffectiveOrderAsInt(getImpl(), *this); |
| 68 | } |
| 69 | |
| 70 | /// Derive a new layout by dropping sgLayout and sgData |
| 71 | xegpu::DistributeLayoutAttr mlir::xegpu::DistributeLayoutAttr::dropSgLayoutAndData() const { |
| 72 | return getImpl()->dropSgLayoutAndData(getImpl(), *this); |
| 73 | } |
| 74 | |
| 75 | /// Derive a new layout by dropping InstData |
| 76 | xegpu::DistributeLayoutAttr mlir::xegpu::DistributeLayoutAttr::dropInstData() const { |
| 77 | return getImpl()->dropInstData(getImpl(), *this); |
| 78 | } |
| 79 | |
| 80 | /// Derive a new layout with sg_data, inst_data and lane_data set to 1 for the specified unit dims |
| 81 | xegpu::DistributeLayoutAttr mlir::xegpu::DistributeLayoutAttr::setUnitDimData(const SmallVector<int64_t> unitDims) const { |
| 82 | return getImpl()->setUnitDimData(getImpl(), *this, unitDims); |
| 83 | } |
| 84 | |
| 85 | /// Derive a new layout with sg_lane and lane_layout set to 1 for the specified unit dims |
| 86 | xegpu::DistributeLayoutAttr mlir::xegpu::DistributeLayoutAttr::setUnitDimLayout(const SmallVector<int64_t> unitDims) const { |
| 87 | return getImpl()->setUnitDimLayout(getImpl(), *this, unitDims); |
| 88 | } |
| 89 | |
| 90 | /// Delinearizes a linear ID into its multidimensional |
| 91 | /// indices based on the effective layout level. |
| 92 | FailureOr<SmallVector<Value>> mlir::xegpu::DistributeLayoutAttr::delinearizeId(OpBuilder & builder, Location loc, Value linearId) const { |
| 93 | return getImpl()->delinearizeId(getImpl(), *this, builder, loc, linearId); |
| 94 | } |
| 95 | |
| 96 | /// Derive a new layout with sg_data, inst_data and lane_data set to the |
| 97 | /// specified values for the given dimension. Passing -1 for any parameter |
| 98 | /// preserves its original value. |
| 99 | xegpu::DistributeLayoutAttr mlir::xegpu::DistributeLayoutAttr::setDimData(int64_t dim, int64_t sgData, int64_t instData, int64_t laneData) const { |
| 100 | return getImpl()->setDimData(getImpl(), *this, dim, sgData, instData, laneData); |
| 101 | } |
| 102 | |
| 103 | /// Derive a new layout by removing dimensions. |
| 104 | /// `dimGroup` specifies a group of dimensions to be removed in the derived layout. |
| 105 | xegpu::DistributeLayoutAttr mlir::xegpu::DistributeLayoutAttr::dropDims(SmallVector<int64_t> dimGroup) const { |
| 106 | return getImpl()->dropDims(getImpl(), *this, dimGroup); |
| 107 | } |
| 108 | |
| 109 | /// Derive a new layout by collapsing dimensions. |
| 110 | /// `dimGroup` specifies a group of adjacent dimensions that are collapsed into |
| 111 | /// a single dimension in the derived layout. |
| 112 | xegpu::DistributeLayoutAttr mlir::xegpu::DistributeLayoutAttr::collapseDims(SmallVector<int64_t> dimGroup) const { |
| 113 | return getImpl()->collapseDims(getImpl(), *this, dimGroup); |
| 114 | } |
| 115 | |
| 116 | /// Derive a new layout by expanding a single dimension into |
| 117 | /// multiple adjacent dimensions whose extents are given by `targetShape` |
| 118 | /// (`product(targetShape) == originalSize` on `dim`). The original layout's |
| 119 | /// per-dim values on `dim` are distributed across the new dims: |
| 120 | /// `sg_layout` and `lane_layout` spread outer-to-inner (capped per dim by |
| 121 | /// `targetShape[i]`); `sg_data`, `lane_data`, and `inst_data` fill innermost- |
| 122 | /// first; `inst_data` is seeded from `lane_layout * lane_data` per new dim. |
| 123 | /// `order`, when present, is rewritten so the expanded dims appear |
| 124 | /// innermost-fastest in the original dim's slot; if the input has no |
| 125 | /// `order`, the result has no `order` either (the default FCD-first |
| 126 | /// order `[rank-1, ..., 0]` is assumed). |
| 127 | /// Example: layout<sg_layout=[2, 16], sg_data=[1, 1]> with |
| 128 | /// expandDim(1, [2, 8]) -> layout<sg_layout=[2, 2, 8], sg_data=[1, 1, 1]> |
| 129 | /// (no order in, no order out). |
| 130 | xegpu::DistributeLayoutAttr mlir::xegpu::DistributeLayoutAttr::expandDim(int64_t dim, ArrayRef<int64_t> targetShape) const { |
| 131 | return getImpl()->expandDim(getImpl(), *this, dim, targetShape); |
| 132 | } |
| 133 | |
| 134 | /// Derive a new layout by trasnposing it using `permutation`. |
| 135 | xegpu::DistributeLayoutAttr mlir::xegpu::DistributeLayoutAttr::transposeDims(ArrayRef<int64_t> permutation) const { |
| 136 | return getImpl()->transposeDims(getImpl(), *this, permutation); |
| 137 | } |
| 138 | |
| 139 | /// Generates instructions to compute multidimensional coordinates for dist units |
| 140 | /// assigned to a level identified by linearId. The shape parameter |
| 141 | /// represents the higher-level problem size. Each level may access |
| 142 | /// multiple blocks according to round-robin distribution rules. |
| 143 | FailureOr<SmallVector<SmallVector<Value>>> mlir::xegpu::DistributeLayoutAttr::computeDistributedCoords(OpBuilder & builder, Location loc, Value linearId, ArrayRef<int64_t> shape) const { |
| 144 | return getImpl()->computeDistributedCoords(getImpl(), *this, builder, loc, linearId, shape); |
| 145 | } |
| 146 | |
| 147 | /// Statically computes multidimensional coordinates for all dist units |
| 148 | /// assigned to a compute unit identified by `linearId`. This is the |
| 149 | /// compile-time counterpart of `computeDistributedCoords`: it performs |
| 150 | /// the same delinearization and round-robin enumeration but operates |
| 151 | /// entirely on static integer values. Returns a list of coordinate |
| 152 | /// vectors, one per dist unit. |
| 153 | SmallVector<SmallVector<int64_t>> mlir::xegpu::DistributeLayoutAttr::computeStaticDistributedCoords(int64_t linearId, ArrayRef<int64_t> shape) const { |
| 154 | return getImpl()->computeStaticDistributedCoords(getImpl(), *this, linearId, shape); |
| 155 | } |
| 156 | |
| 157 | /// Computes the distributed shape for each compute unit by dividing each |
| 158 | /// dimension of `shape` by the corresponding layout factor (sg_layout or |
| 159 | /// lane_layout). |
| 160 | /// The distributed shape represents the per-compute-unit tile. Each |
| 161 | /// distribution unit is defined as the combination of layout factors and |
| 162 | /// per-unit data (`subshape`, e.g., sg_data or lane_data). When `shape` |
| 163 | /// spans multiple distribution units, the distributed shape may contain |
| 164 | /// multiple such units. |
| 165 | /// For wrap-around dimensions where the division is uneven, the tensor tile |
| 166 | /// is broadcast to all subgroups/lanes. |
| 167 | FailureOr<SmallVector<int64_t>> mlir::xegpu::DistributeLayoutAttr::computeDistributedShape(SmallVector<int64_t> shape) const { |
| 168 | return getImpl()->computeDistributedShape(getImpl(), *this, shape); |
| 169 | } |
| 170 | |
| 171 | /// Checks if the given shape can be distributed by the layout |
| 172 | bool mlir::xegpu::DistributeLayoutAttr::isDistributable(SmallVector<int64_t> shape) const { |
| 173 | return getImpl()->isDistributable(getImpl(), *this, shape); |
| 174 | } |
| 175 | |
| 176 | /// Check if this layout is a slice of another layout. |
| 177 | bool mlir::xegpu::DistributeLayoutAttr::isSliceOf(const xegpu::DistributeLayoutAttr& other) const { |
| 178 | return getImpl()->isSliceOf(getImpl(), *this, other); |
| 179 | } |
| 180 | |
| 181 | /// Check if this layout is a transpose of |
| 182 | /// the other layout according to given permutation of (0...n-1). |
| 183 | bool mlir::xegpu::DistributeLayoutAttr::isTransposeOf(const xegpu::DistributeLayoutAttr& other, ArrayRef<int64_t> perm, xegpu::LayoutKind kind) const { |
| 184 | return getImpl()->isTransposeOf(getImpl(), *this, other, perm, kind); |
| 185 | } |
| 186 | |
| 187 | /// Check if this layout is compatible with another layout |
| 188 | /// at a specific level of the layout hierarchy regarding a given shape. |
| 189 | bool mlir::xegpu::DistributeLayoutAttr::isCompatibleWith(const xegpu::DistributeLayoutAttr& other, SmallVector<int64_t> shape, xegpu::LayoutKind level) const { |
| 190 | return getImpl()->isCompatibleWith(getImpl(), *this, other, shape, level); |
| 191 | } |
| 192 | |
| 193 | /// Check if this layout is equal to another layout. |
| 194 | /// For LayoutAttr, this compares all fields. |
| 195 | /// For SliceAttr, this requires the same parent and same sliced dims. |
| 196 | bool mlir::xegpu::DistributeLayoutAttr::isEqualTo(const xegpu::DistributeLayoutAttr& other) const { |
| 197 | return getImpl()->isEqualTo(getImpl(), *this, other); |
| 198 | } |
| 199 | |