From 391d66381f25d3d011e63ce3343bdd28af0a9a6b Mon Sep 17 00:00:00 2001 From: Jack Zhou Date: Fri, 26 Aug 2022 11:20:52 +0800 Subject: [PATCH] Remove eigen compliation option (#161) Remove eigen option --- CMakeLists.txt | 19 +++++-------------- csrc/fastdeploy/function/reduce.cc | 4 ---- csrc/fastdeploy/function/reduce.h | 2 -- csrc/fastdeploy/function/softmax.cc | 3 --- csrc/fastdeploy/function/softmax.h | 2 -- csrc/fastdeploy/function/transpose.cc | 3 +-- csrc/fastdeploy/function/transpose.h | 3 +-- tests/function/test_reduce.cc | 2 -- tests/function/test_softmax.cc | 4 ++-- tests/function/test_transpose.cc | 3 +-- 10 files changed, 10 insertions(+), 35 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3aa2ead67..b8c72a53e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,8 +49,6 @@ option(ENABLE_VISION "Whether to enable vision models usage." OFF) option(ENABLE_VISION_VISUALIZE "Whether to enable visualize vision model result toolbox." ON) option(ENABLE_TEXT "Whether to enable text models usage." OFF) option(WITH_TESTING "Whether to compile with unittest." OFF) -# TODO(zhoushunjie): Will remove it later. -option(ENABLE_FDTENSOR_FUNC "Whether to compile with function of FDTensor." OFF) # Please don't open this flag now, some bugs exists. option(ENABLE_OPENCV_CUDA "Whether to enable opencv with cuda, this will allow process image with GPU." OFF) @@ -122,7 +120,7 @@ file(GLOB_RECURSE DEPLOY_OPENVINO_SRCS ${PROJECT_SOURCE_DIR}/${CSRCS_DIR_NAME}/f file(GLOB_RECURSE DEPLOY_VISION_SRCS ${PROJECT_SOURCE_DIR}/${CSRCS_DIR_NAME}/fastdeploy/vision/*.cc) file(GLOB_RECURSE DEPLOY_TEXT_SRCS ${PROJECT_SOURCE_DIR}/${CSRCS_DIR_NAME}/fastdeploy/text/*.cc) file(GLOB_RECURSE DEPLOY_PYBIND_SRCS ${PROJECT_SOURCE_DIR}/${CSRCS_DIR_NAME}/fastdeploy/pybind/*.cc ${PROJECT_SOURCE_DIR}/${CSRCS_DIR_NAME}/fastdeploy/*_pybind.cc) -list(REMOVE_ITEM ALL_DEPLOY_SRCS ${DEPLOY_ORT_SRCS} ${DEPLOY_PADDLE_SRCS} ${DEPLOY_TRT_SRCS} ${DEPLOY_OPENVINO_SRCS} ${DEPLOY_VISION_SRCS} ${DEPLOY_TEXT_SRCS} ${FDTENSOR_FUNC_SRCS}) +list(REMOVE_ITEM ALL_DEPLOY_SRCS ${DEPLOY_ORT_SRCS} ${DEPLOY_PADDLE_SRCS} ${DEPLOY_TRT_SRCS} ${DEPLOY_OPENVINO_SRCS} ${DEPLOY_VISION_SRCS} ${DEPLOY_TEXT_SRCS}) set(DEPEND_LIBS "") @@ -130,9 +128,9 @@ file(READ "${PROJECT_SOURCE_DIR}/VERSION_NUMBER" FASTDEPLOY_VERSION) string(STRIP "${FASTDEPLOY_VERSION}" FASTDEPLOY_VERSION) set(THIRD_PARTY_PATH ${CMAKE_CURRENT_BINARY_DIR}/third_libs) -if(ENABLE_FDTENSOR_FUNC OR ENABLE_TEXT) - include(external/eigen.cmake) -endif() + +include(external/eigen.cmake) + if(ENABLE_PADDLE_FRONTEND) add_definitions(-DENABLE_PADDLE_FRONTEND) include(${PROJECT_SOURCE_DIR}/external/paddle2onnx.cmake) @@ -257,11 +255,6 @@ if(ENABLE_TEXT) include(external/faster_tokenizer.cmake) endif() -if (ENABLE_FDTENSOR_FUNC) - add_definitions(-DENABLE_FDTENSOR_FUNC) - list(APPEND ALL_DEPLOY_SRCS ${FDTENSOR_FUNC_SRCS}) -endif() - configure_file(${PROJECT_SOURCE_DIR}/${CSRCS_DIR_NAME}/fastdeploy/core/config.h.in ${PROJECT_SOURCE_DIR}/${CSRCS_DIR_NAME}/fastdeploy/core/config.h) configure_file(${PROJECT_SOURCE_DIR}/${CSRCS_DIR_NAME}/fastdeploy/pybind/main.cc.in ${PROJECT_SOURCE_DIR}/${CSRCS_DIR_NAME}/fastdeploy/pybind/main.cc) configure_file(${PROJECT_SOURCE_DIR}/FastDeploy.cmake.in ${PROJECT_SOURCE_DIR}/FastDeploy.cmake @ONLY) @@ -270,9 +263,7 @@ configure_file(${PROJECT_SOURCE_DIR}/fastdeploy/c_lib_wrap.py.in ${PROJECT_SOURC list(REMOVE_ITEM ALL_DEPLOY_SRCS ${DEPLOY_PYBIND_SRCS}) add_library(${LIBRARY_NAME} SHARED ${ALL_DEPLOY_SRCS}) -if(ENABLE_FDTENSOR_FUNC OR ENABLE_TEXT) - add_dependencies(${LIBRARY_NAME} extern_eigen3) -endif() +add_dependencies(${LIBRARY_NAME} extern_eigen3) redefine_file_macro(${LIBRARY_NAME}) set_target_properties(${LIBRARY_NAME} PROPERTIES COMPILE_FLAGS "-fvisibility=hidden") diff --git a/csrc/fastdeploy/function/reduce.cc b/csrc/fastdeploy/function/reduce.cc index 305fbff53..f005285bf 100644 --- a/csrc/fastdeploy/function/reduce.cc +++ b/csrc/fastdeploy/function/reduce.cc @@ -24,8 +24,6 @@ namespace fastdeploy { -#ifdef ENABLE_FDTENSOR_FUNC - template void ReduceFunctor(const FDTensor& input, FDTensor* output, const std::vector& dims, bool keep_dim) { @@ -404,6 +402,4 @@ void ArgMin(const FDTensor& x, FDTensor* out, int64_t axis, })); } -#endif - } // namespace fastdeploy \ No newline at end of file diff --git a/csrc/fastdeploy/function/reduce.h b/csrc/fastdeploy/function/reduce.h index 3d77ed30f..77ec2c5c0 100644 --- a/csrc/fastdeploy/function/reduce.h +++ b/csrc/fastdeploy/function/reduce.h @@ -18,7 +18,6 @@ namespace fastdeploy { -#ifdef ENABLE_FDTENSOR_FUNC /** Excute the maximum operation for input FDTensor along given dims. @param x The input tensor. @param out The output tensor which stores the result. @@ -124,5 +123,4 @@ FASTDEPLOY_DECL void ArgMin(const FDTensor& x, FDTensor* out, int64_t axis, FDDataType output_dtype = FDDataType::INT64, bool keep_dim = false, bool flatten = false); -#endif } // namespace fastdeploy diff --git a/csrc/fastdeploy/function/softmax.cc b/csrc/fastdeploy/function/softmax.cc index 83b110200..52fe5e975 100644 --- a/csrc/fastdeploy/function/softmax.cc +++ b/csrc/fastdeploy/function/softmax.cc @@ -21,8 +21,6 @@ #include "fastdeploy/utils/utils.h" namespace fastdeploy { -#ifdef ENABLE_FDTENSOR_FUNC - template struct ValueClip { T operator()(const T& x) const { @@ -122,5 +120,4 @@ void Softmax(const FDTensor& x, FDTensor* out, int axis) { FD_VISIT_FLOAT_TYPES(x.dtype, "SoftmaxKernel", ([&] { SoftmaxKernel(x, out, axis); })); } -#endif } // namespace fastdeploy diff --git a/csrc/fastdeploy/function/softmax.h b/csrc/fastdeploy/function/softmax.h index 869fb7460..2c3aa78d3 100644 --- a/csrc/fastdeploy/function/softmax.h +++ b/csrc/fastdeploy/function/softmax.h @@ -18,7 +18,6 @@ namespace fastdeploy { -#ifdef ENABLE_FDTENSOR_FUNC /** Excute the softmax operation for input FDTensor along given dims. @param x The input tensor. @param out The output tensor which stores the result. @@ -26,5 +25,4 @@ namespace fastdeploy { */ FASTDEPLOY_DECL void Softmax(const FDTensor& x, FDTensor* out, int axis = -1); -#endif } // namespace fastdeploy diff --git a/csrc/fastdeploy/function/transpose.cc b/csrc/fastdeploy/function/transpose.cc index 6f276e886..76196a6dd 100644 --- a/csrc/fastdeploy/function/transpose.cc +++ b/csrc/fastdeploy/function/transpose.cc @@ -17,7 +17,6 @@ #include "fastdeploy/utils/utils.h" namespace fastdeploy { -#ifdef ENABLE_FDTENSOR_FUNC template struct TransposeNormalKernel { @@ -115,5 +114,5 @@ void Transpose(const FDTensor& x, FDTensor* out, FD_VISIT_ALL_TYPES(x.dtype, "TransposeKernel", ([&] { TransposeKernel(x, out, dims); })); } -#endif + } // namespace fastdeploy \ No newline at end of file diff --git a/csrc/fastdeploy/function/transpose.h b/csrc/fastdeploy/function/transpose.h index 3e822c241..e59fe10f7 100644 --- a/csrc/fastdeploy/function/transpose.h +++ b/csrc/fastdeploy/function/transpose.h @@ -17,7 +17,7 @@ #include "fastdeploy/core/fd_tensor.h" namespace fastdeploy { -#ifdef ENABLE_FDTENSOR_FUNC + /** Excute the transpose operation for input FDTensor along given dims. @param x The input tensor. @param out The output tensor which stores the result. @@ -25,5 +25,4 @@ namespace fastdeploy { */ FASTDEPLOY_DECL void Transpose(const FDTensor& x, FDTensor* out, const std::vector& dims); -#endif } // namespace fastdeploy diff --git a/tests/function/test_reduce.cc b/tests/function/test_reduce.cc index 91de87fa6..6a7c7bcf1 100644 --- a/tests/function/test_reduce.cc +++ b/tests/function/test_reduce.cc @@ -22,7 +22,6 @@ namespace fastdeploy { -#ifdef ENABLE_FDTENSOR_FUNC TEST(fastdeploy, reduce_max) { FDTensor input, output; CheckShape check_shape; @@ -372,5 +371,4 @@ TEST(fastdeploy, reduce_argmin) { expected_result_noaxis.data(), expected_result_noaxis.size()); } -#endif } // namespace fastdeploy diff --git a/tests/function/test_softmax.cc b/tests/function/test_softmax.cc index 0a2d60a56..2c1adeba0 100644 --- a/tests/function/test_softmax.cc +++ b/tests/function/test_softmax.cc @@ -20,7 +20,7 @@ #include "gtest_utils.h" namespace fastdeploy { -#ifdef ENABLE_FDTENSOR_FUNC + TEST(fastdeploy, softmax) { FDTensor input, output; CheckShape check_shape; @@ -44,5 +44,5 @@ TEST(fastdeploy, softmax) { check_data(reinterpret_cast(output.Data()), expected_result_axis1.data(), expected_result_axis1.size()); } -#endif + } // namespace fastdeploy \ No newline at end of file diff --git a/tests/function/test_transpose.cc b/tests/function/test_transpose.cc index ec13625ed..7804efa88 100644 --- a/tests/function/test_transpose.cc +++ b/tests/function/test_transpose.cc @@ -22,7 +22,7 @@ #include "gtest_utils.h" namespace fastdeploy { -#ifdef ENABLE_FDTENSOR_FUNC + TEST(fastdeploy, transpose_2d) { FDTensor input, output; CheckShape check_shape; @@ -57,5 +57,4 @@ TEST(fastdeploy, transpose_5d) { expected_result.data(), expected_result.size()); } -#endif } // namespace fastdeploy