Skip to content
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

[TRT] elementwise_add+transpose fusion #50081

Merged
merged 7 commits into from Feb 11, 2023

Conversation

wwbitejotunn
Copy link
Contributor

@wwbitejotunn wwbitejotunn commented Jan 30, 2023

PR types

Performance optimization

PR changes

OPs

Describe

This pr make fusion of elementwise_add and transpose which transpose nhwc to nchw.

@wwbitejotunn wwbitejotunn changed the title [trt] elementwise_add+transpose fusion [TRT] elementwise_add+transpose fusion Feb 8, 2023
for (int i = 0; i < out_dims.nbDims; i++) {
out_shape.push_back(out_dims.d[i]);
out_numel *= out_dims.d[i];
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复杂的前处理都移到config里

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已将前处理都移到config里, 感谢review

auto input_type = input_desc[0].type;
auto output_format = output_desc[0].format;
if (input_type == nvinfer1::DataType::kFLOAT) {
VLOG(1) << "TRT Plugin DataType selected. elementwiseadd_transpose-->fp16";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fp32

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改笔误, 感谢review

const float *y = static_cast<const float *>(inputs[1]);
float *out = static_cast<float *>(outputs[0]);
VLOG(1) << "TRT Plugin format selected. elementwiseadd_transpose-->kLINEAR";
phi::DenseTensor ele_out_tensor;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改成成员变量在config里初始化可以不用每次分配释放

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已将中间变量改为成员变量并在config中分配, 感谢review

phi::make_ddim(x_shape));
phi::DenseTensorMeta y_meta(phi::DataType::FLOAT32,
phi::make_ddim(y_shape));
phi::DenseTensorMeta out_meta(phi::DataType::FLOAT32,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meta都可以改到config里

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已将meta都改到configezhong, 感谢review

Copy link
Contributor

@XiaoguangHu01 XiaoguangHu01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@joey12300 joey12300 merged commit fd0d4fa into PaddlePaddle:develop Feb 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants