未验证 提交 51cae7f7 编写于 作者: J JingZhuangzhuang 提交者: GitHub

fix_paddle_numel_check (#41607)

* fix_paddle_numel_check

* fix_paddle_numel_check
上级 bc01242b
...@@ -99,10 +99,11 @@ struct GpuLaunchConfig { ...@@ -99,10 +99,11 @@ struct GpuLaunchConfig {
inline GpuLaunchConfig GetGpuLaunchConfig1D( inline GpuLaunchConfig GetGpuLaunchConfig1D(
const platform::CUDADeviceContext& context, int64_t numel, const platform::CUDADeviceContext& context, int64_t numel,
int vec_size = 1) { int vec_size = 1) {
PADDLE_ENFORCE_GT(numel, 0, platform::errors::InvalidArgument( PADDLE_ENFORCE_GE(numel, 0,
"element quantity should be greater than 0," platform::errors::InvalidArgument(
" but received value is: %d.", "element quantity should be greater than or equal 0,"
numel)); " but received value is: %d.",
numel));
// Get compute_capability // Get compute_capability
const int capability = context.GetComputeCapability(); const int capability = context.GetComputeCapability();
/* If thread number per block is 64/128/256/512, cuda performs better.*/ /* If thread number per block is 64/128/256/512, cuda performs better.*/
......
...@@ -101,12 +101,12 @@ struct GpuLaunchConfig { ...@@ -101,12 +101,12 @@ struct GpuLaunchConfig {
inline GpuLaunchConfig GetGpuLaunchConfig1D(const phi::GPUContext& context, inline GpuLaunchConfig GetGpuLaunchConfig1D(const phi::GPUContext& context,
int64_t numel, int64_t numel,
int vec_size = 1) { int vec_size = 1) {
PADDLE_ENFORCE_GT( PADDLE_ENFORCE_GE(numel,
numel, 0,
0, phi::errors::InvalidArgument(
phi::errors::InvalidArgument("element quantity should be greater than 0," "element quantity should be greater than or equal 0,"
" but received value is: %d.", " but received value is: %d.",
numel)); numel));
// Get compute_capability // Get compute_capability
const int capability = context.GetComputeCapability(); const int capability = context.GetComputeCapability();
/* If thread number per block is 64/128/256/512, cuda performs better.*/ /* If thread number per block is 64/128/256/512, cuda performs better.*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册