Skip to content

Commit

Permalink
[cmake] upgrade windows paddle inference -> 2.5.0 (#2100)
Browse files Browse the repository at this point in the history
* [cmake] upgrade windows paddle inference -> 2.5.0

* [cmake] upgrade windows paddle inference -> 2.5.0

* fix paddle custom ops bug on windows
  • Loading branch information
DefTruth committed Jul 12, 2023
1 parent c95fc1f commit 2542a75
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 31 deletions.
58 changes: 30 additions & 28 deletions cmake/paddle_inference.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ else()
set(PADDLEINFERENCE_URL_BASE "https://bj.bcebos.com/fastdeploy/third_libs/")
if(WIN32)
if (WITH_GPU)
set(PADDLEINFERENCE_FILE "paddle_inference-win-x64-gpu-trt8.5.2.2-mkl-avx-0.0.0.575cafb44b.zip")
set(PADDLEINFERENCE_VERSION "0.0.0.575cafb44b")
set(PADDLEINFERENCE_FILE "paddle_inference-win-x64-gpu-trt8.5.2.2-mkl-2.5.0.281761089e.zip")
set(PADDLEINFERENCE_VERSION "2.5.0.281761089e")
else()
set(PADDLEINFERENCE_FILE "paddle_inference-win-x64-mkl-avx-0.0.0.cbdba50933.zip")
set(PADDLEINFERENCE_VERSION "0.0.0.cbdba50933")
set(PADDLEINFERENCE_FILE "paddle_inference-win-x64-mkl-2.5.0.281761089e.zip")
set(PADDLEINFERENCE_VERSION "2.5.0.281761089e")
endif()
elseif(APPLE)
if(CURRENT_OSX_ARCH MATCHES "arm64")
Expand Down Expand Up @@ -310,33 +310,35 @@ if(PADDLEINFERENCE_API_COMPAT_2_5_x)
endif()

function(set_paddle_custom_ops_compatible_policy)
if(PADDLEINFERENCE_API_CUSTOM_OP AND (NOT MSVC))
# TODO: add non c++ 14 policy for latest dev
if(NOT PADDLEINFERENCE_API_COMPAT_2_5_x)
# gcc c++ 14 policy for 2.4.x
if(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14 PARENT_SCOPE)
message(WARNING "Found PADDLEINFERENCE_API_CUSTOM_OP=ON, but CMAKE_CXX_STANDARD is not defined, use c++ 14 by default!")
elseif(NOT (CMAKE_CXX_STANDARD EQUAL 14))
set(CMAKE_CXX_STANDARD 14 PARENT_SCOPE)
message(WARNING "Found PADDLEINFERENCE_API_CUSTOM_OP=ON, force use c++ 14!")
endif()
endif()
if(WITH_GPU)
# cuda c++ 14 policy for 2.4.x
if(PADDLEINFERENCE_API_CUSTOM_OP)
if(NOT MSVC)
# TODO: add non c++ 14 policy for latest dev
if(NOT PADDLEINFERENCE_API_COMPAT_2_5_x)
if(NOT DEFINED CMAKE_CUDA_STANDARD)
set(CMAKE_CUDA_STANDARD 14 PARENT_SCOPE)
message(WARNING "Found PADDLEINFERENCE_API_CUSTOM_OP=ON and WITH_GPU=ON, but CMAKE_CUDA_STANDARD is not defined, use c++ 14 by default!")
elseif(NOT (CMAKE_CUDA_STANDARD EQUAL 14))
set(CMAKE_CUDA_STANDARD 14 PARENT_SCOPE)
message(WARNING "Found PADDLEINFERENCE_API_CUSTOM_OP=ON and WITH_GPU=ON, force use c++ 14!")
# gcc c++ 14 policy for 2.4.x
if(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14 PARENT_SCOPE)
message(WARNING "Found PADDLEINFERENCE_API_CUSTOM_OP=ON, but CMAKE_CXX_STANDARD is not defined, use c++ 14 by default!")
elseif(NOT (CMAKE_CXX_STANDARD EQUAL 14))
set(CMAKE_CXX_STANDARD 14 PARENT_SCOPE)
message(WARNING "Found PADDLEINFERENCE_API_CUSTOM_OP=ON, force use c++ 14!")
endif()
endif()
if(WITH_GPU)
# cuda c++ 14 policy for 2.4.x
if(NOT PADDLEINFERENCE_API_COMPAT_2_5_x)
if(NOT DEFINED CMAKE_CUDA_STANDARD)
set(CMAKE_CUDA_STANDARD 14 PARENT_SCOPE)
message(WARNING "Found PADDLEINFERENCE_API_CUSTOM_OP=ON and WITH_GPU=ON, but CMAKE_CUDA_STANDARD is not defined, use c++ 14 by default!")
elseif(NOT (CMAKE_CUDA_STANDARD EQUAL 14))
set(CMAKE_CUDA_STANDARD 14 PARENT_SCOPE)
message(WARNING "Found PADDLEINFERENCE_API_CUSTOM_OP=ON and WITH_GPU=ON, force use c++ 14!")
endif()
endif()
endif()
# compile flags for paddle custom ops
add_definitions(-DPADDLE_WITH_CUDA)
add_definitions(-DPADDLE_ON_INFERENCE)
add_definitions(-DPADDLE_NO_PYTHON)
endif()
# common compile flags for paddle custom ops
add_definitions(-DPADDLE_WITH_CUDA)
add_definitions(-DPADDLE_ON_INFERENCE)
add_definitions(-DPADDLE_NO_PYTHON)
endif()
endfunction()
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#define DIVUP(m, n) ((m) / (n) + ((m) % (n) > 0))

const int THREADS_PER_BLOCK_NMS = sizeof(int64_t) * 8;
static const int THREADS_PER_BLOCK_NMS = sizeof(int64_t) * 8;

void NmsLauncher(const cudaStream_t &stream, const float *bboxes,
const int *index, const int64_t *sorted_index,
Expand Down
12 changes: 10 additions & 2 deletions fastdeploy/runtime/backends/paddle/ops/iou3d_nms_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,16 @@ All Rights Reserved 2019-2020.
#define THREADS_PER_BLOCK 16
#define DIVUP(m, n) ((m) / (n) + ((m) % (n) > 0))

const int THREADS_PER_BLOCK_NMS = sizeof(int64_t) * 8;
const float EPS = 1e-8;
static const int THREADS_PER_BLOCK_NMS = sizeof(int64_t) * 8;
#if defined(_WIN32)
#if defined(EPS)
#undef EPS
#endif
#define EPS 1e-8
#else
static const float EPS = 1e-8;
#endif

struct Point {
float x, y;
__device__ Point() {}
Expand Down

0 comments on commit 2542a75

Please sign in to comment.