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 case3: paddle.crop #49994

Merged
merged 3 commits into from
Feb 1, 2023
Merged
Changes from 2 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
10 changes: 10 additions & 0 deletions paddle/phi/kernels/impl/crop_kernel_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ void CropTensorFunction(const Context& dev_ctx,
out->Resize(out_dims);
dev_ctx.template Alloc<T>(out);
for (size_t i = 0; i < offsets_vec.size(); ++i) {
PADDLE_ENFORCE_GE(
offsets_vec[i],
0,
errors::InvalidArgument("The offsets (%d) of the %uth elements of"
" Op(crop_tensor) "
"should be greater than or "
"equal to 0.",
offsets_vec[i],
i));

PADDLE_ENFORCE_LE(offsets_vec[i] + shape_vec[i],
x_dims[i],
errors::InvalidArgument(
Expand Down