未验证 提交 6a1ddd61 编写于 作者: J JingZhuangzhuang 提交者: GitHub

[cherry pick]fix paddle tensor numel check (#41665)

上级 43ee4a33
...@@ -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 to 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 to 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.
先完成此消息的编辑!
想要评论请 注册