diff --git a/paddle/fluid/platform/enforce.h b/paddle/fluid/platform/enforce.h index cad60275a2e255f1158278bbdc8d15389ad00190..81b5359b40589d898bda0dfa71afb6f51385354b 100644 --- a/paddle/fluid/platform/enforce.h +++ b/paddle/fluid/platform/enforce.h @@ -263,7 +263,7 @@ inline void throw_on_error(T e) { * PADDLE_ENFORCE_EQ(a, b); * * will raise an expression described as follows: - * "Data check failed. Expected input a == b, but received a(1) != b(2)." + * "Enforce failed. Expected input a == b, but received a(1) != b(2)." * with detailed stack information. * * extra messages is also supported, for example: @@ -293,7 +293,7 @@ inline void throw_on_error(T e) { #define __PADDLE_BINARY_COMPARE(__VAL0, __VAL1, __CMP, __INV_CMP, ...) \ do { \ if (UNLIKELY(!((__VAL0)__CMP(__VAL1)))) { \ - PADDLE_THROW("Data check failed. Expected %s " #__CMP \ + PADDLE_THROW("Enforce failed. Expected %s " #__CMP \ " %s, but received %s:%s " #__INV_CMP " %s:%s.\n%s", \ #__VAL0, #__VAL1, #__VAL0, \ paddle::string::to_string(__VAL0), #__VAL1, \ diff --git a/paddle/fluid/platform/enforce_test.cc b/paddle/fluid/platform/enforce_test.cc index 8dcf39fdaaa9571d4345d5b57cc4d839904c7c11..d52182965552e9ec945cb7d0b421d8addcb758e9 100644 --- a/paddle/fluid/platform/enforce_test.cc +++ b/paddle/fluid/platform/enforce_test.cc @@ -56,7 +56,7 @@ TEST(ENFORCE_EQ, NO_EXTRA_MSG_FAIL) { caught_exception = true; HasPrefix( StringPiece(error.what()), - "Data check failed. Expected a == 1 + 3, but received a:2 != 1 + 3:4."); + "Enforce failed. Expected a == 1 + 3, but received a:2 != 1 + 3:4."); } EXPECT_TRUE(caught_exception); } @@ -69,7 +69,7 @@ TEST(ENFORCE_EQ, EXTRA_MSG_FAIL) { } catch (paddle::platform::EnforceNotMet error) { caught_exception = true; HasPrefix(StringPiece(error.what()), - "Data check failed. Expected a == 1 + 3, but received a:2 != 1 + " + "Enforce failed. Expected a == 1 + 3, but received a:2 != 1 + " "3:4.\ntheir size not match"); } EXPECT_TRUE(caught_exception); @@ -89,7 +89,7 @@ TEST(ENFORCE_NE, FAIL) { caught_exception = true; EXPECT_TRUE(HasPrefix( StringPiece(error.what()), - "Data check failed. Expected 1.0 != 1UL, but received 1.0:1 == 1UL:1.")) + "Enforce failed. Expected 1.0 != 1UL, but received 1.0:1 == 1UL:1.")) << error.what() << " does not have expected prefix"; } EXPECT_TRUE(caught_exception); @@ -104,7 +104,7 @@ TEST(ENFORCE_GT, FAIL) { caught_exception = true; EXPECT_TRUE(HasPrefix( StringPiece(error.what()), - "Data check failed. Expected 1 > 2UL, but received 1:1 <= 2UL:2.")); + "Enforce failed. Expected 1 > 2UL, but received 1:1 <= 2UL:2.")); } EXPECT_TRUE(caught_exception); } @@ -123,7 +123,7 @@ TEST(ENFORCE_GE, FAIL) { caught_exception = true; EXPECT_TRUE(HasPrefix( StringPiece(error.what()), - "Data check failed. Expected 1 >= 2UL, but received 1:1 < 2UL:2.")); + "Enforce failed. Expected 1 >= 2UL, but received 1:1 < 2UL:2.")); } EXPECT_TRUE(caught_exception); } @@ -143,7 +143,7 @@ TEST(ENFORCE_LE, FAIL) { caught_exception = true; EXPECT_TRUE(HasPrefix( StringPiece(error.what()), - "Data check failed. Expected 1 > 2UL, but received 1:1 <= 2UL:2.")); + "Enforce failed. Expected 1 > 2UL, but received 1:1 <= 2UL:2.")); } EXPECT_TRUE(caught_exception); } @@ -160,7 +160,7 @@ TEST(ENFORCE_LT, FAIL) { } catch (paddle::platform::EnforceNotMet error) { caught_exception = true; EXPECT_TRUE(HasPrefix(StringPiece(error.what()), - "Data check failed. Expected 1UL < 0.12, but " + "Enforce failed. Expected 1UL < 0.12, but " "received 1UL:1 >= 0.12:0.12.")); } EXPECT_TRUE(caught_exception); diff --git a/paddle/fluid/platform/gpu_info.cc b/paddle/fluid/platform/gpu_info.cc index f9e2e8c69d5884a8607b25366b1419baafa9c3a8..126636d879213b1c8f242db8fbdf6a358a1d2da9 100644 --- a/paddle/fluid/platform/gpu_info.cc +++ b/paddle/fluid/platform/gpu_info.cc @@ -100,25 +100,26 @@ size_t GpuMinChunkSize() { size_t GpuMaxChunkSize() { size_t total = 0; - size_t available_memory = 0; + size_t available = 0; - GpuMemoryUsage(&available_memory, &total); - VLOG(10) << "GPU Usage " << available_memory / 1024 / 1024 << "M/" + GpuMemoryUsage(&available, &total); + VLOG(10) << "GPU Usage " << available / 1024 / 1024 << "M/" << total / 1024 / 1024 << "M"; size_t reserving = static_cast(0.05 * total); // If available less than minimum chunk size, no usable memory exists. - available_memory = std::min( - std::max(available_memory, GpuMinChunkSize()) - GpuMinChunkSize(), - total - reserving); + available = + std::min(std::max(available, GpuMinChunkSize()) - GpuMinChunkSize(), + total - reserving); // Reserving the rest memory for page tables, etc. - size_t allocating_memory = static_cast( - FLAGS_fraction_of_gpu_memory_to_use * (total - reserving)); + size_t allocating = static_cast(FLAGS_fraction_of_gpu_memory_to_use * + (total - reserving)); - PADDLE_ENFORCE_LE(allocating_memory, available_memory); + PADDLE_ENFORCE_LE(allocating, available, + "Insufficient GPU memory to allocation."); - return allocating_memory; + return allocating; } void GpuMemcpyAsync(void *dst, const void *src, size_t count,