| 1 | /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ |
| 2 | |* *| |
| 3 | |* Interface Declarations *| |
| 4 | |* *| |
| 5 | |* Automatically generated file, do not edit! *| |
| 6 | |* *| |
| 7 | \*===----------------------------------------------------------------------===*/ |
| 8 | |
| 9 | #include "mlir/IR/OpDefinition.h" |
| 10 | |
| 11 | namespace mlir::shard { |
| 12 | |
| 13 | /// Interface for allowing operations to expose information needed to |
| 14 | /// shard them. |
| 15 | class ShardingInterface; |
| 16 | |
| 17 | } // namespace mlir::shard |
| 18 | namespace mlir::shard { |
| 19 | |
| 20 | /// Interface for allowing operations to expose information needed to |
| 21 | /// shard them. |
| 22 | namespace detail { |
| 23 | struct ShardingInterfaceInterfaceTraits { |
| 24 | struct Concept { |
| 25 | /// The methods defined by the interface. |
| 26 | SmallVector<mlir::utils::IteratorType> (*getLoopIteratorTypes)(const Concept *impl, ::mlir::Operation *); |
| 27 | SmallVector<ReductionKind> (*getReductionLoopIteratorKinds)(const Concept *impl, ::mlir::Operation *); |
| 28 | SmallVector<AffineMap> (*getIndexingMaps)(const Concept *impl, ::mlir::Operation *); |
| 29 | FailureOr<ShardingOption> (*getShardingOption)(const Concept *impl, ::mlir::Operation *, ArrayRef<Sharding>, ArrayRef<Sharding>); |
| 30 | FailureOr<std::vector<Sharding>> (*getShardingAnnotations)(const Concept *impl, ::mlir::Operation *, const ShardingOption &); |
| 31 | LogicalResult (*addShardingAnnotations)(const Concept *impl, ::mlir::Operation *, OpBuilder &, const ShardingOption &); |
| 32 | LogicalResult (*partition)(const Concept *impl, ::mlir::Operation *, ArrayRef<Value>, ArrayRef<Sharding>, ArrayRef<Sharding>, IRMapping&, SymbolTableCollection &, OpBuilder &); |
| 33 | }; |
| 34 | template<typename ConcreteOp> |
| 35 | class Model : public Concept { |
| 36 | public: |
| 37 | using Interface = ::mlir::shard::ShardingInterface; |
| 38 | using GeneratedModel = Model; |
| 39 | constexpr Model() : Concept{.getLoopIteratorTypes: getLoopIteratorTypes, .getReductionLoopIteratorKinds: getReductionLoopIteratorKinds, .getIndexingMaps: getIndexingMaps, .getShardingOption: getShardingOption, .getShardingAnnotations: getShardingAnnotations, .addShardingAnnotations: addShardingAnnotations, .partition: partition} {} |
| 40 | |
| 41 | static inline SmallVector<mlir::utils::IteratorType> getLoopIteratorTypes(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); |
| 42 | static inline SmallVector<ReductionKind> getReductionLoopIteratorKinds(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); |
| 43 | static inline SmallVector<AffineMap> getIndexingMaps(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); |
| 44 | static inline FailureOr<ShardingOption> getShardingOption(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ArrayRef<Sharding> operandShardings, ArrayRef<Sharding> resultShardings); |
| 45 | static inline FailureOr<std::vector<Sharding>> getShardingAnnotations(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, const ShardingOption & shardingOption); |
| 46 | static inline LogicalResult addShardingAnnotations(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, OpBuilder & b, const ShardingOption & shardingOption); |
| 47 | static inline LogicalResult partition(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ArrayRef<Value> partitionedOperands, ArrayRef<Sharding> operandShardings, ArrayRef<Sharding> resultShardings, IRMapping& partitionMap, SymbolTableCollection & symbolTableCollection, OpBuilder & builder); |
| 48 | }; |
| 49 | template<typename ConcreteOp> |
| 50 | class FallbackModel : public Concept { |
| 51 | public: |
| 52 | using Interface = ::mlir::shard::ShardingInterface; |
| 53 | FallbackModel() : Concept{.getLoopIteratorTypes: getLoopIteratorTypes, .getReductionLoopIteratorKinds: getReductionLoopIteratorKinds, .getIndexingMaps: getIndexingMaps, .getShardingOption: getShardingOption, .getShardingAnnotations: getShardingAnnotations, .addShardingAnnotations: addShardingAnnotations, .partition: partition} {} |
| 54 | |
| 55 | static inline SmallVector<mlir::utils::IteratorType> getLoopIteratorTypes(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); |
| 56 | static inline SmallVector<ReductionKind> getReductionLoopIteratorKinds(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); |
| 57 | static inline SmallVector<AffineMap> getIndexingMaps(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); |
| 58 | static inline FailureOr<ShardingOption> getShardingOption(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ArrayRef<Sharding> operandShardings, ArrayRef<Sharding> resultShardings); |
| 59 | static inline FailureOr<std::vector<Sharding>> getShardingAnnotations(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, const ShardingOption & shardingOption); |
| 60 | static inline LogicalResult addShardingAnnotations(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, OpBuilder & b, const ShardingOption & shardingOption); |
| 61 | static inline LogicalResult partition(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ArrayRef<Value> partitionedOperands, ArrayRef<Sharding> operandShardings, ArrayRef<Sharding> resultShardings, IRMapping& partitionMap, SymbolTableCollection & symbolTableCollection, OpBuilder & builder); |
| 62 | }; |
| 63 | template<typename ConcreteModel, typename ConcreteOp> |
| 64 | class ExternalModel : public FallbackModel<ConcreteModel> { |
| 65 | public: |
| 66 | using ConcreteEntity = ConcreteOp; |
| 67 | SmallVector<mlir::utils::IteratorType> getLoopIteratorTypes(::mlir::Operation *tablegen_opaque_val) const; |
| 68 | SmallVector<ReductionKind> getReductionLoopIteratorKinds(::mlir::Operation *tablegen_opaque_val) const; |
| 69 | SmallVector<AffineMap> getIndexingMaps(::mlir::Operation *tablegen_opaque_val) const; |
| 70 | FailureOr<ShardingOption> getShardingOption(::mlir::Operation *tablegen_opaque_val, ArrayRef<Sharding> operandShardings, ArrayRef<Sharding> resultShardings) const; |
| 71 | FailureOr<std::vector<Sharding>> getShardingAnnotations(::mlir::Operation *tablegen_opaque_val, const ShardingOption &shardingOption) const; |
| 72 | LogicalResult addShardingAnnotations(::mlir::Operation *tablegen_opaque_val, OpBuilder &b, const ShardingOption &shardingOption) const; |
| 73 | LogicalResult partition(::mlir::Operation *tablegen_opaque_val, ArrayRef<Value> partitionedOperands, ArrayRef<Sharding> operandShardings, ArrayRef<Sharding> resultShardings, IRMapping&partitionMap, SymbolTableCollection &symbolTableCollection, OpBuilder &builder) const; |
| 74 | }; |
| 75 | }; |
| 76 | template <typename ConcreteOp> |
| 77 | struct ShardingInterfaceTrait; |
| 78 | |
| 79 | } // namespace detail |
| 80 | class ShardingInterface : public ::mlir::OpInterface<ShardingInterface, detail::ShardingInterfaceInterfaceTraits> { |
| 81 | public: |
| 82 | using ::mlir::OpInterface<ShardingInterface, detail::ShardingInterfaceInterfaceTraits>::OpInterface; |
| 83 | template <typename ConcreteOp> |
| 84 | struct Trait : public detail::ShardingInterfaceTrait<ConcreteOp> {}; |
| 85 | |
| 86 | /// Returns a list of iterator types that describe the number of loops. |
| 87 | /// The iterator types determine how the operation traverses its input and |
| 88 | /// output tensors. |
| 89 | /// |
| 90 | /// Example 1: A gemm op has 3 loops, M, N and K. Their loop iterator |
| 91 | /// types are parallel, parallel, reduction. This indicates that M and |
| 92 | /// N are traversed in parallel, while the K dimension is used for |
| 93 | /// reduction. |
| 94 | SmallVector<mlir::utils::IteratorType> getLoopIteratorTypes(); |
| 95 | |
| 96 | /// Return the kind of all reduction loop iterators. |
| 97 | /// The order is the same as the same as the result from |
| 98 | /// `getLoopIteratorTypes`. |
| 99 | /// |
| 100 | /// Example 1: |
| 101 | /// iterator types = (parallel, reduction, parallel, reduction) |
| 102 | /// || || |
| 103 | /// reduction kinds = ( sum, max) |
| 104 | /// |
| 105 | /// Example 2: |
| 106 | /// A softmax op's loop iterator types are parallel and |
| 107 | /// reduction. |
| 108 | /// The reduction iterator will be of kind `generic`, since it is non of |
| 109 | /// the available presets. |
| 110 | SmallVector<ReductionKind> getReductionLoopIteratorKinds(); |
| 111 | |
| 112 | /// Return the indexing maps attribute within the current operation. |
| 113 | /// Indexing maps determine how indices in the iteration space map to |
| 114 | /// tensor indices. They are specified using `affine_map` in MLIR, which |
| 115 | /// provides an affine transformation of indices. |
| 116 | SmallVector<AffineMap> getIndexingMaps(); |
| 117 | |
| 118 | /// Given that certain operands or results of the operation may have |
| 119 | /// sharding annotations, this method leverages this information to |
| 120 | /// deduce how the operation should be sharded. |
| 121 | /// The passed sharding may be incomplete, this gives freedom for the |
| 122 | /// op to select the most appropriate shardings for all the operands |
| 123 | /// and results and the op itself. |
| 124 | FailureOr<ShardingOption> getShardingOption(ArrayRef<Sharding> operandShardings, ArrayRef<Sharding> resultShardings); |
| 125 | |
| 126 | /// Based on a given ShardingOption, get the operand and result |
| 127 | /// operations for the operands and results sharding annotations. |
| 128 | /// This is what shardings the operands and results need to have in order |
| 129 | /// to shard the op according to shardingOption. |
| 130 | FailureOr<std::vector<Sharding>> getShardingAnnotations(const ShardingOption & shardingOption); |
| 131 | |
| 132 | /// Based on a given ShardingOption, this method adds `shard.shard` |
| 133 | /// operations for the operands and results that previously lacked |
| 134 | /// sharding annotations. |
| 135 | LogicalResult addShardingAnnotations(OpBuilder & b, const ShardingOption & shardingOption); |
| 136 | |
| 137 | /// Convert self to SPMD form. |
| 138 | /// This method is used during the partition pass of a program fully |
| 139 | /// annotated with shardings. |
| 140 | /// |
| 141 | /// The partition algorithm would read the surrounding sharding |
| 142 | /// annotations from the IR for each argument/result and prepare |
| 143 | /// `operandShardings` and `resultShardings`. |
| 144 | /// Values that are not ranked tensors do not have sharding annotations. |
| 145 | /// In this case their corresponding Sharding is null. |
| 146 | /// |
| 147 | /// For convenience it will also prepare `partitionedOperands`, although |
| 148 | /// they can be retrieved from the `partitionMap`. |
| 149 | /// |
| 150 | /// The `partitionMap` contains a mapping from unsharded to |
| 151 | /// sharded/partitioned values that are constructed during the partition |
| 152 | /// pass. The interface implementation must populate `partitionMap` |
| 153 | /// with the mapping for this op's results. |
| 154 | /// |
| 155 | /// `builder` is set to insert new operations in the appropriate point. |
| 156 | /// The implementation should not return the builder to the original |
| 157 | /// insertion point. |
| 158 | /// It should leave it as is after all insertions are done. |
| 159 | /// |
| 160 | /// The default implementation does full replication. |
| 161 | /// This assumes that all sharding annotations are for full replication. |
| 162 | LogicalResult partition(ArrayRef<Value> partitionedOperands, ArrayRef<Sharding> operandShardings, ArrayRef<Sharding> resultShardings, IRMapping& partitionMap, SymbolTableCollection & symbolTableCollection, OpBuilder & builder); |
| 163 | |
| 164 | LogicalResult verifyShardingInterfaceImpl(); |
| 165 | |
| 166 | void printLoopTypesAndIndexingMaps(raw_ostream &os); |
| 167 | }; |
| 168 | |
| 169 | } // namespace mlir::shard |
| 170 | namespace mlir::shard::detail { |
| 171 | |
| 172 | template <typename ConcreteOp> |
| 173 | struct ShardingInterfaceTrait : public ::mlir::OpInterface<ShardingInterface, detail::ShardingInterfaceInterfaceTraits>::Trait<ConcreteOp> { |
| 174 | |
| 175 | /// Returns a list of iterator types that describe the number of loops. |
| 176 | /// The iterator types determine how the operation traverses its input and |
| 177 | /// output tensors. |
| 178 | /// |
| 179 | /// Example 1: A gemm op has 3 loops, M, N and K. Their loop iterator |
| 180 | /// types are parallel, parallel, reduction. This indicates that M and |
| 181 | /// N are traversed in parallel, while the K dimension is used for |
| 182 | /// reduction. |
| 183 | SmallVector<mlir::utils::IteratorType> getLoopIteratorTypes() { |
| 184 | return {}; |
| 185 | } |
| 186 | |
| 187 | /// Return the kind of all reduction loop iterators. |
| 188 | /// The order is the same as the same as the result from |
| 189 | /// `getLoopIteratorTypes`. |
| 190 | /// |
| 191 | /// Example 1: |
| 192 | /// iterator types = (parallel, reduction, parallel, reduction) |
| 193 | /// || || |
| 194 | /// reduction kinds = ( sum, max) |
| 195 | /// |
| 196 | /// Example 2: |
| 197 | /// A softmax op's loop iterator types are parallel and |
| 198 | /// reduction. |
| 199 | /// The reduction iterator will be of kind `generic`, since it is non of |
| 200 | /// the available presets. |
| 201 | SmallVector<ReductionKind> getReductionLoopIteratorKinds() { |
| 202 | return {}; |
| 203 | } |
| 204 | |
| 205 | /// Return the indexing maps attribute within the current operation. |
| 206 | /// Indexing maps determine how indices in the iteration space map to |
| 207 | /// tensor indices. They are specified using `affine_map` in MLIR, which |
| 208 | /// provides an affine transformation of indices. |
| 209 | SmallVector<AffineMap> getIndexingMaps() { |
| 210 | return {}; |
| 211 | } |
| 212 | |
| 213 | /// Given that certain operands or results of the operation may have |
| 214 | /// sharding annotations, this method leverages this information to |
| 215 | /// deduce how the operation should be sharded. |
| 216 | /// The passed sharding may be incomplete, this gives freedom for the |
| 217 | /// op to select the most appropriate shardings for all the operands |
| 218 | /// and results and the op itself. |
| 219 | FailureOr<ShardingOption> getShardingOption(ArrayRef<Sharding> operandShardings, ArrayRef<Sharding> resultShardings) { |
| 220 | return detail::defaultGetShardingOption( |
| 221 | op: (*static_cast<ConcreteOp *>(this)).getOperation(), operandShardings, resultShardings); |
| 222 | } |
| 223 | |
| 224 | /// Based on a given ShardingOption, get the operand and result |
| 225 | /// operations for the operands and results sharding annotations. |
| 226 | /// This is what shardings the operands and results need to have in order |
| 227 | /// to shard the op according to shardingOption. |
| 228 | FailureOr<std::vector<Sharding>> getShardingAnnotations(const ShardingOption & shardingOption) { |
| 229 | return detail::defaultGetShardingAnnotations( |
| 230 | op: (*static_cast<ConcreteOp *>(this)).getOperation(), shardingOption); |
| 231 | } |
| 232 | |
| 233 | /// Based on a given ShardingOption, this method adds `shard.shard` |
| 234 | /// operations for the operands and results that previously lacked |
| 235 | /// sharding annotations. |
| 236 | LogicalResult addShardingAnnotations(OpBuilder & b, const ShardingOption & shardingOption) { |
| 237 | return detail::defaultAddShardingAnnotations( |
| 238 | op: (*static_cast<ConcreteOp *>(this)).getOperation(), b, shardingOption); |
| 239 | } |
| 240 | |
| 241 | /// Convert self to SPMD form. |
| 242 | /// This method is used during the partition pass of a program fully |
| 243 | /// annotated with shardings. |
| 244 | /// |
| 245 | /// The partition algorithm would read the surrounding sharding |
| 246 | /// annotations from the IR for each argument/result and prepare |
| 247 | /// `operandShardings` and `resultShardings`. |
| 248 | /// Values that are not ranked tensors do not have sharding annotations. |
| 249 | /// In this case their corresponding Sharding is null. |
| 250 | /// |
| 251 | /// For convenience it will also prepare `partitionedOperands`, although |
| 252 | /// they can be retrieved from the `partitionMap`. |
| 253 | /// |
| 254 | /// The `partitionMap` contains a mapping from unsharded to |
| 255 | /// sharded/partitioned values that are constructed during the partition |
| 256 | /// pass. The interface implementation must populate `partitionMap` |
| 257 | /// with the mapping for this op's results. |
| 258 | /// |
| 259 | /// `builder` is set to insert new operations in the appropriate point. |
| 260 | /// The implementation should not return the builder to the original |
| 261 | /// insertion point. |
| 262 | /// It should leave it as is after all insertions are done. |
| 263 | /// |
| 264 | /// The default implementation does full replication. |
| 265 | /// This assumes that all sharding annotations are for full replication. |
| 266 | LogicalResult partition(ArrayRef<Value> partitionedOperands, ArrayRef<Sharding> operandShardings, ArrayRef<Sharding> resultShardings, IRMapping& partitionMap, SymbolTableCollection & symbolTableCollection, OpBuilder & builder) { |
| 267 | partitionFullyReplicatedOperation( |
| 268 | *(*static_cast<ConcreteOp *>(this)).getOperation(), partitionedOperands, operandShardings, |
| 269 | resultShardings, partitionMap, symbolTableCollection, builder); |
| 270 | return success(); |
| 271 | } |
| 272 | }; |
| 273 | |
| 274 | } // namespace mlir::shard::detail |
| 275 | namespace mlir::shard { |
| 276 | |
| 277 | template<typename ConcreteOp> |
| 278 | SmallVector<mlir::utils::IteratorType> detail::ShardingInterfaceInterfaceTraits::Model<ConcreteOp>::getLoopIteratorTypes(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { |
| 279 | return (llvm::cast<ConcreteOp>(tablegen_opaque_val)).getLoopIteratorTypes(); |
| 280 | } |
| 281 | template<typename ConcreteOp> |
| 282 | SmallVector<ReductionKind> detail::ShardingInterfaceInterfaceTraits::Model<ConcreteOp>::getReductionLoopIteratorKinds(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { |
| 283 | return (llvm::cast<ConcreteOp>(tablegen_opaque_val)).getReductionLoopIteratorKinds(); |
| 284 | } |
| 285 | template<typename ConcreteOp> |
| 286 | SmallVector<AffineMap> detail::ShardingInterfaceInterfaceTraits::Model<ConcreteOp>::getIndexingMaps(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { |
| 287 | return (llvm::cast<ConcreteOp>(tablegen_opaque_val)).getIndexingMaps(); |
| 288 | } |
| 289 | template<typename ConcreteOp> |
| 290 | FailureOr<ShardingOption> detail::ShardingInterfaceInterfaceTraits::Model<ConcreteOp>::getShardingOption(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ArrayRef<Sharding> operandShardings, ArrayRef<Sharding> resultShardings) { |
| 291 | return (llvm::cast<ConcreteOp>(tablegen_opaque_val)).getShardingOption(operandShardings, resultShardings); |
| 292 | } |
| 293 | template<typename ConcreteOp> |
| 294 | FailureOr<std::vector<Sharding>> detail::ShardingInterfaceInterfaceTraits::Model<ConcreteOp>::getShardingAnnotations(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, const ShardingOption & shardingOption) { |
| 295 | return (llvm::cast<ConcreteOp>(tablegen_opaque_val)).getShardingAnnotations(shardingOption); |
| 296 | } |
| 297 | template<typename ConcreteOp> |
| 298 | LogicalResult detail::ShardingInterfaceInterfaceTraits::Model<ConcreteOp>::addShardingAnnotations(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, OpBuilder & b, const ShardingOption & shardingOption) { |
| 299 | return (llvm::cast<ConcreteOp>(tablegen_opaque_val)).addShardingAnnotations(b, shardingOption); |
| 300 | } |
| 301 | template<typename ConcreteOp> |
| 302 | LogicalResult detail::ShardingInterfaceInterfaceTraits::Model<ConcreteOp>::partition(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ArrayRef<Value> partitionedOperands, ArrayRef<Sharding> operandShardings, ArrayRef<Sharding> resultShardings, IRMapping& partitionMap, SymbolTableCollection & symbolTableCollection, OpBuilder & builder) { |
| 303 | return (llvm::cast<ConcreteOp>(tablegen_opaque_val)).partition(partitionedOperands, operandShardings, resultShardings, partitionMap, symbolTableCollection, builder); |
| 304 | } |
| 305 | template<typename ConcreteOp> |
| 306 | SmallVector<mlir::utils::IteratorType> detail::ShardingInterfaceInterfaceTraits::FallbackModel<ConcreteOp>::getLoopIteratorTypes(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { |
| 307 | return static_cast<const ConcreteOp *>(impl)->getLoopIteratorTypes(tablegen_opaque_val); |
| 308 | } |
| 309 | template<typename ConcreteOp> |
| 310 | SmallVector<ReductionKind> detail::ShardingInterfaceInterfaceTraits::FallbackModel<ConcreteOp>::getReductionLoopIteratorKinds(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { |
| 311 | return static_cast<const ConcreteOp *>(impl)->getReductionLoopIteratorKinds(tablegen_opaque_val); |
| 312 | } |
| 313 | template<typename ConcreteOp> |
| 314 | SmallVector<AffineMap> detail::ShardingInterfaceInterfaceTraits::FallbackModel<ConcreteOp>::getIndexingMaps(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { |
| 315 | return static_cast<const ConcreteOp *>(impl)->getIndexingMaps(tablegen_opaque_val); |
| 316 | } |
| 317 | template<typename ConcreteOp> |
| 318 | FailureOr<ShardingOption> detail::ShardingInterfaceInterfaceTraits::FallbackModel<ConcreteOp>::getShardingOption(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ArrayRef<Sharding> operandShardings, ArrayRef<Sharding> resultShardings) { |
| 319 | return static_cast<const ConcreteOp *>(impl)->getShardingOption(tablegen_opaque_val, operandShardings, resultShardings); |
| 320 | } |
| 321 | template<typename ConcreteOp> |
| 322 | FailureOr<std::vector<Sharding>> detail::ShardingInterfaceInterfaceTraits::FallbackModel<ConcreteOp>::getShardingAnnotations(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, const ShardingOption & shardingOption) { |
| 323 | return static_cast<const ConcreteOp *>(impl)->getShardingAnnotations(tablegen_opaque_val, shardingOption); |
| 324 | } |
| 325 | template<typename ConcreteOp> |
| 326 | LogicalResult detail::ShardingInterfaceInterfaceTraits::FallbackModel<ConcreteOp>::addShardingAnnotations(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, OpBuilder & b, const ShardingOption & shardingOption) { |
| 327 | return static_cast<const ConcreteOp *>(impl)->addShardingAnnotations(tablegen_opaque_val, b, shardingOption); |
| 328 | } |
| 329 | template<typename ConcreteOp> |
| 330 | LogicalResult detail::ShardingInterfaceInterfaceTraits::FallbackModel<ConcreteOp>::partition(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ArrayRef<Value> partitionedOperands, ArrayRef<Sharding> operandShardings, ArrayRef<Sharding> resultShardings, IRMapping& partitionMap, SymbolTableCollection & symbolTableCollection, OpBuilder & builder) { |
| 331 | return static_cast<const ConcreteOp *>(impl)->partition(tablegen_opaque_val, partitionedOperands, operandShardings, resultShardings, partitionMap, symbolTableCollection, builder); |
| 332 | } |
| 333 | template<typename ConcreteModel, typename ConcreteOp> |
| 334 | SmallVector<mlir::utils::IteratorType> detail::ShardingInterfaceInterfaceTraits::ExternalModel<ConcreteModel, ConcreteOp>::getLoopIteratorTypes(::mlir::Operation *tablegen_opaque_val) const { |
| 335 | return {}; |
| 336 | } |
| 337 | template<typename ConcreteModel, typename ConcreteOp> |
| 338 | SmallVector<ReductionKind> detail::ShardingInterfaceInterfaceTraits::ExternalModel<ConcreteModel, ConcreteOp>::getReductionLoopIteratorKinds(::mlir::Operation *tablegen_opaque_val) const { |
| 339 | return {}; |
| 340 | } |
| 341 | template<typename ConcreteModel, typename ConcreteOp> |
| 342 | SmallVector<AffineMap> detail::ShardingInterfaceInterfaceTraits::ExternalModel<ConcreteModel, ConcreteOp>::getIndexingMaps(::mlir::Operation *tablegen_opaque_val) const { |
| 343 | return {}; |
| 344 | } |
| 345 | template<typename ConcreteModel, typename ConcreteOp> |
| 346 | FailureOr<ShardingOption> detail::ShardingInterfaceInterfaceTraits::ExternalModel<ConcreteModel, ConcreteOp>::getShardingOption(::mlir::Operation *tablegen_opaque_val, ArrayRef<Sharding> operandShardings, ArrayRef<Sharding> resultShardings) const { |
| 347 | return detail::defaultGetShardingOption( |
| 348 | op: (llvm::cast<ConcreteOp>(tablegen_opaque_val)).getOperation(), operandShardings, resultShardings); |
| 349 | } |
| 350 | template<typename ConcreteModel, typename ConcreteOp> |
| 351 | FailureOr<std::vector<Sharding>> detail::ShardingInterfaceInterfaceTraits::ExternalModel<ConcreteModel, ConcreteOp>::getShardingAnnotations(::mlir::Operation *tablegen_opaque_val, const ShardingOption &shardingOption) const { |
| 352 | return detail::defaultGetShardingAnnotations( |
| 353 | op: (llvm::cast<ConcreteOp>(tablegen_opaque_val)).getOperation(), shardingOption); |
| 354 | } |
| 355 | template<typename ConcreteModel, typename ConcreteOp> |
| 356 | LogicalResult detail::ShardingInterfaceInterfaceTraits::ExternalModel<ConcreteModel, ConcreteOp>::addShardingAnnotations(::mlir::Operation *tablegen_opaque_val, OpBuilder &b, const ShardingOption &shardingOption) const { |
| 357 | return detail::defaultAddShardingAnnotations( |
| 358 | op: (llvm::cast<ConcreteOp>(tablegen_opaque_val)).getOperation(), b, shardingOption); |
| 359 | } |
| 360 | template<typename ConcreteModel, typename ConcreteOp> |
| 361 | LogicalResult detail::ShardingInterfaceInterfaceTraits::ExternalModel<ConcreteModel, ConcreteOp>::partition(::mlir::Operation *tablegen_opaque_val, ArrayRef<Value> partitionedOperands, ArrayRef<Sharding> operandShardings, ArrayRef<Sharding> resultShardings, IRMapping&partitionMap, SymbolTableCollection &symbolTableCollection, OpBuilder &builder) const { |
| 362 | partitionFullyReplicatedOperation( |
| 363 | *(llvm::cast<ConcreteOp>(tablegen_opaque_val)).getOperation(), partitionedOperands, operandShardings, |
| 364 | resultShardings, partitionMap, symbolTableCollection, builder); |
| 365 | return success(); |
| 366 | } |
| 367 | |
| 368 | } // namespace mlir::shard |
| 369 | |