提交 ccdcc319 authored 作者: Ian Goodfellow's avatar Ian Goodfellow

moved some preprocessing code inside a branch so it only executes if

needed
上级 79c950fa
...@@ -672,6 +672,13 @@ def _populate_grad_dict(var_to_node_to_idx, ...@@ -672,6 +672,13 @@ def _populate_grad_dict(var_to_node_to_idx,
inputs = node.inputs inputs = node.inputs
output_grads = [access_grad_cache(var) for var in node.outputs]
if False in [isinstance(g.type, DisconnectedType)
for g in output_grads]:
# Some outputs of this op are connected to the cost so we must
# call the op's grad method
# Each Op's grad function requires inputs and output_grads # Each Op's grad function requires inputs and output_grads
# If the Op destroys any input, but the grad expression uses it, # If the Op destroys any input, but the grad expression uses it,
# then chances are the resulting graph will have a dependency # then chances are the resulting graph will have a dependency
...@@ -690,13 +697,6 @@ def _populate_grad_dict(var_to_node_to_idx, ...@@ -690,13 +697,6 @@ def _populate_grad_dict(var_to_node_to_idx,
inputs = [try_to_copy_if_needed(ipt) for ipt in inputs] inputs = [try_to_copy_if_needed(ipt) for ipt in inputs]
output_grads = [access_grad_cache(var) for var in node.outputs]
if False in [isinstance(g.type, DisconnectedType)
for g in output_grads]:
# Some outputs of this op are connected to the cost so we must
# call the ops grad method
input_grads = node.op.grad(inputs, output_grads) input_grads = node.op.grad(inputs, output_grads)
if input_grads is None: if input_grads is None:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论