test_opt.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:Theano-Deep-learning 作者: GeekLiB 项目源码 文件源码
def test2(self):
        # Test that alloc never gets instantiated during optimization
        mode = mode_opt.excluding('local_canonicalize_alloc')

        x = tensor.matrix('x')
        y = tensor.tile(x, (1,)*2)

        f = function([x], [y], mode=mode)
        op_classes = [node.op.__class__ for node in f.maker.fgraph.toposort()]
        print(op_classes)

        # We are supposed to test if tensr.Alloc is not in op_classes,
        # but since the proper proper optimization is not currently
        # implemented it will fail. Once the correct optimization is in place,
        # we have to change the following we should not see tensor.Alloc
        # in op_classes and we have to change the assert.
        assert tensor.Alloc in op_classes
        # The correct opt removes nodes, no need for check_stack_trace
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号