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


Python Optimizer.new_constant_int方法代码示例

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


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

示例1: test_subtraction

# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import new_constant_int [as 别名]
    def test_subtraction(self):
        opt = Optimizer([ConstantFold])
        opt.add_operation(Types.INT, Operations.INT_SUB,
            [opt.new_constant_int(1), opt.new_constant_int(0)]
        )
        ops = opt.build_operations()

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

示例2: test_addition

# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import new_constant_int [as 别名]
    def test_addition(self):
        opt = Optimizer([ConstantFold])

        res = opt.add_operation(Types.INT, Operations.INT_ADD,
            [opt.new_constant_int(1), opt.new_constant_int(0)]
        )
        ops = opt.build_operations()

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

示例3: test_lt

# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import new_constant_int [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

示例4: test_lt_reverse

# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import new_constant_int [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

示例5: test_cant_fold

# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import new_constant_int [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

示例6: test_guard_false

# 需要导入模块: from optimizer import Optimizer [as 别名]
# 或者: from optimizer.Optimizer import new_constant_int [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


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