-
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
[XPU][PHI Kernels] bind rsqrt、bitwise_or、arange_tensor for xpu #58950
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ See the License for the specific language governing permissions and | |
limitations under the License. */ | ||
|
||
#include "paddle/phi/kernels/arange_kernel.h" | ||
#include "paddle/phi/backends/xpu/enforce_xpu.h" | ||
|
||
#include "paddle/phi/core/kernel_registry.h" | ||
#include "paddle/phi/kernels/funcs/range_function.h" | ||
|
@@ -32,19 +33,11 @@ void ArangeTensorKernel(const Context& dev_ctx, | |
int64_t size = 0; | ||
phi::funcs::GetSize(start_value, end_value, step_value, &size); | ||
out->Resize(phi::make_ddim({size})); | ||
dev_ctx.template Alloc<T>(out); | ||
|
||
DenseTensor out_cpu; | ||
out_cpu.Resize({out->numel()}); | ||
dev_ctx.template HostAlloc<T>(&out_cpu); | ||
T* out_cpu_data = out_cpu.data<T>(); | ||
|
||
T value = start_value; | ||
for (int64_t i = 0; i < size; ++i) { | ||
out_cpu_data[i] = value; | ||
value += step_value; | ||
} | ||
phi::Copy(dev_ctx, out_cpu, out->place(), true, out); | ||
auto* out_data = dev_ctx.template Alloc<T>(out); | ||
|
||
int ret = xpu::range<T>( | ||
dev_ctx.x_context(), out_data, start_value, step_value, size); | ||
PADDLE_ENFORCE_XDNN_SUCCESS(ret, "range"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 原来的CPU实现替换为xpu::range |
||
} | ||
|
||
} // namespace phi | ||
|
@@ -54,7 +47,6 @@ PD_REGISTER_KERNEL(arange_tensor, | |
ALL_LAYOUT, | ||
phi::ArangeTensorKernel, | ||
float, | ||
double, | ||
int, | ||
int64_t) { | ||
kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,17 @@ void BitwiseAndKernel(const Context& ctx, | |
// counterpart. Need to be changed when adding support to other types. | ||
LogicalAndKernel<T, Context>(ctx, x, y, out); | ||
} | ||
|
||
template <typename T, typename Context> | ||
void BitwiseOrKernel(const Context& ctx, | ||
const DenseTensor& x, | ||
const DenseTensor& y, | ||
DenseTensor* out) { | ||
// Same reason as bitwise_and | ||
LogicalOrKernel<T, Context>(ctx, x, y, out); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bitwise_or之前已有已有单测 |
||
} // namespace phi | ||
|
||
PD_REGISTER_KERNEL(bitwise_not, XPU, ALL_LAYOUT, phi::BitwiseNotKernel, bool) {} | ||
PD_REGISTER_KERNEL(bitwise_and, XPU, ALL_LAYOUT, phi::BitwiseAndKernel, bool) {} | ||
PD_REGISTER_KERNEL(bitwise_or, XPU, ALL_LAYOUT, phi::BitwiseOrKernel, bool) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
#58381 这个PR把kernel的名字从arange改成了arange_tensor,导致xpu不能从xpu2/3_op_list中找到对应的kernel信息从而触发fallback