未验证 提交 8ee9140b 编写于 作者: F Feiyu Chan 提交者: GitHub

Change the way to set attributes for grad op maker (#44514)

* fix typos in template for codegen of operators
* change the way to set attributes for grad op maker
上级 822e42d7
......@@ -333,6 +333,7 @@ class {{name | to_pascal_case}}OpMaker : public framework::SingleGradOpMaker<T>
forward_output_orig_names)}});
{% endfor %}
grad_op->SetAttrMap(this->Attrs());
{% for attr in api["attrs"] %}
{% set attr_name = attr["name"] %}
{% if attr_name in forward_attr_names %}
......@@ -342,7 +343,6 @@ class {{name | to_pascal_case}}OpMaker : public framework::SingleGradOpMaker<T>
{% elif attr["typename"] == "Scalar" %}
grad_op->SetInput("{{attr_name | to_pascal_case}}Tensor", this->Input("{{attr_name | to_pascal_case}}Tensor"));
{% endif %}
grad_op->SetAttr("{{attr_name}}", this->GetAttr("{{forward_attr_orig_names[forward_attr_names.index(attr_name)]}}"));
{% else %}{# maybe something wrong: backward op has more attrs than the forward one#}
grad_op->AddAttr<{{attr["typename"] | to_op_attr_type}}>({{attr_name}}, "({{attr["typename"] | to_op_attr_type}}), exceptional attr {{attr_name}}");
grad_op->SetAttr("{{attr_name}}", {{process_default_value(attr)}});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册