Skip to content

Commit 9d10b75

Browse files
authored
Merge pull request #332 from Xilinx/jrickert.remove_torch
Remove torch-mlir related code and add option to control the building of conversion passes
2 parents a62f5fe + d10b104 commit 9d10b75

34 files changed

Lines changed: 38 additions & 1650 deletions

.github/actions/build-with-llvm/Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
# (c) Copyright 2022 - 2024 Advanced Micro Devices, Inc. All Rights reserved.
33

44
# Container image that runs your code
5-
FROM ghcr.io/stephenneuendorffer/torch-mlir:main
6-
#FROM ghcr.io/stephenneuendorffer/mlir-xten-llvm:main
5+
FROM ghcr.io/stephenneuendorffer/mlir-xten-llvm:main
76

87
# Copies your code file from your action repository to the filesystem path `/` of the container
98
COPY entrypoint.sh /entrypoint.sh

.github/actions/build-with-llvm/entrypoint.sh

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,11 @@ ls
1313
#apt-get install python3-dev
1414
#pip3 install pybind11
1515

16-
# cd /build
17-
# git clone https://github.com/llvm/torch-mlir.git
18-
# cd torch-mlir
19-
# git checkout 077e55d7565e22113
20-
# cmake -B build -S . -G Ninja \
21-
# -DMLIR_DIR=/build/build/lib/cmake/mlir
22-
# ninja
23-
# cd ${GITHUB_WORKSPACE}
2416

2517
#pybind11_DIR=/build/.pyenv/versions/3.7.0/lib/python3.7/site-packages/pybind11/share/cmake/pybind11
2618
#pybind11_DIR=/usr/local/lib/python3.8/dist-packages/pybind11/share/cmake/pybind11
2719
cmake -B build -S . -G Ninja \
28-
-DMLIR_DIR=/build/build/lib/cmake/mlir \
29-
-DTORCH_MLIR_BINARY_DIR=/build/torch-mlir-build \
30-
-DTORCH_MLIR_SOURCE_DIR=/build/torch-mlir
20+
-DMLIR_DIR=/build/build/lib/cmake/mlir
3121

3222
#https://github.com/Xilinx/mlir-xten.git
3323
# -Dpybind11_DIR=${pybind11_DIR}

.github/workflows/buildAndTest.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,6 @@ jobs:
6666
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
6767
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
6868
-DLLVM_EXTERNAL_PROJECTS=mlir-xten \
69-
-DMLIR_XTEN_ENABLE_TORCH=OFF \
70-
-DLLVM_EXTERNAL_MLIR_XTEN_SOURCE_DIR="$PWD"
69+
-DLLVM_EXTERNAL_MLIR_XTEN_SOURCE_DIR="$PWD" \
70+
-DMLIR_XTEN_ENABLE_CONVERSION_PASSES=ON
7171
ninja -C build check-xten-all

CMakeLists.txt

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ set(CMAKE_C_STANDARD 11)
3131
set(CMAKE_CXX_STANDARD 20)
3232
set(CMAKE_VERBOSE_MAKEFILE ON)
3333

34-
option(MLIR_XTEN_ENABLE_TORCH "Enable torch-mlir" ON)
34+
option(MLIR_XTEN_ENABLE_CONVERSION_PASSES
35+
"Build XTen conversion passes and register them in aten-opt" OFF)
3536

3637
function(detect_pybind11_install)
3738
if(pybind11_DIR)
@@ -78,7 +79,6 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
7879
include(AddMLIR)
7980
include(HandleLLVMOptions)
8081

81-
link_directories(${TORCH_MLIR_LIB_DIR})
8282
else()
8383
message(STATUS "Building MLIR-XTEN in-tree")
8484
# Build via external projects mechanism
@@ -90,11 +90,6 @@ else()
9090
list(APPEND CMAKE_MODULE_PATH ${MLIR_MAIN_SRC_DIR}/cmake/modules)
9191
list(APPEND CMAKE_MODULE_PATH ${LLVM_MAIN_SRC_DIR}/cmake)
9292

93-
if (MLIR_XTEN_ENABLE_TORCH)
94-
set(TORCH_MLIR_INCLUDE_DIRS
95-
${LLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR}/include
96-
${LLVM_BINARY_DIR}/tools/torch-mlir/include)
97-
endif()
9893
endif()
9994

10095
# Define the default arguments to use with 'lit', and an option for the user to
@@ -118,10 +113,6 @@ include_directories(${MLIR_INCLUDE_DIRS})
118113
include_directories(${XTEN_SOURCE_DIR}/include)
119114
include_directories(${XTEN_BINARY_DIR}/include)
120115

121-
if(MLIR_XTEN_ENABLE_TORCH)
122-
include_directories(${TORCH_MLIR_INCLUDE_DIRS})
123-
endif()
124-
125116
add_definitions(${LLVM_DEFINITIONS})
126117

127118
# Create a general check-all command to run both lit and unittests

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<!--- (c) Copyright 2021 Xilinx, Inc. All Rights reserved.--->
22
<!--- (c) Copyright 2022 - 2024 Advanced Micro Devices, Inc. All Rights reserved.--->
33

4-
# Extensions to Torch-MLIR
4+
# Extensions to MLIR
55

66
![](https://mlir.llvm.org//mlir-logo.png)
77

8-
This repository contains Xilinx extensions to the torch-mlir ATen dialect to enable expressing the input and output of partial results. Using these extensions, a prototype streaming dataflow exploration tool scans the design space for compute/memory/computation balanced partitioning of CNNs on the AIE array of Xilinx' Versal devices.
8+
This repository contains Xilinx extensions to the ONNX-MLIR and TOSA dialect to enable expressing the input and output of partial results. Using these extensions, a prototype streaming dataflow exploration tool scans the design space for compute/memory/computation balanced partitioning of CNNs on the AIE array of Xilinx' Versal devices.
99

1010
[Full Documentation](https://xilinx.github.io/mlir-xten/)
1111

docs/Building.md

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,10 @@
99
cmake 3.20.6 or higher
1010
ninja 1.8.2
1111
clang/llvm 14+ from source https://github.com/llvm/llvm-project
12-
llvm/torch-mlir from https://github.com/llvm/torch-mlir
1312
```
1413

1514
## Building on X86
1615

17-
NOTE: this initial version of mlir-xten currently fails to build against head torch-mlir. Fixes in progress.
18-
19-
### Compile torch-mlir
20-
21-
Clone torch-mlir from https://github.com/llvm/torch-mlir and follow the build instructions. This process builds torch-mlir integrated with LLVM/MLIR. We recommend adding the additional CMake flags: `-DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_LINK_LLVM_DYLIB=ON` to build and link with libLLVM.so.
22-
23-
```sh
24-
cmake --build build
25-
```
26-
2716
### Compile mlir-xten
2817

2918
```sh
@@ -32,10 +21,8 @@ mkdir build; cd build
3221
cmake ..\
3322
-DCMAKE_C_COMPILER=clang \
3423
-DCMAKE_CXX_COMPILER=clang++ \
35-
-DLLVM_DIR=${absolute path to torchMlirBuild}/cmake/llvm \
36-
-DMLIR_DIR=${absolute path to torchMlirBuild}/cmake/mlir \
37-
-DTORCH_MLIR_SOURCE_DIR=${absolute path to torchMlirSource} \
38-
-DTORCH_MLIR_BINARY_DIR=${absolute path to torchMlirBuild}
24+
-DLLVM_DIR=${absolute path to llvm build}/cmake/llvm \
25+
-DMLIR_DIR=${absolute path to mlir build}/cmake/mlir
3926
```
4027

4128
## Environment setup

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!--- (c) Copyright 2022 - 2024 Advanced Micro Devices, Inc. All Rights reserved.--->
22

3-
# Extensions to Torch-MLIR
3+
# Extensions to MLIR
44

55
![](https://mlir.llvm.org//mlir-logo.png)
66

include/xten/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@
88
# (c) Copyright 2022 - 2024 Advanced Micro Devices, Inc. All Rights reserved.
99

1010
add_subdirectory(Dialect)
11-
add_subdirectory(Conversion)
11+
if(MLIR_XTEN_ENABLE_CONVERSION_PASSES)
12+
add_subdirectory(Conversion)
13+
endif()

include/xten/Conversion/CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,5 @@
1010
set(LLVM_TARGET_DEFINITIONS Passes.td)
1111
mlir_tablegen(Passes.h.inc -gen-pass-decls -name XTenConversion)
1212

13-
if(MLIR_XTEN_ENABLE_TORCH)
14-
set(LLVM_TARGET_DEFINITIONS PassesTorch.td)
15-
mlir_tablegen(PassesTorch.h.inc -gen-pass-decls -name XTenConversion)
16-
endif()
17-
1813
add_mlir_doc(Passes XTenConversionPasses ./ -gen-pass-doc)
1914
add_public_tablegen_target(XTenConversionIncGen)

include/xten/Conversion/Passes.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
#include "xten/Conversion/TosaToXTenNNPass.h"
1818
#include "xten/Conversion/XTenNNToLinalgPass.h"
19-
#include "xten/Conversion/XTenNNToTorchPass.h"
2019
#include "xten/Conversion/XTenNNToTosaPass.h"
2120

2221
namespace xilinx {
@@ -27,14 +26,6 @@ namespace xten {
2726

2827
#include "xten/Conversion/Passes.h.inc"
2928

30-
#ifdef MLIR_XTEN_ENABLE_TORCH
31-
namespace torch {
32-
#define GEN_PASS_DECL
33-
#define GEN_PASS_REGISTRATION
34-
#include "xten/Conversion/PassesTorch.h.inc"
35-
}
36-
#endif
37-
3829
void registerConversionPasses();
3930

4031
} // namespace xten

0 commit comments

Comments
 (0)