提交 f80fbcea authored 作者: Reyhane Askari's avatar Reyhane Askari

flake8

上级 2e10599b
...@@ -1449,6 +1449,7 @@ def is_in_ancestors(l_node, f_node): ...@@ -1449,6 +1449,7 @@ def is_in_ancestors(l_node, f_node):
@contextlib.contextmanager @contextlib.contextmanager
def nodes_constructed(): def nodes_constructed():
new_nodes = [] new_nodes = []
def observer(node): def observer(node):
new_nodes.append(node) new_nodes.append(node)
Variable.append_construction_observer(observer) Variable.append_construction_observer(observer)
......
...@@ -260,7 +260,9 @@ def op_lifter(OP, cuda_only=False): ...@@ -260,7 +260,9 @@ def op_lifter(OP, cuda_only=False):
to_cpu_fn = safe_to_cpu to_cpu_fn = safe_to_cpu
else: # suppose it is a variable on the GPU else: # suppose it is a variable on the GPU
new_outputs = [new_op] new_outputs = [new_op]
to_cpu_fn = lambda x: x.transfer('cpu')
def to_cpu_fn(x):
return x.transfer('cpu')
# copy stack traces onto gpu outputs # copy stack traces onto gpu outputs
# also copy the stack traces onto HostFromGpu outputs # also copy the stack traces onto HostFromGpu outputs
for old_output, new_output in zip(node.outputs, new_outputs): for old_output, new_output in zip(node.outputs, new_outputs):
...@@ -673,8 +675,8 @@ def local_gpua_alloc_empty_to_zeros(node): ...@@ -673,8 +675,8 @@ def local_gpua_alloc_empty_to_zeros(node):
context_name = infer_context_name(*node.inputs) context_name = infer_context_name(*node.inputs)
z = np.asarray(0, dtype=node.outputs[0].dtype) z = np.asarray(0, dtype=node.outputs[0].dtype)
with inherit_stack_trace(node.outputs): with inherit_stack_trace(node.outputs):
return [GpuAlloc(context_name)(as_gpuarray_variable(z, context_name), return [GpuAlloc(context_name)(
*node.inputs)] as_gpuarray_variable(z, context_name), *node.inputs)]
optdb.register('local_gpua_alloc_empty_to_zeros', optdb.register('local_gpua_alloc_empty_to_zeros',
theano.tensor.opt.in2out(local_gpua_alloc_empty_to_zeros), theano.tensor.opt.in2out(local_gpua_alloc_empty_to_zeros),
# After move to gpu and merge2, before inplace. # After move to gpu and merge2, before inplace.
......
...@@ -49,6 +49,7 @@ def _check_stack_trace(thing): ...@@ -49,6 +49,7 @@ def _check_stack_trace(thing):
return check_stack_trace(thing, ops_to_check=_ops_to_check, return check_stack_trace(thing, ops_to_check=_ops_to_check,
bug_print="ignore") bug_print="ignore")
def test_local_assert(): def test_local_assert():
x = theano.tensor.fmatrix() x = theano.tensor.fmatrix()
a = theano.tensor.opt.assert_op(x, theano.tensor.eq(x, 0).any()) a = theano.tensor.opt.assert_op(x, theano.tensor.eq(x, 0).any())
...@@ -282,6 +283,7 @@ def test_rebroadcast(): ...@@ -282,6 +283,7 @@ def test_rebroadcast():
assert isinstance(rebr.outputs[0].type, GpuArrayType) assert isinstance(rebr.outputs[0].type, GpuArrayType)
assert _check_stack_trace(f) assert _check_stack_trace(f)
class TestSpecifyShape(test_basic.TestSpecifyShape): class TestSpecifyShape(test_basic.TestSpecifyShape):
mode = mode_with_gpu mode = mode_with_gpu
input_type = GpuArrayType input_type = GpuArrayType
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论