提交 c8c4f236 authored 作者: --global's avatar --global

In PdbBreakpoint.make_node, create new op instance to apply on inputs.

上级 56fed244
...@@ -76,15 +76,21 @@ class PdbBreakpoint(Op): ...@@ -76,15 +76,21 @@ class PdbBreakpoint(Op):
# is should be evaluated) # is should be evaluated)
assert (condition.ndim == 0) assert (condition.ndim == 0)
# Build the op's view_map; every output i is a view of the input i+1. # Because the user might be tempted to instantiate PdbBreakpoint only
self.view_map = {} # once and apply it many times on different number of inputs, we must
# create a new instance of the op here, define the view_map in that
# instance and then apply it on the inputs.
new_op = PdbBreakpoint(name=self.name)
new_op.view_map = {}
for i in range(len(monitored_vars)): for i in range(len(monitored_vars)):
self.view_map[i] = [i+1] # Every output i is a view of the input i+1 because of the input
# condition.
new_op.view_map[i] = [i+1]
# Build the Apply node # Build the Apply node
inputs = [condition] + list(monitored_vars) inputs = [condition] + list(monitored_vars)
outputs = [inp.type() for inp in monitored_vars] outputs = [inp.type() for inp in monitored_vars]
return Apply(op=self, inputs=inputs, outputs=outputs) return Apply(op=new_op, inputs=inputs, outputs=outputs)
def perform(self, node, inputs, output_storage): def perform(self, node, inputs, output_storage):
condition = inputs[0] condition = inputs[0]
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论