Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
Browse files Browse the repository at this point in the history
… sum
  • Loading branch information
zeroRains committed Apr 12, 2024
2 parents 9fc3081 + 22fb3b1 commit 77acfd3
Show file tree
Hide file tree
Showing 1,248 changed files with 24,782 additions and 10,404 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,7 @@
path = third_party/cryptopp-cmake
url = https://github.com/noloader/cryptopp-cmake.git
ignore = dirty
[submodule "third_party/nlohmann_json"]
path = third_party/nlohmann_json
url = https://github.com/nlohmann/json.git
ignore = dirty
6 changes: 3 additions & 3 deletions cmake/cinn.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ if(WITH_MKL)
add_dependencies(cinn_mklml ${MKLML_PROJECT})
add_definitions(-DCINN_WITH_MKL_CBLAS)
endif()
if(WITH_MKLDNN)
if(WITH_ONEDNN)
add_definitions(-DCINN_WITH_DNNL)
endif()

Expand Down Expand Up @@ -177,7 +177,7 @@ target_link_libraries(cinnapi ${PYTHON_LIBRARIES})
if(WITH_MKL)
target_link_libraries(cinnapi cinn_mklml)
add_dependencies(cinnapi cinn_mklml)
if(WITH_MKLDNN)
if(WITH_ONEDNN)
target_link_libraries(cinnapi ${MKLDNN_LIB})
add_dependencies(cinnapi ${ONEDNN_PROJECT})
endif()
Expand Down Expand Up @@ -238,7 +238,7 @@ function(gen_cinncore LINKTYPE)
if(WITH_MKL)
target_link_libraries(${CINNCORE_TARGET} cinn_mklml)
add_dependencies(${CINNCORE_TARGET} cinn_mklml)
if(WITH_MKLDNN)
if(WITH_ONEDNN)
target_link_libraries(${CINNCORE_TARGET} ${MKLDNN_LIB})
add_dependencies(${CINNCORE_TARGET} ${ONEDNN_PROJECT})
endif()
Expand Down
43 changes: 43 additions & 0 deletions cmake/external/json.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# 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.

include(ExternalProject)

set(JSON_PREFIX_DIR ${THIRD_PARTY_PATH}/nlohmann_json)
set(JSON_INCLUDE_DIR ${JSON_PREFIX_DIR}/include)

set(SOURCE_DIR ${PADDLE_SOURCE_DIR}/third_party/nlohmann_json)
set(SOURCE_INCLUDE_DIR ${SOURCE_DIR}/include)

include_directories(${JSON_INCLUDE_DIR})

set(JSON_BuildTests
OFF
CACHE INTERNAL "")

ExternalProject_Add(
extern_json
${EXTERNAL_PROJECT_LOG_ARGS} ${SHALLOW_CLONE}
SOURCE_DIR ${SOURCE_DIR}
PREFIX ${JSON_PREFIX_DIR}
UPDATE_COMMAND ""
CONFIGURE_COMMAND ""
BUILD_IN_SOURCE 1
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND "")

add_library(json INTERFACE)
#target_include_directories(json PRIVATE ${JSON_INCLUDE_DIR})
add_dependencies(json extern_json)
4 changes: 2 additions & 2 deletions cmake/external/lite.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ if(NOT LITE_SOURCE_DIR OR NOT LITE_BINARY_DIR)
set(LITE_OPTIONAL_ARGS
-DWITH_MKL=OFF
-DLITE_WITH_CUDA=OFF
-DWITH_MKLDNN=OFF
-DWITH_ONEDNN=OFF
-DLITE_WITH_X86=OFF
-DLITE_WITH_LIGHT_WEIGHT_FRAMEWORK=ON
-DLITE_WITH_PROFILE=OFF
Expand Down Expand Up @@ -141,7 +141,7 @@ if(NOT LITE_SOURCE_DIR OR NOT LITE_BINARY_DIR)
set(LITE_OPTIONAL_ARGS
-DWITH_MKL=ON
-DLITE_WITH_CUDA=OFF
-DWITH_MKLDNN=OFF
-DWITH_ONEDNN=OFF
-DLITE_WITH_X86=ON
-DLITE_WITH_PROFILE=OFF
-DWITH_LITE=OFF
Expand Down
51 changes: 15 additions & 36 deletions cmake/external/rocksdb.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

include(ExternalProject)

# find_package(jemalloc REQUIRED)

set(ROCKSDB_SOURCE_DIR ${PADDLE_SOURCE_DIR}/third_party/rocksdb)
set(ROCKSDB_TAG 6.19.fb)

Expand All @@ -32,28 +30,10 @@ set(ROCKSDB_INCLUDE_DIR
set(ROCKSDB_LIBRARIES
"${ROCKSDB_INSTALL_DIR}/lib/librocksdb.a"
CACHE FILEPATH "rocksdb library." FORCE)
set(ROCKSDB_COMMON_FLAGS
"-g -pipe -O2 -W -Wall -Wno-unused-parameter -fPIC -fno-builtin-memcmp -fno-omit-frame-pointer"
)
set(ROCKSDB_FLAGS
"-DNDEBUG -DROCKSDB_JEMALLOC -DJEMALLOC_NO_DEMANGLE -DROCKSDB_PLATFORM_POSIX -DROCKSDB_LIB_IO_POSIX -DOS_LINUX -DROCKSDB_FALLOCATE_PRESENT -DHAVE_PCLMUL -DZLIB -DROCKSDB_MALLOC_USABLE_SIZE -DROCKSDB_PTHREAD_ADAPTIVE_MUTEX -DROCKSDB_BACKTRACE -DROCKSDB_SUPPORT_THREAD_LOCAL -DROCKSDB_USE_RTTI -DROCKSDB_SCHED_GETCPU_PRESENT -DROCKSDB_RANGESYNC_PRESENT -DROCKSDB_AUXV_GETAUXVAL_PRESENT"
)
set(ROCKSDB_CMAKE_CXX_FLAGS
"${ROCKSDB_COMMON_FLAGS} -DROCKSDB_LIBAIO_PRESENT ${ROCKSDB_FLAGS} -fPIC -I${JEMALLOC_INCLUDE_DIR}"
)
if(NOT WITH_ARM)
set(ROCKSDB_FLAGS "${ROCKSDB_FLAGS} -DHAVE_SSE42")
set(ROCKSDB_CMAKE_CXX_FLAGS
"${ROCKSDB_CMAKE_CXX_FLAGS} -msse -msse4.2 -mpclmul")
endif()
set(ROCKSDB_CMAKE_C_FLAGS
"${ROCKSDB_COMMON_FLAGS} ${ROCKSDB_FLAGS} -DROCKSDB_LIBAIO_PRESENT -fPIC -I${JEMALLOC_INCLUDE_DIR}"
)
include_directories(${ROCKSDB_INCLUDE_DIR})

set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -pthread")

set(ROCKSDB_CMAKE_SHARED_LINKER_FLAGS "-ldl -lrt -lz")
set(ROCKSDB_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -DROCKSDB_LIBAIO_PRESENT -I${JEMALLOC_INCLUDE_DIR}")
set(ROCKSDB_SHARED_LINKER_FLAGS "-Wl,--no-as-needed -ldl")

if(WITH_ARM)
file(TO_NATIVE_PATH ${PADDLE_SOURCE_DIR}/patches/rocksdb/libaio.h.patch
Expand All @@ -62,6 +42,7 @@ if(WITH_ARM)
git checkout -- . && git checkout ${ROCKSDB_TAG} && patch -Nd
${PADDLE_SOURCE_DIR}/third_party/rocksdb/env/ < ${native_src})
endif()

ExternalProject_Add(
extern_rocksdb
${EXTERNAL_PROJECT_LOG_ARGS}
Expand All @@ -76,25 +57,23 @@ ExternalProject_Add(
-DWITH_GFLAGS=OFF
-DWITH_TESTS=OFF
-DWITH_JEMALLOC=ON
-DWITH_BENCHMARK_TOOLS=OFF
-DFAIL_ON_WARNINGS=OFF # For Clang compatibility
-DJeMalloc_LIBRARIES=${JEMALLOC_LIBRARIES}
-DJeMalloc_INCLUDE_DIRS=${JEMALLOC_INCLUDE_DIR}
-DCMAKE_CXX_FLAGS=${ROCKSDB_CMAKE_CXX_FLAGS}
-DCMAKE_C_FLAGS=${ROCKSDB_CMAKE_C_FLAGS}
-DCMAKE_SHARED_LINKER_FLAGS=${ROCKSDB_CMAKE_SHARED_LINKER_FLAGS}
INSTALL_COMMAND
mkdir -p ${ROCKSDB_INSTALL_DIR}/lib/ && cp
${ROCKSDB_PREFIX_DIR}/src/extern_rocksdb-build/librocksdb.a
${ROCKSDB_LIBRARIES} && cp -r ${ROCKSDB_SOURCE_DIR}/include
${ROCKSDB_INSTALL_DIR}/
-DWITH_BENCHMARK_TOOLS=OFF
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_CXX_FLAGS=${ROCKSDB_CXX_FLAGS}
-DCMAKE_SHARED_LINKER_FLAGS=${ROCKSDB_SHARED_LINKER_FLAGS}
CMAKE_CACHE_ARGS
-DCMAKE_INSTALL_PREFIX:PATH=${ROCKSDB_INSTALL_DIR}
-DCMAKE_INSTALL_LIBDIR:PATH=${ROCKSDB_INSTALL_DIR}/lib
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON
-DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE}
BUILD_BYPRODUCTS ${ROCKSDB_LIBRARIES})
add_dependencies(extern_rocksdb snappy extern_jemalloc)

add_library(rocksdb STATIC IMPORTED GLOBAL)

add_dependencies(extern_rocksdb snappy)
add_dependencies(extern_rocksdb extern_jemalloc)
set_property(TARGET rocksdb PROPERTY IMPORTED_LOCATION ${ROCKSDB_LIBRARIES})
include_directories(${ROCKSDB_INCLUDE_DIR})
add_dependencies(rocksdb extern_rocksdb)

list(APPEND external_project_dependencies rocksdb)
11 changes: 9 additions & 2 deletions cmake/external/xpu.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ set(XPU_XFA_LIB_NAME "libxpu_flash_attention.so")
if(NOT DEFINED XPU_BASE_DATE)
set(XPU_BASE_DATE "20240104")
endif()
if(NOT DEFINED XPU_XDNN_BASE_DATE)
set(XPU_XDNN_BASE_DATE "20240327")
endif()
if(NOT DEFINED XPU_XHPC_BASE_DATE)
set(XPU_XHPC_BASE_DATE "20240328")
endif()
Expand All @@ -45,6 +48,10 @@ else()
set(XPU_BASE_URL "${XPU_BASE_URL}")
endif()

set(XPU_XDNN_BASE_URL
"https://klx-sdk-release-public.su.bcebos.com/xdnn/stable/${XPU_XDNN_BASE_DATE}"
)

set(XPU_XCCL_BASE_URL
"https://klx-sdk-release-public.su.bcebos.com/xccl/release/${XPU_XCCL_BASE_VERSION}"
)
Expand Down Expand Up @@ -105,7 +112,7 @@ set(XPU_XRE_URL
"${XPU_BASE_URL}/${XPU_XRE_DIR_NAME}.tar.gz"
CACHE STRING "" FORCE)
set(XPU_XDNN_URL
"${XPU_BASE_URL}/${XPU_XDNN_DIR_NAME}.tar.gz"
"${XPU_XDNN_BASE_URL}/${XPU_XDNN_DIR_NAME}.tar.gz"
CACHE STRING "" FORCE)
set(XPU_XCCL_URL
"${XPU_XCCL_BASE_URL}/${XPU_XCCL_DIR_NAME}.tar.gz"
Expand Down Expand Up @@ -229,7 +236,7 @@ if(WITH_XPTI)
endif()

if(WITH_XPU_XHPC)
target_link_libraries(xpulib ${XPU_API_LIB} ${XPU_RT_LIB} ${XPU_XBLAS_LIB}
target_link_libraries(xpulib ${XPU_RT_LIB} ${XPU_XBLAS_LIB} ${XPU_API_LIB}
${XPU_XFA_LIB})
endif()

Expand Down
5 changes: 5 additions & 0 deletions cmake/flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ if(NOT WIN32)
-Wno-error=unused-function # Warnings in Numpy Header.
-Wno-error=array-bounds # Warnings in Eigen::array
)

if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(GPU_COMMON_FLAGS -ccbin=${CMAKE_CXX_COMPILER} ${GPU_COMMON_FLAGS})
endif()

if(NOT WITH_NV_JETSON
AND NOT WITH_ARM
AND NOT WITH_SW
Expand Down
2 changes: 1 addition & 1 deletion cmake/generic.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ function(paddle_test_build TARGET_NAME)
${paddle_test_DEPS} common paddle_gtest_main_new)
add_dependencies(${TARGET_NAME} ${paddle_lib} ${paddle_test_DEPS} common
paddle_gtest_main_new)
if(WITH_MKLDNN)
if(WITH_ONEDNN)
target_link_libraries(${TARGET_NAME} onednn)
add_dependencies(${TARGET_NAME} onednn)
endif()
Expand Down
2 changes: 1 addition & 1 deletion cmake/inference_lib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function(copy_part_of_third_party TARGET DST)
endif()
endif()

if(WITH_MKLDNN)
if(WITH_ONEDNN)
set(dst_dir "${DST}/third_party/install/onednn")
if(WIN32)
copy(
Expand Down
8 changes: 4 additions & 4 deletions cmake/operators.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function(register_onednn_kernel TARGET)
"The MKLDNN kernel file of ${TARGET} should contains at least one *.*_onednn_op.cc file"
)
endif()
if(WITH_MKLDNN)
if(WITH_ONEDNN)
cc_library(
${TARGET}
SRCS ${onednn_cc_srcs}
Expand Down Expand Up @@ -237,7 +237,7 @@ function(op_library TARGET)
list(APPEND miopen_cu_srcs ${MIOPEN_FILE}.cu)
endif()
endif()
if(WITH_MKLDNN)
if(WITH_ONEDNN)
string(REPLACE "_op" "_onednn_op" MKLDNN_FILE "${TARGET}")
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/onednn/${MKLDNN_FILE}.cc)
list(APPEND onednn_cc_srcs onednn/${MKLDNN_FILE}.cc)
Expand Down Expand Up @@ -275,7 +275,7 @@ function(op_library TARGET)
list(APPEND cudnn_cu_cc_srcs ${src})
elseif(WITH_GPU AND ${src} MATCHES ".*\\.cu.cc$")
list(APPEND cu_cc_srcs ${src})
elseif(WITH_MKLDNN AND ${src} MATCHES ".*_onednn_op.cc$")
elseif(WITH_ONEDNN AND ${src} MATCHES ".*_onednn_op.cc$")
list(APPEND onednn_cc_srcs ${src})
elseif(WITH_XPU AND ${src} MATCHES ".*_op_xpu.cc$")
list(APPEND xpu_cc_srcs ${src})
Expand Down Expand Up @@ -610,7 +610,7 @@ function(op_library TARGET)
endif()

# pybind USE_OP_DEVICE_KERNEL for MKLDNN
if(WITH_MKLDNN AND ${onednn_cc_srcs_len} GREATER 0)
if(WITH_ONEDNN AND ${onednn_cc_srcs_len} GREATER 0)
# Append first implemented MKLDNN activation operator
if(${MKLDNN_FILE} STREQUAL "activation_onednn_op")
file(APPEND ${pybind_file} "USE_OP_DEVICE_KERNEL(softplus, MKLDNN);\n")
Expand Down
5 changes: 5 additions & 0 deletions cmake/simd.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
set(AVX_FLAG "-mavx")
set(AVX2_FLAG "-mavx2")
set(AVX512F_FLAG "-mavx512f")
set(Wno_Maybe_Uninitialized "-Wno-maybe-uninitialized")
set(FMA_FLAG "-mfma")
elseif(MSVC)
set(MMX_FLAG "/arch:MMX")
set(SSE2_FLAG "/arch:SSE2")
set(SSE3_FLAG "/arch:SSE3")
set(AVX_FLAG "/arch:AVX")
set(AVX2_FLAG "/arch:AVX2")
set(AVX512F_FLAG "/arch:AVX512")
set(Wno_Maybe_Uninitialized "/wd4701")
set(FMA_FLAG "/arch:AVX2")
endif()

set(CMAKE_REQUIRED_FLAGS_RETAINED ${CMAKE_REQUIRED_FLAGS})
Expand Down
17 changes: 11 additions & 6 deletions cmake/third_party.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -254,19 +254,19 @@ if(WIN32 OR APPLE)
endif()

set(WITH_MKLML ${WITH_MKL})
if(NOT DEFINED WITH_MKLDNN)
if(NOT DEFINED WITH_ONEDNN)
if(WITH_MKL AND AVX2_FOUND)
set(WITH_MKLDNN ON)
set(WITH_ONEDNN ON)
else()
message(STATUS "Do not have AVX2 intrinsics and disabled MKL-DNN.")
set(WITH_MKLDNN OFF)
set(WITH_ONEDNN OFF)
endif()
endif()

if(WIN32)
if(MSVC)
if(MSVC_VERSION LESS 1920)
set(WITH_MKLDNN OFF)
set(WITH_ONEDNN OFF)
endif()
endif()
endif()
Expand Down Expand Up @@ -303,7 +303,7 @@ if(WITH_CINN)
if(WITH_MKL)
add_definitions(-DCINN_WITH_MKL_CBLAS)
endif()
if(WITH_MKLDNN)
if(WITH_ONEDNN)
add_definitions(-DCINN_WITH_DNNL)
endif()
include(cmake/cinn/version.cmake)
Expand Down Expand Up @@ -362,7 +362,7 @@ elseif(${CBLAS_PROVIDER} STREQUAL EXTERN_OPENBLAS)
list(APPEND third_party_deps extern_openblas)
endif()

if(WITH_MKLDNN)
if(WITH_ONEDNN)
include(external/onednn) # download, build, install onednn
list(APPEND third_party_deps extern_onednn)
endif()
Expand All @@ -372,6 +372,11 @@ if(TARGET extern_protobuf)
list(APPEND third_party_deps extern_protobuf)
endif()

include(external/json) # find first, then build json
if(TARGET extern_json)
list(APPEND third_party_deps extern_json)
endif()

if(NOT ((NOT WITH_PYTHON) AND ON_INFER))
include(external/python) # find python and python_module
include(external/pybind11) # prepare submodule pybind11
Expand Down
2 changes: 1 addition & 1 deletion cmake/version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function(version version_file)
"Paddle version: ${PADDLE_VERSION}\n"
"GIT COMMIT ID: ${PADDLE_GIT_COMMIT}\n"
"WITH_MKL: ${WITH_MKL}\n"
"WITH_MKLDNN: ${WITH_MKLDNN}\n"
"WITH_ONEDNN: ${WITH_ONEDNN}\n"
"WITH_GPU: ${WITH_GPU}\n"
"WITH_ROCM: ${WITH_ROCM}\n"
"WITH_IPU: ${WITH_IPU}\n")
Expand Down
7 changes: 5 additions & 2 deletions paddle/cinn/ast_gen_ius/ast_gen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,11 @@ ir::Expr AstGen::Build(const ir::Tensor& tensor, TensorGroup* tensor_group) {
const std::vector<ir::Var>& axis = tensor->axis();
const std::vector<ir::Expr>& shape = tensor->shape;
size_t axis_len = axis.size();
CHECK_EQ(shape.size(), axis_len) << "Internal Error: Tensor has different "
"shape and axis length in AstGen";
PADDLE_ENFORCE_EQ(
shape.size(),
axis_len,
phi::errors::InvalidArgument("Internal Error: Tensor has different "
"shape and axis length in AstGen"));
std::vector<ir::Expr> axis_exprs;
for (const auto& a : axis) {
axis_exprs.push_back(a);
Expand Down
Loading

0 comments on commit 77acfd3

Please sign in to comment.