Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

branching on a stride triggers validation error in bounds checking #740

Open
meganfrisella opened this issue Nov 6, 2024 · 0 comments
Open
Labels
C: Internal Implementation detail S: Available Available to be worked upon T: Bug Something isn't working

Comments

@meganfrisella
Copy link

The program test_branch_stride1 hits a validation error in bounds checking. Interestingly, test_branch_stride2 and test_branch_stride3 are subtly different and do not trigger any error.

# validation error
def test_branch_stride1(compiler):
    @proc
    def bar(B: [i8][3,4], res: f32):
        if (stride(B, 0) == 8):
            res = 1
    @proc
    def foo(A: i8[3,4], res: f32):
        bar(A[:,:], res)

# OK
def test_branch_stride2(compiler):
    @proc
    def bar(B: [i8][3,4], res: f32):
        if (stride(B, 0) == 8):
            res = 1
    @proc
    def foo(A: i8[3,4], res: f32):
        bar(A, res)

# OK
def test_branch_stride3(compiler):
    @proc
    def bar(B: [i8][3,4], res: f32):
        a: f32
        a = 0
        if (stride(B, 0) == 8):
            a = 1
        res = a
    @proc
    def foo(A: i8[3,4], res: f32):
        bar(A[:,:], res)

Error trace for test_branch_stride1:

src/exo/API.py:51: in proc
    return Procedure(parser.result())
src/exo/API.py:173: in __init__
    CheckBounds(proc)
src/exo/boundscheck.py:567: in __init__
    body_eff = self.map_stmts(proc.body, self.rec_proc_types(proc))
src/exo/boundscheck.py:1058: in map_stmts
    eff = eff.subst(bind)
src/exo/boundscheck.py:150: in subst
    return eff_subst(env, self)
src/exo/boundscheck.py:198: in eff_subst
    [eff_subst(env, es) for es in eff.writes],
src/exo/boundscheck.py:160: in eff_subst
    pred = eff_subst(env, eff.pred) if eff.pred else None
src/exo/boundscheck.py:177: in eff_subst
    eff_subst(env, eff.lhs),
src/exo/boundscheck.py:184: in eff_subst
    return E.Stride(name, eff.dim, eff.type, eff.srcinfo)
<string>:2: in __init__
    ???
../../.venv/exo/lib/python3.12/site-packages/asdl_adt/adt.py:46: in validate
    return point_valid(val)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

obj = Effects.Stride(name=B_1, dim=0, type=LoopIR.Stride(), srcinfo=<exo.prelude.SrcInfo object at 0x1057772c0>)

    def _validator(obj):
        if obj is not None:
            if isinstance(obj, typ):
                return obj
    
            if convert:
                return typ(obj)
    
>       raise ValidationError(typ, type(obj))
E       asdl_adt.validators.ValidationError: expected: Sym, actual: Effects.Stride

../../.venv/exo/lib/python3.12/site-packages/asdl_adt/validators.py:42: ValidationError
@meganfrisella meganfrisella added the T: Bug Something isn't working label Nov 6, 2024
@yamaguchi1024 yamaguchi1024 added C: Internal Implementation detail S: Available Available to be worked upon labels Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: Internal Implementation detail S: Available Available to be worked upon T: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants