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

6 7 8
add_subdirectory(fuse_optimizer_ops_pass)
add_subdirectory(memory_optimize_pass)
add_subdirectory(multi_devices_graph_pass)
Y
Yan Chunwei 已提交
9 10

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

    # Get optional argument
    set(extraMacroArgs ${ARGN})
    list(LENGTH extraMacroArgs numExtraMacroArgs)
    if(numExtraMacroArgs GREATER 0)
        list(GET extraMacroArgs 0 targetPrefix)
    endif()

L
luotao1 已提交
25
    cmake_parse_arguments(op_library "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
26 27 28 29 30 31
    if(targetPrefix)
        cc_library(${TARGET} SRCS ${targetPrefix}/${TARGET}.cc DEPS graph_pattern_detector pass fuse_pass_base ${op_library_DEPS})
    else()
        cc_library(${TARGET} SRCS ${TARGET}.cc DEPS graph_pattern_detector pass fuse_pass_base ${op_library_DEPS})
    endif()

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

Y
yuyang18 已提交
40
cc_library(node SRCS node.cc DEPS proto_desc)
Y
Yan Chunwei 已提交
41
cc_library(graph SRCS graph.cc DEPS node pretty_log)
X
better  
Xin Pan 已提交
42
cc_library(graph_helper SRCS graph_helper.cc DEPS graph)
X
Xin Pan 已提交
43
cc_library(pass SRCS pass.cc DEPS graph node graph_helper)
44
cc_library(graph_traits SRCS graph_traits.cc DEPS graph)
L
luotao1 已提交
45
cc_library(graph_pattern_detector SRCS graph_pattern_detector.cc DEPS graph graph_helper graph_traits)
W
Wojciech Uss 已提交
46
cc_library(fuse_pass_base SRCS fuse_pass_base.cc DEPS pass)
L
luotao1 已提交
47

48
cc_library(coalesce_grad_tensor_pass SRCS coalesce_grad_tensor_pass.cc DEPS graph graph_helper)
49

Y
Yan Chunwei 已提交
50 51
pass_library(graph_to_program_pass base)
pass_library(graph_viz_pass base)
M
minqiyang 已提交
52
pass_library(lock_free_optimize_pass base)
Y
Yan Chunwei 已提交
53 54 55
pass_library(fc_fuse_pass inference)
pass_library(attention_lstm_fuse_pass inference)
pass_library(fc_lstm_fuse_pass inference)
56
pass_library(embedding_fc_lstm_fuse_pass inference)
57
pass_library(fc_gru_fuse_pass inference)
Y
Yan Chunwei 已提交
58
pass_library(seq_concat_fc_fuse_pass inference)
59
pass_library(multi_batch_merge_pass base)
S
Sylwester Fraczek 已提交
60
pass_library(conv_bn_fuse_pass inference)
T
tensor-tang 已提交
61
pass_library(seqconv_eltadd_relu_fuse_pass inference)
T
tensor-tang 已提交
62
pass_library(seqpool_concat_fuse_pass inference)
63
pass_library(seqpool_cvm_concat_fuse_pass inference)
T
tensor-tang 已提交
64
pass_library(repeated_fc_relu_fuse_pass inference)
65
pass_library(squared_mat_sub_fuse_pass inference)
66
pass_library(is_test_pass base)
67 68
pass_library(conv_elementwise_add_act_fuse_pass inference)
pass_library(conv_elementwise_add2_act_fuse_pass inference)
N
nhzlx 已提交
69
pass_library(conv_elementwise_add_fuse_pass inference)
N
nhzlx 已提交
70
pass_library(conv_affine_channel_fuse_pass inference)
71
pass_library(transpose_flatten_concat_fuse_pass inference)
72
pass_library(identity_scale_op_clean_pass base)
Q
qingqing01 已提交
73
pass_library(sync_batch_norm_pass base)
L
luotao1 已提交
74
pass_library(runtime_context_cache_pass base)
N
nhzlx 已提交
75 76
pass_library(quant_conv2d_dequant_fuse_pass inference)
pass_library(fillconstant_elementwisemul_fuse inference)
77
pass_library(shuffle_channel_detect_pass inference)
78
pass_library(delete_quant_dequant_op_pass inference)
79

80
if(ANAKIN_SUBGRAPH)
N
nhzlx 已提交
81 82
pass_library(simplify_anakin_priorbox_detection_out_pass inference)
endif()
83

W
Wojciech Uss 已提交
84
if(WITH_MKLDNN)
85 86 87
    pass_library(mkldnn_placement_pass base mkldnn)
    pass_library(depthwise_conv_mkldnn_pass base mkldnn)
    pass_library(conv_bias_mkldnn_fuse_pass inference mkldnn)
88
    pass_library(conv_activation_mkldnn_fuse_pass inference mkldnn)
89
    pass_library(conv_concat_relu_mkldnn_fuse_pass inference mkldnn)
90
    pass_library(conv_elementwise_add_mkldnn_fuse_pass inference mkldnn)
91
    pass_library(fc_mkldnn_pass inference mkldnn)
92 93 94
    pass_library(cpu_quantize_placement_pass base mkldnn)
    pass_library(cpu_quantize_pass inference mkldnn)
    pass_library(cpu_quantize_squash_pass inference mkldnn)
W
Wojciech Uss 已提交
95
endif()
96

M
mozga-intel 已提交
97 98 99 100 101 102 103 104
if(WITH_NGRAPH)
    cc_library(ngraph_subgraph_pass SRCS ngraph_subgraph_pass.cc DEPS ngraph_bridge
      analysis_helper subgraph_detector graph_pattern_detector pass fuse_pass_base ${op_library_DEPS})
    set(pass_file ${PADDLE_BINARY_DIR}/paddle/fluid/inference/api/paddle_inference_pass.h)
    file(APPEND ${pass_file} "USE_PASS(ngraph_subgraph_pass);\n")
    set(INFER_IR_PASSES ${INFER_IR_PASSES} ngraph_subgraph_pass CACHE INTERNAL "")
endif()

C
chengduo 已提交
105
cc_library(fuse_elewise_add_act_pass SRCS fuse_elewise_add_act_pass.cc DEPS pass graph_pattern_detector )
106
cc_library(fuse_relu_depthwise_conv_pass SRCS fuse_relu_depthwise_conv_pass.cc DEPS pass graph_pattern_detector )
C
chengduo 已提交
107

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

110 111
cc_library(pass_builder SRCS pass_builder.cc DEPS pass)

X
Xin Pan 已提交
112
cc_test(node_test SRCS node_test.cc DEPS node)
X
Xin Pan 已提交
113 114 115
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 已提交
116
cc_test(graph_to_program_pass_test SRCS graph_to_program_pass_test.cc DEPS graph_to_program_pass)
117
cc_test(test_graph_pattern_detector SRCS graph_pattern_detector_tester.cc DEPS graph_pattern_detector)
L
luotao1 已提交
118
cc_test(test_fc_fuse_pass SRCS fc_fuse_pass_tester.cc DEPS fc_fuse_pass framework_proto)
119
cc_test(test_seqpool_concat_fuse_pass SRCS seqpool_concat_fuse_pass_tester.cc DEPS seqpool_concat_fuse_pass framework_proto)
120
cc_test(test_seqpool_cvm_concat_fuse_pass SRCS seqpool_cvm_concat_fuse_pass_tester.cc DEPS seqpool_cvm_concat_fuse_pass framework_proto)
121
cc_test(test_is_test_pass SRCS is_test_pass_tester.cc DEPS is_test_pass)
Q
qingqing01 已提交
122 123 124
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 已提交
125
if (WITH_MKLDNN)
126
    cc_test(test_depthwise_conv_mkldnn_pass SRCS mkldnn/depthwise_conv_mkldnn_pass_tester.cc DEPS depthwise_conv_mkldnn_pass)
127
    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)
128
    cc_test(test_conv_activation_mkldnn_fuse_pass SRCS mkldnn/conv_activation_mkldnn_fuse_pass_tester.cc DEPS conv_activation_mkldnn_fuse_pass)
129
    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)
130
    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)
131
    cc_test(test_mkldnn_placement_pass SRCS mkldnn/mkldnn_placement_pass_tester.cc DEPS mkldnn_placement_pass)
132 133 134
    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)
T
Tao Luo 已提交
135
endif ()