sparse_op.c.j2 1.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
{% from "operator_utils.c.j2" import op_maker, backward_op_maker, backward_op_reused_maker, operator, register_op_with_components, register_op_version %}
// this file is generated by paddle/phi/api/yaml/generator/generate_op.py, do not edit.
#include <string>
#include "paddle/fluid/framework/infershape_utils.h"
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/phi/core/infermeta_utils.h"
#include "paddle/phi/infermeta/backward.h"
#include "paddle/phi/infermeta/binary.h"
#include "paddle/phi/infermeta/multiary.h"
#include "paddle/phi/infermeta/sparse/backward.h"
#include "paddle/phi/infermeta/sparse/binary.h"
#include "paddle/phi/infermeta/sparse/multiary.h"
#include "paddle/phi/infermeta/sparse/unary.h"
#include "paddle/phi/infermeta/ternary.h"
#include "paddle/phi/infermeta/unary.h"

namespace paddle {
namespace operators {

using paddle::framework::GradVarName;

22 23
{% for op in ops %}
  {% if op is base_op %}
24

25
{{op_maker(op)}}
26

27
{{operator(op)}}
28 29 30
  {% endif %}
{% endfor %}

31 32
{% for op in backward_ops %}
  {% if op is base_op %}
33

34
{{backward_op_maker(op, op_dict[op["forward"]["name"]])}}
35

36
{{operator(op)}}
37
 {% else %}
38
{{backward_op_reused_maker(op, op_dict[op["forward"]["name"]], op["invoke"])}}
39 40 41 42 43 44
  {% endif %}
{% endfor %}
}  // namespace operators
}  // namespace paddle

namespace ops = paddle::operators;
45 46 47
{% for op in ops + backward_ops %}
{% if op is base_op %}
{{register_op_with_components(op)}}
48 49
{% endif %}
{% endfor %}