-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Repurpose the existing --ttir-generic pass to pattern match against any ops that implement `GenericRegionOpInterface`. Ops that implement the `GenericRegionOpInterface` must implement methods: - `getIndexingMaps`: Return a pair of indexingMaps and iteratorTypes for the given GenericRegionOp. - `buildGenericRegion`: Rewrite self into the generic region block using the arith and math dialects. One of the other major differences in this change is to rewrite the generic region operands to be tensors with encoding `ShardLayout`. Previously they were just memrefs, but arith and math dialects cannot work with memref, tensor seemed like a sensible container, `ShardLayout` now holds the memref inside of it. Here's an example of what this transformation does, given input: ```mlir %1 = "ttir.add"(%arg0, %arg1, %0) <{ operandSegmentSizes = array<i32: 2, 1>, operand_constraints = [#any_device, #any_device, #any_device]}> : (tensor<64x128xf32>, tensor<64x128xf32>, tensor<64x128xf32>) -> tensor<64x128xf32> ``` We now have: ```mlir %5 = "ttir.generic"(%1, %3, %4) <{ grid = #tt.grid<1x1>, indexing_maps = [#map, #map, #map], iterator_types = [#parallel, #parallel], operandSegmentSizes = array<i32: 2, 1>, operand_constraints = [#any_device_tile, #any_device_tile, #any_device_tile]}> ({ ^bb0(%arg2: tensor<64x128xf32, #tt.shard_layout<memref<2x4x!tt.tile<32x32, f32>, #l1_>>>, %arg3: tensor<64x128xf32, #tt.shard_layout<memref<2x4x!tt.tile<32x32, f32>, #l1_>>>, %arg4: tensor<64x128xf32, #tt.shard_layout<memref<2x4x!tt.tile<32x32, f32>, #l1_>>>): %8 = arith.addf %arg2, %arg3 : tensor<64x128xf32, #tt.shard_layout<memref<2x4x!tt.tile<32x32, f32>, #l1_>>> "ttir.yield"(%8) : (tensor<64x128xf32, #tt.shard_layout<memref<2x4x!tt.tile<32x32, f32>, #l1_>>>) -> () }) : (tensor<64x128xf32, #layout1>, tensor<64x128xf32, #layout1>, tensor<64x128xf32, #layout1>) -> tensor<64x128xf32, #layout1> } ``` Currently the only ops that implement this interface are eltwise.
- Loading branch information
Showing
9 changed files
with
267 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.