"LLVM ERROR: Type mismatch in constant table!" on empty host list #256

Closed
opened 2022-04-06 03:13:22 +08:00 by ychenfo · 1 comment
Collaborator

Notice this error when looking into optimization for unwrap on KernelInvariant fields.

Currently empty host lists are represented by empty int32 lists in get_symbol_value, which will cause LLVM ERROR: Type mismatch in constant table! when encountering empty host lists of different type:

@nac3
class A:
    a: KernelInvariant[int32]
    def __init__(self, a):
        self.a = a

    @kernel
    def info(self):
        print_int32(self.a)

@nac3
class Demo:
    core: KernelInvariant[Core]
    l: KernelInvariant[list[A]]
    def __init__(self):
        self.core = Core()
        self.l = []

    @kernel
    def run(self):
        for i in self.l:
            i.info()

if __name__ == "__main__":
    Demo().run()

This empty list issue should somehow be isomorphic to the handling of none for the Option type... thinking of passing an additional argument to get_symbol_value(get_obj_value, to_basic_value_enum) to indicate the expected type, and do the casting accordingly?

Notice this error when looking into optimization for `unwrap` on `KernelInvariant` fields. Currently empty host lists are represented by empty `int32` lists in `get_symbol_value`, which will cause `LLVM ERROR: Type mismatch in constant table!` when encountering empty host lists of different type: ```python @nac3 class A: a: KernelInvariant[int32] def __init__(self, a): self.a = a @kernel def info(self): print_int32(self.a) @nac3 class Demo: core: KernelInvariant[Core] l: KernelInvariant[list[A]] def __init__(self): self.core = Core() self.l = [] @kernel def run(self): for i in self.l: i.info() if __name__ == "__main__": Demo().run() ``` This empty list issue should somehow be isomorphic to the handling of `none` for the Option type... thinking of passing an additional argument to `get_symbol_value`(`get_obj_value`, `to_basic_value_enum`) to indicate the expected type, and do the casting accordingly?

Yes, add expected type to get_symbol_value is fine IMO.

Yes, add expected type to `get_symbol_value` is fine IMO.
sb10q closed this issue 2022-04-10 08:33:50 +08:00
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: M-Labs/nac3#256
There is no content yet.