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 across loops generates invalid ISL

Blealtan opened this issue · comments

import ir

with ir.VarDef("u", (64, 64, 64, 5, ), "float64", "inout", "cpu") as u: 
    with ir.For("step", 0, 200) as step:
        with ir.VarDef("spmv_7", (64, 64, 62, 5, ), "float64", "cache", "cpu") as spmv__7: 
            with ir.VarDef("spmv_8", (62, 62, 62, 5, ), "float64", "cache", "cpu") as spmv__8: 
                with ir.For("ij", 0, 4096) as ij:
                    with ir.For("k", 0, 62) as k:
                        with ir.For("ii", 0, 5) as ii:
                            spmv__7[(ij // 64), (ij % 64), k, ii] = u[(ij // 64), (ij % 64), 1, ii]
                with ir.For("ijki", 0, 1191640) as ijki:
                    spmv__8[(ijki // 19220), ((ijki // 310) % 62), ((ijki // 5) % 62), (ijki % 5)] = spmv__7[((ijki // 19220) + 1), (((ijki // 310) % 62) + 1), ((ijki // 5) % 62), (ijki % 5)]
                with ir.For("ijki2", 0, 1310720) as ijki2:
                    u[((ijki2 // 5) // 4096), (((ijki2 // 5) // 64) % 64), ((ijki2 // 5) % 64), (ijki2 % 5)] = spmv__8[(((ijki2 // 5) // 4096) - 1), ((((ijki2 // 5) // 64) % 64) - 1), (((ijki2 // 5) % 64) - 1), (ijki2 % 5)]

ir.lower(ir.pop_ast(), ir.CPU())

on prop-across-loops branch generates

syntax error (1, 31): unknown identifier
got ident 'ij'
syntax error (1, 34): expecting other token
got '/'
syntax error (1, 39): expecting other token
got ')'
syntax error (1, 39): unexpected token
got ')'
Traceback (most recent call last):
  File "solve_step.scheduled.dumped.py", line 16, in <module>
    ir.lower(ir.pop_ast(), ir.CPU())
  File "/home/blealtancao/NPB-Python/deps/roastduck-ir/python/ir/core/passes.py", line 40, in lower
    return ffi.lower(ast, target)
ffi.Error: [ERROR] /home/blealtancao/NPB-Python/deps/roastduck-ir/include/math/presburger.h:63: Unable to construct an PBMap from {[step, 1, ijki, 0] -> [floor(ij / 64), (ij % 64), 1, ii]: ((step >= 0 and step < 200) and ((step - 0) % 1) = 0) and ((ijki >= 0 and ijki < 1191640) and ((ijki - 0) % 1) = 0)}