Create a operator node in the graph. Args: op_type(str): the type of the operator node. attrs(dict): the attributes of the operator node. inputs(dict): the inputs of the operator node. outputs(dict): the outputs of the operator node.
(self, op_type, attrs, inputs, outputs)
| 5731 | return IrVarNode(self.graph.create_var_node(var_desc)) |
| 5732 | |
| 5733 | def create_op_node(self, op_type, attrs, inputs, outputs): |
| 5734 | """ |
| 5735 | Create a operator node in the graph. |
| 5736 | |
| 5737 | Args: |
| 5738 | op_type(str): the type of the operator node. |
| 5739 | attrs(dict): the attributes of the operator node. |
| 5740 | inputs(dict): the inputs of the operator node. |
| 5741 | outputs(dict): the outputs of the operator node. |
| 5742 | |
| 5743 | Returns: |
| 5744 | IrOpNode: the created operator node. |
| 5745 | """ |
| 5746 | op_desc = core.OpDesc() |
| 5747 | op_desc.set_type(op_type) |
| 5748 | for attr, value in attrs.items(): |
| 5749 | self._update_desc_attr(op_desc, attr, value) |
| 5750 | for input_name, var_nodes in inputs.items(): |
| 5751 | if not isinstance(var_nodes, list): |
| 5752 | var_nodes = [var_nodes] |
| 5753 | op_desc.set_input( |
| 5754 | input_name, [var_node.name() for var_node in var_nodes] |
| 5755 | ) |
| 5756 | for output_name, var_nodes in outputs.items(): |
| 5757 | if not isinstance(var_nodes, list): |
| 5758 | var_nodes = [var_nodes] |
| 5759 | op_desc.set_output( |
| 5760 | output_name, [var_node.name() for var_node in var_nodes] |
| 5761 | ) |
| 5762 | return IrOpNode(self.graph.create_op_node(op_desc)) |
| 5763 | |
| 5764 | def create_op_node_from_desc(self, op_desc): |
| 5765 | """ |