Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix out-of-tree cmake build of torch-mlir-dialects #726

Merged
merged 1 commit into from
Apr 4, 2022

Conversation

oowekyala
Copy link
Contributor

This follows up on #623 for out-of-tree builds of torch-mlir, which added building torch-mir-dialects as a subdirectory.

We found that we needed some more cmake adaptions to make this work. We're initially opening this PR as a draft to gather opinions as to whether this approach suits at least the short-term torch-mlir-dialects goals.

Our goal is to support both in-tree and out-of-tree builds of torch-mlir with minimum hassle, for instance by using the same variable names in both setups. Specifically in externals/llvm-external-projects/torch-mlir-dialects/CMakeLists.txt :

  • We use MLIR_FOUND to detect that it is being build as a subdirectory and the llvm+mlir cmake infrastructure is already set up (via find_package in the parent build) as opposed to an in-tree build.
  • For in-tree, the setting of variables and loading of llvm+mlir cmake infrastructure is now conditionally performed.
  • For in-tree, the names of cmake variables being defined for are adjusted to match those llvm-project makes available through find_package(MLIR REQUIRED CONFIG), under the assumption that those are the more "standardized" names.

Further optional items we could contribute if you're interested:

  • build instructions for an out-of-tree setup (eg in README.md)
  • a CI flow to test an out-of-tree setup, so that all code paths of the cmake scripts are tested (even though we expect most llvm developers to use in-tree builds)

Follows up on llvm#623 for out-of-tree builds of torch-mlir, which
added building `torch-mir-dialects` as a subdirectory.

Our goal is to support both in-tree and out-of-tree builds of
`torch-mlir` with minimum hassle, for instance by using the same
variable names in both setups.

Specific changes to `externals/llvm-external-projects/torch-mlir-dialects/CMakeLists.txt`:
- We use `MLIR_FOUND` to detect that it is being build as a subdirectory
and the llvm+mlir cmake infrastructure is already set up (via
find_package in the parent build) as opposed to an in-tree build.
- For in-tree, the setting of variables and loading of llvm+mlir cmake
infrastructure is now conditionally performed.
- For in-tree, the names of cmake variables being defined for are
adjusted to match those `llvm-project` makes available through
`find_package(MLIR REQUIRED CONFIG)`, under the assumption that those
are the more "standardized" names.

Co-authored-by: Clément Fournier <clement.fournier@amd.com>
@ljfitz ljfitz requested a review from cathyzhyi April 1, 2022 16:20
@silvasean
Copy link
Contributor

Thanks for working on this. Out-of-tree build instructions and CI would be very much appreciated. I'll let @cathyzhyi review the PR itself since she is most familiar with torch-mlir-dialects.

Copy link
Contributor

@cathyzhyi cathyzhyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the change! I am not very familiar with llvm cmakes but the change looks reasonable to the best of my knowledge.

Further optional items we could contribute if you're interested:
build instructions for an out-of-tree setup (eg in README.md)
a CI flow to test an out-of-tree setup, so that all code paths of the cmake scripts are tested (even though we expect most llvm developers to use in-tree builds)

Those are great items to add. Thanks!

@oowekyala oowekyala marked this pull request as ready for review April 4, 2022 09:36
@ljfitz ljfitz merged commit 886ad16 into llvm:main Apr 4, 2022
@oowekyala
Copy link
Contributor Author

@silvasean @cathyzhyi Thanks for the reviews! I'll put together a followup PR for those additional items.

@oowekyala oowekyala deleted the clem.tmdialects_upstreamable branch April 4, 2022 09:44
qedawkins pushed a commit to nod-ai/torch-mlir that referenced this pull request Oct 3, 2022
* shape inference

Signed-off-by: chentong <chentong@us.ibm.com>

* lowering

Signed-off-by: chentong <chentong@us.ibm.com>

* type

Signed-off-by: chentong <chentong@us.ibm.com>

* test

Signed-off-by: chentong <chentong@us.ibm.com>

* response

Signed-off-by: chentong <chentong@us.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants