Skip to content

Commit

Permalink
fixed error messages in 4 files (#66872)
Browse files Browse the repository at this point in the history
  • Loading branch information
Whsjrczr authored Aug 1, 2024
1 parent 1a1404f commit 2dfdf06
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
6 changes: 4 additions & 2 deletions paddle/fluid/framework/fleet/fleet_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,10 @@ class FleetWrapper {
void Revert();

std::string GetDistDesc() const {
CHECK(is_initialized_ == true)
<< "fleetwrapper should be initialized first!!!";
PADDLE_ENFORCE_EQ(is_initialized_,
true,
phi::errors::PermissionDenied(
"FleetWrapper should be initialized first!!!"));
return dist_desc_;
}

Expand Down
17 changes: 15 additions & 2 deletions paddle/fluid/framework/fleet/heter_ps/heter_comm.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,21 @@ class HeterComm {
}
void check(const size_t& len,
const size_t& value_bytes = sizeof(GradType)) {
CHECK_GE(all_keys_mem->size(), len);
CHECK_GE(all_grads_mem->size(), len * value_bytes);
PADDLE_ENFORCE_GE(all_keys_mem->size(),
len,
phi::errors::InvalidArgument(
"Invalid size of all keys memory. Expect to be "
"equal to length %d. But recieved %d.",
len,
all_keys_mem->size()));
PADDLE_ENFORCE_GE(
all_grads_mem->size(),
len * value_bytes,
phi::errors::InvalidArgument(
"Invalid size of all gradients memory. Expect to be equal to "
"length * value bytes %d. But recieved %d.",
len * value_bytes,
all_grads_mem->size()));
}
void init_pull(const size_t& len) {
pull_res.h_recv_fea_num = len;
Expand Down
8 changes: 7 additions & 1 deletion paddle/fluid/framework/fleet/heter_ps/heter_resource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,13 @@ GpuRDMAChecker *GpuRDMAChecker::get(int device_num) {
g_checker = std::make_shared<GpuRDMAChecker>(device_num);
}
// check gpu num
CHECK(device_num == g_checker->device_num());
PADDLE_ENFORCE_EQ(
device_num,
g_checker->device_num(),
phi::errors::InvalidArgument(
"Invalid number of device. Should be %d. But received %d.",
device_num,
g_checker->device_num()));
return g_checker.get();
}
GpuRDMAChecker::GpuRDMAChecker(int device_num) {
Expand Down
5 changes: 4 additions & 1 deletion paddle/fluid/framework/io/fs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ static std::shared_ptr<FILE> fs_open_internal(const std::string& path,
setvbuf(&*fp, buffer, _IOFBF, buffer_size),
phi::errors::InvalidArgument("Set Buffer Failed, Please Check!"));
fp = {&*fp, [fp, buffer](FILE*) mutable { // NOLINT
CHECK(fp.unique()); // NOLINT
PADDLE_ENFORCE_EQ(fp.unique(),
true,
phi::errors::PermissionDenied(
"File Pointer is not unique!!!")); // NOLINT
fp = nullptr;
delete[] buffer;
}};
Expand Down

0 comments on commit 2dfdf06

Please sign in to comment.