-
Notifications
You must be signed in to change notification settings - Fork 61
Invalid result for HO function with bound instancemethod argument #63
Comments
Both HPAT and Numba fail to compile this code: import numpy as np
from numba import jit
@jit(nopython=True)
def indirect_ok(fn):
return fn()
@jit(nopython=True)
def works_as_expected():
a = np.array([1])
return indirect_ok(a.sum)
print(works_as_expected()) For HPAT: import numpy as np
import hpat
@hpat.jit
def indirect_ok(fn):
return fn()
@hpat.jit
def works_as_expected():
a = np.array([1])
return indirect_ok(a.sum)
print(works_as_expected()) |
HPAT has an inline pass that inlines other jit functions. With inlining in place, I don't think these example will have higher order function call. However, this pass was a quick hack for a use case written long time ago and definitely needs to be revisited. For example, it might not set the IR definitions data structures properly. |
Ah, I see. |
I looked at these examples some more. Looks like inlining is fine. For the top example, the I think the |
Numba does partially support higher-order functions and local closures, but the boundaries are not clearly defined as well as the inlining effect on it.
For HPAT, code below actually results in invalid results and no JIT compilation time error.
We should fix this bug and properly document what kinds of callable values HPAT supports.
After that, it would be simpler to give proper error messages to the user.
Right now it's unclear what are should be compiled and what should result in a compilation error.
Reproducer:
Results for code without
@hpat.hit
decorator:Results for code with JIT:
The text was updated successfully, but these errors were encountered: