From 8c94d8cb4c4800fc159d0146856c15aa5ebbaeb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=B3=E6=99=93=E4=BC=9F?= <39303645+Shixiaowei02@users.noreply.github.com> Date: Sat, 27 Feb 2021 10:27:49 +0800 Subject: [PATCH] [Custom OP] change the user header file format, test=develop (#31274) --- cmake/inference_lib.cmake | 4 ++++ paddle/extension.h | 2 +- .../extension/include/{all.h => ext_all.h} | 10 +++++----- .../include/{dispatch.h => ext_dispatch.h} | 2 +- .../include/{dll_decl.h => ext_dll_decl.h} | 0 .../extension/include/{dtype.h => ext_dtype.h} | 0 .../{op_meta_info.h => ext_op_meta_info.h} | 4 ++-- .../extension/include/{place.h => ext_place.h} | 0 .../include/{tensor.h => ext_tensor.h} | 8 +++++--- .../{op_meta_info.cc => ext_op_meta_info.cc} | 2 +- .../extension/src/{tensor.cc => ext_tensor.cc} | 2 +- paddle/fluid/framework/CMakeLists.txt | 18 +++++++++++++----- paddle/fluid/framework/custom_operator.cc | 2 +- paddle/fluid/framework/custom_operator.h | 2 +- paddle/fluid/framework/custom_tensor_test.cc | 2 +- paddle/fluid/framework/custom_tensor_utils.h | 2 +- paddle/fluid/framework/op_meta_info_helper.h | 2 +- paddle/fluid/inference/CMakeLists.txt | 3 ++- 18 files changed, 40 insertions(+), 25 deletions(-) rename paddle/fluid/extension/include/{all.h => ext_all.h} (76%) rename paddle/fluid/extension/include/{dispatch.h => ext_dispatch.h} (99%) rename paddle/fluid/extension/include/{dll_decl.h => ext_dll_decl.h} (100%) rename paddle/fluid/extension/include/{dtype.h => ext_dtype.h} (100%) rename paddle/fluid/extension/include/{op_meta_info.h => ext_op_meta_info.h} (99%) rename paddle/fluid/extension/include/{place.h => ext_place.h} (100%) rename paddle/fluid/extension/include/{tensor.h => ext_tensor.h} (95%) rename paddle/fluid/extension/src/{op_meta_info.cc => ext_op_meta_info.cc} (98%) rename paddle/fluid/extension/src/{tensor.cc => ext_tensor.cc} (99%) diff --git a/cmake/inference_lib.cmake b/cmake/inference_lib.cmake index 059c3a04487..90410353d5e 100644 --- a/cmake/inference_lib.cmake +++ b/cmake/inference_lib.cmake @@ -189,6 +189,10 @@ copy(inference_lib_dist DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/crypto/) include_directories(${CMAKE_BINARY_DIR}/../paddle/fluid/framework/io) +copy(inference_lib_dist + SRCS ${PADDLE_SOURCE_DIR}/paddle/fluid/extension/include/* + DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/) + # CAPI inference library for only inference set(PADDLE_INFERENCE_C_INSTALL_DIR "${CMAKE_BINARY_DIR}/paddle_inference_c_install_dir" CACHE STRING "A path setting CAPI paddle inference shared") diff --git a/paddle/extension.h b/paddle/extension.h index 1c64b92c5a3..71469576853 100644 --- a/paddle/extension.h +++ b/paddle/extension.h @@ -15,4 +15,4 @@ limitations under the License. */ #pragma once // All paddle apis in C++ frontend -#include "paddle/fluid/extension/include/all.h" +#include "paddle/fluid/extension/include/ext_all.h" diff --git a/paddle/fluid/extension/include/all.h b/paddle/fluid/extension/include/ext_all.h similarity index 76% rename from paddle/fluid/extension/include/all.h rename to paddle/fluid/extension/include/ext_all.h index e2a3bc38c5f..e3b9cb4606c 100644 --- a/paddle/fluid/extension/include/all.h +++ b/paddle/fluid/extension/include/ext_all.h @@ -24,8 +24,8 @@ limitations under the License. */ #endif #endif -#include "paddle/fluid/extension/include/dispatch.h" -#include "paddle/fluid/extension/include/dtype.h" -#include "paddle/fluid/extension/include/op_meta_info.h" -#include "paddle/fluid/extension/include/place.h" -#include "paddle/fluid/extension/include/tensor.h" +#include "ext_dispatch.h" // NOLINT +#include "ext_dtype.h" // NOLINT +#include "ext_op_meta_info.h" // NOLINT +#include "ext_place.h" // NOLINT +#include "ext_tensor.h" // NOLINT diff --git a/paddle/fluid/extension/include/dispatch.h b/paddle/fluid/extension/include/ext_dispatch.h similarity index 99% rename from paddle/fluid/extension/include/dispatch.h rename to paddle/fluid/extension/include/ext_dispatch.h index 3da64ad07aa..557f2ec1dfb 100644 --- a/paddle/fluid/extension/include/dispatch.h +++ b/paddle/fluid/extension/include/ext_dispatch.h @@ -14,7 +14,7 @@ limitations under the License. */ #pragma once -#include "paddle/fluid/extension/include/dtype.h" +#include "ext_dtype.h" // NOLINT namespace paddle { diff --git a/paddle/fluid/extension/include/dll_decl.h b/paddle/fluid/extension/include/ext_dll_decl.h similarity index 100% rename from paddle/fluid/extension/include/dll_decl.h rename to paddle/fluid/extension/include/ext_dll_decl.h diff --git a/paddle/fluid/extension/include/dtype.h b/paddle/fluid/extension/include/ext_dtype.h similarity index 100% rename from paddle/fluid/extension/include/dtype.h rename to paddle/fluid/extension/include/ext_dtype.h diff --git a/paddle/fluid/extension/include/op_meta_info.h b/paddle/fluid/extension/include/ext_op_meta_info.h similarity index 99% rename from paddle/fluid/extension/include/op_meta_info.h rename to paddle/fluid/extension/include/ext_op_meta_info.h index 9c8d9fa40f1..5ac8b2edad0 100644 --- a/paddle/fluid/extension/include/op_meta_info.h +++ b/paddle/fluid/extension/include/ext_op_meta_info.h @@ -21,8 +21,8 @@ limitations under the License. */ #include -#include "paddle/fluid/extension/include/dll_decl.h" -#include "paddle/fluid/extension/include/tensor.h" +#include "ext_dll_decl.h" // NOLINT +#include "ext_tensor.h" // NOLINT /** * Op Meta Info Related Define. diff --git a/paddle/fluid/extension/include/place.h b/paddle/fluid/extension/include/ext_place.h similarity index 100% rename from paddle/fluid/extension/include/place.h rename to paddle/fluid/extension/include/ext_place.h diff --git a/paddle/fluid/extension/include/tensor.h b/paddle/fluid/extension/include/ext_tensor.h similarity index 95% rename from paddle/fluid/extension/include/tensor.h rename to paddle/fluid/extension/include/ext_tensor.h index e6066b42322..77d4ec36e5b 100644 --- a/paddle/fluid/extension/include/tensor.h +++ b/paddle/fluid/extension/include/ext_tensor.h @@ -16,12 +16,14 @@ limitations under the License. */ #include #include -#include "paddle/fluid/extension/include/dll_decl.h" -#include "paddle/fluid/extension/include/dtype.h" -#include "paddle/fluid/extension/include/place.h" #ifdef PADDLE_WITH_CUDA #include #endif + +#include "ext_dll_decl.h" // NOLINT +#include "ext_dtype.h" // NOLINT +#include "ext_place.h" // NOLINT + namespace paddle { namespace framework { class CustomTensorUtils; diff --git a/paddle/fluid/extension/src/op_meta_info.cc b/paddle/fluid/extension/src/ext_op_meta_info.cc similarity index 98% rename from paddle/fluid/extension/src/op_meta_info.cc rename to paddle/fluid/extension/src/ext_op_meta_info.cc index 20129435f26..40cad7a1552 100644 --- a/paddle/fluid/extension/src/op_meta_info.cc +++ b/paddle/fluid/extension/src/ext_op_meta_info.cc @@ -12,7 +12,7 @@ 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. */ -#include "paddle/fluid/extension/include/op_meta_info.h" +#include "paddle/fluid/extension/include/ext_op_meta_info.h" #include #include diff --git a/paddle/fluid/extension/src/tensor.cc b/paddle/fluid/extension/src/ext_tensor.cc similarity index 99% rename from paddle/fluid/extension/src/tensor.cc rename to paddle/fluid/extension/src/ext_tensor.cc index fa8c3c4f090..88c2050bc8a 100644 --- a/paddle/fluid/extension/src/tensor.cc +++ b/paddle/fluid/extension/src/ext_tensor.cc @@ -12,7 +12,7 @@ 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. */ -#include "paddle/fluid/extension/include/tensor.h" +#include "paddle/fluid/extension/include/ext_tensor.h" #include #include "paddle/fluid/framework/custom_tensor_utils.h" #include "paddle/fluid/framework/lod_tensor.h" diff --git a/paddle/fluid/framework/CMakeLists.txt b/paddle/fluid/framework/CMakeLists.txt index 4c92a06aed3..36ba17a7423 100644 --- a/paddle/fluid/framework/CMakeLists.txt +++ b/paddle/fluid/framework/CMakeLists.txt @@ -346,11 +346,13 @@ message(STATUS "branch: ${PADDLE_BRANCH}") configure_file(commit.h.in commit.h) -cc_library(custom_tensor SRCS ../extension/src/tensor.cc DEPS lod_tensor memory enforce) -cc_library(op_meta_info SRCS ../extension/src/op_meta_info.cc DEPS custom_tensor) +cc_library(custom_tensor SRCS ../extension/src/ext_tensor.cc DEPS lod_tensor memory enforce) +cc_library(op_meta_info SRCS ../extension/src/ext_op_meta_info.cc DEPS custom_tensor) cc_library(custom_operator SRCS custom_operator.cc DEPS tensor attribute framework_proto op_registry operator dynamic_loader string_helper custom_tensor op_meta_info) cc_test(custom_tensor_test SRCS custom_tensor_test.cc DEPS custom_tensor glog) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../extension/include) + set(FLUID_FRAMEWORK_MODULES proto_desc memory lod_tensor executor data_feed_proto layer dynamic_loader custom_operator) cc_library(paddle_framework DEPS ${FLUID_FRAMEWORK_MODULES}) @@ -394,10 +396,16 @@ endif() # if not deps `layer`, will cause: undefined symbol: _ZN6paddle10imperative7VarBase9name_set_ set(PADDLE_CUSTOM_OP_MODULES custom_tensor op_meta_info custom_operator layer) +set(PADDLE_CUSTOM_OP_SRCS + ${CMAKE_CURRENT_SOURCE_DIR}/custom_operator.cc + ${CMAKE_CURRENT_SOURCE_DIR}/../extension/src/ext_tensor.cc + ${CMAKE_CURRENT_SOURCE_DIR}/../extension/src/ext_op_meta_info.cc + ${CMAKE_SOURCE_DIR}/paddle/fluid/imperative/layer.cc) +set(PADDLE_CUSTOM_OP_SRCS ${PADDLE_CUSTOM_OP_SRCS} PARENT_SCOPE) + cc_library(paddle_custom_op_shared - SHARED SRCS custom_operator.cc ../extension/src/tensor.cc ../extension/src/op_meta_info.cc - ${CMAKE_SOURCE_DIR}/paddle/fluid/imperative/layer.cc - DEPS ${PADDLE_CUSTOM_OP_MODULES}) + SHARED SRCS ${PADDLE_CUSTOM_OP_SRCS} DEPS ${PADDLE_CUSTOM_OP_MODULES}) + get_property(os_dependency_modules GLOBAL PROPERTY OS_DEPENDENCY_MODULES) set_target_properties(paddle_custom_op_shared PROPERTIES OUTPUT_NAME paddle_custom_op) target_link_libraries(paddle_custom_op_shared ${os_dependency_modules}) diff --git a/paddle/fluid/framework/custom_operator.cc b/paddle/fluid/framework/custom_operator.cc index 582e328dcfd..cbc7d3fec23 100644 --- a/paddle/fluid/framework/custom_operator.cc +++ b/paddle/fluid/framework/custom_operator.cc @@ -25,7 +25,7 @@ limitations under the License. */ #include #include -#include "paddle/fluid/extension/include/tensor.h" +#include "paddle/fluid/extension/include/ext_tensor.h" #include "paddle/fluid/framework/attribute.h" #include "paddle/fluid/framework/c/c_api.h" #include "paddle/fluid/framework/custom_tensor_utils.h" diff --git a/paddle/fluid/framework/custom_operator.h b/paddle/fluid/framework/custom_operator.h index f2f97e5e582..117841f80cf 100644 --- a/paddle/fluid/framework/custom_operator.h +++ b/paddle/fluid/framework/custom_operator.h @@ -16,7 +16,7 @@ limitations under the License. */ #include -#include "paddle/fluid/extension/include/op_meta_info.h" +#include "paddle/fluid/extension/include/ext_op_meta_info.h" namespace paddle { namespace framework { diff --git a/paddle/fluid/framework/custom_tensor_test.cc b/paddle/fluid/framework/custom_tensor_test.cc index 0f351c3bbdb..b891975b96d 100644 --- a/paddle/fluid/framework/custom_tensor_test.cc +++ b/paddle/fluid/framework/custom_tensor_test.cc @@ -14,7 +14,7 @@ #include "glog/logging.h" #include "gtest/gtest.h" -#include "paddle/fluid/extension/include/all.h" +#include "paddle/fluid/extension/include/ext_all.h" #include "paddle/fluid/framework/custom_tensor_utils.h" #include "paddle/fluid/framework/lod_tensor.h" diff --git a/paddle/fluid/framework/custom_tensor_utils.h b/paddle/fluid/framework/custom_tensor_utils.h index f481d2881dd..919a3a1a49c 100644 --- a/paddle/fluid/framework/custom_tensor_utils.h +++ b/paddle/fluid/framework/custom_tensor_utils.h @@ -16,7 +16,7 @@ limitations under the License. */ #include -#include "paddle/fluid/extension/include/tensor.h" +#include "paddle/fluid/extension/include/ext_tensor.h" #include "paddle/fluid/framework/data_type.h" #include "paddle/fluid/platform/gpu_info.h" #include "paddle/fluid/platform/place.h" diff --git a/paddle/fluid/framework/op_meta_info_helper.h b/paddle/fluid/framework/op_meta_info_helper.h index 06d9c94172d..c70fe2f38ab 100644 --- a/paddle/fluid/framework/op_meta_info_helper.h +++ b/paddle/fluid/framework/op_meta_info_helper.h @@ -17,7 +17,7 @@ limitations under the License. */ #include #include -#include "paddle/fluid/extension/include/op_meta_info.h" +#include "paddle/fluid/extension/include/ext_op_meta_info.h" namespace paddle { namespace framework { diff --git a/paddle/fluid/inference/CMakeLists.txt b/paddle/fluid/inference/CMakeLists.txt index 8ef6bcd8600..7a8bfc1a8c7 100644 --- a/paddle/fluid/inference/CMakeLists.txt +++ b/paddle/fluid/inference/CMakeLists.txt @@ -73,7 +73,8 @@ set(SHARED_INFERENCE_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/api/analysis_predictor.cc ${CMAKE_CURRENT_SOURCE_DIR}/api/details/zero_copy_tensor.cc ${CMAKE_CURRENT_SOURCE_DIR}/utils/io_utils.cc - ${mkldnn_quantizer_src_file}) + ${mkldnn_quantizer_src_file} + ${PADDLE_CUSTOM_OP_SRCS}) # shared inference library deps set(SHARED_INFERENCE_DEPS ${fluid_modules} analysis_predictor) -- GitLab