Skip to content

Commit

Permalink
fixed 4 error message. (#66832)
Browse files Browse the repository at this point in the history
  • Loading branch information
Whsjrczr authored Aug 1, 2024
1 parent 2dfdf06 commit 7e05766
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
10 changes: 9 additions & 1 deletion paddle/fluid/distributed/common/chunk_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@ template <class T>
class ChunkAllocator {
public:
explicit ChunkAllocator(size_t chunk_size = 64) {
CHECK(sizeof(Node) == std::max(sizeof(void*), sizeof(T)));
PADDLE_ENFORCE_EQ(
sizeof(Node),
std::max(sizeof(void*), sizeof(T)),
phi::errors::InvalidArgument(
"The size of Node is invalid. Expected sizeof(Node) == "
"max(sizeof(void*), sizeif(T)).\nBut recieved sizeof(Node) = %u "
"and max(sizeof(void*), sizeif(T)) = %u.",
sizeof(Node),
std::max(sizeof(void*), sizeof(T))));
_chunk_size = chunk_size;
_chunks = NULL;
_free_nodes = NULL;
Expand Down
14 changes: 11 additions & 3 deletions paddle/fluid/distributed/ps/service/brpc_ps_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1915,9 +1915,17 @@ std::future<int32_t> BrpcPsClient::PushDense(const Region *regions,
uint32_t pos = 0;
for (size_t i = 0; i < region_num; ++i) {
uint32_t data_num = regions[i].size / sizeof(float);
CHECK(pos + data_num <= data_size)
<< "invalid dense size, cur pos[" << pos << "]"
<< " data_num[" << data_num << "] size[" << data_size << "]";
PADDLE_ENFORCE_LE((pos + data_num),
data_size,
phi::errors::InvalidArgument(
"Invalid dense size."
"Expect the sum of current position and data number "
"to be equal to or smaller than the size."
"But recieved current position = %lu, data number = "
"%lu, size = %lu.",
pos,
data_num,
data_size));
const float *region_data = (const float *)(regions[i].data);
memcpy(data + pos, region_data, regions[i].size);
pos += data_num;
Expand Down
10 changes: 8 additions & 2 deletions paddle/fluid/distributed/ps/service/brpc_ps_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,14 @@ class DownpourPsClientService : public PsService {
::google::protobuf::Closure *done) {
brpc::ClosureGuard done_guard(done);
size_t client_id = request->client_id();
CHECK(_client->_client_id == client_id)
<< "request client id not matched self";
PADDLE_ENFORCE_EQ(
client_id,
(_client->_client_id),
phi::errors::PreconditionNotMet(
"Wrong request client's id. Expect to match self. But recieved "
"request client's id = %lu and self = %lu.",
client_id,
(_client->_client_id)));
_fl_strategy = request->str_params();
_is_fl_strategy_ready = true;
response->set_err_code(0);
Expand Down
3 changes: 2 additions & 1 deletion paddle/fluid/distributed/ps/service/ps_service/service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ int PSCore::InitServer(
_server_ptr = std::shared_ptr<::paddle::distributed::PSServer>(
::paddle::distributed::PSServerFactory::Create(_ps_param));
ret = _server_ptr->Configure(_ps_param, _ps_env, index, server_sub_program);
CHECK(ret == 0) << "failed to configure server";
PADDLE_ENFORCE_EQ(
ret, 0UL, phi::errors::PreconditionNotMet("Failed to configure server."));
return ret;
}

Expand Down

0 comments on commit 7e05766

Please sign in to comment.