From 07c416c8f8784b5dcceb491277b119c35811e10a Mon Sep 17 00:00:00 2001 From: Charles-hit <56987902+Charles-hit@users.noreply.github.com> Date: Fri, 24 Feb 2023 14:45:46 +0800 Subject: [PATCH] fix composite grad maker code gen (#50854) --- .../fluid/operators/generator/templates/operator_utils.c.j2 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/operators/generator/templates/operator_utils.c.j2 b/paddle/fluid/operators/generator/templates/operator_utils.c.j2 index 2284923de6d..5f0147f61d1 100644 --- a/paddle/fluid/operators/generator/templates/operator_utils.c.j2 +++ b/paddle/fluid/operators/generator/templates/operator_utils.c.j2 @@ -694,7 +694,11 @@ class {{op_name | to_composite_grad_opmaker_name}} : public prim::CompositeGradO {% macro construct_composite_attr(attrs, fluid_attrs, attr_dict) %} {% set attrs_length = attrs | length %} {% for i in range(attrs_length) %} - {% set attrs_data_type = attr_dict[attrs[i]]["typename"] | to_op_attr_type %} + {% if "data_type" in attr_dict[attrs[i]] %} + {% set attrs_data_type = attr_dict[attrs[i]]["data_type"]%} + {% else %} + {% set attrs_data_type = attr_dict[attrs[i]]["typename"] | to_op_attr_type %} + {%- endif %} const {{attrs_data_type}} {{attrs[i]}} = this->Attr<{{attrs_data_type}}>("{{fluid_attrs[i]}}"); {% endfor %} {%- endmacro %} -- GitLab