def test_ifelse():
a = T.scalar()
b = generic()
c = generic()
notimpl = NotImplementedOp()
lazys = [True]
# We need lazy to end up being True for this test.
if theano.config.vm.lazy in [True, None]:
lazys = [True, None]
cloops = [True, False]
if theano.config.cxx == "":
cloops = [False]
for cloop in cloops:
for lazy in lazys:
linker = theano.gof.vm.VM_Linker(use_cloop=cloop, lazy=lazy)
f = function([a, b, c], ifelse(a, notimpl(b), c),
mode=Mode(linker=linker, optimizer='fast_run'))
try:
# print "case 1"
f(1, 'a', 'b')
assert False
except NotImplementedOp.E:
pass
# print "... passed"
# print "case 2"
# print f(0, 'a', 'b')
assert f(0, 'a', 'b') == 'b'
# print "... passed"
评论列表
文章目录