CMakeLists.txt 3.5 KB
Newer Older
W
Wu Yi 已提交
1
include(operators)
2 3 4 5
if(WITH_UNITY_BUILD)
    # Load Unity Build rules for operators in paddle/fluid/operators/fused.
    include(unity_build_rule.cmake)
endif()
6
register_operators(EXCLUDES
Z
Zhen Wang 已提交
7
    fused_bn_activation_op
8 9 10 11
    conv_fusion_op
    fusion_transpose_flatten_concat_op
    fusion_conv_inception_op
    fused_fc_elementwise_layernorm_op
12
    multihead_matmul_op
13
    skip_layernorm_op
14
    fused_embedding_eltwise_layernorm_op
A
Adam 已提交
15
    fusion_group_op
Z
Zhang Ting 已提交
16
    fusion_gru_op
17
    fusion_lstm_op
F
Feng Xing 已提交
18 19
    fused_bn_add_activation_op
    fused_transformer_op)
A
Adam 已提交
20 21 22

# fusion_gru_op does not have CUDA kernel
op_library(fusion_gru_op)
23
op_library(fusion_lstm_op)
24
file(APPEND ${pybind_file} "USE_CPU_ONLY_OP(fusion_gru);\n")
25 26
file(APPEND ${pybind_file} "USE_CPU_ONLY_OP(fusion_lstm);\n")

27

28
if (WITH_GPU OR WITH_ROCM)
Z
Zhen Wang 已提交
29
    # fused_bn_activation_op needs cudnn 7.4.1 above
30 31
    # HIP not support bn act fuse in MIOPEN
    if ((NOT WITH_ROCM) AND (NOT ${CUDNN_VERSION} VERSION_LESS 7401))
Z
Zhen Wang 已提交
32 33 34
        op_library(fused_bn_activation_op)
        file(APPEND ${pybind_file} "USE_CUDA_ONLY_OP(fused_batch_norm_act);\n")
    endif()
35
    # conv_fusion_op needs cudnn 7 above
R
ronnywang 已提交
36
    if (NOT ${CUDNN_VERSION} VERSION_LESS 7100)
37 38 39 40
        op_library(conv_fusion_op)
        file(APPEND ${pybind_file} "USE_CUDA_ONLY_OP(conv2d_fusion);\n")
    endif()
    # fusion_transpose_flatten_concat_op
41 42 43 44 45
    # HIP not support cudnnTransformTensor
    if(NOT WITH_ROCM)
        op_library(fusion_transpose_flatten_concat_op)
        file(APPEND ${pybind_file} "USE_CUDA_ONLY_OP(fusion_transpose_flatten_concat);\n")
    endif()
46
    # fusion_conv_inception_op needs cudnn 7 above
47 48
    # HIP not support cudnnConvolutionBiasActivationForward
    if ((NOT WITH_ROCM) AND (NOT ${CUDNN_VERSION} VERSION_LESS 7100))
49 50 51 52 53 54 55 56 57
        op_library(fusion_conv_inception_op)
        file(APPEND ${pybind_file} "USE_CUDA_ONLY_OP(conv2d_inception_fusion);\n")
    endif()
    # fused_fc_elementwise_layernorm_op
    op_library(fused_fc_elementwise_layernorm_op)
    file(APPEND ${pybind_file} "USE_CUDA_ONLY_OP(fused_fc_elementwise_layernorm);\n")
    # multihead_matmul_op
    op_library(multihead_matmul_op)
    file(APPEND ${pybind_file} "USE_CUDA_ONLY_OP(multihead_matmul);\n")
58 59
    op_library(skip_layernorm_op)
    file(APPEND ${pybind_file} "USE_CUDA_ONLY_OP(skip_layernorm);\n")
60 61
    op_library(fused_embedding_eltwise_layernorm_op)
    file(APPEND ${pybind_file} "USE_CUDA_ONLY_OP(fused_embedding_eltwise_layernorm);\n")
62 63 64 65 66 67
    # fusion_group
    if(NOT APPLE AND NOT WIN32)
        op_library(fusion_group_op DEPS device_code)
        file(APPEND ${pybind_file} "USE_CUDA_ONLY_OP(fusion_group);\n")
        cc_test(test_fusion_group_op SRCS fusion_group_op_test.cc DEPS fusion_group_op)
    endif()
Z
Zhang Ting 已提交
68
    # fused_bn_add_activation
69 70 71 72
    # HIP not support bn act fuse in MIOPEN
    if ((NOT WITH_ROCM) AND (NOT ${CUDNN_VERSION} VERSION_LESS 7401))
        op_library(fused_bn_add_activation_op)
        file(APPEND ${pybind_file} "USE_CUDA_ONLY_OP(fused_bn_add_activation);\n")
Z
Zhang Ting 已提交
73
    endif()
74 75 76
    # fused_dropout
    # only support CUDA
    if(NOT WITH_ROCM)
77 78 79
        nv_test(test_fused_residual_dropout_bias SRCS fused_residual_dropout_bias_test.cu DEPS tensor op_registry dropout_op layer_norm_op device_context generator memory)
        nv_test(test_fused_dropout_act_bias SRCS fused_dropout_act_bias_test.cu DEPS tensor op_registry dropout_op layer_norm_op device_context generator memory)
        nv_test(test_fused_layernorm_residual_dropout_bias SRCS fused_layernorm_residual_dropout_bias_test.cu DEPS tensor op_registry dropout_op layer_norm_op device_context generator memory)
80
    endif()
81
endif()