提交 2f82eef2 authored 作者: abergeron's avatar abergeron

Merge pull request #2831 from nouiz/tests

[TEST, BUILDBOT] Update tests since new optimization
...@@ -343,7 +343,7 @@ def test_local_gpu_split(): ...@@ -343,7 +343,7 @@ def test_local_gpu_split():
f = theano.function([x, splits], [ra, rb, rc], mode=mode_with_gpu) f = theano.function([x, splits], [ra, rb, rc], mode=mode_with_gpu)
gpu_res = f([0, 1, 2, 3, 4, 5], [3, 2, 1]) gpu_res = f([0, 1, 2, 3, 4, 5], [3, 2, 1])
l = f.maker.fgraph.toposort() l = f.maker.fgraph.toposort()
assert any([isinstance(o.op, theano.sandbox.cuda.GpuSplit) for o in l]) assert any([isinstance(o.op, cuda.GpuSplit) for o in l])
# Check equality # Check equality
assert all([(cpu == gpu).all() for cpu, gpu in zip(cpu_res, gpu_res)]) assert all([(cpu == gpu).all() for cpu, gpu in zip(cpu_res, gpu_res)])
...@@ -354,7 +354,7 @@ def test_local_gpu_split(): ...@@ -354,7 +354,7 @@ def test_local_gpu_split():
mode=mode_with_gpu.excluding("InputToGpuOptimizer")) mode=mode_with_gpu.excluding("InputToGpuOptimizer"))
gpu_res = f([0, 1, 2, 3, 4, 5], [3, 2, 1]) gpu_res = f([0, 1, 2, 3, 4, 5], [3, 2, 1])
l = f.maker.fgraph.toposort() l = f.maker.fgraph.toposort()
assert any([isinstance(o.op, theano.sandbox.cuda.GpuSplit) for o in l]) assert any([isinstance(o.op, cuda.GpuSplit) for o in l])
# Check equality # Check equality
assert all([(cpu == gpu).all() for cpu, gpu in zip(cpu_res, gpu_res)]) assert all([(cpu == gpu).all() for cpu, gpu in zip(cpu_res, gpu_res)])
...@@ -363,13 +363,16 @@ def test_local_gpu_split(): ...@@ -363,13 +363,16 @@ def test_local_gpu_split():
f = theano.function([x, splits], [ra], mode=mode_without_gpu) f = theano.function([x, splits], [ra], mode=mode_without_gpu)
cpu_res = f([0, 1, 2, 3, 4, 5], [6]) cpu_res = f([0, 1, 2, 3, 4, 5], [6])
l = f.maker.fgraph.toposort() l = f.maker.fgraph.toposort()
# Ensure that one op is theano.tensor.Split # Ensure that no op is theano.tensor.Split or GpuSplit, they get
assert any([isinstance(o.op, theano.tensor.Split) for o in l]) # optimized away.
assert not any([isinstance(o.op, (theano.tensor.Split,
cuda.GpuSplit)) for o in l])
# GPU version # GPU version
f = theano.function([x, splits], [ra], mode=mode_with_gpu) f = theano.function([x, splits], [ra], mode=mode_with_gpu)
gpu_res = f([0, 1, 2, 3, 4, 5], [6]) gpu_res = f([0, 1, 2, 3, 4, 5], [6])
l = f.maker.fgraph.toposort() l = f.maker.fgraph.toposort()
assert any([isinstance(o.op, theano.sandbox.cuda.GpuSplit) for o in l]) assert not any([isinstance(o.op, (theano.tensor.Split,
cuda.GpuSplit)) for o in l])
# Check equality # Check equality
assert all([(cpu == gpu).all() for cpu, gpu in zip(cpu_res, gpu_res)]) assert all([(cpu == gpu).all() for cpu, gpu in zip(cpu_res, gpu_res)])
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论