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 825f6960cf27d7c25a08c91e22f4fd328564f69e..43f48f87c09a513cb52088e7527cb3c2df13eb1a 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 abab96ea3b601cb089251fa46645779303cf727f..bdcb54cfe2e8e2b288402816376ced61855747a9 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,