提交 0cb1e431 authored 作者: Frederic Bastien's avatar Frederic Bastien

Fix local_gpua_advanced_incsubtensor to return variable on the GPU. op_lifer…

Fix local_gpua_advanced_incsubtensor to return variable on the GPU. op_lifer expect that. fix gh-5589
上级 f141420e
......@@ -1056,7 +1056,8 @@ def local_gpua_advanced_incsubtensor(op, context_name, inputs, outputs):
x = x.dimshuffle(0, 'x')
y = y.dimshuffle('x', 'x')
ret = GpuAdvancedIncSubtensor1_dev20(
set_instead_of_inc=set_instead_of_inc)(x, y, ilist).dimshuffle(0)
set_instead_of_inc=set_instead_of_inc)(x, y, ilist)
ret = GpuDimShuffle(ret.type.broadcastable, [0])(ret)
return ret
elif compute_capability < 2 or x.ndim != 2 or y.ndim != 2:
return GpuAdvancedIncSubtensor1(
......
......@@ -560,3 +560,13 @@ def test_local_lift_solve():
A_val = np.random.uniform(-0.4, 0.4, (5, 5)).astype("float32")
b_val = np.random.uniform(-0.4, 0.4, (5, 3)).astype("float32")
utt.assert_allclose(f_cpu(A_val, b_val), f_gpu(A_val, b_val))
def test_local_gpua_advanced_incsubtensor():
# test a corner case reported at gh-5589
target = tensor.ftensor4()
y = target.dimshuffle(1, 0, 2, 3).flatten(ndim=1)
w = tensor.ones_like(y)
w = tensor.set_subtensor(w[tensor.eq(y, 1.0).nonzero()], 100)
w = tensor.set_subtensor(w[tensor.eq(y, -1.0).nonzero()], 0)
theano.function([target], w)
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论