Skip to content

Commit

Permalink
Support generating onnx-mlir with mlir (llvm#1273)
Browse files Browse the repository at this point in the history
Changes required to support use cases where onnx-mlir and llvm-project/mlir are generated together.

Signed-off-by: Nathaniel McVicar <[email protected]>
  • Loading branch information
NathanielMcVicar authored Mar 29, 2022
1 parent d685f59 commit 35352d1
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ CMakePresets.json
# Filesystem
.DS_Store

# Nested build directory
/build*

# The following .gitignore content is taken from
# https://github.com/github/gitignore/blob/main/Python.gitignore

Expand Down
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ set(BENCHMARK_ENABLE_TESTING OFF)
add_subdirectory(third_party/onnx)
add_subdirectory(third_party/pybind11)
add_subdirectory(third_party/rapidcheck)
add_subdirectory(third_party/benchmark)
if (NOT TARGET benchmark)
add_subdirectory(third_party/benchmark)
endif()

# Ensure warnings are reported for onnx-mlir code.
if (ONNX_MLIR_SUPPRESS_THIRD_PARTY_WARNINGS)
Expand Down
2 changes: 1 addition & 1 deletion src/Builder/OpBuildTable.inc.dc.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
file-same-as-stdout({"file": "@CMAKE_CURRENT_SOURCE_DIR@/OpBuildTable.inc", "cmd": ["@Python3_EXECUTABLE@", "@CMAKE_SOURCE_DIR@/utils/gen_onnx_mlir.py", "--dry-run-op-build-table"]})
file-same-as-stdout({"file": "@CMAKE_CURRENT_SOURCE_DIR@/OpBuildTable.inc", "cmd": ["@Python3_EXECUTABLE@", "@PROJECT_SOURCE_DIR@/utils/gen_onnx_mlir.py", "--dry-run-op-build-table"]})
2 changes: 1 addition & 1 deletion src/Dialect/ONNX/ONNXOps.td.inc.dc.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
file-same-as-stdout({"file": "@CMAKE_CURRENT_SOURCE_DIR@/ONNXOps.td.inc", "cmd": ["@Python3_EXECUTABLE@", "@CMAKE_SOURCE_DIR@/utils/gen_onnx_mlir.py", "--dry-run-onnx-ops"]})
file-same-as-stdout({"file": "@CMAKE_CURRENT_SOURCE_DIR@/ONNXOps.td.inc", "cmd": ["@Python3_EXECUTABLE@", "@PROJECT_SOURCE_DIR@/utils/gen_onnx_mlir.py", "--dry-run-onnx-ops"]})
6 changes: 3 additions & 3 deletions utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Invoke gen_onnx_mlir.py to obtain ONNXOps.td.inc, OpBuildTable.inc.
add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/ONNXOps.td.inc
${CMAKE_CURRENT_SOURCE_DIR}/OpBuildTable.inc
COMMAND Python3::Interpreter ${CMAKE_CURRENT_SOURCE_DIR}/gen_onnx_mlir.py
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gen_onnx_mlir.py)
COMMAND Python3::Interpreter ${CMAKE_CURRENT_LIST_DIR}/gen_onnx_mlir.py
DEPENDS ${CMAKE_CURRENT_LIST_DIR}/gen_onnx_mlir.py)

# Move the generated files to respective destinations:
# ONNXOps.td.inc -> src/Dialect/ONNX/ONNXOps.td.inc
Expand All @@ -26,4 +26,4 @@ add_custom_target(OMONNXOpsIncTranslation
OMONNXOpsBuildTableIncGen)

add_custom_target(OMONNXCheckVersion
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/gen_onnx_mlir.py --check-operation-version)
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/gen_onnx_mlir.py --check-operation-version)

0 comments on commit 35352d1

Please sign in to comment.