CMakeLists.txt 11.8 KB
Newer Older
1 2
set(pass_file ${PADDLE_BINARY_DIR}/paddle/fluid/inference/api/paddle_inference_pass.h.tmp)
set(pass_file_final ${PADDLE_BINARY_DIR}/paddle/fluid/inference/api/paddle_inference_pass.h)
L
luotao1 已提交
3
file(WRITE ${pass_file} "// Generated by the paddle/fluid/framework/ir/CMakeLists.txt.  DO NOT EDIT!\n\n")
L
luotao1 已提交
4
file(APPEND ${pass_file} "\#pragma once\n")
L
luotao1 已提交
5
file(APPEND ${pass_file} "\#include \"paddle/fluid/framework/ir/pass.h\"\n")
Y
Yan Chunwei 已提交
6

7
copy_if_different(${pass_file} ${pass_file_final})
8

9 10 11
add_subdirectory(fuse_optimizer_ops_pass)
add_subdirectory(memory_optimize_pass)
add_subdirectory(multi_devices_graph_pass)
12
if(NOT APPLE AND NOT WIN32 AND WITH_GPU)
13 14
    add_subdirectory(fusion_group)
endif()
Y
Yan Chunwei 已提交
15 16

# Usage: pass_library(target inference) will append to paddle_inference_pass.h
17
unset(INFER_IR_PASSES CACHE) # clear the global variable
Y
Yan Chunwei 已提交
18
function(pass_library TARGET DEST)
L
luotao1 已提交
19 20
    set(options "")
    set(oneValueArgs "")
21
    set(multiValueArgs SRCS DEPS DIR)
22 23
    set(targetPrefix "")

24 25
    cmake_parse_arguments(pass_library "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
    if(pass_library_DIR)
26
        cc_library(${TARGET} SRCS ${pass_library_DIR}/${TARGET}.cc DEPS graph_pattern_detector pass fuse_pass_base op_version_registry ${pass_library_DEPS})
27
    else()
28
        cc_library(${TARGET} SRCS ${TARGET}.cc DEPS graph_pattern_detector pass fuse_pass_base op_version_registry ${pass_library_DEPS})
29 30
    endif()

Y
Yan Chunwei 已提交
31 32
    # add more DEST here, such as train, dist and collect USE_PASS into a file automatically.
    if (${DEST} STREQUAL "base" OR ${DEST} STREQUAL "inference")
33 34 35
        if(NOT CMAKE_BUILD_TYPE STREQUAL "Release")
            message(STATUS "add pass ${TARGET} ${DEST}")
        endif()
Y
Yan Chunwei 已提交
36
        file(APPEND ${pass_file} "USE_PASS(${TARGET});\n")
37
        set(INFER_IR_PASSES ${INFER_IR_PASSES} ${TARGET} CACHE INTERNAL "")
Y
Yan Chunwei 已提交
38
    endif()
L
luotao1 已提交
39 40
endfunction()

Y
yuyang18 已提交
41
cc_library(node SRCS node.cc DEPS proto_desc)
Y
Yan Chunwei 已提交
42
cc_library(graph SRCS graph.cc DEPS node pretty_log)
X
better  
Xin Pan 已提交
43
cc_library(graph_helper SRCS graph_helper.cc DEPS graph)
X
Xin Pan 已提交
44
cc_library(pass SRCS pass.cc DEPS graph node graph_helper)
45
cc_library(graph_traits SRCS graph_traits.cc DEPS graph)
H
Huihuang Zheng 已提交
46 47 48 49 50 51 52

SET(GRAPH_PATTERN_DETECTOR_DEPS graph graph_helper graph_traits)
if (WITH_TESTING)
    SET(GRAPH_PATTERN_DETECTOR_DEPS ${GRAPH_PATTERN_DETECTOR_DEPS} gtest)
endif(WITH_TESTING)
cc_library(graph_pattern_detector SRCS graph_pattern_detector.cc DEPS ${GRAPH_PATTERN_DETECTOR_DEPS})

53
cc_library(subgraph_detector SRCS subgraph_detector.cc DEPS graph_pattern_detector executor)
W
Wojciech Uss 已提交
54
cc_library(fuse_pass_base SRCS fuse_pass_base.cc DEPS pass)
55
cc_library(placement_pass_base SRCS placement_pass_base.cc DEPS pass)
L
luotao1 已提交
56

57
cc_library(coalesce_grad_tensor_pass SRCS coalesce_grad_tensor_pass.cc DEPS graph graph_helper)
58

Y
Yan Chunwei 已提交
59 60
pass_library(graph_to_program_pass base)
pass_library(graph_viz_pass base)
M
minqiyang 已提交
61
pass_library(lock_free_optimize_pass base)
Y
Yan Chunwei 已提交
62
pass_library(fc_fuse_pass inference)
63
pass_library(map_matmul_to_mul_pass inference)
Y
Yan Chunwei 已提交
64 65
pass_library(attention_lstm_fuse_pass inference)
pass_library(fc_lstm_fuse_pass inference)
66
pass_library(embedding_fc_lstm_fuse_pass inference)
67
pass_library(fc_gru_fuse_pass inference)
Y
Yan Chunwei 已提交
68
pass_library(seq_concat_fc_fuse_pass inference)
69
pass_library(multi_batch_merge_pass base)
S
Sylwester Fraczek 已提交
70
pass_library(conv_bn_fuse_pass inference)
T
tensor-tang 已提交
71
pass_library(seqconv_eltadd_relu_fuse_pass inference)
T
tensor-tang 已提交
72
pass_library(seqpool_concat_fuse_pass inference)
73
pass_library(seqpool_cvm_concat_fuse_pass inference)
T
tensor-tang 已提交
74
pass_library(repeated_fc_relu_fuse_pass inference)
75
pass_library(squared_mat_sub_fuse_pass inference)
76
pass_library(is_test_pass base)
77 78
pass_library(conv_elementwise_add_act_fuse_pass inference)
pass_library(conv_elementwise_add2_act_fuse_pass inference)
N
nhzlx 已提交
79
pass_library(conv_elementwise_add_fuse_pass inference)
N
nhzlx 已提交
80
pass_library(conv_affine_channel_fuse_pass inference)
81
pass_library(transpose_flatten_concat_fuse_pass inference)
82
pass_library(identity_scale_op_clean_pass base)
Q
qingqing01 已提交
83
pass_library(sync_batch_norm_pass base)
L
luotao1 已提交
84
pass_library(runtime_context_cache_pass base)
N
nhzlx 已提交
85
pass_library(quant_conv2d_dequant_fuse_pass inference)
86
pass_library(shuffle_channel_detect_pass inference)
87
pass_library(delete_quant_dequant_op_pass inference)
88
pass_library(delete_quant_dequant_filter_op_pass inference)
89
pass_library(simplify_with_basic_ops_pass base)
90
pass_library(fc_elementwise_layernorm_fuse_pass base)
91
pass_library(skip_layernorm_fuse_pass base)
92
pass_library(multihead_matmul_fuse_pass inference)
93 94
pass_library(adaptive_pool2d_convert_global_pass inference)
pass_library(unsqueeze2_eltwise_fuse_pass inference)
95 96
if(WITH_GPU)
    pass_library(cudnn_placement_pass base DEPS placement_pass_base)
97
    pass_library(embedding_eltwise_layernorm_fuse_pass inference)
98
endif()
99

W
Wojciech Uss 已提交
100
if(WITH_MKLDNN)
101
    pass_library(mkldnn_placement_pass base DEPS placement_pass_base DIR mkldnn)
102
    pass_library(mkldnn_inplace_pass inference DEPS mkldnn_placement_pass op_registry elementwise_add_op gelu_op activation_op softmax_op softmax DIR mkldnn)
103 104 105 106 107
    pass_library(depthwise_conv_mkldnn_pass base DIR mkldnn)
    pass_library(conv_bias_mkldnn_fuse_pass inference DIR mkldnn)
    pass_library(conv_activation_mkldnn_fuse_pass inference DIR mkldnn)
    pass_library(conv_concat_relu_mkldnn_fuse_pass inference DIR mkldnn)
    pass_library(conv_elementwise_add_mkldnn_fuse_pass inference DIR mkldnn)
108
    pass_library(scale_matmul_fuse_pass inference DIR mkldnn)
109 110
    pass_library(cpu_bfloat16_placement_pass inference DIR mkldnn)
    pass_library(cpu_bfloat16_pass inference DIR mkldnn)
111
    pass_library(fc_mkldnn_pass inference DIR mkldnn)
112
    pass_library(interpolate_mkldnn_pass inference DIR mkldnn)
113
    pass_library(fc_act_mkldnn_fuse_pass inference DIR mkldnn)
114 115 116
    pass_library(cpu_quantize_placement_pass base DIR mkldnn)
    pass_library(cpu_quantize_pass inference DIR mkldnn)
    pass_library(cpu_quantize_squash_pass inference DIR mkldnn)
117
    pass_library(reshape_transpose_matmul_mkldnn_fuse_pass inference DIR mkldnn)
118
    pass_library(matmul_transpose_reshape_fuse_pass inference DIR mkldnn)
119
    pass_library(batch_norm_act_fuse_pass inference DIR mkldnn)
120
    pass_library(multi_gru_fuse_pass inference DIR mkldnn)
121
    pass_library(multi_gru_seq_fuse_pass inference DIR mkldnn)
W
Wojciech Uss 已提交
122
endif()
123

Z
Zhen Wang 已提交
124
cc_library(fuse_bn_act_pass SRCS fuse_bn_act_pass.cc DEPS pass graph_pattern_detector )
Z
Zhang Ting 已提交
125
cc_library(fuse_bn_add_act_pass SRCS fuse_bn_add_act_pass.cc DEPS pass graph_pattern_detector )
C
chengduo 已提交
126
cc_library(fuse_elewise_add_act_pass SRCS fuse_elewise_add_act_pass.cc DEPS pass graph_pattern_detector )
127
cc_library(fuse_relu_depthwise_conv_pass SRCS fuse_relu_depthwise_conv_pass.cc DEPS pass graph_pattern_detector )
C
chengduo 已提交
128

L
luotao1 已提交
129
set(GLOB_PASS_LIB ${PASS_LIBRARY} CACHE INTERNAL "Global PASS library")
X
Xin Pan 已提交
130

131 132
cc_library(pass_builder SRCS pass_builder.cc DEPS pass)

X
Xin Pan 已提交
133
cc_test(node_test SRCS node_test.cc DEPS node)
X
Xin Pan 已提交
134 135 136
cc_test(pass_test SRCS pass_test.cc DEPS graph pass graph_helper)
cc_test(graph_test SRCS graph_test.cc DEPS graph graph_helper op_registry)
cc_test(graph_helper_test SRCS graph_helper_test.cc DEPS graph graph_helper op_registry)
X
Xin Pan 已提交
137
cc_test(graph_to_program_pass_test SRCS graph_to_program_pass_test.cc DEPS graph_to_program_pass)
138
cc_test(test_graph_pattern_detector SRCS graph_pattern_detector_tester.cc DEPS graph_pattern_detector)
Y
YUNSHEN XIE 已提交
139 140 141
cc_test(test_fc_fuse_pass_cc SRCS fc_fuse_pass_tester.cc DEPS fc_fuse_pass framework_proto)
cc_test(test_fc_lstm_fuse_pass_cc SRCS fc_lstm_fuse_pass_tester.cc DEPS fc_lstm_fuse_pass framework_proto)
cc_test(test_fc_gru_fuse_pass_cc SRCS fc_gru_fuse_pass_tester.cc DEPS fc_gru_fuse_pass framework_proto)
142
cc_test(test_seqpool_concat_fuse_pass SRCS seqpool_concat_fuse_pass_tester.cc DEPS seqpool_concat_fuse_pass framework_proto)
143
cc_test(test_seqpool_cvm_concat_fuse_pass SRCS seqpool_cvm_concat_fuse_pass_tester.cc DEPS seqpool_cvm_concat_fuse_pass framework_proto)
Y
YUNSHEN XIE 已提交
144
cc_test(test_repeated_fc_relu_fuse_pass_cc SRCS repeated_fc_relu_fuse_pass_tester.cc DEPS repeated_fc_relu_fuse_pass framework_proto)
145
cc_test(test_is_test_pass SRCS is_test_pass_tester.cc DEPS is_test_pass)
146
cc_test(test_simplify_with_basic_ops_pass SRCS simplify_with_basic_ops_pass_tester.cc DEPS simplify_with_basic_ops_pass)
147
cc_test(test_fc_elementwise_layernorm_fuse_pass SRCS fc_elementwise_layernorm_fuse_pass_tester.cc DEPS fc_elementwise_layernorm_fuse_pass)
148
cc_test(test_skip_layernorm_fuse_pass SRCS skip_layernorm_fuse_pass_tester.cc DEPS skip_layernorm_fuse_pass)
149
cc_test(test_multihead_matmul_fuse_pass SRCS multihead_matmul_fuse_pass_tester.cc DEPS multihead_matmul_fuse_pass)
Y
YUNSHEN XIE 已提交
150
cc_test(test_conv_bn_fuse_pass_cc SRCS conv_bn_fuse_pass_tester.cc DEPS conv_bn_fuse_pass)
151 152
cc_test(test_adaptive_pool2d_convert_global_pass SRCS adaptive_pool2d_convert_global_pass_tester.cc DEPS adaptive_pool2d_convert_global_pass)
cc_test(test_unsqueeze2_eltwise_fuse_pass SRCS unsqueeze2_eltwise_fuse_pass_tester.cc DEPS unsqueeze2_eltwise_fuse_pass)
153
if(WITH_GPU)
154
    cc_test(test_embedding_eltwise_layernorm_fuse_pass SRCS embedding_eltwise_layernorm_fuse_pass_tester.cc DEPS embedding_eltwise_layernorm_fuse_pass)
155 156
    cc_test(test_cudnn_placement_pass SRCS cudnn_placement_pass_tester.cc DEPS cudnn_placement_pass)
endif()
Q
qingqing01 已提交
157 158 159
if(NOT WIN32)
    cc_test(test_sync_batch_norm_pass SRCS sync_batch_norm_pass_tester.cc DEPS sync_batch_norm_pass)
endif()
T
Tao Luo 已提交
160
if (WITH_MKLDNN)
161
    cc_test(test_depthwise_conv_mkldnn_pass SRCS mkldnn/depthwise_conv_mkldnn_pass_tester.cc DEPS depthwise_conv_mkldnn_pass)
162
    cc_test(test_conv_bias_mkldnn_fuse_pass SRCS mkldnn/conv_bias_mkldnn_fuse_pass_tester.cc DEPS conv_bias_mkldnn_fuse_pass naive_executor)
163
    cc_test(test_conv_activation_mkldnn_fuse_pass SRCS mkldnn/conv_activation_mkldnn_fuse_pass_tester.cc DEPS conv_activation_mkldnn_fuse_pass)
164
    cc_test(test_conv_concat_relu_mkldnn_fuse_pass SRCS mkldnn/conv_concat_relu_mkldnn_fuse_pass_tester.cc DEPS conv_concat_relu_mkldnn_fuse_pass)
165
    cc_test(test_conv_elementwise_add_mkldnn_fuse_pass SRCS mkldnn/conv_elementwise_add_mkldnn_fuse_pass_tester.cc DEPS conv_elementwise_add_mkldnn_fuse_pass)
166
    cc_test(test_fc_act_mkldnn_fuse_pass SRCS mkldnn/fc_act_mkldnn_fuse_pass_tester.cc DEPS fc_act_mkldnn_fuse_pass)
167
    cc_test(test_batch_norm_act_fuse_pass SRCS mkldnn/batch_norm_act_fuse_pass_tester.cc DEPS batch_norm_act_fuse_pass)
168 169 170 171 172
    set(TEST_CONV_BN_PASS_DEPS conv_bn_fuse_pass graph_to_program_pass conv_op conv_transpose_op math_function im2col vol2col batch_norm_op gelu_op activation_op elementwise_add_op concat_and_split naive_executor device_context)
if (WITH_GPU)
    set(TEST_CONV_BN_PASS_DEPS ${TEST_CONV_BN_PASS_DEPS} depthwise_conv)
endif()
    cc_test(test_conv_batch_norm_mkldnn_fuse_pass SRCS mkldnn/mkldnn_conv_bn_fuse_pass_tester.cc DEPS ${TEST_CONV_BN_PASS_DEPS})
173
    cc_test(test_scale_matmul_fuse_pass SRCS mkldnn/scale_matmul_fuse_pass_tester.cc DEPS scale_matmul_fuse_pass)
174
    cc_test(test_mkldnn_placement_pass SRCS mkldnn/mkldnn_placement_pass_tester.cc DEPS mkldnn_placement_pass)
175
    cc_test(test_mkldnn_inplace_pass SRCS mkldnn/mkldnn_inplace_pass_tester.cc DEPS mkldnn_inplace_pass)
176 177 178
    cc_test(test_cpu_quantize_placement_pass SRCS mkldnn/cpu_quantize_placement_pass_tester.cc DEPS cpu_quantize_placement_pass)
    cc_test(test_cpu_quantize_pass SRCS mkldnn/cpu_quantize_pass_tester.cc DEPS cpu_quantize_pass naive_executor)
    cc_test(test_cpu_quantize_squash_pass SRCS mkldnn/cpu_quantize_squash_pass_tester.cc DEPS cpu_quantize_squash_pass naive_executor)
179
    cc_test(test_reshape_transpose_matmul_mkldnn_fuse_pass SRCS mkldnn/reshape_transpose_matmul_mkldnn_fuse_pass_tester.cc DEPS reshape_transpose_matmul_mkldnn_fuse_pass)
180
    cc_test(test_matmul_transpose_reshape_fuse_pass SRCS mkldnn/matmul_transpose_reshape_fuse_pass_tester.cc DEPS matmul_transpose_reshape_fuse_pass)
181 182
    cc_test(test_cpu_bfloat16_placement_pass SRCS mkldnn/cpu_bfloat16_placement_pass_tester.cc DEPS cpu_bfloat16_placement_pass)
    cc_test(test_cpu_bfloat16_pass SRCS mkldnn/cpu_bfloat16_pass_tester.cc DEPS cpu_bfloat16_pass)
183
    cc_test(test_multi_gru_fuse_pass SRCS mkldnn/multi_gru_fuse_pass_tester.cc DEPS multi_gru_fuse_pass)
184
    cc_test(test_multi_gru_seq_fuse_pass SRCS mkldnn/multi_gru_seq_fuse_pass_tester.cc DEPS multi_gru_seq_fuse_pass)
T
Tao Luo 已提交
185
endif ()