-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Consider deprecating numba.generated_jit
#8466
Comments
#8467 removes internal uses of |
From discussion at the Numba public meeting today.
|
This deprecates numba.generated_jit as outlined in numba#8466 Closes numba#8466
With reference to #8466 (comment). Items 1. and 3. are implemented in #8499. It turns out that 2. can be done with: def generated_jit(function=None, cache=False,
pipeline_class=None, **options):
"""
This decorator allows flexible type-based compilation
of a jitted function. It works as `@jit`, except that the decorated
function is called at compile-time with the *types* of the arguments
and should return an implementation function for those types.
"""
from numba.extending import overload
jit_options = dict()
if pipeline_class is not None:
jit_options['pipeline_class'] = pipeline_class
jit_options['cache'] = cache
jit_options |= options
if function is not None:
overload(function, jit_options=jit_options,
strict=False)(function)
return function
else:
def wrapper(func):
overload(func, jit_options=jit_options,
strict=False)(func)
return func
return wrapper However, this leads to issues as it slightly changes the behaviour of a. In the case of a call like b. The use of @generated_jit
def foo(a, b=1):
if isinstance(a, types.Float):
def impl(a, b): # Note that b is not declared as a kwarg
return a + b
return impl |
Do you have an example of the caching issue? I tried a few things and the caching is working. |
I think it was test:
|
notes from out-of-band discussion for #8466 (comment): The failure of the test actually came from the replacement implementation of |
Some notes from another OOB discussion... If the Conclusions were:
|
The decorator
@numba.generated_jit
provides similar functionality to the much more powerful@numba.extending.overload
decorator. This issue discusses issues with the@generated_jit
functionality and is to track decisions, if any, over deprecation in favour of just using@overload
.The
@generated_jit
decorator essentially provides functionality to allow type-based selection of an implementation at compile time. Example:A few issues exist with the concept/implementation:
generated_jit
use tends to break "JIT transparency", i.e. if the@jit
family decorators are removed or the environment variableNUMBA_DISABLE_JIT
is set, then the source code does not execute in the same way as it would were the JIT compiler present (xref: NUMBA_DISABLE_JIT breaks @generated_jit #4759).@generated_jit
, for example inlining (xref: generated_jit doesn't get passed correct arguments with inline='always' argument #4692).Conceptually,
@generated_jit
is like@overload
but the overloaded function is the decorated function, as a result, there already exists a replacement for@generated_jit
, it's@overload
. Taking the example above and turning it into an@overload
:Further, since preliminary support for
isinstance
has been added, along with advances in branch pruning, the necessity for@generated_jit
in basic cases like the above has decreased, for example, this is a shorter version of the above.Final points...
@overload
and@intrinsic
and will inherit all the effort that has been put into those decorators, trying to make@generated_jit
work seems unnecessary given the replacement already exists.@generated_jit
is not particularly involved in part because it is not as heavily developed as@overload
.Considerations:
@generated_jit
provides that@overload
does not?@overload
perhaps need an update to assist with 1. ?@overload
be provided?The text was updated successfully, but these errors were encountered: