-
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
Move one hot to phi #39876
Merged
Merged
Move one hot to phi #39876
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
93d5d80
move one hot to phi; test=develop
phlrain 2dceef2
fix bugs; test=develop
phlrain 9a6e674
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain ef461d8
fix bugs; test=develop
phlrain 97078d9
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain 599f3be
add infer meta; test=develop
phlrain 580a92a
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain f508706
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain 57565f4
fix bugs; test=develop
phlrain d986047
resolve confilct
phlrain a9375a5
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain 1b27159
resolve confilct
phlrain 85b3ee1
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain a3a5e6f
fix bug;
phlrain 14a50dc
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain f8bf9fa
fix error; test=develop
phlrain a79301d
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain b90ac0d
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain 4f1c6bd
update; test=develop
phlrain 1ee9c28
polish code; test=develop
phlrain bc71a67
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain c6b6933
Merge branch 'develop' into move_one_hot_to_phi
phlrain 1612279
add one api in eager mode; test=develop
phlrain 2fcd542
add one hot test; test=develop
phlrain 6476aba
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain a6a9990
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain 270f945
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain 3cc76bc
Merge branch 'move_one_hot_to_phi' of https://github.com/phlrain/Padd…
phlrain ad36baa
Merge branch 'develop' into move_one_hot_to_phi
phlrain 3bc0090
Merge branch 'move_one_hot_to_phi' of https://github.com/phlrain/Padd…
phlrain 97a6fb9
remove use less code; test=develop
phlrain 0188a7b
fix bug; test=develop
phlrain 8ed5106
polish code; test=develop
phlrain c0dac61
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain 370201e
polish code; test=develop
phlrain 731fae3
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -1602,6 +1602,43 @@ void UnfoldInferMeta(const MetaTensor& x, | |
out->set_dims(phi::make_ddim(out_dims)); | ||
} | ||
|
||
void OneHotRawInferMeta(const MetaTensor& x, | ||
int32_t depth, | ||
DataType dtype, | ||
bool allow_out_of_range, | ||
MetaTensor* out) { | ||
auto x_dims = x.dims(); | ||
PADDLE_ENFORCE_GE( | ||
x_dims.size(), | ||
1, | ||
phi::errors::InvalidArgument("Rank of Input(X) should be at least 1.")); | ||
|
||
auto out_dims_vec = phi::vectorize(x_dims); | ||
out_dims_vec.push_back(depth); | ||
auto out_dims = phi::make_ddim(out_dims_vec); | ||
out->set_dims(out_dims); | ||
out->share_lod(x); | ||
out->set_dtype(dtype); | ||
} | ||
|
||
void OneHotInferMeta(const MetaTensor& x, | ||
const Scalar& depth_t, | ||
MetaTensor* out) { | ||
auto x_dims = x.dims(); | ||
PADDLE_ENFORCE_GE( | ||
x_dims.size(), | ||
1, | ||
phi::errors::InvalidArgument("Rank of Input(X) should be at least 1.")); | ||
|
||
int depth = depth_t.to<int>(); | ||
auto out_dims_vec = phi::vectorize(x_dims); | ||
out_dims_vec.push_back(depth); | ||
auto out_dims = phi::make_ddim(out_dims_vec); | ||
out->set_dims(out_dims); | ||
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. 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. done |
||
out->share_lod(x); | ||
out->set_dtype(phi::DataType::FLOAT32); | ||
} | ||
|
||
void WhereIndexInferMeta(const MetaTensor& condition, MetaTensor* out) { | ||
auto rank = condition.dims().size(); | ||
PADDLE_ENFORCE_GE( | ||
|
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
Oops, something went wrong.
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.
这个分支在前面好像有了?和前面合并一下?
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
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.
既然scalar去不掉的话,我们是否有必要单独为depth增加这几处分支