MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / create_op_node

Method create_op_node

python/paddle/base/framework.py:5733–5762  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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 """

Calls 8

_update_desc_attrMethod · 0.95
IrOpNodeClass · 0.85
OpDescMethod · 0.80
set_typeMethod · 0.45
itemsMethod · 0.45
set_inputMethod · 0.45
nameMethod · 0.45
set_outputMethod · 0.45

Tested by 1

test_create_op_nodeMethod · 0.64