Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
co63oc committed Apr 12, 2024
2 parents a6b99fc + 22fb3b1 commit 48b3c94
Show file tree
Hide file tree
Showing 1,463 changed files with 28,624 additions and 12,262 deletions.
8 changes: 6 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@
path = third_party/xbyak
url = https://github.com/herumi/xbyak.git
ignore = dirty
[submodule "third_party/mkldnn"]
path = third_party/mkldnn
[submodule "third_party/onednn"]
path = third_party/onednn
url = https://github.com/oneapi-src/oneDNN.git
ignore = dirty
[submodule "third_party/flashattn"]
Expand Down 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 .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ repos:
hooks:
- id: copyright_checker
name: copyright_checker
entry: python ./tools/codestyle/copyright.hook
entry: python ./tools/codestyle/copyright.py
language: system
files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|proto|xpu|kps|py|sh)$
exclude: |
Expand All @@ -67,15 +67,15 @@ repos:
- id: clang-format
name: clang-format
description: Format files with ClangFormat.
entry: bash ./tools/codestyle/clang_format.hook -i
entry: bash ./tools/codestyle/clang_format.sh -i
language: system
files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|xpu|kps)$
- repo: local
hooks:
- id: cpplint-cpp-source
name: cpplint
description: Check C++ code style using cpplint.py.
entry: bash ./tools/codestyle/cpplint_pre_commit.hook
entry: bash ./tools/codestyle/cpplint_pre_commit.sh
language: system
files: \.(cc|cxx|cpp|cu|h|hpp|hxx)$
args:
Expand Down
14 changes: 0 additions & 14 deletions ISSUE_TEMPLATE.md

This file was deleted.

28 changes: 17 additions & 11 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 @@ -164,6 +164,8 @@ cinn_cc_library(
isl
ginac
pybind
group_cluster
cinn_op_dialect
${jitify_deps})
add_dependencies(cinnapi GEN_LLVM_RUNTIME_IR_HEADER ZLIB::ZLIB)
add_dependencies(cinnapi GEN_LLVM_RUNTIME_IR_HEADER ${core_deps})
Expand All @@ -175,9 +177,9 @@ 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 ${MKLDNN_PROJECT})
add_dependencies(cinnapi ${ONEDNN_PROJECT})
endif()
endif()

Expand Down Expand Up @@ -220,21 +222,25 @@ function(gen_cinncore LINKTYPE)
schedule_desc_proto
absl
isl
ginac)
ginac
pybind
group_cluster
cinn_op_dialect
${jitify_deps})
add_dependencies(${CINNCORE_TARGET} GEN_LLVM_RUNTIME_IR_HEADER ZLIB::ZLIB)
add_dependencies(${CINNCORE_TARGET} GEN_LLVM_RUNTIME_IR_HEADER ${core_deps})
target_link_libraries(${CINNCORE_TARGET} op_dialect pir phi)
add_dependencies(${CINNCORE_TARGET} op_dialect pir phi)

add_dependencies(${CINNCORE_TARGET} pybind)
# add_dependencies(${CINNCORE_TARGET} pybind)
target_link_libraries(${CINNCORE_TARGET} ${PYTHON_LIBRARIES})

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} ${MKLDNN_PROJECT})
add_dependencies(${CINNCORE_TARGET} ${ONEDNN_PROJECT})
endif()
endif()

Expand All @@ -247,16 +253,16 @@ function(gen_cinncore LINKTYPE)
${CUBLAS}
${CUDNN}
${CURAND}
${CUSOLVER}
${jitify_deps})
${CUSOLVER})
# ${jitify_deps})
if(NVTX_FOUND)
target_link_libraries(${CINNCORE_TARGET} ${CUDA_NVTX_LIB})
endif()
endif()

if(WITH_CUTLASS)
target_link_libraries(cinnapi cutlass)
add_dependencies(cinnapi cutlass)
target_link_libraries(${CINNCORE_TARGET} cutlass)
add_dependencies(${CINNCORE_TARGET} cutlass)
endif()
endfunction()

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
70 changes: 35 additions & 35 deletions cmake/external/mkldnn.cmake → cmake/external/onednn.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@

include(ExternalProject)

set(MKLDNN_PROJECT "extern_mkldnn")
set(MKLDNN_PREFIX_DIR ${THIRD_PARTY_PATH}/mkldnn)
set(MKLDNN_INSTALL_DIR ${THIRD_PARTY_PATH}/install/mkldnn)
set(ONEDNN_PROJECT "extern_onednn")
set(ONEDNN_PREFIX_DIR ${THIRD_PARTY_PATH}/onednn)
set(MKLDNN_INSTALL_DIR ${THIRD_PARTY_PATH}/install/onednn)
set(MKLDNN_INC_DIR
"${MKLDNN_INSTALL_DIR}/include"
CACHE PATH "mkldnn include directory." FORCE)
set(SOURCE_DIR ${PADDLE_SOURCE_DIR}/third_party/mkldnn)
CACHE PATH "oneDNN include directory." FORCE)
set(SOURCE_DIR ${PADDLE_SOURCE_DIR}/third_party/onednn)

# Introduce variables:
# * CMAKE_INSTALL_LIBDIR
Expand All @@ -36,28 +36,28 @@ set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}"
"${MKLDNN_INSTALL_DIR}/${LIBDIR}")

include_directories(${MKLDNN_INC_DIR}
)# For MKLDNN code to include internal headers.
)# For oneDNN code to include internal headers.

if(NOT WIN32)
set(MKLDNN_FLAG
set(ONEDNN_FLAG
"-Wno-error=strict-overflow -Wno-error=unused-result -Wno-error=array-bounds"
)
set(MKLDNN_FLAG "${MKLDNN_FLAG} -Wno-unused-result -Wno-unused-value")
set(MKLDNN_CFLAG "${CMAKE_C_FLAGS} ${MKLDNN_FLAG}")
set(MKLDNN_CXXFLAG "${CMAKE_CXX_FLAGS} ${MKLDNN_FLAG}")
set(MKLDNN_CXXFLAG_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
set(MKLDNN_CFLAG_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
set(ONEDNN_FLAG "${ONEDNN_FLAG} -Wno-unused-result -Wno-unused-value")
set(ONEDNN_CFLAG "${CMAKE_C_FLAGS} ${ONEDNN_FLAG}")
set(ONEDNN_CXXFLAG "${CMAKE_CXX_FLAGS} ${ONEDNN_FLAG}")
set(ONEDNN_CXXFLAG_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
set(ONEDNN_CFLAG_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
set(MKLDNN_LIB
"${MKLDNN_INSTALL_DIR}/${LIBDIR}/libdnnl.so"
CACHE FILEPATH "mkldnn library." FORCE)
CACHE FILEPATH "oneDNN library." FORCE)
else()
set(MKLDNN_CXXFLAG "${CMAKE_CXX_FLAGS} /EHsc")
set(MKLDNN_CFLAG "${CMAKE_C_FLAGS}")
string(REPLACE "/O2 " "" MKLDNN_CFLAG_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
string(REPLACE "/O2 " "" MKLDNN_CXXFLAG_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
set(ONEDNN_CXXFLAG "${CMAKE_CXX_FLAGS} /EHsc")
set(ONEDNN_CFLAG "${CMAKE_C_FLAGS}")
string(REPLACE "/O2 " "" ONEDNN_CFLAG_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
string(REPLACE "/O2 " "" ONEDNN_CXXFLAG_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
set(MKLDNN_LIB
"${MKLDNN_INSTALL_DIR}/bin/mkldnn.lib"
CACHE FILEPATH "mkldnn library." FORCE)
CACHE FILEPATH "oneDNN library." FORCE)
endif()

if(LINUX)
Expand All @@ -67,21 +67,21 @@ else()
endif()

ExternalProject_Add(
${MKLDNN_PROJECT}
${ONEDNN_PROJECT}
${EXTERNAL_PROJECT_LOG_ARGS}
SOURCE_DIR ${SOURCE_DIR}
DEPENDS ${MKLDNN_DEPENDS}
PREFIX ${MKLDNN_PREFIX_DIR}
DEPENDS ${ONEDNN_DEPENDS}
PREFIX ${ONEDNN_PREFIX_DIR}
UPDATE_COMMAND ""
#BUILD_ALWAYS 1
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_FLAGS=${MKLDNN_CXXFLAG}
-DCMAKE_CXX_FLAGS_RELEASE=${MKLDNN_CXXFLAG_RELEASE}
-DCMAKE_CXX_FLAGS=${ONEDNN_CXXFLAG}
-DCMAKE_CXX_FLAGS_RELEASE=${ONEDNN_CXXFLAG_RELEASE}
-DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG}
-DCMAKE_C_FLAGS=${MKLDNN_CFLAG}
-DCMAKE_C_FLAGS=${ONEDNN_CFLAG}
-DCMAKE_C_FLAGS_DEBUG=${CMAKE_C_FLAGS_DEBUG}
-DCMAKE_C_FLAGS_RELEASE=${MKLDNN_CFLAG_RELEASE}
-DCMAKE_C_FLAGS_RELEASE=${ONEDNN_CFLAG_RELEASE}
-DCMAKE_INSTALL_PREFIX=${MKLDNN_INSTALL_DIR}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
Expand All @@ -90,7 +90,7 @@ ExternalProject_Add(
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${MKLDNN_INSTALL_DIR}
BUILD_BYPRODUCTS ${BUILD_BYPRODUCTS_ARGS})

message(STATUS "MKLDNN library: ${MKLDNN_LIB}")
message(STATUS "OneDNN library: ${MKLDNN_LIB}")
add_definitions(-DPADDLE_WITH_DNNL)
# copy the real so.0 lib to install dir
# it can be directly contained in wheel or capi
Expand Down Expand Up @@ -123,21 +123,21 @@ if(WIN32)
COMMAND lib /def:${MKLDNN_INSTALL_DIR}/bin/mkldnn.def /out:${MKLDNN_LIB}
/machine:x64
COMMENT "Generate mkldnn.lib manually--->"
DEPENDS ${MKLDNN_PROJECT}
DEPENDS ${ONEDNN_PROJECT}
VERBATIM)
add_custom_target(mkldnn_cmd ALL DEPENDS ${MKLDNN_LIB})
add_custom_target(onednn_cmd ALL DEPENDS ${MKLDNN_LIB})
else()
set(MKLDNN_SHARED_LIB ${MKLDNN_INSTALL_DIR}/libdnnl.so.3)
add_custom_command(
OUTPUT ${MKLDNN_SHARED_LIB}
COMMAND ${CMAKE_COMMAND} -E copy ${MKLDNN_LIB} ${MKLDNN_SHARED_LIB}
DEPENDS ${MKLDNN_PROJECT})
add_custom_target(mkldnn_cmd ALL DEPENDS ${MKLDNN_SHARED_LIB})
DEPENDS ${ONEDNN_PROJECT})
add_custom_target(onednn_cmd ALL DEPENDS ${MKLDNN_SHARED_LIB})
endif()

# generate a static dummy target to track mkldnn dependencies
# for cc_library(xxx SRCS xxx.c DEPS mkldnn)
generate_dummy_static_lib(LIB_NAME "mkldnn" GENERATOR "mkldnn.cmake")
# generate a static dummy target to track onednn dependencies
# for cc_library(xxx SRCS xxx.c DEPS onednn)
generate_dummy_static_lib(LIB_NAME "onednn" GENERATOR "onednn.cmake")

target_link_libraries(mkldnn ${MKLDNN_LIB} ${MKLML_IOMP_LIB})
add_dependencies(mkldnn ${MKLDNN_PROJECT} mkldnn_cmd)
target_link_libraries(onednn ${MKLDNN_LIB} ${MKLML_IOMP_LIB})
add_dependencies(onednn ${ONEDNN_PROJECT} onednn_cmd)
Loading

0 comments on commit 48b3c94

Please sign in to comment.