Reimplementation of NodeProto from ONNX, but in a form more convenient to work with from Python.
| 988 | |
| 989 | |
| 990 | class 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 | |
| 1023 | class OnnxAttributes(dict): |
no outgoing calls
no test coverage detected