diff --git a/cmake/phi_header.cmake b/cmake/phi_header.cmake index b1476761897eaad19de24a6a3946bbc441e86c75..910532f483899708cd6b0ebaaae90c6fa7eaff25 100644 --- a/cmake/phi_header.cmake +++ b/cmake/phi_header.cmake @@ -17,21 +17,24 @@ set(PADDLE_INFERENCE_INSTALL_DIR function(phi_header_path_compat TARGET_PATH) message(STATUS "phi header path compat processing: ${TARGET_PATH}") - file(GLOB HEADERS "${TARGET_PATH}/*" "*.h") - foreach(header ${HEADERS}) - if(${header} MATCHES ".*.h$") - file(READ ${header} HEADER_CONTENT) - string(REPLACE "paddle/phi/" "paddle/include/experimental/phi/" - HEADER_CONTENT "${HEADER_CONTENT}") - string(REPLACE "paddle/fluid/platform/" - "paddle/include/experimental/phi/" HEADER_CONTENT - "${HEADER_CONTENT}") - string(REPLACE "paddle/utils/" "paddle/include/experimental/utils/" - HEADER_CONTENT "${HEADER_CONTENT}") - file(WRITE ${header} "${HEADER_CONTENT}") - message(STATUS "phi header path compat processing complete: ${header}") - endif() - endforeach() + string(FIND ${TARGET_PATH} "experimental" pos) + if(pos GREATER 1) + file(GLOB HEADERS "${TARGET_PATH}/*" "*.h") + foreach(header ${HEADERS}) + if(${header} MATCHES ".*.h$") + file(READ ${header} HEADER_CONTENT) + string(REPLACE "paddle/phi/" "paddle/include/experimental/phi/" + HEADER_CONTENT "${HEADER_CONTENT}") + string(REPLACE "paddle/fluid/platform/" + "paddle/include/experimental/phi/" HEADER_CONTENT + "${HEADER_CONTENT}") + string(REPLACE "paddle/utils/" "paddle/include/experimental/utils/" + HEADER_CONTENT "${HEADER_CONTENT}") + file(WRITE ${header} "${HEADER_CONTENT}") + message(STATUS "phi header path compat processing complete: ${header}") + endif() + endforeach() + endif() endfunction() phi_header_path_compat( @@ -48,7 +51,16 @@ phi_header_path_compat( ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/phi/common) phi_header_path_compat( ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/phi/core) -phi_header_path_compat(${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/) + +# NOTE(liuyuanle): In inference lib, no need include paddle/utils/pybind.h, so we delete this. +file(READ + ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/extension.h + HEADER_CONTENT) +string(REGEX REPLACE "#if !defined\\(PADDLE_ON_INFERENCE\\).*#endif" "" + HEADER_CONTENT "${HEADER_CONTENT}") +file(WRITE + ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/extension.h + "${HEADER_CONTENT}") # In order to be compatible with the original behavior, the header file name needs to be changed file(RENAME diff --git a/paddle/extension.h b/paddle/extension.h index ba4af636b212637c1d08392f23a48d208bc5871f..c60ee269fb173f0908e9c26c3d69d280b021c2a8 100644 --- a/paddle/extension.h +++ b/paddle/extension.h @@ -16,8 +16,8 @@ limitations under the License. */ // All paddle apis in C++ frontend #include "paddle/phi/api/all.h" -// Python bindings for the C++ frontend (includes Python.h) #if !defined(PADDLE_ON_INFERENCE) && !defined(PADDLE_NO_PYTHON) +// Python bindings for the C++ frontend (includes Python.h) #include "paddle/utils/pybind.h" #endif // For initialization of DeviceContextPool and MemoryMethod diff --git a/paddle/fluid/inference/api/analysis_predictor.cc b/paddle/fluid/inference/api/analysis_predictor.cc index 45e4d763e6bd9fca62ee03217a2e8c1ba7f347ec..b0ef79a0c7bdf540907280ea1312c5e102507a74 100644 --- a/paddle/fluid/inference/api/analysis_predictor.cc +++ b/paddle/fluid/inference/api/analysis_predictor.cc @@ -56,7 +56,7 @@ #include "paddle/fluid/platform/device_context.h" #include "paddle/fluid/platform/place.h" #include "paddle/fluid/platform/profiler.h" -#include "paddle/phi/api/ext/op_meta_info.h" +#include "paddle/phi/api/include/tensor.h" #include "paddle/phi/common/backend.h" #include "paddle/phi/common/data_type.h" #include "paddle/phi/common/place.h" diff --git a/paddle/fluid/inference/api/paddle_pass_builder.cc b/paddle/fluid/inference/api/paddle_pass_builder.cc index d1aa3bd492d7f89e1686676016bfebc079fa8d8f..1be90972b924bd26e870ff8b74736c9fcbac0122 100644 --- a/paddle/fluid/inference/api/paddle_pass_builder.cc +++ b/paddle/fluid/inference/api/paddle_pass_builder.cc @@ -266,7 +266,6 @@ GpuPassStrategy::GpuPassStrategy() : PassStrategy({}) { "transpose_flatten_concat_fuse_pass", // "conv2d_fusion_layout_transfer_pass", // "auto_mixed_precision_pass", // - "delete_cast_op_pass", // "inplace_op_var_pass", // should be the last pass. }); diff --git a/paddle/fluid/inference/api/paddle_tensor.h b/paddle/fluid/inference/api/paddle_tensor.h index b9c86a60f55b846c4a061e2e2bbdc3269aaa57dc..3838bc1c829c441cc4b89e7bf9e952582237d3eb 100644 --- a/paddle/fluid/inference/api/paddle_tensor.h +++ b/paddle/fluid/inference/api/paddle_tensor.h @@ -21,13 +21,15 @@ #include "paddle_infer_declare.h" // NOLINT -#include "paddle/phi/api/include/tensor.h" // expose paddle::Tensor - #ifdef PADDLE_WITH_ONNXRUNTIME #include "onnxruntime_c_api.h" // NOLINT #include "onnxruntime_cxx_api.h" // NOLINT #endif +namespace paddle { +class Tensor; +} + namespace paddle_infer { /// \brief Experimental. diff --git a/paddle/fluid/platform/init_phi.h b/paddle/fluid/platform/init_phi.h index cb409e16f34ab63fc1a8fd2749ced6c3213d69ee..80c1d6242e545eb32a6fbe3841d4d6ef9c5bc4d8 100644 --- a/paddle/fluid/platform/init_phi.h +++ b/paddle/fluid/platform/init_phi.h @@ -11,8 +11,11 @@ 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. */ + #pragma once + #include "paddle/phi/api/include/dll_decl.h" + namespace paddle { class PADDLE_API InitPhi { diff --git a/paddle/phi/api/all.h b/paddle/phi/api/all.h index b70119e1e4e5dff7729546c81b94bd7adee5f256..74a016a183b2b4603791758262929c20bc597bfc 100644 --- a/paddle/phi/api/all.h +++ b/paddle/phi/api/all.h @@ -14,10 +14,6 @@ limitations under the License. */ #pragma once -#if !defined(_MSC_VER) && __cplusplus < 201402L -#error C++14 or later compatible compiler is required to use Paddle. -#endif - #ifdef _WIN32 #ifndef NOMINMAX #define NOMINMAX // msvc max/min macro conflict with std::min/max