Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions paddle/phi/kernels/gpu/index_sample_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ __global__ void IndexSampleForward(const SampleIndexT* index,
ElementIndexT index_idx = index_j * index_length + index_i;
ElementIndexT in_idx = index_j * input_length + index_i;
SampleIndexT sample_idx = index[index_idx];
PADDLE_ENFORCE(sample_idx >= 0 && sample_idx < input_length,
"Variable value (index) of OP(index_sample) "
"expected >= 0 and < %ld, but got %ld. Please check input "
"value.",
input_length,
sample_idx);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在cuda kernel中添加这些检查是十分不合理的,会影响cuda warp的执行效率,报错时也会产生特别多的重复日志。这部分检查需要想办法转化为在launch cuda kernel之前在CPU侧完成

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, 改成 copy 到 cpu 上进行检查了

out_data[index_idx] = in_data[in_idx - index_i + sample_idx];
}
}
Expand Down
Loading