提交 49e7b915 authored 作者: Frederic Bastien's avatar Frederic Bastien

added some test of the not optimized function.

上级 c0b57d75
...@@ -25,6 +25,7 @@ from theano import function, compile ...@@ -25,6 +25,7 @@ from theano import function, compile
mode_opt = theano.config.mode mode_opt = theano.config.mode
if mode_opt == 'FAST_COMPILE': if mode_opt == 'FAST_COMPILE':
mode_opt = 'FAST_RUN' mode_opt = 'FAST_RUN'
mode_opt = theano.compile.mode.get_mode(mode_opt)
def inputs(xbc = (0, 0), ybc = (0, 0), zbc = (0, 0)): def inputs(xbc = (0, 0), ybc = (0, 0), zbc = (0, 0)):
x = TensorType(broadcastable = xbc, dtype = 'float64')('x') x = TensorType(broadcastable = xbc, dtype = 'float64')('x')
...@@ -1282,7 +1283,8 @@ class test_local_subtensor_merge(unittest.TestCase): ...@@ -1282,7 +1283,8 @@ class test_local_subtensor_merge(unittest.TestCase):
else: else:
# A non-empty subtensor of an empty one should be an IndexError # A non-empty subtensor of an empty one should be an IndexError
self.assertRaises(IndexError, f, x_val) self.assertRaises(IndexError, f, x_val)
f = function([x], x[::-1][idx], mode=mode_opt.excluding('local_subtensor_merge'))
self.assertRaises(IndexError, f, x_val)
def test_scalar(self): def test_scalar(self):
# var[int::][-1] -> var[-1] # var[int::][-1] -> var[-1]
...@@ -1302,9 +1304,13 @@ class test_local_subtensor_merge(unittest.TestCase): ...@@ -1302,9 +1304,13 @@ class test_local_subtensor_merge(unittest.TestCase):
f(x_val, idx) # let debugmode test something f(x_val, idx) # let debugmode test something
for idx in range(2,5): for idx in range(2,5):
self.assertRaises(IndexError, f, x_val, idx) self.assertRaises(IndexError, f, x_val, idx)
f = function([x,y], x[::-1][y], mode=mode_opt.excluding('local_subtensor_merge'))
self.assertRaises(IndexError, f, x_val, idx)
def test_dont_opt(self): def test_dont_opt(self):
# Test that we don't optimize some case # Test that we don't optimize some case
# var[int::][-1]] should be optimized but not
# var[int::][other int]
x = TT.matrix('x') x = TT.matrix('x')
f = function([x], x[1::][0], mode=mode_opt) f = function([x], x[1::][0], mode=mode_opt)
#theano.printing.debugprint(f) #theano.printing.debugprint(f)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论