提交 93f1f189 authored 作者: Frederic's avatar Frederic

Fix the Stack profiler. Make it work as the Loop, LoopGC and CVM profiler.

上级 cfd4b870
...@@ -246,7 +246,6 @@ class Stack(VM): ...@@ -246,7 +246,6 @@ class Stack(VM):
self.base_apply_stack = [o.owner for o in fgraph.outputs if o.owner] self.base_apply_stack = [o.owner for o in fgraph.outputs if o.owner]
self.outputs = fgraph.outputs self.outputs = fgraph.outputs
self.storage_map = storage_map self.storage_map = storage_map
self.apply_time = {}
self.outputs_size = {} self.outputs_size = {}
self.compute_map = compute_map self.compute_map = compute_map
self.node_idx = node_idx = {} self.node_idx = node_idx = {}
...@@ -256,7 +255,6 @@ class Stack(VM): ...@@ -256,7 +255,6 @@ class Stack(VM):
for i, node in enumerate(self.nodes): for i, node in enumerate(self.nodes):
node_idx[node] = i node_idx[node] = i
self.apply_time[node] = 0
self.outputs_size[node] = [] self.outputs_size[node] = []
# XXX: inconsistent style - why modify node here rather # XXX: inconsistent style - why modify node here rather
# than track destroy_dependencies with dictionary like # than track destroy_dependencies with dictionary like
...@@ -357,7 +355,9 @@ class Stack(VM): ...@@ -357,7 +355,9 @@ class Stack(VM):
_, dt = self.run_thunk_of_node(current_apply) _, dt = self.run_thunk_of_node(current_apply)
del _ del _
if config.profile: if config.profile:
self.apply_time[current_apply] += dt nodes_idx = self.nodes.index(current_apply)
self.call_counts[nodes_idx] += 1
self.call_times[nodes_idx] += dt
## Computing the memory footprint of the the op ## Computing the memory footprint of the the op
# ?? What about inplace .. if the op is inplace # ?? What about inplace .. if the op is inplace
# you don't actually ask for more memory! # you don't actually ask for more memory!
...@@ -424,7 +424,9 @@ class Stack(VM): ...@@ -424,7 +424,9 @@ class Stack(VM):
try: try:
requires, dt = self.run_thunk_of_node(current_apply) requires, dt = self.run_thunk_of_node(current_apply)
self.apply_time[current_apply] += dt nodes_idx = self.nodes.index(current_apply)
self.call_counts[nodes_idx] += 1
self.call_times[nodes_idx] += dt
except Exception: except Exception:
raise_with_op(current_apply) raise_with_op(current_apply)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论