提交 495e144e authored 作者: --global's avatar --global

Only transfer monitored variables to the host when necessary

上级 1427753f
...@@ -98,14 +98,15 @@ class PdbBreakpoint(Op): ...@@ -98,14 +98,15 @@ class PdbBreakpoint(Op):
def perform(self, node, inputs, output_storage): def perform(self, node, inputs, output_storage):
condition = inputs[0] condition = inputs[0]
try:
monitored = [numpy.asarray(inp) for inp in inputs[1:]]
except:
raise ValueError("Some of the inputs to the PdbBreakpoint op '%s'"
"could not be casted to NumPy arrays" %
self.name)
if condition: if condition:
try:
monitored = [numpy.asarray(inp) for inp in inputs[1:]]
except:
raise ValueError("Some of the inputs to the PdbBreakpoint op "
"'%s' could not be casted to NumPy arrays" %
self.name)
print("\n") print("\n")
print("-------------------------------------------------") print("-------------------------------------------------")
print("Conditional breakpoint '%s' activated\n" % self.name) print("Conditional breakpoint '%s' activated\n" % self.name)
...@@ -116,10 +117,15 @@ class PdbBreakpoint(Op): ...@@ -116,10 +117,15 @@ class PdbBreakpoint(Op):
print("-------------------------------------------------") print("-------------------------------------------------")
pdb.set_trace() pdb.set_trace()
# Take the new values in monitored, cast them back to their original # Take the new values in monitored, cast them back to their
# type and store them in the output_storage # original type and store them in the output_storage
for i in range(len(output_storage)): for i in range(len(output_storage)):
output_storage[i][0] = self.inp_types[i].filter(monitored[i]) output_storage[i][0] = self.inp_types[i].filter(monitored[i])
else:
# Simply return views on the monitored variables
for i in range(len(output_storage)):
output_storage[i][0] = inputs[i+1]
def grad(self, inputs, output_gradients): def grad(self, inputs, output_gradients):
return ([DisconnectedType()()] + output_gradients) return ([DisconnectedType()()] + output_gradients)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论