Skip to content

Commit dfec7a0

Browse files
committed
Merge From Develop
2 parents 16e6bf1 + fe81306 commit dfec7a0

File tree

418 files changed

+28313
-8643
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

418 files changed

+28313
-8643
lines changed

cmake/external/boost.cmake

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ set(BOOST_PROJECT "extern_boost")
2323
# checked that the devtools package of CentOS 6 installs boost 1.41.0.
2424
# So we use 1.41.0 here.
2525
set(BOOST_VER "1.41.0")
26-
set(BOOST_TAR "boost_1_41_0" CACHE STRING "" FORCE)
26+
# boost_1_41_0_2021_10.tar.gz is almost the same with boost_1_41_0.tar.gz,
27+
# except in visualc.hpp i comment a warning of "unknown compiler version",
28+
# so if you need to change boost, you may need to block the warning similarly.
29+
set(BOOST_TAR "boost_1_41_0_2021_10" CACHE STRING "" FORCE)
2730
set(BOOST_URL "http://paddlepaddledeps.bj.bcebos.com/${BOOST_TAR}.tar.gz" CACHE STRING "" FORCE)
2831

2932
MESSAGE(STATUS "BOOST_VERSION: ${BOOST_VER}, BOOST_URL: ${BOOST_URL}")
@@ -46,7 +49,7 @@ ExternalProject_Add(
4649
${BOOST_PROJECT}
4750
${EXTERNAL_PROJECT_LOG_ARGS}
4851
"${BOOST_DOWNLOAD_CMD}"
49-
URL_MD5 f891e8c2c9424f0565f0129ad9ab4aff
52+
URL_MD5 51be7cc203628dc0848e97eee32d79e3
5053
PREFIX ${BOOST_PREFIX_DIR}
5154
DOWNLOAD_DIR ${BOOST_SOURCE_DIR}
5255
SOURCE_DIR ${BOOST_SOURCE_DIR}

cmake/external/cinn.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ add_definitions(-w)
2727
include(ExternalProject)
2828
set(CINN_SOURCE_DIR ${THIRD_PARTY_PATH}/CINN)
2929
# TODO(zhhsplendid): Modify git tag after we have release tag
30-
set(CINN_GIT_TAG e422c01b7875301996a2baf67a14ba61b0e6192a)
30+
set(CINN_GIT_TAG 2122413fc74f4020ff4397b54488a793529d581b)
3131
set(CINN_OPTIONAL_ARGS -DPY_VERSION=${PY_VERSION} -DWITH_CUDA=${WITH_GPU} -DWITH_CUDNN=${WITH_GPU} -DPUBLISH_LIBS=ON -DWITH_TESTING=ON)
3232
set(CINN_BUILD_COMMAND $(MAKE) cinnapi -j)
3333
ExternalProject_Add(

cmake/external/xpu.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ ELSE ()
3535
ENDIF()
3636

3737
SET(XPU_BASE_URL_WITHOUT_DATE "https://baidu-kunlun-product.cdn.bcebos.com/KL-SDK/klsdk-dev")
38-
SET(XPU_BASE_URL "${XPU_BASE_URL_WITHOUT_DATE}/20210921")
38+
SET(XPU_BASE_URL "${XPU_BASE_URL_WITHOUT_DATE}/20211020")
3939
SET(XPU_XRE_URL "${XPU_BASE_URL}/${XPU_XRE_DIR_NAME}.tar.gz" CACHE STRING "" FORCE)
4040
SET(XPU_XDNN_URL "${XPU_BASE_URL}/${XPU_XDNN_DIR_NAME}.tar.gz" CACHE STRING "" FORCE)
4141
SET(XPU_XCCL_URL "${XPU_BASE_URL_WITHOUT_DATE}/20210623/${XPU_XCCL_DIR_NAME}.tar.gz" CACHE STRING "" FORCE)

cmake/operators.cmake

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ function(op_library TARGET)
185185
list(REMOVE_ITEM hip_srcs "cholesky_op.cu")
186186
list(REMOVE_ITEM hip_srcs "matrix_rank_op.cu")
187187
list(REMOVE_ITEM hip_srcs "svd_op.cu")
188+
list(REMOVE_ITEM hip_srcs "eigvalsh_op.cu")
188189
list(REMOVE_ITEM hip_srcs "qr_op.cu")
189190
list(REMOVE_ITEM hip_srcs "eigh_op.cu")
190191
list(REMOVE_ITEM hip_srcs "multinomial_op.cu")
@@ -217,7 +218,8 @@ function(op_library TARGET)
217218
"fusion_transpose_flatten_concat_op" "fusion_conv_inception_op"
218219
"sync_batch_norm_op" "sparse_attention_op" "dgc_op" "fused_fc_elementwise_layernorm_op"
219220
"skip_layernorm_op" "multihead_matmul_op" "fusion_group_op" "fused_bn_activation_op" "fused_embedding_eltwise_layernorm_op" "fusion_gru_op" "fusion_lstm_op"
220-
"fused_bn_add_activation_op" "fused_attention_op" "resnet_unit_op")
221+
"fused_bn_add_activation_op" "fused_attention_op" "resnet_unit_op" "fused_feedforward_op")
222+
221223
if ("${TARGET}" STREQUAL "${manual_pybind_op}")
222224
set(pybind_flag 1)
223225
endif()
@@ -298,7 +300,7 @@ function(op_library TARGET)
298300
file(APPEND ${pybind_file} "USE_OP_DEVICE_KERNEL(${TARGET}, CUDNN);\n")
299301
endif()
300302

301-
if (WITH_XPU AND ${xpu_cc_srcs_len} GREATER 0)
303+
if (WITH_XPU AND ${pybind_flag} EQUAL 0 AND ${xpu_cc_srcs_len} GREATER 0)
302304
file(APPEND ${pybind_file} "USE_OP_DEVICE_KERNEL(${TARGET}, XPU);\n")
303305
endif()
304306

cmake/third_party.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ endif (WITH_LITE)
363363
if (WITH_CINN)
364364
message(STATUS "Compile Paddle with CINN.")
365365
include(external/cinn)
366+
add_definitions(-DPADDLE_WITH_CINN)
366367
endif (WITH_CINN)
367368

368369
if (WITH_CRYPTO)

paddle/fluid/distributed/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
1111
"${DISTRIBUTE_COMPILE_FLAGS} -faligned-new")
1212
endif()
1313

14+
add_subdirectory(common)
1415
add_subdirectory(service)
1516
add_subdirectory(table)
1617
add_subdirectory(test)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
cc_library(afs_wrapper SRCS afs_warpper.cc DEPS fs ps_framework_proto)
3+
4+
#set_property(GLOBAL PROPERTY COMMON_DEPS afs_warpper)
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
// Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include "paddle/fluid/distributed/common/afs_warpper.h"
16+
#include "paddle/fluid/framework/io/fs.h"
17+
18+
namespace paddle {
19+
namespace distributed {
20+
// AfsClient impl
21+
int AfsClient::initialize(const FsClientParameter& fs_client_param) {
22+
// temporarily implemented with hdfs-client
23+
return initialize(fs_client_param.hadoop_bin(), fs_client_param.uri(),
24+
fs_client_param.user(), fs_client_param.passwd(),
25+
fs_client_param.buffer_size());
26+
}
27+
int AfsClient::initialize(const std::string& hadoop_bin, const std::string& uri,
28+
const std::string& user, const std::string& passwd,
29+
int buffer_size_param) {
30+
return initialize(hadoop_bin, uri, paddle::string::format_string(
31+
"%s,%s", user.c_str(), passwd.c_str()),
32+
buffer_size_param);
33+
}
34+
int AfsClient::initialize(const std::string& hadoop_bin, const std::string& uri,
35+
const std::string& ugi, int buffer_size_param) {
36+
// temporarily implemented with hdfs-client
37+
size_t buffer_size = 1L << 25; // 32MB
38+
if (buffer_size_param > static_cast<int>(buffer_size)) {
39+
buffer_size = buffer_size_param;
40+
}
41+
paddle::framework::hdfs_set_buffer_size(buffer_size);
42+
paddle::framework::hdfs_set_command(paddle::string::format_string(
43+
"2>>./hdfs_err.log %s fs -Dfs.default.name=%s -Dhadoop.job.ugi=%s "
44+
"-Ddfs.client.block.write.retries=15 -Ddfs.rpc.timeout=300000",
45+
hadoop_bin.c_str(), uri.c_str(), ugi.c_str()));
46+
return 0;
47+
}
48+
49+
// open file in 'w' or 'r'
50+
std::shared_ptr<FsReadChannel> AfsClient::open_r(const FsChannelConfig& config,
51+
uint32_t buffer_size,
52+
int* err_no) {
53+
std::shared_ptr<FsReadChannel> channel =
54+
std::make_shared<FsReadChannel>(buffer_size);
55+
std::shared_ptr<FILE> fp =
56+
paddle::framework::fs_open_read(config.path, err_no, config.deconverter);
57+
channel->open(fp, config);
58+
return channel;
59+
}
60+
std::shared_ptr<FsWriteChannel> AfsClient::open_w(const FsChannelConfig& config,
61+
uint32_t buffer_size,
62+
int* err_no) {
63+
std::shared_ptr<FsWriteChannel> channel =
64+
std::make_shared<FsWriteChannel>(buffer_size);
65+
std::shared_ptr<FILE> fp =
66+
paddle::framework::fs_open_write(config.path, err_no, config.converter);
67+
channel->open(fp, config);
68+
return channel;
69+
}
70+
71+
// remove file in path, path maybe a reg, such as 'part-000-*'
72+
void AfsClient::remove(const std::string& path) {
73+
return paddle::framework::fs_remove(path);
74+
}
75+
void AfsClient::remove_dir(const std::string& dir) {
76+
return paddle::framework::fs_remove(dir);
77+
}
78+
79+
// list files in path, path maybe a dir with reg
80+
std::vector<std::string> AfsClient::list(const std::string& path) {
81+
return paddle::framework::fs_list(path);
82+
}
83+
84+
// exist or not
85+
bool AfsClient::exist(const std::string& dir) {
86+
return paddle::framework::fs_exists(dir);
87+
}
88+
} // namespace distributed
89+
} // namespace paddle
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
// Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#pragma once
16+
17+
#include <functional>
18+
#include <iostream>
19+
#include <memory>
20+
#include <string>
21+
#include <vector>
22+
#include "paddle/fluid/distributed/ps.pb.h"
23+
#include "paddle/fluid/string/string_helper.h"
24+
25+
namespace paddle {
26+
namespace distributed {
27+
struct FsDataConverter {
28+
std::string converter;
29+
std::string deconverter;
30+
};
31+
32+
struct FsChannelConfig {
33+
std::string path; // path of file
34+
std::string converter; // data converter
35+
std::string deconverter;
36+
};
37+
38+
class FsReadChannel {
39+
public:
40+
FsReadChannel() : _buffer_size(0) {}
41+
explicit FsReadChannel(uint32_t buffer_size) : _buffer_size(buffer_size) {}
42+
virtual ~FsReadChannel() {}
43+
FsReadChannel(FsReadChannel&&) = delete;
44+
FsReadChannel(const FsReadChannel&) = delete;
45+
int open(std::shared_ptr<FILE> fp, const FsChannelConfig& config) {
46+
_file = fp;
47+
return 0;
48+
}
49+
inline int close() {
50+
_file.reset();
51+
return 0;
52+
}
53+
54+
inline uint32_t read_line(std::string& line_data) { // NOLINT
55+
line_data.clear();
56+
char buffer = '\0';
57+
size_t read_count = 0;
58+
while (1 == fread(&buffer, 1, 1, _file.get()) && buffer != '\n') {
59+
++read_count;
60+
line_data.append(&buffer, 1);
61+
}
62+
if (read_count == 0 && buffer != '\n') {
63+
return -1;
64+
}
65+
return 0;
66+
}
67+
68+
private:
69+
uint32_t _buffer_size;
70+
FsChannelConfig _config;
71+
std::shared_ptr<FILE> _file;
72+
};
73+
class FsWriteChannel {
74+
public:
75+
FsWriteChannel() : _buffer_size(0) {}
76+
explicit FsWriteChannel(uint32_t buffer_size) : _buffer_size(buffer_size) {}
77+
virtual ~FsWriteChannel() {}
78+
FsWriteChannel(FsWriteChannel&&) = delete;
79+
FsWriteChannel(const FsWriteChannel&) = delete;
80+
81+
int open(std::shared_ptr<FILE> fp, const FsChannelConfig& config) {
82+
_file = fp;
83+
84+
// the buffer has set in fs.cc
85+
// if (_buffer_size != 0) {
86+
// _buffer = std::shared_ptr<char>(new char[_buffer_size]);
87+
88+
// CHECK(0 == setvbuf(&*_file, _buffer.get(), _IOFBF, _buffer_size));
89+
//}
90+
return 0;
91+
}
92+
93+
inline void flush() { return; }
94+
95+
inline int close() {
96+
flush();
97+
_file.reset();
98+
return 0;
99+
}
100+
101+
inline uint32_t write_line(const char* data, uint32_t size) {
102+
size_t write_count = fwrite_unlocked(data, 1, size, _file.get());
103+
if (write_count != size) {
104+
return -1;
105+
}
106+
write_count = fwrite_unlocked("\n", 1, 1, _file.get());
107+
if (write_count != 1) {
108+
return -1;
109+
}
110+
return 0;
111+
}
112+
inline uint32_t write_line(const std::string& data) {
113+
return write_line(data.c_str(), data.size());
114+
}
115+
116+
private:
117+
uint32_t _buffer_size;
118+
FsChannelConfig _config;
119+
std::shared_ptr<FILE> _file;
120+
std::shared_ptr<char> _buffer;
121+
};
122+
123+
class AfsClient {
124+
public:
125+
AfsClient() {}
126+
virtual ~AfsClient() {}
127+
AfsClient(AfsClient&&) = delete;
128+
AfsClient(const AfsClient&) = delete;
129+
130+
int initialize(const FsClientParameter& fs_client_param);
131+
int initialize(const std::string& hadoop_bin, const std::string& uri,
132+
const std::string& user, const std::string& passwd,
133+
int buffer_size_param = (1L << 25));
134+
int initialize(const std::string& hadoop_bin, const std::string& uri,
135+
const std::string& ugi, int buffer_size_param = (1L << 25));
136+
137+
// open file in 'w' or 'r'
138+
std::shared_ptr<FsReadChannel> open_r(const FsChannelConfig& config,
139+
uint32_t buffer_size = 0,
140+
int* err_no = nullptr);
141+
std::shared_ptr<FsWriteChannel> open_w(const FsChannelConfig& config,
142+
uint32_t buffer_size = 0,
143+
int* err_no = nullptr);
144+
145+
// remove file in path, path maybe a reg, such as 'part-000-*'
146+
void remove(const std::string& path);
147+
void remove_dir(const std::string& dir);
148+
149+
// list files in path, path maybe a dir with reg
150+
std::vector<std::string> list(const std::string& path);
151+
152+
// exist or not
153+
bool exist(const std::string& dir);
154+
};
155+
} // namespace distributed
156+
} // namespace paddle

0 commit comments

Comments
 (0)