CMakeLists.txt 4.4 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 17 18
if(APPLE)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=pessimizing-move")
endif(APPLE)
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
  cc_library(${mkldnn_quantizer_cfg} SRCS mkldnn_quantizer_config.cc DEPS lod_tensor paddle_pass_builder)
26
  set(mkldnn_quantizer_cfg ${mkldnn_quantizer_cfg} PARENT_SCOPE)
27 28
endif()

S
Steffy-zxf 已提交
29
cc_library(analysis_config SRCS analysis_config.cc DEPS ${mkldnn_quantizer_cfg} lod_tensor paddle_pass_builder table_printer utf8proc)
30
cc_library(paddle_infer_contrib SRCS paddle_infer_contrib.cc DEPS zero_copy_tensor)
31
cc_library(paddle_pass_builder SRCS paddle_pass_builder.cc)
32

33
set(paddle_inference_api_deps lod_tensor scope reset_tensor_array
34
    analysis_config paddle_infer_contrib zero_copy_tensor trainer_desc_proto custom_operator)
35

36
if(WITH_CRYPTO)
37
    list(APPEND paddle_inference_api_deps paddle_crypto)
38
endif()
39

40 41
cc_library(paddle_inference_api SRCS api.cc api_impl.cc helper.cc DEPS ${paddle_inference_api_deps})

42 43 44 45
if(WIN32)
    target_link_libraries(paddle_inference_api gflags)
endif()

46 47 48 49 50 51
set(inference_deps ${analysis_deps} paddle_inference_api analysis naive_executor ${GLOB_PASS_LIB})

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

52 53 54 55 56 57 58 59 60
if (WITH_ONNXRUNTIME)
    cc_library(analysis_predictor SRCS analysis_predictor.cc ${mkldnn_quantizer_src} DEPS ${inference_deps} 
              zero_copy_tensor ir_pass_manager op_compatible_info infer_io_utils onnxruntime paddle2onnx)
    cc_library(onnxruntime_predictor SRCS onnxruntime_predictor.cc DEPS analysis_predictor)
else (WITH_ONNXRUNTIME)
    cc_library(analysis_predictor SRCS analysis_predictor.cc ${mkldnn_quantizer_src} DEPS ${inference_deps} 
              zero_copy_tensor ir_pass_manager op_compatible_info infer_io_utils)
endif (WITH_ONNXRUNTIME)

61

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

64
if(WITH_TESTING)
65
  if (NOT APPLE AND NOT WIN32)
Y
YUNSHEN XIE 已提交
66 67 68 69
    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})
    endif()
70
  elseif(WIN32)
71
    inference_base_test(test_api_impl SRCS api_impl_tester.cc DEPS ${inference_deps}
W
Wilber 已提交
72
      ARGS --word2vec_dirname=${WORD2VEC_MODEL_DIR} --book_dirname=${IMG_CLS_RESNET_INSTALL_DIR})
73
  endif()
74

75
endif()
76 77

if (NOT APPLE AND NOT WIN32)
78
  cc_test(test_analysis_predictor SRCS analysis_predictor_tester.cc DEPS paddle_inference_shared
79
          ARGS --dirname=${WORD2VEC_MODEL_DIR})
80
elseif (WIN32)
81 82 83
  cc_test(test_analysis_predictor SRCS analysis_predictor_tester.cc DEPS analysis_predictor benchmark ${inference_deps}
          ARGS --dirname=${WORD2VEC_MODEL_DIR})
endif()
84

85 86 87 88 89 90 91 92 93 94
if (WITH_ONNXRUNTIME)
  if (NOT APPLE AND NOT WIN32)
    cc_test(test_onnxruntime_predictor SRCS onnxruntime_predictor_tester.cc DEPS paddle_inference_shared
            ARGS --dirname=${MOBILENETV2_MODEL_DIR})
  elseif (WIN32)
    cc_test(test_onnxruntime_predictor SRCS onnxruntime_predictor_tester.cc DEPS onnxruntime_predictor benchmark ${inference_deps}
            ARGS --dirname=${MOBILENETV2_MODEL_DIR})
  endif()
endif()

95 96 97 98 99 100 101 102 103
if(WITH_TESTING AND WITH_MKLDNN)
  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})
  endif()
endif()

104
if(WITH_TESTING AND TEST test_api_impl)
Y
YUNSHEN XIE 已提交
105 106 107 108
    if(NOT APPLE)
        set_tests_properties(test_api_impl PROPERTIES TIMEOUT 120)
    endif()
endif()