提交 25ea9bc3 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Include "canonicalize" in tests for shape opt.

上级 332cd5d4
...@@ -95,10 +95,15 @@ class T_transpose(unittest.TestCase): ...@@ -95,10 +95,15 @@ class T_transpose(unittest.TestCase):
class SparseInferShapeTester(unittest.TestCase): class SparseInferShapeTester(unittest.TestCase):
def setUp(self): def setUp(self):
utt.seed_rng() utt.seed_rng()
# This mode seems to be the minimal one including the shape_i
# optimizations, if we don't want to enumerate them explicitly.
self.mode = theano.compile.get_default_mode().including("canonicalize")
def _compile_and_check(self, inputs, outputs, numeric_inputs, cls): def _compile_and_check(self, inputs, outputs, numeric_inputs, cls):
outputs_function = theano.function(inputs, outputs) outputs_function = theano.function(inputs, outputs, mode=self.mode)
shapes_function = theano.function(inputs, [o.shape for o in outputs]) shapes_function = theano.function(inputs, [o.shape for o in outputs],
mode=self.mode)
theano.printing.debugprint(shapes_function)
# Check that the Op is removed from the compiled function. # Check that the Op is removed from the compiled function.
topo_shape = shapes_function.maker.env.toposort() topo_shape = shapes_function.maker.env.toposort()
assert not any(isinstance(t.op, cls) for t in topo_shape) assert not any(isinstance(t.op, cls) for t in topo_shape)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论