-
Notifications
You must be signed in to change notification settings - Fork 518
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
[cmake] Enable accepting external stablehlo project #3927
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -43,6 +43,14 @@ option(TORCH_MLIR_ENABLE_STABLEHLO "Add stablehlo dialect" ON) | |||||||||||||
if(TORCH_MLIR_ENABLE_STABLEHLO) | ||||||||||||||
add_definitions(-DTORCH_MLIR_ENABLE_STABLEHLO) | ||||||||||||||
endif() | ||||||||||||||
# It is possible that both stablehlo and torch_mlir projects are used in some compiler project. | ||||||||||||||
# In this case, we might not want to use stablehlo that is downloaded by torch_mlir (in external/stablehlo folder) | ||||||||||||||
# but instead stablehlo that is part of the top level compiler project. | ||||||||||||||
# TORCH_MLIR_EXTERNAL_STABLEHLO_DIR represents stablehlo directory (<some_path>/stablehlo) | ||||||||||||||
# in top level compiler project that will be included in torch_mlir. It is assumed that top level | ||||||||||||||
# compiler project makes stablehlo targets available (for example with `add_subdirectory`) and | ||||||||||||||
# thus they are not added. | ||||||||||||||
set(TORCH_MLIR_EXTERNAL_STABLEHLO_DIR "" CACHE STRING "Path to stablehlo dir from super project") | ||||||||||||||
|
||||||||||||||
option(TORCH_MLIR_OUT_OF_TREE_BUILD "Specifies an out of tree build" OFF) | ||||||||||||||
|
||||||||||||||
|
@@ -233,12 +241,17 @@ endif() | |||||||||||||
# project that we don't actually depend on. Further some of those parts | ||||||||||||||
# do not even compile on all platforms. | ||||||||||||||
if (TORCH_MLIR_ENABLE_STABLEHLO) | ||||||||||||||
set(STABLEHLO_BUILD_EMBEDDED ON) | ||||||||||||||
set(STABLEHLO_ENABLE_BINDINGS_PYTHON ON) | ||||||||||||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/externals/stablehlo | ||||||||||||||
${CMAKE_CURRENT_BINARY_DIR}/stablehlo | ||||||||||||||
EXCLUDE_FROM_ALL) | ||||||||||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/externals/stablehlo) | ||||||||||||||
if (NOT "${TORCH_MLIR_EXTERNAL_STABLEHLO_DIR}" STREQUAL "") | ||||||||||||||
# Only include directories. It is assumed that stablehlo targets are made available by external project. | ||||||||||||||
include_directories(${TORCH_MLIR_EXTERNAL_STABLEHLO_DIR}) | ||||||||||||||
else() | ||||||||||||||
Comment on lines
+244
to
+247
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually
Suggested change
should be sufficient. In that case I would probably replace the string with a boolean as it seems that the string isn't used elsewhere. Depending on how the super project is set up (and pulls in torch-mlir and stablehlo) we could consider to add a |
||||||||||||||
set(STABLEHLO_BUILD_EMBEDDED ON) | ||||||||||||||
set(STABLEHLO_ENABLE_BINDINGS_PYTHON ON) | ||||||||||||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/externals/stablehlo | ||||||||||||||
${CMAKE_CURRENT_BINARY_DIR}/stablehlo | ||||||||||||||
EXCLUDE_FROM_ALL) | ||||||||||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/externals/stablehlo) | ||||||||||||||
endif() | ||||||||||||||
endif() | ||||||||||||||
|
||||||||||||||
#------------------------------------------------------------------------------- | ||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have assumed that the external project also makes the includes available.