From 26c573decf29cc46e61603b370e5ac3677792526 Mon Sep 17 00:00:00 2001 From: whs Date: Thu, 11 Aug 2022 11:05:43 +0800 Subject: [PATCH] Change bias to persistable in preln_residual_bias_fuse_pass (#45037) --- paddle/fluid/framework/ir/preln_residual_bias_fuse_pass.cc | 3 ++- .../fluid/inference/tensorrt/convert/preln_residual_bias.cc | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/paddle/fluid/framework/ir/preln_residual_bias_fuse_pass.cc b/paddle/fluid/framework/ir/preln_residual_bias_fuse_pass.cc index 825f6960cf2..43f48f87c09 100644 --- a/paddle/fluid/framework/ir/preln_residual_bias_fuse_pass.cc +++ b/paddle/fluid/framework/ir/preln_residual_bias_fuse_pass.cc @@ -61,7 +61,8 @@ void PrelnResidualBias::operator()(PDNode *x, PDNode *y) { auto *elementwise0 = pattern->NewNode(elementwise0_repr())->assert_is_op("elementwise_add"); auto *elementwise_bias_var = pattern->NewNode(elementwise_bias_repr()) - ->assert_is_op_input("elementwise_add", "Y"); + ->assert_is_op_input("elementwise_add", "Y") + ->assert_is_persistable_var(); auto *elementwise0_out_var = pattern->NewNode(elementwise0_out_repr()) ->assert_is_op_output("elementwise_add") ->assert_is_op_input("elementwise_add") diff --git a/paddle/fluid/inference/tensorrt/convert/preln_residual_bias.cc b/paddle/fluid/inference/tensorrt/convert/preln_residual_bias.cc index abab96ea3b6..bdcb54cfe2e 100644 --- a/paddle/fluid/inference/tensorrt/convert/preln_residual_bias.cc +++ b/paddle/fluid/inference/tensorrt/convert/preln_residual_bias.cc @@ -66,8 +66,8 @@ class PrelnResidualBiasOpConverter : public OpConverter { nvinfer1::ILayer* layer = nullptr; plugin::DynamicPluginTensorRT* plugin = nullptr; if (with_fp16) { - auto half_ele_bias_data = new half[bias_size]; - for (int i = 0; i < bias_size; i++) { + auto half_ele_bias_data = new half[ele_bias_size]; + for (int i = 0; i < ele_bias_size; i++) { half_ele_bias_data[i] = static_cast(ele_bias[i]); } plugin = new plugin::PrelnResidualBiasPluginDynamic(bias, -- GitLab