当前位置: 首页>>代码示例>>Python>>正文


Python Optimizer.add_input方法代码示例

本文整理汇总了Python中optimizer.Optimizer.add_input方法的典型用法代码示例。如果您正苦于以下问题:Python Optimizer.add_input方法的具体用法?Python Optimizer.add_input怎么用?Python Optimizer.add_input使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在optimizer.Optimizer的用法示例。


在下文中一共展示了Optimizer.add_input方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_cant_fold

# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import add_input [as 别名]
    def test_cant_fold(self):
        opt = Optimizer([ConstantFold])
        i0 = opt.add_input(Types.INT)

        opt.add_operation(Types.INT, Operations.INT_ADD,
            [i0, opt.new_constant_int(1)]
        )
        ops = opt.build_operations()
        assert len(ops) == 1
开发者ID:fijal,项目名称:optimizer-model,代码行数:11,代码来源:test_optimizations.py

示例2: test_inputs

# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import add_input [as 别名]
    def test_inputs(self):
        opt = Optimizer()
        res = opt.add_input(Types.INT)

        opt.add_operation(Types.VOID, Operations.FINISH, [res])
        ops = opt.build_operations()

        assert len(ops) == 1
        assert ops[0].op == Operations.FINISH
        assert ops[0].getarglist() == [res]
开发者ID:fijal,项目名称:optimizer-model,代码行数:12,代码来源:test_basic.py

示例3: test_known_guard_true

# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import add_input [as 别名]
    def test_known_guard_true(self):
        opt = Optimizer([GuardPropagation])
        i0 = opt.add_input(Types.INT)

        opt.add_operation(Types.VOID, Operations.GUARD_TRUE, [i0])
        opt.add_operation(Types.VOID, Operations.GUARD_TRUE, [i0])

        ops = opt.build_operations()
        assert len(ops) == 1

        assert opt.getvalue(i0).getint() == 1
开发者ID:fijal,项目名称:optimizer-model,代码行数:13,代码来源:test_optimizations.py

示例4: test_guard_false

# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import add_input [as 别名]
    def test_guard_false(self):
        opt = Optimizer([ConstantFold, GuardPropagation])
        i0 = opt.add_input(Types.INT)

        opt.add_operation(Types.VOID, Operations.GUARD_FALSE, [i0])
        opt.add_operation(Types.INT, Operations.INT_EQ, [i0, opt.new_constant_int(1)])

        ops = opt.build_operations()
        assert len(ops) == 1

        assert opt.getvalue(i0).getint() == 0
开发者ID:fijal,项目名称:optimizer-model,代码行数:13,代码来源:test_optimizations.py

示例5: test_setfield

# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import add_input [as 别名]
    def test_setfield(self, cpu):
        opt = Optimizer([Virtualize])
        i0 = opt.add_input(Types.INT)
        struct_descr = cpu.new_struct()
        field_descr = cpu.new_field(struct_descr)

        p0 = opt.add_operation(Types.REF, Operations.NEW, [], descr=struct_descr)
        opt.add_operation(Types.VOID, Operations.SETFIELD, [p0, i0], descr=field_descr)

        ops = opt.build_operations()
        assert len(ops) == 0
开发者ID:fijal,项目名称:optimizer-model,代码行数:13,代码来源:test_optimizations.py

示例6: test_lt

# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import add_input [as 别名]
    def test_lt(self):
        opt = Optimizer([IntBounds, GuardPropagation])
        i0 = opt.add_input(Types.INT)

        i1 = opt.add_operation(Types.INT, Operations.INT_LT,
            [i0, opt.new_constant_int(10)],
        )
        opt.add_operation(Types.VOID, Operations.GUARD_TRUE, [i1])
        opt.add_operation(Types.INT, Operations.INT_LT, [i0, opt.new_constant_int(15)])

        ops = opt.build_operations()
        assert len(ops) == 2
开发者ID:fijal,项目名称:optimizer-model,代码行数:14,代码来源:test_optimizations.py

示例7: test_lt_reverse

# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import add_input [as 别名]
    def test_lt_reverse(self):
        opt = Optimizer([IntBounds, GuardPropagation])
        i0 = opt.add_input(Types.INT)

        i1 = opt.add_operation(Types.INT, Operations.INT_GT,
            [i0, opt.new_constant_int(5)]
        )
        opt.add_operation(Types.VOID, Operations.GUARD_TRUE, [i1])
        i2 = opt.add_operation(Types.INT, Operations.INT_LT,
            [i0, opt.new_constant_int(3)]
        )
        opt.add_operation(Types.VOID, Operations.GUARD_FALSE, [i2])

        ops = opt.build_operations()
        assert len(ops) == 2
        assert opt.getvalue(i2).getint() == 0
开发者ID:fijal,项目名称:optimizer-model,代码行数:18,代码来源:test_optimizations.py

示例8: test_multiple_setfields

# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import add_input [as 别名]
    def test_multiple_setfields(self, cpu):
        opt = Optimizer([Virtualize])
        struct_descr = cpu.new_struct()
        field_descr1 = cpu.new_field(struct_descr)
        field_descr2 = cpu.new_field(struct_descr)
        i0 = opt.add_input(Types.INT)
        i1 = opt.add_input(Types.INT)

        p0 = opt.add_operation(Types.REF, Operations.NEW, [], descr=struct_descr)
        opt.add_operation(Types.VOID, Operations.SETFIELD, [p0, i0], descr=field_descr1)
        opt.add_operation(Types.VOID, Operations.SETFIELD, [p0, i1], descr=field_descr2)
        i2 = opt.add_operation(Types.INT, Operations.GETFIELD, [p0], descr=field_descr1)
        i3 = opt.add_operation(Types.INT, Operations.GETFIELD, [p0], descr=field_descr2)

        ops = opt.build_operations()
        assert len(ops) == 0

        assert opt.getvalue(i2) is i0
        assert opt.getvalue(i3) is i1
开发者ID:fijal,项目名称:optimizer-model,代码行数:21,代码来源:test_optimizations.py


注:本文中的optimizer.Optimizer.add_input方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。