get a onnx node from singa operator Args: op: a given operator Args: op_t: the tensor of the operator Returns: the onnx node
(cls, op, op_t)
| 884 | |
| 885 | @classmethod |
| 886 | def singa_op_to_onnx_node(cls, op, op_t): |
| 887 | """ |
| 888 | get a onnx node from singa operator |
| 889 | Args: |
| 890 | op: a given operator |
| 891 | Args: |
| 892 | op_t: the tensor of the operator |
| 893 | Returns: |
| 894 | the onnx node |
| 895 | """ |
| 896 | optype = cls._get_singa_op_type(op) |
| 897 | # wether the operator needs special handler |
| 898 | if optype in cls._special_operators: |
| 899 | translator = getattr(cls, cls._special_operators[optype]) |
| 900 | else: |
| 901 | translator = cls._common_singa_tensor_to_onnx_node |
| 902 | nodes = translator(op, op_t) |
| 903 | if not isinstance(nodes, collections.Iterable): |
| 904 | nodes = [nodes] |
| 905 | nodes = [node for node in nodes if node is not None] |
| 906 | return nodes |
| 907 | |
| 908 | @classmethod |
| 909 | def singa_to_onnx_graph(cls, inputs, y, model_name="sonnx"): |
no test coverage detected