提交 7dd0276b authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Add test cases for #698 and #757.

上级 77679d7b
import numpy
from nose.plugins.skip import SkipTest
import theano
from theano.sandbox.cuda.var import float32_shared_constructor as f32sc
from theano.sandbox.cuda import CudaNdarrayType, cuda_available
......@@ -34,3 +35,35 @@ def test_float32_shared_constructor():
assert eq(
f32sc(numpy.zeros((2,3,4,5), dtype='float32')).type,
CudaNdarrayType((False,)*4))
def test_givens():
# Test that you can use a TensorType expression to replace a
# CudaNdarrayType in the givens dictionary.
# This test case uses code mentionned in #757
data = numpy.float32([1,2,3,4])
x = f32sc(data)
y = x**2
f = theano.function([x], y, givens={x:x+1})
def test_updates():
# Test that you can use a TensorType expression to update a
# CudaNdarrayType in the updates dictionary.
data = numpy.float32([1,2,3,4])
x = f32sc(data)
y = x**2
f = theano.function([], y, updates={x:x+1})
def test_updates2():
# Test that you can use a TensorType expression to update a
# CudaNdarrayType in the updates dictionary.
# This test case uses code mentionned in #698
data = numpy.random.rand(10,10).astype('float32')
output_var = f32sc(name="output",
value=numpy.zeros((10,10), 'float32'))
x = theano.tensor.fmatrix('x')
output_updates = {output_var:x**2}
output_givens = {x:data}
output_func = theano.function(inputs=[], outputs=[],
updates=output_updates, givens=output_givens)
output_func()
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论