Example #1
0
 def replace_box(self, oldbox, newbox):
     # here, only for replacing a box with a const
     if isinstance(oldbox, FrontendOp) and isinstance(newbox, Const):
         assert newbox.same_constant(constant_from_op(oldbox))
         oldbox.set_replaced_with_const()
Example #2
0
 def replace_box(self, oldbox, newbox):
     # here, only for replacing a box with a const
     if isinstance(oldbox, FrontendOp) and isinstance(newbox, Const):
         assert newbox.same_constant(constant_from_op(oldbox))
         oldbox.set_replaced_with_const()
Example #3
0
def maybe_replace_with_const(box):
    if not isinstance(box, Const) and box.is_replaced_with_const():
        return constant_from_op(box)
    else:
        return box
Example #4
0
def maybe_replace_with_const(box):
    if not isinstance(box, Const) and box.is_replaced_with_const():
        return constant_from_op(box)
    else:
        return box