Skip to content

Commit

Permalink
Merge branch 'PaddlePaddle:develop' into fix_trt_int8_infer
Browse files Browse the repository at this point in the history
  • Loading branch information
Wanglongzhi2001 authored Nov 22, 2023
2 parents 8507390 + 6747af6 commit 0e1bb0c
Show file tree
Hide file tree
Showing 1,383 changed files with 57,977 additions and 15,754 deletions.
4 changes: 2 additions & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ clang-analyzer-optin.portability.UnixAPI,
clang-analyzer-security.insecureAPI.vfork,
-clang-analyzer-unix.API,
-clang-analyzer-unix.DynamicMemoryModeling,
-clang-analyzer-unix.Malloc,
clang-analyzer-unix.Malloc,
-clang-analyzer-unix.MallocSizeof,
-clang-analyzer-unix.MismatchedDeallocator,
clang-analyzer-unix.Vfork,
Expand All @@ -158,7 +158,7 @@ cppcoreguidelines-explicit-virtual-functions,
cppcoreguidelines-init-variables,
cppcoreguidelines-narrowing-conversions,
cppcoreguidelines-no-malloc,
-cppcoreguidelines-pro-type-const-cast,
cppcoreguidelines-pro-type-const-cast,
-cppcoreguidelines-pro-type-member-init,
-cppcoreguidelines-slicing,
-hicpp-avoid-goto,
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,9 @@ paddle/fluid/ir_adaptor/translator/op_compat_info.cc
paddle/phi/kernels/fusion/cutlass/cutlass_kernels/fpA_intB_gemm/autogen/*
paddle/fluid/pybind/static_op_function.*
paddle/fluid/pybind/ops_api.cc
paddle/fluid/pir/dialect/operator/ir/pd_api.*
paddle/fluid/pir/dialect/operator/ir/op_decomp.cc
paddle/fluid/pir/dialect/operator/ir/pd_op_vjp.cc
paddle/fluid/pir/dialect/operator/ir/pd_op.*
paddle/cinn/hlir/dialect/generated/ops.parsed.yaml
paddle/cinn/hlir/dialect/operator/ir/cinn_op.*
38 changes: 13 additions & 25 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,28 +56,16 @@ repos:
hooks:
- id: black
files: (.*\.(py|pyi|bzl)|BUILD|.*\.BUILD|WORKSPACE)$
- repo: https://github.com/pycqa/isort
rev: 5.11.5
hooks:
- id: isort
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
hooks:
- id: flake8
args: ["--config=.flake8"]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.289
rev: v0.1.5
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --no-cache]
- repo: local
hooks:
- id: pylint-doc-string
name: pylint
description: Check python docstring style using docstring_checker.
entry: bash ./tools/codestyle/pylint_pre_commit.hook
language: system
files: \.(py)$
# For C++ files
- repo: local
hooks:
Expand Down Expand Up @@ -155,18 +143,18 @@ repos:
(?x)^(
paddle/fluid/operators/CMakeLists.txt
)$
- repo: https://github.com/cmake-lint/cmake-lint
rev: 1.4.2
- repo: https://github.com/PFCCLab/cmake-lint-paddle
rev: v1.5.1
hooks:
- id: cmakelint
args: [--config=./tools/codestyle/.cmakelintrc]

- repo: local
hooks:
- id: sort-txt-file
name: sort-txt-file
description: Sorts each line string in a text file
entry: python ./tools/codestyle/sort_txt_file.py
language: python
files: test/white_list/new_ir_op_test_white_list
args: []
# Others
- repo: local
hooks:
- id: sort-txt-file
name: sort-txt-file
description: Sorts each line string in a text file
entry: python ./tools/codestyle/sort_txt_file.py
language: python
files: test/white_list/pir_op_test_white_list
args: []
22 changes: 18 additions & 4 deletions cmake/cinn.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ if(WITH_GPU)
message(STATUS "Enable CINN CUDNN")
add_definitions(-DCINN_WITH_CUDNN)
endif()
if(WITH_CUTLASS)
message(STATUS "Enable CINN CUTLASS")
add_definitions(-DCINN_WITH_CUTLASS)
endif()
enable_language(CUDA)
find_package(CUDA REQUIRED)
include_directories(${CUDA_INCLUDE_DIRS})
Expand Down Expand Up @@ -164,8 +168,8 @@ cinn_cc_library(
add_dependencies(cinnapi GEN_LLVM_RUNTIME_IR_HEADER ZLIB::ZLIB)
add_dependencies(cinnapi GEN_LLVM_RUNTIME_IR_HEADER ${core_deps})
if(NOT CINN_ONLY)
target_link_libraries(cinnapi pd_op_dialect phi)
add_dependencies(cinnapi pd_op_dialect phi)
target_link_libraries(cinnapi op_dialect_vjp phi)
add_dependencies(cinnapi op_dialect_vjp phi)
endif()

target_link_libraries(cinnapi ${PYTHON_LIBRARIES})
Expand Down Expand Up @@ -199,6 +203,11 @@ if(WITH_GPU)
endif()
endif()

if(WITH_CUTLASS)
target_link_libraries(cinnapi cutlass)
add_dependencies(cinnapi cutlass)
endif()

function(gen_cinncore LINKTYPE)
set(CINNCORE_TARGET cinncore)
if(${LINKTYPE} STREQUAL "STATIC")
Expand All @@ -222,8 +231,8 @@ function(gen_cinncore LINKTYPE)
add_dependencies(${CINNCORE_TARGET} GEN_LLVM_RUNTIME_IR_HEADER ZLIB::ZLIB)
add_dependencies(${CINNCORE_TARGET} GEN_LLVM_RUNTIME_IR_HEADER ${core_deps})
if(NOT CINN_ONLY)
target_link_libraries(${CINNCORE_TARGET} pd_op_dialect phi)
add_dependencies(${CINNCORE_TARGET} pd_op_dialect phi)
target_link_libraries(${CINNCORE_TARGET} op_dialect_vjp phi)
add_dependencies(${CINNCORE_TARGET} op_dialect_vjp phi)
endif()

add_dependencies(${CINNCORE_TARGET} pybind)
Expand Down Expand Up @@ -258,6 +267,11 @@ function(gen_cinncore LINKTYPE)
target_link_libraries(${CINNCORE_TARGET} ${CUDA_NVTX_LIB})
endif()
endif()

if(WITH_CUTLASS)
target_link_libraries(cinnapi cutlass)
add_dependencies(cinnapi cutlass)
endif()
endfunction()

gen_cinncore(STATIC)
Expand Down
7 changes: 4 additions & 3 deletions cmake/external/cccl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ ExternalProject_Add(
INSTALL_COMMAND ""
TEST_COMMAND "")

add_library(cccl INTERFACE)

add_dependencies(cccl extern_cccl)
# update include dir and set cccl first for using
include_directories(BEFORE "${CCCL_SOURCE_DIR}/cub")
include_directories(BEFORE "${CCCL_SOURCE_DIR}/libcudacxx/include")
include_directories(BEFORE "${CCCL_SOURCE_DIR}/thrust")
11 changes: 11 additions & 0 deletions cmake/external/gloo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ if(CMAKE_COMPILER_IS_GNUCC)
${SOURCE_DIR}/gloo/ < ${types_header})
endif()
endif()

file(TO_NATIVE_PATH ${PADDLE_SOURCE_DIR}/patches/gloo/linux.cc.patch
linux_cc_ethtool)
if(GLOO_PATCH_COMMAND STREQUAL "")
set(GLOO_PATCH_COMMAND git checkout -- . && git checkout ${GLOO_TAG} && patch
-Nd ${SOURCE_DIR}/gloo/common/ < ${linux_cc_ethtool})
else()
set(GLOO_PATCH_COMMAND ${GLOO_PATCH_COMMAND} && patch -Nd
${SOURCE_DIR}/gloo/common/ < ${linux_cc_ethtool})
endif()

include_directories(${GLOO_INCLUDE_DIR})

ExternalProject_Add(
Expand Down
32 changes: 14 additions & 18 deletions cmake/external/protobuf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ if(NOT "${PROTOBUF_ROOT}" STREQUAL "")
endif()
endif()

function(build_protobuf TARGET_NAME BUILD_FOR_HOST)
function(build_protobuf TARGET_NAME)
string(REPLACE "extern_" "" TARGET_DIR_NAME "${TARGET_NAME}")
set(PROTOBUF_PREFIX_DIR ${THIRD_PARTY_PATH}/${TARGET_DIR_NAME})
set(PROTOBUF_SOURCE_DIR
Expand Down Expand Up @@ -210,22 +210,18 @@ function(build_protobuf TARGET_NAME BUILD_FOR_HOST)
PARENT_SCOPE)

set(OPTIONAL_CACHE_ARGS "")
set(OPTIONAL_ARGS "")
if(BUILD_FOR_HOST)
set(OPTIONAL_ARGS "-Dprotobuf_WITH_ZLIB=OFF")
else()
set(OPTIONAL_ARGS
"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
"-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}"
"-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}"
"-DCMAKE_C_FLAGS_DEBUG=${CMAKE_C_FLAGS_DEBUG}"
"-DCMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE}"
"-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}"
"-DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}"
"-DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG}"
"-Dprotobuf_WITH_ZLIB=ON"
"-DZLIB_ROOT:FILEPATH=${ZLIB_ROOT}"
${EXTERNAL_OPTIONAL_ARGS})
set(OPTIONAL_ARGS
"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
"-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}"
"-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}"
"-DCMAKE_C_FLAGS_DEBUG=${CMAKE_C_FLAGS_DEBUG}"
"-DCMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE}"
"-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}"
"-DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}"
"-DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG}"
"-Dprotobuf_WITH_ZLIB=ON"
${EXTERNAL_OPTIONAL_ARGS})
if(NOT APPLE)
set(OPTIONAL_CACHE_ARGS "-DZLIB_ROOT:STRING=${ZLIB_ROOT}")
endif()
if(WIN32)
Expand Down Expand Up @@ -339,7 +335,7 @@ else()
endif()

if(NOT PROTOBUF_FOUND)
build_protobuf(extern_protobuf FALSE)
build_protobuf(extern_protobuf)

set(PROTOBUF_INCLUDE_DIR
${extern_protobuf_INCLUDE_DIR}
Expand Down
4 changes: 2 additions & 2 deletions cmake/external/xpu.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ set(XPU_XFT_LIB_NAME "libxft.so")
set(XPU_XPTI_LIB_NAME "libxpti.so")

if(NOT DEFINED XPU_BASE_DATE)
set(XPU_BASE_DATE "20231025")
set(XPU_BASE_DATE "20231114")
endif()
set(XPU_XCCL_BASE_VERSION "1.0.53.6")
set(XPU_XCCL_BASE_VERSION "1.1.6.1")
if(NOT DEFINED XPU_XFT_BASE_VERSION)
set(XPU_XFT_BASE_VERSION "20230602")
endif()
Expand Down
4 changes: 0 additions & 4 deletions cmake/generic.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
#
# paddle_test(example SRCS example_test.cc)
#

# including binary directory for generated headers.
include_directories(${CMAKE_CURRENT_BINARY_DIR})
# including io directory for inference lib paddle_api.h
Expand Down Expand Up @@ -1349,9 +1348,6 @@ function(math_library TARGET)
if(WITH_GPU)
if(${CMAKE_CUDA_COMPILER_VERSION} LESS 11.0)
list(APPEND math_common_deps cub)
elseif(${CMAKE_CUDA_COMPILER_VERSION} EQUAL 12.0
OR ${CMAKE_CUDA_COMPILER_VERSION} GREATER 12.0)
list(APPEND math_common_deps cccl)
else()
list(APPEND math_common_deps)
endif()
Expand Down
12 changes: 5 additions & 7 deletions cmake/inference_lib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,11 @@ else()
SRCS ${paddle_phi_lib}
DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/lib)
endif()
if(WITH_SHARED_IR)
set(paddle_pir_lib ${PADDLE_BINARY_DIR}/paddle/pir/libpir.*)
copy(
inference_lib_dist
SRCS ${paddle_pir_lib}
DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/lib)
endif()
set(paddle_common_lib ${PADDLE_BINARY_DIR}/paddle/common/libcommon.*)
copy(
inference_lib_dist
SRCS ${paddle_common_lib}
DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/lib)
endif()

copy(
Expand Down
18 changes: 12 additions & 6 deletions cmake/third_party.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,17 @@ include(external/gflags) # download, build, install gflags
include(external/glog) # download, build, install glog

########################### include third_party according to flags ###############################
if(WITH_GPU
AND NOT WITH_ARM
AND NOT WIN32
AND NOT APPLE)
if(${CMAKE_CUDA_COMPILER_VERSION} GREATER_EQUAL 11.0)
include(external/cutlass) # download, build, install cusparselt
list(APPEND third_party_deps extern_cutlass)
set(WITH_CUTLASS ON)
endif()
endif()

if(WITH_CINN)
if(WITH_MKL)
add_definitions(-DCINN_WITH_MKL_CBLAS)
Expand Down Expand Up @@ -386,7 +397,7 @@ if(WITH_GPU)
elseif(${CMAKE_CUDA_COMPILER_VERSION} EQUAL 12.0
OR ${CMAKE_CUDA_COMPILER_VERSION} GREATER 12.0)
include(external/cccl)
list(APPEND third_party_deps extern_cccl)
add_definitions(-DPADDLE_WITH_CCCL)
endif()
set(URL
"https://paddlepaddledeps.bj.bcebos.com/externalErrorMsg_20210928.tar.gz"
Expand Down Expand Up @@ -555,11 +566,6 @@ if(WITH_GPU
AND NOT WITH_ARM
AND NOT WIN32
AND NOT APPLE)
if(${CMAKE_CUDA_COMPILER_VERSION} GREATER_EQUAL 11.0)
include(external/cutlass) # download, build, install cusparselt
list(APPEND third_party_deps extern_cutlass)
set(WITH_CUTLASS ON)
endif()
if(${CMAKE_CUDA_COMPILER_VERSION} GREATER_EQUAL 11.4)
foreach(arch ${NVCC_ARCH_BIN})
if(${arch} GREATER_EQUAL 80)
Expand Down
1 change: 1 addition & 0 deletions paddle/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ set(PYTHON_TESTS_DIR
CACHE INTERNAL "python tests directory")

add_subdirectory(utils)
add_subdirectory(common)
add_subdirectory(pir)
add_subdirectory(scripts)
add_subdirectory(testing)
Expand Down
1 change: 1 addition & 0 deletions paddle/cinn/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ if(WITH_TESTING)
cinn_cc_library(cinn_gtest_main SRCS gtest_main.cc DEPS gtest ${flags_dep})
endif()

add_subdirectory(adt)
add_subdirectory(api)
add_subdirectory(ast_gen_ius)
add_subdirectory(auto_schedule)
Expand Down
39 changes: 39 additions & 0 deletions paddle/cinn/adt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
if(NOT CINN_ONLY)
add_subdirectory(print_utils)

core_gather_headers()

gather_srcs(
cinnapi_src
SRCS
adapter_tensor.cc
anchor_sd_equation_context.cc
equation_function.cc
equation_solver.cc
equation_value.cc
generate_map_expr.cc
get_sub_reshape_dim_ranges.cc
igroup.cc
index_expr_infer_context.cc
kgroup.cc
m_ir.cc
naive_bidirection_equation_generator.cc
naive_op_equation_context.cc
partition_op_stmts.cc
schedule_descriptor.cc
schedule_dim.cc
schedule_mesh.cc
simplify_value.cc
write_broadcast_disabled_bidirection_equation_generator.cc)

cinn_cc_test(equation_value_match_trait_test SRCS
equation_value_match_trait_test.cc DEPS gtest glog)

cinn_cc_test(tree_test SRCS tree_test.cc DEPS gtest glog)

cinn_cc_test(inline_translator_test SRCS inline_translator_test.cc DEPS
cinncore)

message(STATUS "ADT srcs: ${cinnapi_src}")

endif()
Loading

0 comments on commit 0e1bb0c

Please sign in to comment.