diff --git a/paddle/fluid/framework/ir/multihead_matmul_fuse_pass.cc b/paddle/fluid/framework/ir/multihead_matmul_fuse_pass.cc index cefcca0f83a9e65f6327901cf46bedfd6e24d35e..a48cfde23853db45b5c65b4b446770d94d67c950 100644 --- a/paddle/fluid/framework/ir/multihead_matmul_fuse_pass.cc +++ b/paddle/fluid/framework/ir/multihead_matmul_fuse_pass.cc @@ -931,6 +931,7 @@ int MultiHeadMatmulV2FusePass::BuildFusionV2(Graph* graph, scope->EraseVars({mul1_w->Name(), mul2_w->Name()}); scope->EraseVars({eltadd1_b->Name(), eltadd2_b->Name()}); + paddle::memory::Release(platform::CPUPlace()); auto reshape_desc = reshape2->Op(); int head_number = @@ -1398,6 +1399,7 @@ int MultiHeadMatmulV3FusePass::BuildFusionV3(Graph* graph, sizeof(float) * wq_tensor->numel()); scope->EraseVars({mul1_w->Name(), mul2_w->Name()}); + paddle::memory::Release(platform::CPUPlace()); phi::DenseTensor tmp_combined_bias_tensor; tmp_combined_bias_tensor.Resize(combined_bias_dims); diff --git a/paddle/fluid/framework/ir/trt_multihead_matmul_fuse_pass.cc b/paddle/fluid/framework/ir/trt_multihead_matmul_fuse_pass.cc index 1d17cba4459059c7f55337e55beb6906229b5cf2..5c96c351f5111f4fad5e9370f52585e95f7dbbdd 100644 --- a/paddle/fluid/framework/ir/trt_multihead_matmul_fuse_pass.cc +++ b/paddle/fluid/framework/ir/trt_multihead_matmul_fuse_pass.cc @@ -888,6 +888,7 @@ int TrtMultiHeadMatmulV2FusePass::BuildFusionV2(Graph* graph, sizeof(float) * wq_tensor->numel()); scope->EraseVars({mul1_w->Name(), mul2_w->Name()}); + paddle::memory::Release(platform::CPUPlace()); phi::DenseTensor tmp_combined_bias_tensor; tmp_combined_bias_tensor.Resize(combined_bias_dims); @@ -910,6 +911,7 @@ int TrtMultiHeadMatmulV2FusePass::BuildFusionV2(Graph* graph, sizeof(float) * bq_tensor->numel()); scope->EraseVars({eltadd1_b->Name(), eltadd2_b->Name()}); + paddle::memory::Release(platform::CPUPlace()); auto reshape_desc = reshape2->Op(); int head_number = @@ -1408,6 +1410,7 @@ int TrtMultiHeadMatmulV3FusePass::BuildFusionV3(Graph* graph, sizeof(float) * wq_tensor->numel()); scope->EraseVars({mul1_w->Name(), mul2_w->Name()}); + paddle::memory::Release(platform::CPUPlace()); phi::DenseTensor tmp_combined_bias_tensor; tmp_combined_bias_tensor.Resize(combined_bias_dims); @@ -1430,6 +1433,7 @@ int TrtMultiHeadMatmulV3FusePass::BuildFusionV3(Graph* graph, sizeof(float) * bq_tensor->numel()); scope->EraseVars({eltadd1_b->Name(), eltadd2_b->Name()}); + paddle::memory::Release(platform::CPUPlace()); auto reshape_desc = reshape2->Op(); int head_number =