-
Couldn't load subscription status.
- Fork 5.9k
[phi]migrate increment addmm multinomial cholesky InferShapes to phi #39913
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
Merged
Aganlengzi
merged 2 commits into
PaddlePaddle:develop
from
Aganlengzi:migrate_infershape_to_phi
Feb 25, 2022
Merged
Changes from all commits
Commits
Show all changes
2 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| cc_library(infermeta SRCS nullary.cc unary.cc binary.cc multiary.cc DEPS convert_utils meta_tensor infermeta_utils) | ||
| cc_library(infermeta SRCS nullary.cc unary.cc binary.cc ternary.cc multiary.cc DEPS convert_utils meta_tensor infermeta_utils) | ||
| cc_library(backward_infermeta SRCS backward.cc DEPS meta_tensor convert_utils) |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| /* Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. | ||
|
|
||
| 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. */ | ||
|
|
||
| #include "paddle/phi/infermeta/ternary.h" | ||
| #include "paddle/phi/core/ddim.h" | ||
| #include "paddle/phi/kernels/funcs/common_shape.h" | ||
|
|
||
| namespace phi { | ||
|
|
||
| void AddmmInferMeta(const MetaTensor& input, | ||
| const MetaTensor& x, | ||
| const MetaTensor& y, | ||
| float alpha, | ||
| float beta, | ||
| MetaTensor* out) { | ||
| auto input_dims = input.dims(); | ||
| auto x_dims = x.dims(); | ||
| auto y_dims = y.dims(); | ||
|
|
||
| auto ndim_input = input_dims.size(); | ||
| auto ndim_x = x_dims.size(); | ||
| auto ndim_y = y_dims.size(); | ||
|
|
||
| VLOG(3) << "addmm operator input.shape=" << input_dims | ||
| << " x.shape=" << x_dims << " y.shape=" << y_dims << " beta=" << beta | ||
| << " alpha=" << alpha << " ndim_input=" << ndim_input | ||
| << " ndim_x=" << ndim_x << " ndim_y=" << ndim_y; | ||
|
|
||
| PADDLE_ENFORCE_NE( | ||
| product(input_dims), | ||
| 0, | ||
| errors::PreconditionNotMet("The Input variable 'input' has not " | ||
| "been initialized. You may need to confirm " | ||
| "if you put exe.run(startup_program) " | ||
| "after optimizer.minimize function.")); | ||
|
|
||
| PADDLE_ENFORCE_NE( | ||
| product(x_dims), | ||
| 0, | ||
| errors::PreconditionNotMet("The Input variable 'x' has not " | ||
| "been initialized. You may need to confirm " | ||
| "if you put exe.run(startup_program) " | ||
| "after optimizer.minimize function.")); | ||
|
|
||
| PADDLE_ENFORCE_NE( | ||
| product(y_dims), | ||
| 0, | ||
| errors::PreconditionNotMet("The Input variable 'y' has not " | ||
| "been initialized. You may need to confirm " | ||
| "if you put exe.run(startup_program) " | ||
| "after optimizer.minimize function.")); | ||
| // dim check | ||
| PADDLE_ENFORCE_EQ( | ||
| ndim_input, | ||
| 2, | ||
| errors::InvalidArgument("The input tensor input's dimension must be 2. " | ||
| "But received input's dimension = [%s].", | ||
| ndim_input)); | ||
| PADDLE_ENFORCE_EQ( | ||
| ndim_x, | ||
| 2, | ||
| errors::InvalidArgument("The input tensor x's dimension must be 2. " | ||
| "But received x's dimension = [%s].", | ||
| ndim_x)); | ||
| PADDLE_ENFORCE_EQ( | ||
| ndim_y, | ||
| 2, | ||
| errors::InvalidArgument("The input tensor y's dimension must be 2. " | ||
| "But received y's dimension = [%s].", | ||
| ndim_y)); | ||
|
|
||
| std::vector<int64_t> output_dims; | ||
| output_dims.push_back(x_dims[0]); | ||
| output_dims.push_back(y_dims[1]); | ||
|
|
||
| out->set_dims(make_ddim(output_dims)); | ||
| out->share_lod(input); | ||
| out->set_dtype(input.dtype()); | ||
| } | ||
|
|
||
| } // namespace phi | ||
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.
建议infermeta里一并set一下dtype,在原来体系里这边是一个漏洞
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.
了解,这几个我都加下.