diff --git a/paddle/fluid/ir_adaptor/translator/op_compat_info.h b/paddle/fluid/ir_adaptor/translator/op_compat_info.h index 799e62c7544e3fc89435c66873f733122ae9deb9..a899f99315171d83eb9e189200e2a543dbf7bd25 100644 --- a/paddle/fluid/ir_adaptor/translator/op_compat_info.h +++ b/paddle/fluid/ir_adaptor/translator/op_compat_info.h @@ -82,9 +82,10 @@ class OpNameNormalizer { std::string target = "_grad"; std::string data = "@GRAD"; - size_t first_grad_pos = arg_name.find_first_of(target); - std::string legacy_name = - this->GetLegacyArgName(op_type, arg_name.substr(0, first_grad_pos)); + size_t first_grad_pos = arg_name.find(target); + size_t type_pos = op_type.find(target); + std::string legacy_name = this->GetLegacyArgName( + op_type.substr(0, type_pos), arg_name.substr(0, first_grad_pos)); legacy_name += arg_name.substr(first_grad_pos); for (size_t pos = 0; legacy_name.npos != (pos = legacy_name.find(target, pos));