Skip to content

Commit e9e47ed

Browse files
authored
Merge pull request #2 from doru1004/flatten-src-folder-structure
flatten src directory structure
2 parents 922a409 + 3b7a1c1 commit e9e47ed

33 files changed

+119
-129
lines changed

CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ add_subdirectory(third_party/benchmark)
2424
add_subdirectory(third_party/pybind11)
2525

2626
set(CMAKE_CXX_STANDARD 14)
27-
add_subdirectory(src/builder)
28-
add_subdirectory(src/compiler)
29-
add_subdirectory(src/runtime)
3027
add_subdirectory(src)
3128

3229
add_subdirectory(test)

MLIR.cmake

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,10 @@ set(MLIRWholeArchiveLibs
153153
function(whole_archive_link target lib_dir)
154154
get_property(link_flags TARGET ${target} PROPERTY LINK_FLAGS)
155155
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
156-
set(link_flags "${link_flags} -L${lib_dir} ")
156+
set(link_flags "${link_flags} -L${lib_dir} ")
157157
foreach(LIB ${ARGN})
158158
string(CONCAT link_flags ${link_flags}
159-
"-Wl,-force_load ${lib_dir}/lib${LIB}.a ")
159+
"-Wl,-force_load, ${lib_dir}/lib${LIB}.a ")
160160
endforeach(LIB)
161161
elseif(MSVC)
162162
foreach(LIB ${ARGN})
@@ -177,9 +177,9 @@ function(whole_archive_link_mlir target)
177177
endfunction(whole_archive_link_mlir)
178178

179179
function(whole_archive_link_onnf target)
180-
foreach(LIB ${ARGN})
181-
add_dependencies(${target} ${LIB})
182-
endforeach(LIB)
180+
foreach(lib_target ${ARGN})
181+
add_dependencies(${target} ${lib_target})
182+
endforeach(lib_target)
183183
whole_archive_link(${target} ${CMAKE_BINARY_DIR}/lib ${ARGN})
184184
endfunction(whole_archive_link_onnf)
185185

src/CMakeLists.txt

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,78 @@
1+
add_library(compiler
2+
dialect/krnl/krnl_ops.cpp
3+
dialect/krnl/krnl_ops.hpp
4+
dialect/krnl/krnl_types.cpp
5+
dialect/krnl/krnl_types.hpp
6+
dialect/onnx/onnx_ops.cpp
7+
dialect/onnx/onnx_ops.hpp
8+
dialect/krnl/krnl_helper.cpp
9+
dialect/krnl/krnl_helper.hpp
10+
pass/shape_inference_pass.cpp
11+
pass/shape_inference_interface.hpp
12+
dialect/onnx/onnxop.inc
13+
pass/onnx_combine.cpp
14+
pass/lower_frontend_to_krnl.cpp
15+
pass/passes.hpp)
16+
17+
# Include root src directory.
18+
target_include_directories(compiler PRIVATE ${ONNF_SRC_ROOT})
19+
20+
# Include tablegen generated header files.
21+
target_include_directories(compiler PRIVATE ${ONNF_BIN_ROOT})
22+
23+
target_link_libraries(compiler
24+
${CMAKE_THREAD_LIBS_INIT}
25+
${CMAKE_DL_LIBS}
26+
${MLIRLibs}
27+
curses)
28+
29+
set(LLVM_TARGET_DEFINITIONS pass/shape_inference_interface.td)
30+
onnf_tablegen(shape_inference.hpp.inc -gen-op-interface-decls)
31+
onnf_tablegen(shape_inference.cpp.inc -gen-op-interface-defs)
32+
add_public_tablegen_target(gen_shape_inference)
33+
add_dependencies(compiler gen_shape_inference)
34+
35+
set(LLVM_TARGET_DEFINITIONS pass/onnx_combine.td)
36+
onnf_tablegen(onnx_combine.inc -gen-rewriters)
37+
add_public_tablegen_target(gen_onnx_combine)
38+
add_dependencies(compiler gen_onnx_combine)
39+
40+
set(LLVM_TARGET_DEFINITIONS dialect/onnx/onnx.td)
41+
onnf_tablegen(onnx.hpp.inc -gen-op-decls "-I${CMAKE_SOURCE_DIR}/compiler/pass")
42+
onnf_tablegen(onnx.cpp.inc -gen-op-defs "-I${CMAKE_SOURCE_DIR}/compiler/pass")
43+
add_public_tablegen_target(gen_onnx)
44+
add_dependencies(compiler gen_onnx)
45+
46+
set(LLVM_TARGET_DEFINITIONS dialect/krnl/krnl_ops.td)
47+
onnf_tablegen(krnl.hpp.inc -gen-op-decls)
48+
onnf_tablegen(krnl.cpp.inc -gen-op-defs)
49+
add_public_tablegen_target(gen_krnl_ops)
50+
add_dependencies(compiler gen_krnl_ops)
51+
52+
add_library(onnf_shape_inference pass/shape_inference_pass.cpp)
53+
target_include_directories(onnf_shape_inference
54+
PRIVATE ${ONNF_SRC_ROOT} ${ONNF_BIN_ROOT}
55+
${ONNF_SRC_ROOT})
56+
target_link_libraries(onnf_shape_inference ${MLIRLibs})
57+
add_dependencies(onnf_shape_inference gen_krnl_ops)
58+
59+
add_library(onnf_lower_frontend pass/lower_frontend_to_krnl.cpp)
60+
target_include_directories(onnf_lower_frontend
61+
PRIVATE ${ONNF_SRC_ROOT} ${ONNF_BIN_ROOT}
62+
${ONNF_SRC_ROOT})
63+
target_link_libraries(onnf_lower_frontend ${MLIRLibs})
64+
add_dependencies(onnf_lower_frontend gen_krnl_ops)
65+
66+
add_subdirectory(transform)
67+
add_subdirectory(tool)
68+
add_subdirectory(builder)
69+
add_subdirectory(runtime)
70+
171
add_executable(onnf main.cpp)
272

3-
target_link_libraries(onnf builder compiler ${MLIRLibs} onnf_transform)
4-
whole_archive_link_mlir(onnf ${MLIRWholeArchiveLibs})
73+
target_link_libraries(onnf builder ${MLIRLibs} onnf_transform)
574
set_target_properties(onnf PROPERTIES LINK_FLAGS "-lz")
75+
whole_archive_link_mlir(onnf ${MLIRWholeArchiveLibs})
676

777
target_include_directories(onnf PRIVATE ${CMAKE_SOURCE_DIR})
878
target_include_directories(onnf PRIVATE ${CMAKE_BINARY_DIR})

src/builder/frontend_dialect_transformer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include "llvm/ADT/ScopedHashTable.h"
3636
#include "llvm/Support/raw_ostream.h"
3737

38-
#include "src/compiler/dialect/onnx/onnx_ops.hpp"
38+
#include "src/dialect/onnx/onnx_ops.hpp"
3939

4040
#include "frontend_dialect_transformer.hpp"
4141

src/compiler/CMakeLists.txt

Lines changed: 0 additions & 75 deletions
This file was deleted.

src/compiler/analysis/CMakeLists.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/compiler/dialect/krnl/krnl_helper.cpp renamed to src/dialect/krnl/krnl_helper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "mlir/Dialect/AffineOps/AffineOps.h"
22
#include "mlir/IR/AffineExpr.h"
33

4-
#include "src/compiler/dialect/krnl/krnl_ops.hpp"
4+
#include "src/dialect/krnl/krnl_ops.hpp"
55

66
#include "krnl_helper.hpp"
77

File renamed without changes.

src/compiler/dialect/krnl/krnl_ops.cpp renamed to src/dialect/krnl/krnl_ops.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "llvm/ADT/SetVector.h"
2525
#include "llvm/ADT/SmallBitVector.h"
2626

27-
#include "src/compiler/dialect/krnl/krnl_helper.hpp"
27+
#include "krnl_helper.hpp"
2828

2929
#include "krnl_ops.hpp"
3030

@@ -35,7 +35,7 @@ KrnlOpsDialect::KrnlOpsDialect(MLIRContext *context)
3535
: Dialect(getDialectNamespace(), context) {
3636
addOperations<
3737
#define GET_OP_LIST
38-
#include "src/compiler/krnl.cpp.inc"
38+
#include "src/krnl.cpp.inc"
3939
>();
4040
addTypes<LoopType>();
4141
}
@@ -373,5 +373,5 @@ void KrnlEntryPointOp::build(mlir::Builder *builder, OperationState &state,
373373
}
374374

375375
#define GET_OP_CLASSES
376-
#include "src/compiler/krnl.cpp.inc"
376+
#include "src/krnl.cpp.inc"
377377
} // namespace mlir

src/compiler/dialect/krnl/krnl_ops.hpp renamed to src/dialect/krnl/krnl_ops.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
#include "mlir/IR/OpDefinition.h"
1616
#include "mlir/IR/StandardTypes.h"
1717

18-
#include "src/compiler/dialect/krnl/krnl_helper.hpp"
19-
#include "src/compiler/dialect/krnl/krnl_types.hpp"
18+
#include "src/dialect/krnl/krnl_helper.hpp"
19+
#include "src/dialect/krnl/krnl_types.hpp"
2020

2121
namespace mlir {
2222
class KrnlOpsDialect : public Dialect {
@@ -43,5 +43,5 @@ class KrnlOpsDialect : public Dialect {
4343
};
4444

4545
#define GET_OP_CLASSES
46-
#include "src/compiler/krnl.hpp.inc"
46+
#include "src/krnl.hpp.inc"
4747
} // namespace mlir

0 commit comments

Comments
 (0)