Repository navigation
Migrate Flow dependencies in Stream/Codegen to TensorExt - #20564
Conversation
ad8f982 to
3ddd5c3
Compare
|
My github review UI sucks because there are too many files. It also happens when I set filters on the files. So I'm going to review it in few steps on my local machine:
For bazel BUILD files, I think we can remove more Flow deps in a follow-up. Some CodeGen passes still depend on flow dialect, and I can help clean up later. For this PR, I think we can scope it to pure migration, to reduce review complexity. The removal of deps can be done later because the PR does not add "new" dependencies. The only new dependency should all be TensorExt. Does it sound good? |
|
This is going to be a great cleanup, many thanks to @jtuyls! |
Yeah, sounds good, thanks. I tried to remove all Flow deps that I could, but there are indeed other places where codegen passes still depend on the Flow dialect and keeping this PR as a pure migration is good to reduce review complexity. |
3ddd5c3 to
58ad601
Compare
|
RE mlir files: Skimmed through the diff, which looks good to me. The file was generated by running Most of them are replacing
I confirmed that the dispatch_tensor_folding.mlir is moved from Flow to TensorExt with the replacement: https://gist.github.com/hanhanW/9764fa9539dc4954ef617e9542c6b15c There are three tests are moved from |
|
The changes in BUILD files look very reasonable to me: https://gist.github.com/hanhanW/4449f1cafc63153d6118beaa02824af1 |
|
These three diff files, that exclude the changes in cd compiler/src/iree/compiler
gd HEAD~ **/*.h ':(exclude)Dialect/TensorExt/*' > ~/exclude_tensor_ext_h.patc
gd HEAD~ **/*.cpp ':(exclude)Dialect/TensorExt/*' > ~/exclude_tensor_ext_h.patch
gd HEAD~ **/*.td ':(exclude)Dialect/TensorExt/*' > ~/exclude_tensor_ext_td.patcThe replacement part looks good to me. There are some removal looks reasonable, and I believe that they are moved to |
9d84146 to
2104ef6
Compare
|
I reviewed the other TensorExt files and most of the code are moved from Flow with dialect name update. Overall it looks good to me. I think the next question is how to land it properly. @ScottTodd for this kind of change, do we need to announce it somewhere? @jtuyls do you have some scripts that can help downstream projects integrate this? If so, can you add them to PR description? I have few commands in my mind, and I can share it here. For find ./ -type f -exec sed -i 's/flow.dispatch.workload.ordinal/iree_tensor_ext.dispatch.workload.ordinal/g' {} \;And the below command helps add the includes to c++ files. It adds sed -i '/#include "iree\/compiler\/Dialect\/Flow\/IR\/FlowOps.h"/a #include "iree/compiler/Dialect/TensorExt/IR/TensorExtOps.h"' $(grep -rl '#include "iree/compiler/Dialect/Flow/IR/FlowOps.h"' ./compiler/)And we can do something similar for BUILD files and run Additionally, they need to run |
I think Scott is on holiday, so we might want to check with someone else. And I think we could mention it somewhere on an appropriate channel on the IREE discord?
I think sed commands are the most useful to help update the files so I added them to PR description. I updated them a bit to look for the op names instead of the
I am not sure how to best update the BUILD.bazel files automatically. Just because they have a flow dependency doesn't mean that they need to have a TensorExt dependency after this change as the updated ops might not be used in the respective code files. |
hanhanW
left a comment
There was a problem hiding this comment.
It looks good, I have a quick chat with Mahesh on discord. Let's land it early next week because Canada/UK folks have holidays.
I'm approving the PR, so you can rebase and land it after you're back from holidays, if you have the holidays.
Ok, thanks, sounds good. |
Signed-off-by: Jorn Tuyls <[email protected]>
2104ef6 to
e9eae44
Compare
|
@jtuyls do you have cycles to address the post comments? I can help if you are busy on other things. |
Yes, I can address the above comments. |
Update `Flow` dependencies to `TensorExt` according to IREE changes iree-org/iree#20564.
) Migrates a set of Flow constructs to TensorExt to reduce the dependency in Stream/Codegen on Flow and to avoid a circular dependency from Encoding on Flow encountered during the MaterializeEncodingIntoPadding collapsing work (iree-org#20160 (comment)): - IREE::Flow::DispatchWorkloadOrdinalOp - IREE::Flow::DispatchTensorLoadOp - IREE::Flow::DispatchTensorStoreOp - IREE::Flow::DispatchWorkgroupCountFromSliceOp - IREE::Flow::DispatchWorkgroupCountFromDagRootOp -> moved because it shares a base class with DispatchWorkgroupCountFromSliceOp - IREE::Flow::DispatchTensorType Resolves: [iree-org#20249](iree-org#20249) Note for downstream users, you can use the following commands (in the provided order) to help update your codebase for these changes: ``` # Update the op names in the MLIR files grep -rl flow.dispatch.workload.ordinal | xargs -d '\n' sed -i 's/flow.dispatch.workload.ordinal/iree_tensor_ext.dispatch.workload.ordinal/g' grep -rl flow.dispatch.tensor | xargs -d '\n' sed -i 's/flow.dispatch.tensor/iree_tensor_ext.dispatch.tensor/g' grep -rl flow.dispatch.workgroup_count_from | xargs -d '\n' sed -i 's/flow.dispatch.workgroup_count_from/iree_tensor_ext.dispatch.workgroup_count_from/g' # Add 'TensorExtOps.h' header to files using the ops { grep -rl 'IREE::Flow::DispatchWorkloadOrdinalOp' ./; grep -rl 'IREE::Flow::DispatchTensorLoadOp' ./; grep -rl 'IREE::Flow::DispatchTensorStoreOp' ./; grep -rl 'IREE::Flow::DispatchWorkgroupCount' ./; } | xargs -d '\n' sed -i '/#include "iree\/compiler\/Dialect\/Flow\/IR\/FlowOps.h"/a #include "iree/compiler/Dialect/TensorExt/IR/TensorExtOps.h"' # Add 'TensorExtTypes.h' header to files using 'DispatchTensorType' grep -rl 'IREE::Flow::DispatchTensorType' ./ | xargs -d '\n' sed -i '/#include "iree\/compiler\/Dialect\/Flow\/IR\/FlowTypes.h"/a #include "iree/compiler/Dialect/TensorExt/IR/TensorExtTypes.h"' # Update the op names grep -rl 'IREE::Flow::DispatchWorkloadOrdinalOp' | xargs -d '\n' sed -i 's/IREE::Flow::DispatchWorkloadOrdinalOp/IREE::TensorExt::DispatchWorkloadOrdinalOp/g' grep -rl 'IREE::Flow::DispatchTensorLoadOp' | xargs -d '\n' sed -i 's/IREE::Flow::DispatchTensorLoadOp/IREE::TensorExt::DispatchTensorLoadOp/g' grep -rl 'IREE::Flow::DispatchTensorStoreOp' | xargs -d '\n' sed -i 's/IREE::Flow::DispatchTensorStoreOp/IREE::TensorExt::DispatchTensorStoreOp/g' grep -rl 'IREE::Flow::DispatchWorkgroupCount' | xargs -d '\n' sed -i 's/IREE::Flow::DispatchWorkgroupCount/IREE::TensorExt::DispatchWorkgroupCount/g' # Update 'DispatchTensorType' grep -rl 'IREE::Flow::DispatchTensorType' | xargs -d '\n' sed -i 's/IREE::Flow::DispatchTensorType/IREE::TensorExt::DispatchTensorType/g' ``` Afterwards, you might need to perform following updates manually: - Remove `FlowOps.h` and `FlowTypes.h` include lines from files where they are not needed anymore. - Update `BUILD.bazel` and/or `CmakeLists.txt` files to include the new `TensorExt` dependency and potentially remove `Flow` dependencies if possible. Note that you can use `python build_tools/bazel_to_cmake/bazel_to_cmake.py` to automatically update cmake files once you have updated the `BUILD.bazel` (if using bazel). - Lint your code using `pre-commit run --all-files`, `clang-format` or your own linter if applicable. Signed-off-by: Jorn Tuyls <[email protected]>
Migrates a set of Flow constructs to TensorExt to reduce the dependency in Stream/Codegen on Flow and to avoid a circular dependency from Encoding on Flow encountered during the MaterializeEncodingIntoPadding collapsing work (#20160 (comment)): - IREE::Flow::DispatchWorkloadOrdinalOp - IREE::Flow::DispatchTensorLoadOp - IREE::Flow::DispatchTensorStoreOp - IREE::Flow::DispatchWorkgroupCountFromSliceOp - IREE::Flow::DispatchWorkgroupCountFromDagRootOp -> moved because it shares a base class with DispatchWorkgroupCountFromSliceOp - IREE::Flow::DispatchTensorType Resolves: [#20249](#20249) Note for downstream users, you can use the following commands (in the provided order) to help update your codebase for these changes: ``` # Update the op names in the MLIR files grep -rl flow.dispatch.workload.ordinal | xargs -d '\n' sed -i 's/flow.dispatch.workload.ordinal/iree_tensor_ext.dispatch.workload.ordinal/g' grep -rl flow.dispatch.tensor | xargs -d '\n' sed -i 's/flow.dispatch.tensor/iree_tensor_ext.dispatch.tensor/g' grep -rl flow.dispatch.workgroup_count_from | xargs -d '\n' sed -i 's/flow.dispatch.workgroup_count_from/iree_tensor_ext.dispatch.workgroup_count_from/g' # Add 'TensorExtOps.h' header to files using the ops { grep -rl 'IREE::Flow::DispatchWorkloadOrdinalOp' ./; grep -rl 'IREE::Flow::DispatchTensorLoadOp' ./; grep -rl 'IREE::Flow::DispatchTensorStoreOp' ./; grep -rl 'IREE::Flow::DispatchWorkgroupCount' ./; } | xargs -d '\n' sed -i '/#include "iree\/compiler\/Dialect\/Flow\/IR\/FlowOps.h"/a #include "iree/compiler/Dialect/TensorExt/IR/TensorExtOps.h"' # Add 'TensorExtTypes.h' header to files using 'DispatchTensorType' grep -rl 'IREE::Flow::DispatchTensorType' ./ | xargs -d '\n' sed -i '/#include "iree\/compiler\/Dialect\/Flow\/IR\/FlowTypes.h"/a #include "iree/compiler/Dialect/TensorExt/IR/TensorExtTypes.h"' # Update the op names grep -rl 'IREE::Flow::DispatchWorkloadOrdinalOp' | xargs -d '\n' sed -i 's/IREE::Flow::DispatchWorkloadOrdinalOp/IREE::TensorExt::DispatchWorkloadOrdinalOp/g' grep -rl 'IREE::Flow::DispatchTensorLoadOp' | xargs -d '\n' sed -i 's/IREE::Flow::DispatchTensorLoadOp/IREE::TensorExt::DispatchTensorLoadOp/g' grep -rl 'IREE::Flow::DispatchTensorStoreOp' | xargs -d '\n' sed -i 's/IREE::Flow::DispatchTensorStoreOp/IREE::TensorExt::DispatchTensorStoreOp/g' grep -rl 'IREE::Flow::DispatchWorkgroupCount' | xargs -d '\n' sed -i 's/IREE::Flow::DispatchWorkgroupCount/IREE::TensorExt::DispatchWorkgroupCount/g' # Update 'DispatchTensorType' grep -rl 'IREE::Flow::DispatchTensorType' | xargs -d '\n' sed -i 's/IREE::Flow::DispatchTensorType/IREE::TensorExt::DispatchTensorType/g' ``` Afterwards, you might need to perform following updates manually: - Remove `FlowOps.h` and `FlowTypes.h` include lines from files where they are not needed anymore. - Update `BUILD.bazel` and/or `CmakeLists.txt` files to include the new `TensorExt` dependency and potentially remove `Flow` dependencies if possible. Note that you can use `python build_tools/bazel_to_cmake/bazel_to_cmake.py` to automatically update cmake files once you have updated the `BUILD.bazel` (if using bazel). - Lint your code using `pre-commit run --all-files`, `clang-format` or your own linter if applicable. Signed-off-by: Jorn Tuyls <[email protected]>
Migrates a set of Flow constructs to TensorExt to reduce the dependency in Stream/Codegen on Flow and to avoid a circular dependency from Encoding on Flow encountered during the MaterializeEncodingIntoPadding collapsing work (#20160 (comment)):
Resolves: #20249
Note for downstream users, you can use the following commands (in the provided order) to help update your codebase for these changes:
Afterwards, you might need to perform following updates manually:
FlowOps.handFlowTypes.hinclude lines from files where they are not needed anymore.BUILD.bazeland/orCmakeLists.txtfiles to include the newTensorExtdependency and potentially removeFlowdependencies if possible. Note that you can usepython build_tools/bazel_to_cmake/bazel_to_cmake.pyto automatically update cmake files once you have updated theBUILD.bazel(if using bazel).pre-commit run --all-files,clang-formator your own linter if applicable.