Repository navigation
Add TMTensorToLinalgExtPass - #8575
Conversation
8a68366 to
34faa63
Compare
82adb38 to
f114022
Compare
|
Is this ready for review or still in progress? Could you please add a description? This is a lot of code to have no description :-) |
caf4841 to
8bcdeec
Compare
Sry, I just added the description. Yea, it's ready for review though I am still fixing errors reported from the bazel build. |
MaheshRavishankar
left a comment
There was a problem hiding this comment.
Hi Yi, Sorry for the delay. First round of comments, mostly structural.
| MHLO::buildMHLOInputConversionPassPipeline(passManager); | ||
| break; | ||
| } | ||
| passManager.addNestedPass<FuncOp>( |
There was a problem hiding this comment.
This is OK as long as there are no more passes to be added here. If there are more TM Tensor specific stuff to be done here will probably need to add a new "input" type. Just an FYI, and something for you to consider to do right now depending on whats in store here.
There was a problem hiding this comment.
Thanks for the note. There are no more passes AFAICT. Will add the new input type if things change.
There was a problem hiding this comment.
I'm not as familiar with these, but reading the code I'd expect this to actually need a new input type for consistency. In the future we may autodetect which input type is needed based on the source IR.
5a0a17e to
e19c2d7
Compare
| MHLO::buildMHLOInputConversionPassPipeline(passManager); | ||
| break; | ||
| } | ||
| passManager.addNestedPass<FuncOp>( |
There was a problem hiding this comment.
I'm not as familiar with these, but reading the code I'd expect this to actually need a new input type for consistency. In the future we may autodetect which input type is needed based on the source IR.
| @@ -0,0 +1,328 @@ | |||
| // RUN: iree-opt -split-input-file -verify-diagnostics %s | |||
There was a problem hiding this comment.
You can include torch-mlir specific tests in IREE's third_party/, but we won't run them (just like we don't run any other tests for dependencies). If they are relevant to the integration of torch-mlir into IREE (input conversion, e2e correctness of programs coming from torch) then the tests need to be placed in a directory like the TOSA integration.
I'll also reiterate that third party code must be pristine copies (no modifications at all), at least in the initial check-in. Separating your PR into one that adds the third party code, one that gets it building in IREE (CMake + Bazel), and one that hooks it up to the rest of the system (input type, dialect registration, e2e tests) will make code review much easier. As this is all bundled together there are multiple review threads going on for very different stages of review.
On the license compliance side (https://tldrlegal.com/license/apache-license-2.0-(apache-2.0)), starting with a commit that just adds code makes it easy to see the base, then any patches on top of that can be clearly labeled.
For general docs, see https://opensource.google/documentation/reference/thirdparty
|
Vacation snipped: these kind of IR "stubs" should just be copied into a project that needs them. Per policy, these need to be in third_party if originating "outside". |
Fair points. I think most of my concerns go away by structuring this as one commit that adds the pristine import (with a readme explaining how to pull in updates), then any modifications to that code (including new cmake files) as separate git commits. The current state of the PR is pretty much there now, but going step by step from the start could have streamlined the review process. |
Don't get me wrong: I am definitely in favor of getting the mechanics of complying with our policies right, and this is the first of this kind of dependency to be taken ("ir stubs") so is worth some discussion... It won't be the last and for these transient things, we need to be optimizing for developer throughput. The sooner in and working, the sooner the upstream shape of it takes, and the sooner we get it off our project specific books (which will play out over ~months of code movement). That's the real thing to optimize for here. Ok, I'm out. Beach time :) |
ScottTodd
left a comment
There was a problem hiding this comment.
Thanks for your patience with this, LGTM!
Thanks for all the reviews and feedbacks!! |
186f2e4 to
0d2380b
Compare
GMNGeoffrey
left a comment
There was a problem hiding this comment.
Thank you for splitting this apart. That made it much much easier to review. I still would've preferred this land as three separate PRs, but this is certainly much better :-)
I've left a few minor comments that should be straightforward to address.
Because the commit history here is now meaningful and useful, let's merge this with a merge commit. Please still include your nice PR description as the message for the merge commit.
Copy over torch-mlir-dialects from https://github.com/llvm/torch-mlir with command: rsync -av --exclude=tools \ --exclude=test \ --exclude=lib/Dialect/TMTensor/Transforms \ --exclude=include/torch-mlir-dialects/Dialect/TMTensor/Transforms \ PATH_TO_TORCH_MLIR_REPO/externals/llvm-external-projects/torch-mlir-dialects \ PATH_TO_IREE_REPO/third_party Note this commit doesn't change the torch-mlir-dialects/README.md. The following commit will update the README.md with instructions on how to pull the code from torch-mlir upstream.
- Add torch-mlir-dialects as an external project and add the BUILD.overlay file for bazel build. - Update the third_party/torch-mlir-dialects/README.md to include instructions on how to pull in torch-mlir-dialects from upstream. - Register the torch-mlir tmtensor dialect and update related build and cmake files.
This change adds the `TMTensorToLinalgExtPass` which is a 1 to 1 mapping from `tm_tensor` ops to `linalg.ext` ops. The syntax of the ops from the two dialects are identical. The goal is to use `tm_tensor` as an interface dialect to bridge between projects. The `tm_tensor` dialect will be upstreamed eventually. A high level description about `tm_tensor` dialect can be found in torch-mlir-dialects/include/torch-mlir-dialects/Dialect/TMTensor/IR/TMTensorBase.td A new input type --iree-input-type=tmtensor is added to specify the input contains tmtensor ops.
|
hmm, after rebasing to the head the |
That's preexisting and should be fixed by #8674. |
This is the llvm version used by IREE. Also, based on reviews of iree-org/iree#8575 There are some changes to the llvm-external-projects/torch-mlir-dialects.
|
I can merge this past the failing test if you'd like (admin powers) |
This is the llvm version used by IREE. Also, based on reviews of iree-org/iree#8575 There are some changes to the llvm-external-projects/torch-mlir-dialects.
yes, please! Thanks a lot! |
|
Verified that it is only a single test failing in each of the workflows and it is a known failure. Merging past failing checks |
|
Also, merging with a merge commit, per my above comment that the commit history here is interesting and useful |
This is the llvm version used by IREE. Also, based on reviews of iree-org/iree#8575 There are some changes to the llvm-external-projects/torch-mlir-dialects.
This PR adds the conversions from
tm_tensortolinalg_extops. The goal is to usetm_tensoras an interface dialect to bridge between projects. Thetm_tensordialect will be upstreamed eventually. A high level description abouttm_tensordialect can be found intorch-mlir-dialects/include/torch-mlir-dialects/Dialect/TMTensor/IR/TMTensorBase.td
The change are broken up in to 3 commits:
TMTensorToLinalgExtPasswhich is a 1 to 1 mappingfrom
tm_tensorops tolinalg.extops. The syntax of the ops from thetwo dialects are identical. Add --iree-input-type=tmtensor input type.