MCPcopy Create free account
hub / github.com/apache/singa / OnnxNode

Class OnnxNode

python/singa/sonnx.py:990–1020  ·  view source on GitHub ↗

Reimplementation of NodeProto from ONNX, but in a form more convenient to work with from Python.

Source from the content-addressed store, hash-verified

988
989
990class OnnxNode(object):
991 """
992 Reimplementation of NodeProto from ONNX, but in a form
993 more convenient to work with from Python.
994 """
995
996 def __init__(self, node):
997 self.name = str(node.name).replace(".", "_")
998 self.op_type = str(node.op_type)
999 self.attrs = OnnxAttributes.from_onnx(node.attribute)
1000 # inputs as attributes in singa
1001 self.attr_inputs = {}
1002 # inputs as weights in singa
1003 self.weight_inputs = {}
1004 self.inputs = list(node.input)
1005 self.outputs = list(node.output)
1006
1007 def getattr(self, key, default=None):
1008 return self.attrs[key] if key in self.attrs else default
1009
1010 def set_attr_inputs(self, key, name):
1011 self.attr_inputs[key] = name
1012
1013 def del_attr_inputs(self, key):
1014 del self.attr_inputs[key]
1015
1016 def set_weight_inputs(self, key, name):
1017 self.weight_inputs[key] = name
1018
1019 def del_weight_inputs(self, key):
1020 del self.weight_inputs[key]
1021
1022
1023class OnnxAttributes(dict):

Callers 2

run_nodeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected