MCPcopy
hub / github.com/OpenPPL/ppq / initialize_depth

Method initialize_depth

ppq/quantization/algorithm/training.py:302–315  ·  view source on GitHub ↗

为图中所有节点确定深度,基于拓扑排序与动态规划,O(kn)时间复杂度 k为图节点最大度数,n为图节点个数.

(self)

Source from the content-addressed store, hash-verified

300 return self.create_block(sp=sp, ep=ep)
301
302 def initialize_depth(self) -> None:
303 """为图中所有节点确定深度,基于拓扑排序与动态规划,O(kn)时间复杂度 k为图节点最大度数,n为图节点个数."""
304 for operation in self.op_orders:
305 # graph input operation, set depth as 0
306 if len(self.graph.get_upstream_operations(operation)) == 0:
307 self.depth[operation] = 0
308 continue
309
310 # otherwise we will go dp
311 depths_cache = []
312 for up_op in self.graph.get_upstream_operations(operation):
313 assert up_op in self.depth, ('Oops, that should not happen to your network.')
314 depths_cache.append(self.depth[up_op])
315 self.depth[operation] = max(depths_cache) + 1
316
317
318class LSQDelegator(TorchQuantizeDelegator):

Callers 1

__init__Method · 0.95

Calls 2

appendMethod · 0.45

Tested by

no test coverage detected