def test0(self):
x = shared(self.rng.randn(3, 7))
a = tensor.alloc(x, 6, 7)
# It is a bad idea to have tensor.alloc return x directly,
# because the shape mismatch cannot be caught.
assert a.owner and isinstance(a.owner.op, tensor.Alloc)
f = function([], a, mode=mode_opt)
# The optimization should then be applied, and remove Alloc
assert ([node.op for node in f.maker.fgraph.toposort()]
== [deep_copy_op])
# In DebugMode, the shape mismatch should be detected
if isinstance(mode_opt, compile.DebugMode):
self.assertRaises(ValueError, f)
# No need to check_stack_trace as the optimization
# local_canonicalize_alloc only removes nodes.
评论列表
文章目录