roastduck / FreeTensor

A language and compiler for irregular tensor programs.

Home Page:https://roastduck.github.io/FreeTensor/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Prop One Time Use behaves wrong on modified rhs

Blealtan opened this issue · comments

import ir

print("without input:")

with ir.VarDef("x", (5, ), "float64", "cache", "cpu") as x: 
    with ir.VarDef("y", (5, ), "float64", "output", "cpu") as y: 
            with ir.For("i", 0, 5) as i:
                x[i] = 0
            with ir.For("i", 0, 5) as i:
                x[i] = x[i] - 1
                y[i] = x[i]

f = ir.pop_ast()
print(f)
print(ir.prop_one_time_use(f))

print("with input:")

with ir.VarDef("x", (5, ), "float64", "input", "cpu") as x: 
    with ir.VarDef("y", (5, ), "float64", "output", "cpu") as y: 
            with ir.For("i", 0, 5) as i:
                x[i] = 0
            with ir.For("i", 0, 5) as i:
                x[i] = x[i] - 1
                y[i] = x[i]

f = ir.pop_ast()
print(f)
print(ir.prop_one_time_use(f))

Notice that with x as input the problem does not occur, but with x as cache it occurs.

Fixed in d8b4974