-
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
[2/4] CUDNNv8 ResNet Fusion: Add fused_scale_bias_add_relu OP #58504
Merged
zyfncg
merged 2 commits into
PaddlePaddle:develop
from
Tom-Zheng:gh_add_fused_scale_bias_add_relu
Nov 13, 2023
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 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 |
---|---|---|
|
@@ -1687,41 +1687,40 @@ void LayerNormActXPUInferMeta(const MetaTensor& x, | |
y->set_layout(x.layout()); | ||
} | ||
|
||
void FusedScaleBiasReluConvBnstatsInferMeta( | ||
const MetaTensor& x, | ||
const MetaTensor& w, | ||
const MetaTensor& scale, | ||
const MetaTensor& bias, | ||
const MetaTensor& bn_scale, | ||
const MetaTensor& bn_bias, | ||
const MetaTensor& input_running_mean, | ||
const MetaTensor& input_running_var, | ||
const std::vector<int>& paddings, | ||
const std::vector<int>& dilations, | ||
const std::vector<int>& strides, | ||
const std::string& padding_algorithm, | ||
int groups, | ||
const std::string& data_format, | ||
float momentum, | ||
float epsilon, | ||
bool fuse_prologue, | ||
bool exhaustive_search, | ||
int64_t accumulation_count, | ||
MetaTensor* out, | ||
MetaTensor* out_running_mean, | ||
MetaTensor* out_running_var, | ||
MetaTensor* saved_mean, | ||
MetaTensor* saved_var, | ||
MetaTensor* eq_scale, | ||
MetaTensor* eq_bias) { | ||
void FusedScaleBiasReluConvBnInferMeta(const MetaTensor& x, | ||
const MetaTensor& w, | ||
const MetaTensor& scale, | ||
const MetaTensor& bias, | ||
const MetaTensor& bn_scale, | ||
const MetaTensor& bn_bias, | ||
const MetaTensor& input_running_mean, | ||
const MetaTensor& input_running_var, | ||
const std::vector<int>& paddings, | ||
const std::vector<int>& dilations, | ||
const std::vector<int>& strides, | ||
const std::string& padding_algorithm, | ||
int groups, | ||
const std::string& data_format, | ||
float momentum, | ||
float epsilon, | ||
bool fuse_prologue, | ||
bool exhaustive_search, | ||
int64_t accumulation_count, | ||
MetaTensor* out, | ||
MetaTensor* out_running_mean, | ||
MetaTensor* out_running_var, | ||
MetaTensor* saved_mean, | ||
MetaTensor* saved_var, | ||
MetaTensor* eq_scale, | ||
MetaTensor* eq_bias) { | ||
auto in_dims = x.dims(); | ||
auto filter_dims = w.dims(); | ||
// do some checks | ||
PADDLE_ENFORCE_EQ( | ||
in_dims.size(), | ||
4, | ||
phi::errors::InvalidArgument( | ||
"The input of Op(FusedScaleBiasReluConvBnstats) should be a 4-D " | ||
"The input of Op(FusedScaleBiasReluConvBn) should be a 4-D " | ||
"Tensor. But " | ||
"received: input's dimension is %u, input's shape is [%s].", | ||
in_dims.size(), | ||
|
@@ -1732,7 +1731,7 @@ void FusedScaleBiasReluConvBnstatsInferMeta( | |
filter_dims.size(), | ||
phi::errors::InvalidArgument( | ||
"The input's dimension and filter's dimension of " | ||
"Op(FusedScaleBiasReluConvBnstats) should be equal. But received: " | ||
"Op(FusedScaleBiasReluConvBn) should be equal. But received: " | ||
"the input's" | ||
" shape is [%s], " | ||
"the input's dimension is %d; the filter's shape is [%s], " | ||
|
@@ -1747,7 +1746,7 @@ void FusedScaleBiasReluConvBnstatsInferMeta( | |
data_format, | ||
"NHWC", | ||
phi::errors::InvalidArgument( | ||
"Operator(FusedScaleBiasReluConvBnstats) only supports data format " | ||
"Operator(FusedScaleBiasReluConvBn) only supports data format " | ||
"of " | ||
"channel last (NHWC) now. But recieved: data_format = '%s'.", | ||
data_format)); | ||
|
@@ -1774,7 +1773,7 @@ void FusedScaleBiasReluConvBnstatsInferMeta( | |
filter_dims[1] * groups, | ||
phi::errors::InvalidArgument( | ||
"The number of input's channels should be equal to filter's channels " | ||
"* groups for Op(FusedScaleBiasReluConvBnstats). But received: the " | ||
"* groups for Op(FusedScaleBiasReluConvBn). But received: the " | ||
"input's" | ||
" channels is %d, " | ||
"the input's shape is [%s]; the filter's channels is %d, the " | ||
|
@@ -1821,6 +1820,32 @@ void FusedScaleBiasReluConvBnstatsInferMeta( | |
eq_bias->set_dims(c_dims); | ||
} | ||
|
||
void FusedScaleBiasAddReluInferMeta(const MetaTensor& x1, | ||
const MetaTensor& scale1, | ||
const MetaTensor& bias1, | ||
const MetaTensor& x2, | ||
const MetaTensor& scale2, | ||
const MetaTensor& bias2, | ||
bool fuse_dual, | ||
bool exhaustive_search, | ||
MetaTensor* y) { | ||
// check optional inputs | ||
if (fuse_dual) { | ||
bool has_scale2 = !!scale2; | ||
bool has_bias2 = !!bias2; | ||
PADDLE_ENFORCE(has_scale2 && has_bias2, | ||
phi::errors::InvalidArgument( | ||
"Argument scale2 and bias2 should be provided when " | ||
"fuse_dual is set, but got has_scale2=%d, has_bias2=%d, " | ||
"fuse_dual=%d.", | ||
has_scale2, | ||
has_bias2, | ||
fuse_dual)); | ||
} | ||
// set output dims | ||
y->set_dims(x1.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. 严格来说,这里也需要设置dtype和layout 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. 会在下个PR修改. |
||
} | ||
|
||
void SqueezeExcitationInferMeta(const MetaTensor& x, | ||
const MetaTensor& filter, | ||
const MetaTensor& filter_max, | ||
|
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
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.
一般来说,单输出都取名为out
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.
会在下个PR修改.