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

Method handle_special_ops

python/singa/sonnx.py:2062–2084  ·  view source on GitHub ↗

hanlde some special operations Args: name (str): name of the state node (ONNXNode): ONNX node tensor_dict ({}): tensor dict Returns: the states

(self, node, op, tensor_dict)

Source from the content-addressed store, hash-verified

2060 return self.states[name]
2061
2062 def handle_special_ops(self, node, op, tensor_dict):
2063 """
2064 hanlde some special operations
2065 Args:
2066 name (str): name of the state
2067 node (ONNXNode): ONNX node
2068 tensor_dict ({}): tensor dict
2069 Returns:
2070 the states
2071 """
2072 # todo, hard code
2073 # Conv2d nb_kernels
2074 if node.op_type == "Conv":
2075 shape = self.get_s(node.inputs[1], node, tensor_dict).shape
2076 op.nb_kernels = shape[0]
2077 # Gemm nb_kernels and bias_shape
2078 elif node.op_type == "Gemm":
2079 nb_kernels_flag = 0 if op.transB == 1 else -1
2080 shape = self.get_s(node.inputs[1], node, tensor_dict).shape
2081 op.nb_kernels = shape[nb_kernels_flag]
2082 if op.bias:
2083 shape = self.get_s(node.inputs[2], node, tensor_dict).shape
2084 op.bias_shape = shape
2085
2086 def run(self, x, **kwargs):
2087 """

Callers 2

runMethod · 0.95
singa_to_onnx_graphMethod · 0.45

Calls 1

get_sMethod · 0.95

Tested by

no test coverage detected