-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
[NPU] Support NPU kernel for nearest_interp and nearest_interp_grad op #34881
[NPU] Support NPU kernel for nearest_interp and nearest_interp_grad op #34881
Conversation
✅ This PR's description meets the template requirements! |
Thanks for your contribution! |
… add_npu_op_nearest_interp
namespace ops = paddle::operators; | ||
REGISTER_OP_NPU_KERNEL(nearest_interp, ops::InterpolateNPUKernel<float>, | ||
ops::InterpolateNPUKernel<uint8_t>); | ||
REGISTER_OP_NPU_KERNEL(nearest_interp_grad, ops::InterpolateNPUKernel<float>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
REGISTER_OP_NPU_KERNEL(nearest_interp_grad, ops::InterpolateNPUKernel<float>, | |
REGISTER_OP_NPU_KERNEL(nearest_interp_grad, ops::InterpolateGradNPUKernel<float>, |
/* Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check the copyright format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
class InterpolateNPUKernel : public framework::OpKernel<T> { | ||
public: | ||
void Compute(const framework::ExecutionContext& ctx) const override { | ||
// Note(Ruibiao): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note -> NOTE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
*c = dims[1]; | ||
*h = dims[2]; | ||
*w = dims[3]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems this op only supports tensor with Rank 4?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this OP only supports the nearest interpolation for 2D images, with Rank 4 for the input tensor (n, c, h, w). I got this information from the CPU kernel in "interpolate_op.h", where the "NearestNeighborInterpolate" function is only called for 2D interpolation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PR types
New features
PR changes
OPs
Describe
Develop the NPU kernel for nearest_interp and nearest_interp_grad op.
Unit test result