-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
[Zero-Dim] Fix 0-dim tensor for arg_min_max op. #49570
Merged
Merged
Changes from 2 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
98a27ad
fix 0-d tensor for arg_min_max op.
ZHUI ee43859
fix xpu.
ZHUI b1f71f4
fix zero dims
ZHUI 569f925
Merge remote-tracking branch 'upstream/develop' into fix_0d_tensor
ZHUI 66d71c2
fix
ZHUI 59efb33
Update arg_min_max_kernel.cc
ZHUI f9647d5
Update arg_min_max_kernel.cc
ZHUI b9e0057
Merge branch 'develop' into fix_0d_tensor
ZHUI 24c352e
Update arg_min_max_kernel.cc
ZHUI 35dda3f
Update test_zero_dim_tensor.py
ZHUI e502314
Update test_zero_dim_tensor_xpu.py
ZHUI dd30a10
Update test_zero_dim_tensor.py
ZHUI c1f9126
Update arg_min_max_kernel.cc
ZHUI 42cff0a
Update arg_min_max_kernel.cc
ZHUI 0c3576e
Update arg_min_max_kernel.cc
ZHUI 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
#include "paddle/phi/core/ddim.h" | ||
#include "paddle/phi/core/kernel_registry.h" | ||
#include "paddle/phi/core/utils/data_type.h" | ||
#include "paddle/phi/kernels/funcs/math_function.h" | ||
|
||
namespace phi { | ||
|
||
|
@@ -39,7 +40,12 @@ void ArgMaxKernel(const Context& dev_ctx, | |
DataType::INT64, | ||
DataType::INT32, | ||
dtype)); | ||
// TODO(ZHUI): fix dtype of out | ||
dev_ctx.template Alloc<int64_t>(out); | ||
if (x.dims().size() == 0) { | ||
phi::funcs::set_constant(dev_ctx, out, 0); | ||
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. XPU的设置为常数:
|
||
return; | ||
} | ||
|
||
DDim x_dims; | ||
int axis_val = axis.to<int>(); | ||
|
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.
这个也不用写分支,因为phi::product(x_dims); 里面已经支持了0D的product计算结果是1
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.
额,这里有个flatten的配置,怕这个 为 false的话,后面可能有问题。
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.
0D的时候axis只能为None,就是flatten的情况
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