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

Function post_order_recursive

python/singa/utils.py:234–267  ·  view source on GitHub ↗

return a list by the topological ordering (postorder of Depth-first search) Args: root: singa operator root_t: tensor Returns: deque[int]

(root, root_t)

Source from the content-addressed store, hash-verified

232
233
234def post_order_recursive(root, root_t):
235 """
236 return a list by the topological ordering (postorder of Depth-first search)
237 Args:
238 root: singa operator
239 root_t: tensor
240 Returns:
241 deque[int]
242 """
243
244 def recursive(root, yid, root_t):
245 if root:
246 # srcop: operator for a input of root
247 # yid: id(output of this operator)
248 # y: output of this operator
249 for srcop, yid, y, _ in root.src:
250 recursive(srcop, yid, y)
251
252 if type(root).__name__ == 'Dummy':
253 if root_t != None:
254 # constant within a node: weight
255 weights[root.name] = root_t
256 else:
257 # constant outside a node: input
258 inputs[root.name] = root_t
259 else:
260 nodes[root.name] = root
261
262 nodes = OrderedDict()
263 weights = OrderedDict()
264 inputs = OrderedDict()
265
266 recursive(root, None, root_t)
267 return nodes, weights, inputs

Callers

nothing calls this directly

Calls 1

recursiveFunction · 0.85

Tested by

no test coverage detected