CMakeLists.txt 4.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

16
if(APPLE)
17
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=pessimizing-move")
W
Wilber 已提交
18
endif()
19

Y
Yiqun Liu 已提交
20 21
add_subdirectory(details)

22
if(WITH_MKLDNN)
23
  set(mkldnn_quantizer_cfg mkldnn_quantizer_config)
24
  set(mkldnn_quantizer_src ${CMAKE_CURRENT_SOURCE_DIR}/mkldnn_quantizer.cc)
25 26 27 28 29 30 31
  cc_library(
    ${mkldnn_quantizer_cfg}
    SRCS mkldnn_quantizer_config.cc
    DEPS lod_tensor paddle_pass_builder)
  set(mkldnn_quantizer_cfg
      ${mkldnn_quantizer_cfg}
      PARENT_SCOPE)
32 33
endif()

34 35 36 37 38 39 40 41 42
cc_library(
  analysis_config
  SRCS analysis_config.cc
  DEPS ${mkldnn_quantizer_cfg} lod_tensor paddle_pass_builder table_printer
       utf8proc)
cc_library(
  paddle_infer_contrib
  SRCS paddle_infer_contrib.cc
  DEPS zero_copy_tensor)
43
cc_library(paddle_pass_builder SRCS paddle_pass_builder.cc)
44

45 46 47 48 49 50 51 52 53
set(paddle_inference_api_deps
    lod_tensor
    scope
    reset_tensor_array
    analysis_config
    paddle_infer_contrib
    zero_copy_tensor
    trainer_desc_proto
    custom_operator)
54

55
if(WITH_CRYPTO)
56
  list(APPEND paddle_inference_api_deps paddle_crypto)
57
endif()
58 59 60
if(WITH_CUSTOM_DEVICE)
  set(paddle_inference_api_deps ${paddle_inference_api_deps} phi_capi)
endif()
61

62 63 64 65
cc_library(
  paddle_inference_api
  SRCS api.cc api_impl.cc helper.cc
  DEPS ${paddle_inference_api_deps})
66

67
if(WIN32)
68
  target_link_libraries(paddle_inference_api gflags)
69 70
endif()

71 72
set(inference_deps ${analysis_deps} paddle_inference_api analysis
                   naive_executor ${GLOB_PASS_LIB})
73 74

if(WITH_GPU AND TENSORRT_FOUND)
75
  set(inference_deps ${inference_deps} tensorrt_engine tensorrt_converter)
76 77
endif()

78 79 80 81 82 83 84 85 86 87
if(WITH_ONNXRUNTIME)
  cc_library(
    analysis_predictor
    SRCS analysis_predictor.cc onnxruntime_predictor.cc resource_manager.cc
         infer_context.cc ${mkldnn_quantizer_src}
    DEPS ${inference_deps}
         zero_copy_tensor
         ir_pass_manager
         op_compatible_info
         infer_io_utils
88
         model_utils
89 90
         onnxruntime
         paddle2onnx)
W
Wilber 已提交
91
else()
92 93 94 95 96
  cc_library(
    analysis_predictor
    SRCS analysis_predictor.cc resource_manager.cc infer_context.cc
         ${mkldnn_quantizer_src}
    DEPS ${inference_deps} zero_copy_tensor ir_pass_manager op_compatible_info
97
         infer_io_utils model_utils)
W
Wilber 已提交
98
endif()
99 100 101 102 103

cc_test(
  test_paddle_inference_api
  SRCS api_tester.cc
  DEPS paddle_inference_api)
X
Xin Pan 已提交
104

105 106 107 108 109 110
if(WITH_ONNXRUNTIME AND WIN32)
  # Copy onnxruntime for some c++ test in Windows, since the test will
  # be build only in CI, so suppose the generator in Windows is Ninja.
  copy_onnx(test_paddle_inference_api)
endif()

111
if(WITH_TESTING)
112 113 114 115 116 117 118 119 120 121 122
  if(NOT APPLE AND NOT WIN32)
    if(WITH_GPU)
      inference_base_test(
        test_api_impl
        SRCS
        api_impl_tester.cc
        DEPS
        paddle_inference_shared
        ARGS
        --word2vec_dirname=${WORD2VEC_MODEL_DIR}
        --book_dirname=${IMG_CLS_RESNET_INSTALL_DIR})
Y
YUNSHEN XIE 已提交
123
    endif()
124
  elseif(WIN32)
125 126 127 128 129 130 131 132 133
    inference_base_test(
      test_api_impl
      SRCS
      api_impl_tester.cc
      DEPS
      ${inference_deps}
      ARGS
      --word2vec_dirname=${WORD2VEC_MODEL_DIR}
      --book_dirname=${IMG_CLS_RESNET_INSTALL_DIR})
134
  endif()
135

136
endif()
137

138 139 140 141 142 143 144 145 146 147 148
if(NOT APPLE AND NOT WIN32)
  cc_test(
    test_analysis_predictor
    SRCS analysis_predictor_tester.cc
    DEPS paddle_inference_shared ARGS --dirname=${WORD2VEC_MODEL_DIR})
elseif(WIN32)
  cc_test(
    test_analysis_predictor
    SRCS analysis_predictor_tester.cc
    DEPS analysis_predictor benchmark ${inference_deps} ARGS
         --dirname=${WORD2VEC_MODEL_DIR})
149
endif()
150 151

if(WITH_TESTING AND WITH_MKLDNN)
152 153 154 155 156 157 158 159 160 161 162
  if(NOT APPLE AND NOT WIN32)
    cc_test(
      test_mkldnn_quantizer
      SRCS mkldnn_quantizer_tester.cc
      DEPS paddle_inference_shared ARGS --dirname=${WORD2VEC_MODEL_DIR})
  elseif(WIN32)
    cc_test(
      test_mkldnn_quantizer
      SRCS mkldnn_quantizer_tester.cc
      DEPS analysis_predictor benchmark ${inference_deps} ARGS
           --dirname=${WORD2VEC_MODEL_DIR})
163 164 165
  endif()
endif()

166
if(WITH_TESTING AND TEST test_api_impl)
167 168 169
  if(NOT APPLE)
    set_tests_properties(test_api_impl PROPERTIES TIMEOUT 120)
  endif()
Y
YUNSHEN XIE 已提交
170
endif()