-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
… fix-multinomial-op
- Loading branch information
Showing
533 changed files
with
34,739 additions
and
6,024 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# 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 (NOT WITH_CINN) | ||
return() | ||
endif() | ||
|
||
# TODO(zhhsplendid): CINN has lots of warnings during early development. | ||
# They will be treated as errors under paddle. We set no-error now and we will | ||
# clean the code in the future. | ||
add_definitions(-w) | ||
|
||
###################################### | ||
# Build CINN from Git External Project | ||
###################################### | ||
include(ExternalProject) | ||
set(CINN_SOURCE_DIR ${THIRD_PARTY_PATH}/CINN) | ||
# TODO(zhhsplendid): Modify git tag after we have release tag | ||
set(CINN_GIT_TAG e422c01b7875301996a2baf67a14ba61b0e6192a) | ||
set(CINN_OPTIONAL_ARGS -DPY_VERSION=${PY_VERSION} -DWITH_CUDA=${WITH_GPU} -DWITH_CUDNN=${WITH_GPU} -DPUBLISH_LIBS=ON -DWITH_TESTING=ON) | ||
set(CINN_BUILD_COMMAND $(MAKE) cinnapi -j) | ||
ExternalProject_Add( | ||
external_cinn | ||
${EXTERNAL_PROJECT_LOG_ARGS} | ||
GIT_REPOSITORY "${GIT_URL}/PaddlePaddle/CINN.git" | ||
GIT_TAG ${CINN_GIT_TAG} | ||
PREFIX ${CINN_SOURCE_DIR} | ||
BUILD_COMMAND ${CINN_BUILD_COMMAND} | ||
INSTALL_COMMAND "" | ||
CMAKE_ARGS ${CINN_OPTIONAL_ARGS}) | ||
|
||
|
||
|
||
ExternalProject_Get_property(external_cinn BINARY_DIR) | ||
ExternalProject_Get_property(external_cinn SOURCE_DIR) | ||
set(CINN_BINARY_DIR ${BINARY_DIR}) | ||
set(CINN_SOURCE_DIR ${SOURCE_DIR}) | ||
|
||
message(STATUS "CINN BINARY_DIR: ${CINN_BINARY_DIR}") | ||
message(STATUS "CINN SOURCE_DIR: ${CINN_SOURCE_DIR}") | ||
|
||
|
||
###################################### | ||
# Add CINN's dependencies header files | ||
###################################### | ||
|
||
# Add absl | ||
set(ABSL_INCLUDE_DIR "${CINN_BINARY_DIR}/dist/third_party/absl/include") | ||
include_directories(${ABSL_INCLUDE_DIR}) | ||
|
||
# Add isl | ||
set(ISL_INCLUDE_DIR "${CINN_BINARY_DIR}/dist/third_party/isl/include") | ||
include_directories(${ISL_INCLUDE_DIR}) | ||
|
||
# Add LLVM | ||
set(LLVM_INCLUDE_DIR "${CINN_BINARY_DIR}/dist/third_party/llvm/include") | ||
include_directories(${LLVM_INCLUDE_DIR}) | ||
|
||
###################################################### | ||
# Put external_cinn and dependencies together as a lib | ||
###################################################### | ||
|
||
set(CINN_LIB_NAME "libcinnapi.so") | ||
set(CINN_LIB_LOCATION "${CINN_BINARY_DIR}/dist/cinn/lib") | ||
set(CINN_INCLUDE_DIR "${CINN_BINARY_DIR}/dist/cinn/include") | ||
|
||
add_library(cinn SHARED IMPORTED GLOBAL) | ||
set_target_properties(cinn PROPERTIES IMPORTED_LOCATION "${CINN_LIB_LOCATION}/${CINN_LIB_NAME}") | ||
include_directories(${CINN_INCLUDE_DIR}) | ||
add_dependencies(cinn external_cinn) | ||
|
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,51 @@ | ||
# 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(ExternalProject) | ||
|
||
SET(UTF8PROC_PREFIX_DIR ${THIRD_PARTY_PATH}/utf8proc) | ||
SET(UTF8PROC_INSTALL_DIR ${THIRD_PARTY_PATH}/install/utf8proc) | ||
# As we add extra features for utf8proc, we use the non-official repo | ||
SET(UTF8PROC_REPOSITORY ${GIT_URL}/JuliaStrings/utf8proc.git) | ||
SET(UTF8PROC_TAG v2.6.1) | ||
|
||
IF(WIN32) | ||
SET(UTF8PROC_LIBRARIES "${UTF8PROC_INSTALL_DIR}/lib/utf8proc_static.lib") | ||
add_definitions(-DUTF8PROC_STATIC) | ||
ELSE(WIN32) | ||
SET(UTF8PROC_LIBRARIES "${UTF8PROC_INSTALL_DIR}/lib/libutf8proc.a") | ||
ENDIF(WIN32) | ||
|
||
INCLUDE_DIRECTORIES(${UTF8PROC_INSTALL_DIR}/include) | ||
|
||
ExternalProject_Add( | ||
extern_utf8proc | ||
${EXTERNAL_PROJECT_LOG_ARGS} | ||
${SHALLOW_CLONE} | ||
GIT_REPOSITORY ${UTF8PROC_REPOSITORY} | ||
GIT_TAG ${UTF8PROC_TAG} | ||
PREFIX ${UTF8PROC_PREFIX_DIR} | ||
UPDATE_COMMAND "" | ||
CMAKE_ARGS -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} | ||
-DBUILD_SHARED=ON | ||
-DBUILD_STATIC=ON | ||
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} | ||
-DCMAKE_INSTALL_PREFIX:PATH=${UTF8PROC_INSTALL_DIR} | ||
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} | ||
BUILD_BYPRODUCTS ${UTF8PROC_LIBRARIES} | ||
) | ||
|
||
ADD_LIBRARY(utf8proc STATIC IMPORTED GLOBAL) | ||
SET_PROPERTY(TARGET utf8proc PROPERTY IMPORTED_LOCATION ${UTF8PROC_LIBRARIES}) | ||
ADD_DEPENDENCIES(utf8proc extern_utf8proc) |
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,65 @@ | ||
// 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. | ||
|
||
#pragma once | ||
#include <assert.h> | ||
#include <time.h> | ||
#include <atomic> | ||
#include <random> | ||
|
||
namespace paddle { | ||
namespace distributed { | ||
|
||
// Get time in seconds. | ||
inline double current_realtime() { | ||
struct timespec tp; | ||
clock_gettime(CLOCK_REALTIME, &tp); | ||
return tp.tv_sec + tp.tv_nsec * 1e-9; | ||
} | ||
|
||
inline std::default_random_engine& local_random_engine() { | ||
struct engine_wrapper_t { | ||
std::default_random_engine engine; | ||
engine_wrapper_t() { | ||
static std::atomic<unsigned long> x(0); // NOLINT | ||
std::seed_seq sseq = { | ||
x++, x++, x++, (unsigned long)(current_realtime() * 1000)}; // NOLINT | ||
engine.seed(sseq); | ||
} | ||
}; | ||
thread_local engine_wrapper_t r; | ||
return r.engine; | ||
} | ||
|
||
template <class T = double> | ||
std::uniform_real_distribution<T>& local_uniform_real_distribution() { | ||
thread_local std::uniform_real_distribution<T> distr; | ||
assert(distr.a() == 0.0 && distr.b() == 1.0); | ||
return distr; | ||
} | ||
|
||
template <class T = double> | ||
T uniform_real() { | ||
return local_uniform_real_distribution<T>()(local_random_engine()); | ||
} | ||
|
||
template <class T = double> | ||
T uniform_real(T a, T b) { | ||
if (a == b) { | ||
return a; | ||
} | ||
return (T)(a + uniform_real<T>() * (b - a)); | ||
} | ||
} // namespace distributed | ||
} // namespace paddle |
Oops, something went wrong.
16c8194
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.
✅Congratulation! Your pull request passed all required CI. You could ask reviewer(s) to approve and merge. 🎉