From 03f9fde5f97fe790e04bca4f9aeecc41cbf5bae9 Mon Sep 17 00:00:00 2001 From: hong <43953930+phlrain@users.noreply.github.com> Date: Wed, 5 Jul 2023 20:09:35 +0800 Subject: [PATCH] fix legacy name converter bug (#55144) --- paddle/fluid/ir_adaptor/translator/op_compat_info.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/paddle/fluid/ir_adaptor/translator/op_compat_info.h b/paddle/fluid/ir_adaptor/translator/op_compat_info.h index a899f993151..b07e31c8a13 100644 --- a/paddle/fluid/ir_adaptor/translator/op_compat_info.h +++ b/paddle/fluid/ir_adaptor/translator/op_compat_info.h @@ -93,6 +93,15 @@ class OpNameNormalizer { legacy_name.replace(pos, target.length(), data); } return legacy_name; + } else if (is_grad_op && !is_grad_arg) { + // backwward op using forward args: like trace_grad using forward input + std::string target = "_grad"; + + size_t type_pos = op_type.find(target); + std::string legacy_name = + this->GetLegacyArgName(op_type.substr(0, type_pos), arg_name); + + return legacy_name; } if (op_arg_name_mappings.find(op_type) == op_arg_name_mappings.end()) { return UnderscoreToCamelCase(arg_name); -- GitLab