Skip to content

Commit e2d325a

Browse files
authored
refactor pass_library (#13261)
1 parent 227d806 commit e2d325a

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

paddle/fluid/framework/ir/CMakeLists.txt

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
set(pass_file ${PADDLE_BINARY_DIR}/paddle/fluid/inference/api/paddle_inference_pass.h)
22
file(WRITE ${pass_file} "// Generated by the paddle/fluid/framework/ir/CMakeLists.txt. DO NOT EDIT!\n\n")
33
file(APPEND ${pass_file} "\#include \"paddle/fluid/framework/ir/pass.h\"\n")
4-
function(pass_library TARGET)
4+
5+
6+
# Usage: pass_library(target inference) will append to paddle_inference_pass.h
7+
function(pass_library TARGET DEST)
58
set(options "")
69
set(oneValueArgs "")
710
set(multiValueArgs SRCS DEPS)
811
cmake_parse_arguments(op_library "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
9-
cc_library(${TARGET} SRCS ${TARGET}.cc DEPS graph_pattern_detector pass)
10-
file(APPEND ${pass_file} "USE_PASS(${TARGET});\n")
11-
set(PASS_LIBRARY ${TARGET} ${PASS_LIBRARY} PARENT_SCOPE)
12+
cc_library(${TARGET} SRCS ${TARGET}.cc DEPS graph_pattern_detector pass ${op_library_DEPS})
13+
# add more DEST here, such as train, dist and collect USE_PASS into a file automatically.
14+
if (${DEST} STREQUAL "base" OR ${DEST} STREQUAL "inference")
15+
message(STATUS "add pass ${TARGET} ${DEST}")
16+
file(APPEND ${pass_file} "USE_PASS(${TARGET});\n")
17+
set(PASS_LIBRARY ${TARGET} ${PASS_LIBRARY} PARENT_SCOPE)
18+
endif()
1219
endfunction()
1320

1421
cc_library(node SRCS node.cc DEPS proto_desc)
@@ -18,13 +25,13 @@ cc_library(pass SRCS pass.cc DEPS graph node graph_helper)
1825
cc_library(graph_traits SRCS graph_traits.cc DEPS graph)
1926
cc_library(graph_pattern_detector SRCS graph_pattern_detector.cc DEPS graph graph_helper graph_traits)
2027

21-
pass_library(graph_to_program_pass)
22-
pass_library(graph_viz_pass)
23-
pass_library(fc_fuse_pass)
24-
pass_library(attention_lstm_fuse_pass)
25-
pass_library(infer_clean_graph_pass)
26-
pass_library(fc_lstm_fuse_pass)
27-
pass_library(seq_concat_fc_fuse_pass)
28+
pass_library(graph_to_program_pass base)
29+
pass_library(graph_viz_pass base)
30+
pass_library(fc_fuse_pass inference)
31+
pass_library(attention_lstm_fuse_pass inference)
32+
pass_library(infer_clean_graph_pass inference)
33+
pass_library(fc_lstm_fuse_pass inference)
34+
pass_library(seq_concat_fc_fuse_pass inference)
2835
set(GLOB_PASS_LIB ${PASS_LIBRARY} CACHE INTERNAL "Global PASS library")
2936

3037
cc_test(pass_test SRCS pass_test.cc DEPS graph pass graph_helper)

0 commit comments

Comments
 (0)