-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/develop' into fix_test_imperat…
…ive_transformer_sorted_gradient
- Loading branch information
Showing
872 changed files
with
34,457 additions
and
7,372 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
include(FetchContent) | ||
|
||
set(LLVM_DOWNLOAD_URL https://paddle-inference-dist.bj.bcebos.com/CINN/llvm11.tar.gz) | ||
set(LLVM_MD5 39d32b6be466781dddf5869318dcba53) | ||
|
||
set(FETCHCONTENT_BASE_DIR ${THIRD_PARTY_PATH}/llvm) | ||
set(FETCHCONTENT_QUIET OFF) | ||
FetchContent_Declare(external_llvm | ||
URL ${LLVM_DOWNLOAD_URL} | ||
URL_MD5 ${LLVM_MD5} | ||
PREFIX ${THIRD_PARTY_PATH}/llvm | ||
SOURCE_DIR ${THIRD_PARTY_PATH}/install/llvm | ||
) | ||
if (NOT LLVM_PATH) | ||
FetchContent_GetProperties(external_llvm) | ||
if (NOT external_llvm_POPULATED) | ||
FetchContent_Populate(external_llvm) | ||
endif() | ||
set(LLVM_PATH ${THIRD_PARTY_PATH}/install/llvm) | ||
set(LLVM_DIR ${THIRD_PARTY_PATH}/install/llvm/lib/cmake/llvm) | ||
set(MLIR_DIR ${THIRD_PARTY_PATH}/install/llvm/lib/cmake/mlir) | ||
else () | ||
set(LLVM_DIR ${LLVM_PATH}/lib/cmake/llvm) | ||
set(MLIR_DIR ${LLVM_PATH}/lib/cmake/mlir) | ||
endif() | ||
|
||
if (${CMAKE_CXX_COMPILER} STREQUAL "clang++") | ||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++abi") | ||
endif() | ||
|
||
message(STATUS "set LLVM_DIR: ${LLVM_DIR}") | ||
message(STATUS "set MLIR_DIR: ${MLIR_DIR}") | ||
find_package(LLVM REQUIRED CONFIG HINTS ${LLVM_DIR}) | ||
find_package(MLIR REQUIRED CONFIG HINTS ${MLIR_DIR}) | ||
find_package(ZLIB REQUIRED) | ||
|
||
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}") | ||
include(AddLLVM) | ||
|
||
include_directories(${LLVM_INCLUDE_DIRS}) | ||
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}") | ||
list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}") | ||
include(AddLLVM) | ||
include(TableGen) | ||
include(AddMLIR) | ||
|
||
message(STATUS "Found MLIR: ${MLIR_DIR}") | ||
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") | ||
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") | ||
|
||
# To build with MLIR, the LLVM is build from source code using the following flags: | ||
|
||
#[==[ | ||
cmake -G Ninja ../llvm \ | ||
-DLLVM_ENABLE_PROJECTS="mlir;clang" \ | ||
-DLLVM_BUILD_EXAMPLES=OFF \ | ||
-DLLVM_TARGETS_TO_BUILD="X86" \ | ||
-DCMAKE_BUILD_TYPE=Release \ | ||
-DLLVM_ENABLE_ASSERTIONS=ON \ | ||
-DLLVM_ENABLE_ZLIB=OFF \ | ||
-DLLVM_ENABLE_RTTI=ON \ | ||
#]==] | ||
# The matched llvm-project version is f9dc2b7079350d0fed3bb3775f496b90483c9e42 (currently a temporary commit) | ||
|
||
add_definitions(${LLVM_DEFINITIONS}) | ||
|
||
llvm_map_components_to_libnames(llvm_libs Support Core irreader | ||
X86 executionengine orcjit mcjit all codegen) | ||
|
||
message(STATUS "LLVM libs: ${llvm_libs}") | ||
|
||
get_property(mlir_libs GLOBAL PROPERTY MLIR_ALL_LIBS) | ||
message(STATUS "MLIR libs: ${mlir_libs}") | ||
add_definitions(${LLVM_DEFINITIONS}) | ||
|
||
|
||
# The minimum needed libraries for MLIR IR parse and transform. | ||
set(MLIR_IR_LIBS MLIRAnalysis MLIRStandardOps MLIRPass MLIRParser MLIRDialect MLIRIR MLIROptLib) | ||
|
||
|
||
# tb_base is the name of a xxx.td file (without the .td suffix) | ||
function(mlir_tablegen_on td_base) | ||
set(options) | ||
set(oneValueArgs DIALECT) | ||
cmake_parse_arguments(mlir_tablegen_on "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) | ||
|
||
set(LLVM_TARGET_DEFINITIONS ${td_base}.td) | ||
mlir_tablegen(${td_base}.hpp.inc -gen-op-decls) | ||
mlir_tablegen(${td_base}.cpp.inc -gen-op-defs) | ||
if (mlir_tablegen_on_DIALECT) | ||
mlir_tablegen(${td_base}_dialect.hpp.inc --gen-dialect-decls -dialect=${mlir_tablegen_on_DIALECT}) | ||
endif() | ||
add_public_tablegen_target(${td_base}_IncGen) | ||
add_custom_target(${td_base}_inc DEPENDS ${td_base}_IncGen) | ||
endfunction() | ||
|
||
function(mlir_add_rewriter td_base) | ||
set(LLVM_TARGET_DEFINITIONS ${td_base}.td) | ||
mlir_tablegen(${td_base}.hpp.inc -gen-rewriters "-I${CMAKE_SOURCE_DIR}/infrt/dialect/pass") | ||
add_public_tablegen_target(${td_base}_IncGen) | ||
add_custom_target(${td_base}_inc DEPENDS ${td_base}_IncGen) | ||
endfunction() | ||
|
||
# Execute the mlir script with infrt-exec program. | ||
# @name: name of the test | ||
# @script: path to the mlir script file | ||
function (infrt_exec_check name script) | ||
add_test(NAME ${name} | ||
COMMAND sh -c "${CMAKE_BINARY_DIR}/infrt/host_context/infrt-exec -i ${CMAKE_CURRENT_SOURCE_DIR}/${script}| ${LLVM_PATH}/bin/FileCheck ${CMAKE_CURRENT_SOURCE_DIR}/${script}") | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Copyright (c) 2021 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(WITH_IPU) | ||
set(POPLAR_DIR CACHE PATH "Path to a Poplar install") | ||
set(POPART_DIR CACHE PATH "Path to a Popart install") | ||
set(POPLAR_SDK_DIR CACHE PATH "Path to an extracted SDK archive or to a Poplar & Popart install directory (Will populate POPLAR_DIR and POPART_DIR)") | ||
|
||
if(DEFINED ENV{POPLAR_SDK_DIR}) | ||
set(POPLAR_SDK_DIR $ENV{POPLAR_SDK_DIR}) | ||
execute_process(COMMAND find ${POPLAR_SDK_DIR}/ -maxdepth 1 -type d -name "popart*" | ||
OUTPUT_VARIABLE POPART_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
execute_process(COMMAND find ${POPLAR_SDK_DIR}/ -maxdepth 1 -type d -name "poplar-*" -o -name "poplar" | ||
OUTPUT_VARIABLE POPLAR_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
if(NOT IS_DIRECTORY "${POPLAR_DIR}") | ||
message(FATAL_ERROR "Couldn't find a \"poplar\" or \"poplar-*\" folder in '${POPLAR_SDK_DIR}'") | ||
endif() | ||
if(NOT IS_DIRECTORY "${POPART_DIR}") | ||
message(FATAL_ERROR "Couldn't find a \"popart*\" folder in '${POPLAR_SDK_DIR}'") | ||
endif() | ||
else() | ||
message(FATAL_ERROR "You must provide a path to a Poplar install using export POPLAR_SDK_DIR=/path/to/poplar_sdk") | ||
endif() | ||
|
||
message("POPLAR_DIR is ${POPLAR_DIR}") | ||
message("POPART_DIR is ${POPART_DIR}") | ||
|
||
if(EXISTS ${POPLAR_DIR}) | ||
list(APPEND CMAKE_PREFIX_PATH ${POPLAR_DIR}) | ||
set(ENABLE_POPLAR_CMD "source ${POPLAR_DIR}/enable.sh") | ||
find_package(poplar REQUIRED) | ||
include_directories("${POPLAR_DIR}/include") | ||
link_directories("${POPLAR_DIR}/lib") | ||
endif() | ||
if(NOT poplar_FOUND) | ||
message(FATAL_ERROR "You must provide a path to a Poplar install using -DPOPLAR_DIR=/path/to/popart/build/install") | ||
endif() | ||
|
||
if(EXISTS ${POPART_DIR}) | ||
list(APPEND CMAKE_PREFIX_PATH ${POPART_DIR}) | ||
set(ENABLE_POPART_CMD "source ${POPART_DIR}/enable.sh") | ||
find_package(popart REQUIRED COMPONENTS popart-only) | ||
include_directories("${POPART_DIR}/include") | ||
link_directories("${POPART_DIR}/lib") | ||
endif() | ||
if(NOT popart_FOUND) | ||
message(FATAL_ERROR "You must provide a path to a Popart build using -DPOPART_DIR=/path/to/popart/build") | ||
endif() | ||
add_definitions(-DONNX_NAMESPACE=onnx) | ||
add_custom_target(extern_poplar DEPENDS poplar popart-only) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
paddle/fluid/distributed/fleet_executor/amplifier_interceptor.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright (c) 2021 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 "paddle/fluid/distributed/fleet_executor/amplifier_interceptor.h" | ||
|
||
#include "paddle/fluid/distributed/fleet_executor/task_node.h" | ||
#include "paddle/fluid/framework/operator.h" | ||
|
||
namespace paddle { | ||
namespace distributed { | ||
|
||
AmplifierInterceptor::AmplifierInterceptor(int64_t interceptor_id, | ||
TaskNode* node) | ||
: ComputeInterceptor(interceptor_id, node) { | ||
run_per_steps_ = node->run_per_steps(); | ||
run_at_offset_ = node->run_at_offset(); | ||
reply_up_per_steps_ = node->reply_up_per_steps(); | ||
send_down_per_steps_ = node->send_down_per_steps(); | ||
} | ||
|
||
void AmplifierInterceptor::RunOps() { | ||
// run_per_steps_, run_at_offset_ | ||
// 4, 0 --> run at step 0, 4, 8, 12 | ||
// 4, 3 --> run at step 3, 7, 11, 15 | ||
if ((step_ % run_per_steps_) == run_at_offset_) { | ||
ComputeInterceptor::RunOps(); | ||
} | ||
} | ||
|
||
void AmplifierInterceptor::SendDataReadyToDownStream() { | ||
// run multi times, send ready one times to downstream, that is | ||
// input multi times, output one times | ||
if (step_ % send_down_per_steps_ == 0) { | ||
ComputeInterceptor::SendDataReadyToDownStream(); | ||
} | ||
} | ||
|
||
void AmplifierInterceptor::ReplyCompletedToUpStream() { | ||
// run multi times, reply one times to upstream, that is | ||
// input one times, output multi times | ||
if (step_ % reply_up_per_steps_ == 0) { | ||
ComputeInterceptor::ReplyCompletedToUpStream(); | ||
} | ||
} | ||
|
||
REGISTER_INTERCEPTOR(Amplifier, AmplifierInterceptor); | ||
|
||
} // namespace distributed | ||
} // namespace paddle |
Oops, something went wrong.
fbeab95
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🕵️ CI failures summary
🔍 PR: #37957 Commit ID: fbeab95 contains failed CI.
🔹 Failed: PR-CI-Windows-Inference
Unknown Failed