Skip to content

Commit d7b4965

Browse files
committed
auto generate paddle_inference_pass.h
1 parent 0a5d460 commit d7b4965

File tree

5 files changed

+29
-32
lines changed

5 files changed

+29
-32
lines changed

cmake/inference_lib.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ set(module "inference")
158158
copy(inference_lib DEPS ${inference_deps}
159159
SRCS ${src_dir}/${module}/*.h ${PADDLE_BINARY_DIR}/paddle/fluid/inference/libpaddle_fluid.*
160160
${src_dir}/${module}/api/paddle_inference_api.h ${src_dir}/${module}/api/demo_ci
161-
DSTS ${dst_dir}/${module} ${dst_dir}/${module} ${dst_dir}/${module} ${dst_dir}/${module}
161+
${PADDLE_BINARY_DIR}/paddle/fluid/inference/api/paddle_inference_pass.h
162+
DSTS ${dst_dir}/${module} ${dst_dir}/${module} ${dst_dir}/${module} ${dst_dir}/${module} ${dst_dir}/${module}
162163
)
163164

164165
set(module "platform")
Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,35 @@
1+
set(pass_file ${PADDLE_BINARY_DIR}/paddle/fluid/inference/api/paddle_inference_pass.h)
2+
file(WRITE ${pass_file} "// Generated by the paddle/fluid/framework/ir/CMakeLists.txt. DO NOT EDIT!\n\n")
3+
file(APPEND ${pass_file} "\#include \"paddle/fluid/framework/ir/pass.h\"\n")
4+
function(pass_library TARGET)
5+
set(options "")
6+
set(oneValueArgs "")
7+
set(multiValueArgs SRCS DEPS)
8+
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+
endfunction()
13+
114
cc_library(node SRCS node.cc DEPS proto_desc)
215
cc_library(graph SRCS graph.cc DEPS node)
316
cc_library(graph_helper SRCS graph_helper.cc DEPS graph)
417
cc_library(pass SRCS pass.cc DEPS graph node graph_helper)
5-
cc_library(graph_viz_pass SRCS graph_viz_pass.cc DEPS graph pass graph_helper)
6-
cc_library(graph_to_program_pass SRCS graph_to_program_pass.cc DEPS graph pass graph_helper)
718
cc_library(graph_traits SRCS graph_traits.cc DEPS graph)
8-
cc_library(graph_pattern_detector SRCS graph_pattern_detector.cc DEPS graph graph_helper graph_traits)
9-
cc_library(fc_fuse_pass SRCS fc_fuse_pass.cc DEPS graph graph_pattern_detector)
10-
cc_library(attention_lstm_fuse_pass SRCS attention_lstm_fuse_pass.cc DEPS graph graph_pattern_detector)
11-
cc_library(infer_clean_graph_pass SRCS infer_clean_graph_pass.cc DEPS graph pass)
12-
cc_library(fc_lstm_fuse_pass SRCS fc_lstm_fuse_pass.cc DEPS graph graph_pattern_detector)
13-
cc_library(seq_concat_fc_fuse_pass SRCS seq_concat_fc_fuse_pass.cc DEPS graph graph_pattern_detector)
19+
cc_library(graph_pattern_detector SRCS graph_pattern_detector.cc DEPS graph graph_helper graph_traits gtest)
20+
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+
set(GLOB_PASS_LIB ${PASS_LIBRARY} CACHE INTERNAL "Global PASS library")
1429

1530
cc_test(pass_test SRCS pass_test.cc DEPS graph pass graph_helper)
1631
cc_test(graph_test SRCS graph_test.cc DEPS graph graph_helper op_registry)
1732
cc_test(graph_helper_test SRCS graph_helper_test.cc DEPS graph graph_helper op_registry)
1833
cc_test(graph_to_program_pass_test SRCS graph_to_program_pass_test.cc DEPS graph_to_program_pass)
1934
cc_test(test_graph_pattern_detector SRCS graph_pattern_detector_tester.cc DEPS graph_pattern_detector)
20-
cc_test(test_fc_fuse_pass SRCS fc_fuse_pass_tester.cc DEPS fc_fuse_pass graph_pattern_detector graph pass graph_traits framework_proto)
21-
set(GLOB_PASS_LIB fc_fuse_pass attention_lstm_fuse_pass infer_clean_graph_pass fc_lstm_fuse_pass seq_concat_fc_fuse_pass)
35+
cc_test(test_fc_fuse_pass SRCS fc_fuse_pass_tester.cc DEPS fc_fuse_pass framework_proto)

paddle/fluid/inference/analysis/analyzer_tester.cc

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <gtest/gtest.h>
1919
#include "paddle/fluid/framework/ir/fuse_pass_base.h"
2020
#include "paddle/fluid/framework/ir/pass.h"
21+
#include "paddle/fluid/inference/api/paddle_inference_pass.h"
2122
#include "paddle/fluid/inference/analysis/ut_helper.h"
2223
#include "paddle/fluid/inference/api/analysis_predictor.h"
2324
#include "paddle/fluid/inference/api/helper.h"
@@ -357,10 +358,3 @@ TEST(Analyzer, DituRNN_with_analysis_with_IR) {
357358
} // namespace analysis
358359
} // namespace inference
359360
} // namespace paddle
360-
361-
USE_PASS(fc_fuse_pass);
362-
USE_PASS(seq_concat_fc_fuse_pass);
363-
USE_PASS(fc_lstm_fuse_pass);
364-
USE_PASS(graph_viz_pass);
365-
USE_PASS(infer_clean_graph_pass);
366-
USE_PASS(attention_lstm_fuse_pass);

paddle/fluid/inference/analysis/fluid_to_ir_pass_tester.cc

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include <gtest/gtest.h>
1818
#include "paddle/fluid/inference/analysis/ut_helper.h"
19+
#include "paddle/fluid/inference/api/paddle_inference_pass.h"
1920

2021
namespace paddle {
2122
namespace inference {
@@ -33,10 +34,3 @@ TEST(FluidToIrPass, Test) {
3334
} // namespace analysis
3435
} // namespace inference
3536
} // namespace paddle
36-
37-
USE_PASS(graph_viz_pass);
38-
USE_PASS(infer_clean_graph_pass);
39-
USE_PASS(attention_lstm_fuse_pass);
40-
USE_PASS(fc_lstm_fuse_pass);
41-
USE_PASS(seq_concat_fc_fuse_pass);
42-
USE_PASS(fc_fuse_pass);

paddle/fluid/inference/api/analysis_predictor.cc

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "paddle/fluid/framework/ir/pass.h"
1919
#include "paddle/fluid/framework/scope.h"
2020
#include "paddle/fluid/inference/api/paddle_inference_api.h"
21+
#include "paddle/fluid/inference/api/paddle_inference_pass.h"
2122
#include "paddle/fluid/inference/utils/singleton.h"
2223

2324
namespace paddle {
@@ -133,10 +134,3 @@ std::unique_ptr<PaddlePredictor> CreatePaddlePredictor<
133134
}
134135

135136
} // namespace paddle
136-
137-
USE_PASS(fc_fuse_pass);
138-
USE_PASS(seq_concat_fc_fuse_pass);
139-
USE_PASS(fc_lstm_fuse_pass);
140-
USE_PASS(graph_viz_pass);
141-
USE_PASS(infer_clean_graph_pass);
142-
USE_PASS(attention_lstm_fuse_pass);

0 commit comments

Comments
 (0)