Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UFA非法地址访问(UFA illegal address access) of case1: paddle.vision.ops.nms #49993

Merged
merged 1 commit into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 12 additions & 0 deletions paddle/phi/kernels/cpu/nms_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@ void NMSKernel(const Context& dev_ctx,
const DenseTensor& boxes,
float threshold,
DenseTensor* output) {
PADDLE_ENFORCE_EQ(
boxes.dims().size(),
2,
phi::errors::InvalidArgument("The shape [%s] of boxes must be (N, 4).",
boxes.dims()));

PADDLE_ENFORCE_EQ(
boxes.dims()[1],
4,
phi::errors::InvalidArgument("The shape [%s] of boxes must be (N, 4).",
boxes.dims()));

int64_t num_boxes = boxes.dims()[0];
DenseTensor output_tmp;
output_tmp.Resize(phi::make_ddim({num_boxes}));
Expand Down
12 changes: 12 additions & 0 deletions paddle/phi/kernels/gpu/nms_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@ void NMSKernel(const Context& dev_ctx,
const DenseTensor& boxes,
float threshold,
DenseTensor* output) {
PADDLE_ENFORCE_EQ(
boxes.dims().size(),
2,
phi::errors::InvalidArgument("The shape [%s] of boxes must be (N, 4).",
boxes.dims()));

PADDLE_ENFORCE_EQ(
boxes.dims()[1],
4,
phi::errors::InvalidArgument("The shape [%s] of boxes must be (N, 4).",
boxes.dims()));

const int64_t num_boxes = boxes.dims()[0];
const auto blocks_per_line = CeilDivide(num_boxes, threadsPerBlock);
dim3 block(threadsPerBlock);
Expand Down