From a9b5c6ed85afee4abe955e57b744b43a2109b79f Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 28 Jul 2022 11:43:02 +0800 Subject: [PATCH] Support compile on windows x86 (#49) * Support compile on windows x86 * fix cmake Co-authored-by: root --- CMakeLists.txt | 17 +++++++++++++++++ .../backends/ort/ops/multiclass_nms.cc | 4 ++++ .../backends/ort/ops/multiclass_nms.h | 5 +++++ csrcs/fastdeploy/backends/ort/ort_backend.cc | 2 ++ csrcs/fastdeploy/backends/ort/ort_backend.h | 2 ++ external/onnxruntime.cmake | 3 +++ external/paddle2onnx.cmake | 3 +++ 7 files changed, 36 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e308573ba..5aef0b56e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,6 +54,23 @@ option(ENABLE_DEBUG "if to enable print debug information, this may reduce perfo # Whether to build fastdeply with vision/text/... examples, only for testings. option(WITH_VISION_EXAMPLES "Whether to build fastdeply with vision examples" OFF) +# Check for 32bit system +if(WIN32) + if(NOT CMAKE_CL_64) + message("***********************Compile on non 64-bit system now**********************") + add_definitions(-DNON_64_PLATFORM) + if(WITH_GPU) + message(FATAL_ERROR "-DWITH_GPU=ON doesn't support on non 64-bit system now.") + endif() + if(ENABLE_PADDLE_BACKEND) + message(FATAL_ERROR "-DENABLE_PADDLE_BACKEND=ON doesn't support on non 64-bit system now.") + endif() + if(ENABLE_VISION) + message(FATAL_ERROR "-DENABLE_VISION=ON doesn't support on non 64-bit system now.") + endif() + endif() +endif() + if(ENABLE_DEBUG) add_definitions(-DFASTDEPLOY_DEBUG) endif() diff --git a/csrcs/fastdeploy/backends/ort/ops/multiclass_nms.cc b/csrcs/fastdeploy/backends/ort/ops/multiclass_nms.cc index 6f9f8f2a7..a132dbffc 100644 --- a/csrcs/fastdeploy/backends/ort/ops/multiclass_nms.cc +++ b/csrcs/fastdeploy/backends/ort/ops/multiclass_nms.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#ifndef NON_64_PLATFORM + #include "fastdeploy/backends/ort/ops/multiclass_nms.h" #include #include "fastdeploy/core/fd_tensor.h" @@ -255,3 +257,5 @@ void MultiClassNmsKernel::GetAttribute(const OrtKernelInfo* info) { score_threshold = ort_.KernelInfoGetAttribute(info, "score_threshold"); } } // namespace fastdeploy + +#endif \ No newline at end of file diff --git a/csrcs/fastdeploy/backends/ort/ops/multiclass_nms.h b/csrcs/fastdeploy/backends/ort/ops/multiclass_nms.h index 78f9a2255..4e167d669 100644 --- a/csrcs/fastdeploy/backends/ort/ops/multiclass_nms.h +++ b/csrcs/fastdeploy/backends/ort/ops/multiclass_nms.h @@ -13,7 +13,10 @@ // limitations under the License. #pragma once + #include + +#ifndef NON_64_PLATFORM #include "onnxruntime_cxx_api.h" // NOLINT namespace fastdeploy { @@ -74,3 +77,5 @@ struct MultiClassNmsOp }; } // namespace fastdeploy + +#endif \ No newline at end of file diff --git a/csrcs/fastdeploy/backends/ort/ort_backend.cc b/csrcs/fastdeploy/backends/ort/ort_backend.cc index 27c746a9e..9fdb3c66b 100644 --- a/csrcs/fastdeploy/backends/ort/ort_backend.cc +++ b/csrcs/fastdeploy/backends/ort/ort_backend.cc @@ -292,6 +292,7 @@ TensorInfo OrtBackend::GetOutputInfo(int index) { } void OrtBackend::InitCustomOperators() { +#ifndef NON_64_PLATFORM if (custom_operators_.size() == 0) { MultiClassNmsOp* custom_op = new MultiClassNmsOp{}; custom_operators_.push_back(custom_op); @@ -300,6 +301,7 @@ void OrtBackend::InitCustomOperators() { custom_op_domain_.Add(custom_operators_[i]); } session_options_.Add(custom_op_domain_); +#endif } } // namespace fastdeploy diff --git a/csrcs/fastdeploy/backends/ort/ort_backend.h b/csrcs/fastdeploy/backends/ort/ort_backend.h index 2dab03023..6d8711473 100644 --- a/csrcs/fastdeploy/backends/ort/ort_backend.h +++ b/csrcs/fastdeploy/backends/ort/ort_backend.h @@ -82,7 +82,9 @@ class OrtBackend : public BaseBackend { std::shared_ptr binding_; std::vector inputs_desc_; std::vector outputs_desc_; +#ifndef NON_64_PLATFORM Ort::CustomOpDomain custom_op_domain_ = Ort::CustomOpDomain("Paddle"); +#endif OrtBackendOption option_; void CopyToCpu(const Ort::Value& value, FDTensor* tensor); }; diff --git a/external/onnxruntime.cmake b/external/onnxruntime.cmake index da2ce4368..241fc1aa2 100644 --- a/external/onnxruntime.cmake +++ b/external/onnxruntime.cmake @@ -36,6 +36,9 @@ if(WIN32) else() set(ONNXRUNTIME_FILENAME "onnxruntime-win-x64-${ONNXRUNTIME_VERSION}.zip") endif() + if(NOT CMAKE_CL_64) + set(ONNXRUNTIME_FILENAME "onnxruntime-win-x86-${ONNXRUNTIME_VERSION}.zip") + endif() elseif(APPLE) if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "arm64") set(ONNXRUNTIME_FILENAME "onnxruntime-osx-arm64-${ONNXRUNTIME_VERSION}.tgz") diff --git a/external/paddle2onnx.cmake b/external/paddle2onnx.cmake index 97ba169ac..e226bc6c9 100644 --- a/external/paddle2onnx.cmake +++ b/external/paddle2onnx.cmake @@ -46,6 +46,9 @@ set(PADDLE2ONNX_URL_BASE "https://bj.bcebos.com/paddle2onnx/libs/") set(PADDLE2ONNX_VERSION "1.0.0rc2") if(WIN32) set(PADDLE2ONNX_FILE "paddle2onnx-win-x64-${PADDLE2ONNX_VERSION}.zip") + if(NOT CMAKE_CL_64) + set(PADDLE2ONNX_FILE "paddle2onnx-win-x86-${PADDLE2ONNX_VERSION}.zip") + endif() elseif(APPLE) if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "arm64") set(PADDLE2ONNX_FILE "paddle2onnx-osx-arm64-${PADDLE2ONNX_VERSION}.tgz")