Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/DrRyanHuang/Paddle into …
Browse files Browse the repository at this point in the history
…patch-1
  • Loading branch information
DrRyanHuang committed Dec 18, 2024
2 parents 26a07f2 + 49a6b0a commit 095401d
Show file tree
Hide file tree
Showing 611 changed files with 22,327 additions and 8,907 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,7 @@
[submodule "third_party/yaml-cpp"]
path = third_party/yaml-cpp
url = https://github.com/jbeder/yaml-cpp
[submodule "third_party/openvino"]
path = third_party/openvino
url = https://github.com/openvinotoolkit/openvino.git
ignore = dirty
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ repos:
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.1
rev: v0.8.3
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --no-cache]
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ option(WITH_ONEMKL "Compile PaddlePaddle with oneMKL" OFF)
option(WITH_GPU "Compile PaddlePaddle with NVIDIA GPU" ${CUDA_FOUND})
option(WITH_MPI "Compile PaddlePaddle with MPI" OFF)
option(WITH_TENSORRT "Compile PaddlePaddle with NVIDIA TensorRT" OFF)
option(WITH_OPENVINO "Compile PaddlePaddle with Intel OpenVINO" OFF)
option(WITH_XPU "Compile PaddlePaddle with BAIDU KUNLUN XPU" OFF)
option(WITH_XPU_KP "Compile PaddlePaddle with BAIDU XPU compiler " OFF)
option(WITH_XPU_XFT "Compile PaddlePaddle with BAIDU XPU-XFT" OFF)
Expand Down
32 changes: 0 additions & 32 deletions _typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,6 @@ caculate = 'caculate'
calcualtion = 'calcualtion'
checkings = 'checkings'
childs = 'childs'
comsume = 'comsume'
Continer = 'Continer'
contenst = 'contenst'
conter = 'conter'
Continous = 'Continous'
contibute = 'contibute'
controled = 'controled'
contorl = 'contorl'
converage = 'converage'
Converage = 'Converage'
convertion = 'convertion'
Conver = 'Conver'
convience = 'convience'
coodinate = 'coodinate'
copyed = 'copyed'
Copyed = 'Copyed'
copys = 'copys'
corener = 'corener'
corrrect = 'corrrect'
Correspoding = 'Correspoding'
Cound = 'Cound'
coule = 'coule'
craete = 'craete'
Expand Down Expand Up @@ -92,10 +72,6 @@ defind = 'defind'
defeine = 'defeine'
defition = 'defition'
defination = 'defination'
Destory = 'Destory'
DEIVCE = 'DEIVCE'
dictionnary = 'dictionnary'
diffrence = 'diffrence'
defferent = 'defferent'
differenciation = 'differenciation'
differnt = 'differnt'
Expand Down Expand Up @@ -349,16 +325,8 @@ Neet = 'Neet'
neet = 'neet'
neeed = 'neeed'
nedd = 'nedd'
negtive = 'negtive'
negetive = 'negetive'
nagative = 'nagative'
Neighboor = 'Neighboor'
neigbhors = 'neigbhors'
Neigbors = 'Neigbors'
neighor = 'neighor'
netwrok = 'netwrok'
normlized = 'normlized'
Normlized = 'Normlized'
normlize = 'normlize'
noraml = 'noraml'
numer = 'numer'
Expand Down
7 changes: 7 additions & 0 deletions cmake/cinn.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ if(WITH_ROCM)
add_definitions(-DCINN_WITH_HIP)
endif()

if(CINN_WITH_SYCL)
message(STATUS "CINN Compile with SYCL support")
set(DPCPP_DIR ${PROJECT_SOURCE_DIR}/cmake/cinn)
find_package(DPCPP REQUIRED CONFIG)
add_definitions(-DCINN_WITH_SYCL)
endif()

set(cinnapi_src CACHE INTERNAL "" FORCE)
set(core_src CACHE INTERNAL "" FORCE)
set(core_includes CACHE INTERNAL "" FORCE)
Expand Down
42 changes: 42 additions & 0 deletions cmake/cinn/DPCPPConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
##########################
# FindDPCPP.cmake
##########################

include_guard()

include(FindPackageHandleStandardArgs)

# set DPCPP_ROOT
if(IS_DIRECTORY ${CINN_WITH_SYCL})
set(DPCPP_ROOT ${CINN_WITH_SYCL})
else()
execute_process(
COMMAND which sycl-ls
TIMEOUT 2
OUTPUT_VARIABLE sycl_ls_path
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(EXISTS ${sycl_ls_path})
get_filename_component(DPCPP_ROOT ${sycl_ls_path}/../.. ABSOLUTE)
else()
message(
FATAL_ERROR
"Failed in SYCL path auto search, please set CINN_WITH_SYCL to sycl root path."
)
endif()
endif()
# find libsycl.so
find_library(
DPCPP_LIB
NAMES sycl
PATHS "${DPCPP_ROOT}/lib")
find_package_handle_standard_args(
DPCPP
FOUND_VAR DPCPP_FOUND
REQUIRED_VARS DPCPP_LIB)
if(NOT DPCPP_FOUND)
return()
endif()
message(STATUS "Enable SYCL: " ${DPCPP_ROOT})
include_directories("${DPCPP_ROOT}/include/sycl;${DPCPP_ROOT}/include")
link_libraries(${DPCPP_LIB})
add_definitions(-DSYCL_CXX_COMPILER="${DPCPP_ROOT}/bin/clang++")
4 changes: 2 additions & 2 deletions cmake/external/cudnn-frontend.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ endif()

if((NOT DEFINED CUDNN_FRONTEND_NAME) OR (NOT DEFINED CUDNN_FRONTEND_URL))
set(CUDNN_FRONTEND_VER
"v1.2.0"
"v1.5.2"
CACHE STRING "" FORCE)
set(CUDNN_FRONTEND_NAME
"cudnn-frontend"
Expand All @@ -38,7 +38,7 @@ if((NOT DEFINED CUDNN_FRONTEND_NAME) OR (NOT DEFINED CUDNN_FRONTEND_URL))
CACHE STRING "" FORCE)
endif()
set(CUDNN_FRONTEND_CACHE_FILENAME "${CUDNN_FRONTEND_VER}.tar.gz")
set(CUDNN_FRONTEND_URL_MD5 "35e27c098f536c8064665fb8dfc4f368")
set(CUDNN_FRONTEND_URL_MD5 "5ccb6e50a534670b2af7b30de50e7641")

message(
STATUS
Expand Down
151 changes: 151 additions & 0 deletions cmake/external/openvino.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# 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.

if(NOT LINUX)
message(STATUS "OpenVINO only support Linux.")
set(WITH_OPENVINO OFF)
return()
endif()

include(ExternalProject)

set(OPENVINO_PROJECT "extern_openvino")
set(OPENVINO_PREFIX_DIR ${THIRD_PARTY_PATH}/openvino)
set(OPENVINO_INSTALL_DIR ${THIRD_PARTY_PATH}/install/openvino)
set(OPENVINO_INC_DIR
"${OPENVINO_INSTALL_DIR}/runtime/include"
CACHE PATH "OpenVINO include directory." FORCE)
set(SOURCE_DIR ${PADDLE_SOURCE_DIR}/third_party/openvino)

set(TBB_INC_DIR
"${OPENVINO_INSTALL_DIR}/runtime/3rdparty/tbb/include"
CACHE PATH "OpenVINO TBB include directory." FORCE)

# Introduce variables:
# * CMAKE_INSTALL_LIBDIR
include(GNUInstallDirs)
string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} ARCH)
if(ARCH STREQUAL "x86_64"
OR ARCH STREQUAL "amd64"
OR CMAKE_OSX_ARCHITECTURES STREQUAL "x86_64")
set(ARCH intel64)
elseif(ARCH STREQUAL "i386")
set(ARCH ia32)
endif()
set(LIBDIR "runtime/lib/${ARCH}")
set(TBBDIR "runtime/3rdparty/tbb/lib")

set(OPENVINO_LIB_NAME
"libopenvino.so.2500"
CACHE PATH "libopenvino name." FORCE)
set(OPENVINO_PADDLE_LIB_NAME
"libopenvino_paddle_frontend.so.2500"
CACHE PATH "libopenvino_paddle_frontend name." FORCE)
set(OPENVINO_CPU_PLUGIN_LIB_NAME
"libopenvino_intel_cpu_plugin.so"
CACHE PATH "libopenvino_intel_cpu_plugin name." FORCE)
set(TBB_LIB_NAME
"libtbb.so.12"
CACHE PATH "libtbb name." FORCE)

message(STATUS "Set ${OPENVINO_INSTALL_DIR}/${LIBDIR} to runtime path")
message(STATUS "Set ${OPENVINO_INSTALL_DIR}/${TBBDIR} to runtime path")
set(OPENVINO_LIB_DIR ${OPENVINO_INSTALL_DIR}/${LIBDIR})
set(TBB_LIB_DIR ${OPENVINO_INSTALL_DIR}/${TBBDIR})

set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}" "${OPENVINO_LIB_DIR}"
"${TBB_LIB_DIR}")

include_directories(${OPENVINO_INC_DIR}
)# For OpenVINO code to include internal headers.

include_directories(${TBB_INC_DIR}
)# For OpenVINO TBB code to include third_party headers.

if(LINUX)
set(OPENVINO_LIB
"${OPENVINO_INSTALL_DIR}/${LIBDIR}/${OPENVINO_LIB_NAME}"
CACHE FILEPATH "OpenVINO library." FORCE)
set(OPENVINO_PADDLE_LIB
"${OPENVINO_INSTALL_DIR}/${LIBDIR}/${OPENVINO_PADDLE_LIB_NAME}"
CACHE FILEPATH "OpenVINO paddle frontend library." FORCE)
set(OPENVINO_CPU_PLUGIN_LIB
"${OPENVINO_INSTALL_DIR}/${LIBDIR}/${OPENVINO_CPU_PLUGIN_LIB_NAME}"
CACHE FILEPATH "OpenVINO cpu inference library." FORCE)
set(TBB_LIB
"${OPENVINO_INSTALL_DIR}/${TBBDIR}/${TBB_LIB_NAME}"
CACHE FILEPATH "TBB library." FORCE)
else()
message(ERROR "Only support Linux.")
endif()

if(LINUX)
set(BUILD_BYPRODUCTS_ARGS ${OPENVINO_LIB} ${TBB_LIB} ${OPENVINO_PADDLE_LIB}
${OPENVINO_CPU_PLUGIN_LIB})
else()
set(BUILD_BYPRODUCTS_ARGS "")
endif()

set(OPENVINO_COMMIT 07ecdf07d2974410dc1d67d9fa2d3433dcab7865)
file(TO_NATIVE_PATH ${PADDLE_SOURCE_DIR}/patches/openvino/convert.patch
native_convert)

set(OPENVINO_PATCH_COMMAND
git checkout -- . && git checkout ${OPENVINO_COMMIT} && patch -Np1 -d
${SOURCE_DIR} < ${native_convert} || true)

ExternalProject_Add(
${OPENVINO_PROJECT}
${EXTERNAL_PROJECT_LOG_ARGS}
SOURCE_DIR ${SOURCE_DIR}
DEPENDS ${OPENVINO_DEPENDS}
PREFIX ${OPENVINO_PREFIX_DIR}
UPDATE_COMMAND ""
#BUILD_ALWAYS 1
PATCH_COMMAND ${OPENVINO_PATCH_COMMAND}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${OPENVINO_INSTALL_DIR}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DTHREADING=TBB
-DENABLE_INTEL_CPU=ON
-DENABLE_INTEL_GPU=OFF
-DENABLE_OV_JAX_FRONTEND=OFF
-DENABLE_OV_ONNX_FRONTEND=OFF
-DENABLE_OV_PYTORCH_FRONTEND=OFF
-DENABLE_OV_TF_FRONTEND=OFF
-DENABLE_OV_TF_LITE_FRONTEND=OFF
-DENABLE_INTEL_NPU=OFF
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${OPENVINO_INSTALL_DIR}
BUILD_BYPRODUCTS ${BUILD_BYPRODUCTS_ARGS})

message(STATUS "OpenVINO library: ${OPENVINO_LIB}")
message(STATUS "OpenVINO Paddle library: ${OPENVINO_PADDLE_LIB}")
message(STATUS "OpenVINO CPU Inference library: ${OPENVINO_CPU_PLUGIN_LIB}")
message(STATUS "OpenVINO TBB library: ${TBB_LIB}")
add_definitions(-DPADDLE_WITH_OPENVINO)

add_library(openvino SHARED IMPORTED GLOBAL)
add_library(openvino_paddle SHARED IMPORTED GLOBAL)
add_library(openvino_cpu_plugin SHARED IMPORTED GLOBAL)
add_library(tbb SHARED IMPORTED GLOBAL)
set_property(TARGET openvino PROPERTY IMPORTED_LOCATION ${OPENVINO_LIB})
set_property(TARGET openvino_paddle PROPERTY IMPORTED_LOCATION
${OPENVINO_PADDLE_LIB})
set_property(TARGET openvino_cpu_plugin PROPERTY IMPORTED_LOCATION
${OPENVINO_CPU_PLUGIN_LIB})
set_property(TARGET tbb PROPERTY IMPORTED_LOCATION ${TBB_LIB})
add_dependencies(openvino ${OPENVINO_PROJECT})
add_dependencies(openvino_paddle ${OPENVINO_PROJECT})
add_dependencies(openvino_cpu_plugin ${OPENVINO_PROJECT})
add_dependencies(tbb ${OPENVINO_PROJECT})
3 changes: 2 additions & 1 deletion cmake/external/warpctc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ if(WITH_ROCM)
set(WARPCTC_PATHCH_ROCM_COMMAND
patch -p1 <
${PADDLE_SOURCE_DIR}/patches/warpctc/CMakeLists.txt.rocm.patch && patch
-p1 < ${PADDLE_SOURCE_DIR}/patches/warpctc/devicetypes.cuh.patch)
-p1 < ${PADDLE_SOURCE_DIR}/patches/warpctc/devicetypes.cuh.patch && patch
-p1 < ${PADDLE_SOURCE_DIR}/patches/warpctc/hip.cmake.patch)
endif()

set(WARPCTC_INCLUDE_DIR
Expand Down
14 changes: 14 additions & 0 deletions cmake/inference_lib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,20 @@ function(copy_part_of_third_party TARGET DST)
DSTS ${dst_dir}/include ${dst_dir})
endif()

if(WITH_OPENVINO)
set(dst_dir "${DST}/third_party/install/openvino")
copy(
${TARGET}
SRCS ${OPENVINO_INC_DIR} ${OPENVINO_LIB_DIR}
DSTS ${dst_dir} ${dst_dir})

set(dst_dir "${DST}/third_party/install/tbb")
copy(
${TARGET}
SRCS ${TBB_INC_DIR} ${TBB_LIB_DIR}
DSTS ${dst_dir} ${dst_dir})
endif()

set(dst_dir "${DST}/third_party/install/gflags")
copy(
${TARGET}
Expand Down
5 changes: 5 additions & 0 deletions cmake/third_party.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -638,4 +638,9 @@ if(WITH_CUDNN_FRONTEND)
list(APPEND third_party_deps extern_cudnn_frontend)
endif()

if(WITH_OPENVINO)
include(external/openvino)
list(APPEND third_party_deps extern_openvino)
endif()

add_custom_target(third_party ALL DEPENDS ${third_party_deps})
1 change: 1 addition & 0 deletions cmake/version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ function(version version_file)
"GIT COMMIT ID: ${PADDLE_GIT_COMMIT}\n"
"WITH_MKL: ${WITH_MKL}\n"
"WITH_ONEDNN: ${WITH_ONEDNN}\n"
"WITH_OPENVINO: ${WITH_OPENVINO}\n"
"WITH_GPU: ${WITH_GPU}\n"
"WITH_ROCM: ${WITH_ROCM}\n"
"WITH_IPU: ${WITH_IPU}\n")
Expand Down
Loading

0 comments on commit 095401d

Please sign in to comment.