From e0d12b8d1c8deaf26592c1640bea6a35156bbf1a Mon Sep 17 00:00:00 2001 From: hong <43953930+phlrain@users.noreply.github.com> Date: Wed, 6 Apr 2022 08:41:47 +0800 Subject: [PATCH] fix eager gen opt meta tensor name bug (#41401) --- python/paddle/utils/code_gen/api_base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/paddle/utils/code_gen/api_base.py b/python/paddle/utils/code_gen/api_base.py index c51e2b0acd2..38aa3e0cb0b 100644 --- a/python/paddle/utils/code_gen/api_base.py +++ b/python/paddle/utils/code_gen/api_base.py @@ -486,8 +486,8 @@ PADDLE_API {self.gene_return_type_code()} {self.get_api_func_name() + '_'}({self elif param in self.optional_vars: meta_tensor_code = meta_tensor_code + f""" {code_indent} paddle::optional {PREFIX_TENSOR_NAME}meta_ref_{param} = paddle::none; -{code_indent} phi::DenseTensor dt; -{code_indent} phi::MetaTensor {PREFIX_TENSOR_NAME}meta_tmp_{param}(dt); +{code_indent} phi::DenseTensor {param}_dt; +{code_indent} phi::MetaTensor {PREFIX_TENSOR_NAME}meta_tmp_{param}({param}_dt); {code_indent} if ({PREFIX_TENSOR_NAME}{param}_ptr) {{ {code_indent} {PREFIX_TENSOR_NAME}meta_tmp_{param}.set_dtype( {PREFIX_TENSOR_NAME}{param}_ptr->dtype() ); {code_indent} {PREFIX_TENSOR_NAME}meta_tmp_{param}.set_dims( {PREFIX_TENSOR_NAME}{param}_ptr->dims() ); -- GitLab