Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pushing this up early to request comments / feedback - I think this is one way to solve rapidsai/cudf#15694, with broad applicability to other use cases - this should allow Numba-jitted functions to be called on anything that has an
__array__()
function, much like CUDA kernels can be called on anything that supports the CUDA Array Interface.The implementation handles typing and unboxing by falling back to using
__array__()
only if treating the object as anndarray
fails - therefore, it should not impact the fastest path through dispatch - the code additions here are only executed in cases where the dispatch would otherwise have failed.One minimal test case is added to demonstrate the idea. Additional tests I think would be needed:
numba_adapt_ndarray
that can be deleted.__array__()
andndarray
arguments.cc @brandon-b-miller @AjayThorve
Another benefit of this PR - the following:
presently fails on
main
with an error ending in:but with this PR, gives:
In general, it becomes possible to pass pandas objects directly to jitted functions.