Skip to content

Type inference failure #481

Open
@xywei

Description

@xywei

Type inference on the following kernel fails with message UnboundLocalError: local variable 'symbols_with_unavailable_types' referenced before assignment:

import pyopencl as cl
import numpy as np
import loopy as lp

ctx = cl.create_some_context()
queue = cl.CommandQueue(ctx)

prog = lp.make_kernel(
        "{[i]: 0<=i<3}",
        """
        <> x[i] = if(i==0, 1, if(i==1, 1.1, if(i==2, 1.11, -1))) {id=insn1}
        x[i] = if(x[i]>1.1, 2, x[i]) {id=insn2,dep=insn1,dup=i}
        out[i] = x[i] {dep=insn2,dup=i}
        """)
evt, (out, ) = prog(queue)

The kernel compiles if the conditional in insn2 is not an expression of x[i], e.g.,

x[i] = if(1<0, 2.5, x[i]) {id=insn2,dep=insn1,dup=i}

This issue was revealed in volumential's table building https://gitlab.tiker.net/xywei/volumential/-/jobs/305193.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions