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
Replace context.compile_internal
by @overload
in cmathimpl.py
#9516
base: main
Are you sure you want to change the base?
Replace context.compile_internal
by @overload
in cmathimpl.py
#9516
Conversation
...
numba/core/lowering.py:1392: in lower_expr
self.incref(resty, castval)
numba/core/lowering.py:1560: in incref
self.context.nrt.incref(self.builder, typ, val)
numba/core/runtime/context.py:382: in incref
self._call_incref_decref(builder, typ, value, "NRT_incref")
numba/core/runtime/context.py:367: in _call_incref_decref
meminfos = self.get_meminfos(builder, typ, value)
numba/core/runtime/context.py:355: in get_meminfos
field = getter(val)
numba/core/datamodel/models.py:713: in getter
raise TypeError("expecting {0} but got {1}".format(*args))
E TypeError: expecting {float, float} but got {double, double} |
5aa64fc
to
44d86e6
Compare
context.compile_internal
by context.call_overload
context.compile_internal
by @overload
in cmathimpl.py
a408eab
to
ca143f6
Compare
ca143f6
to
6fc1a93
Compare
6fc1a93
to
ff3338c
Compare
Should this be moved from draft status now it's RFR? |
gpuci run tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many thanks for the improvements! I've left some comments on the diff.
Unfortunately this seems to have broken CUDA ufuncs e.g. - https://gpuci.gpuopenanalytics.com/job/numba/job/numba/job/prb/job/numba-prb/675/CUDA_TOOLKIT_VER=11.8,CUDA_VER=11.2,LINUX_VER=ubuntu18.04,PYTHON_VER=3.8,RAPIDS_VER=21.12/console
Do you need some help looking into the CUDA issue, or are you happy to fix this up?
@lower(cmath.sqrt, types.Complex) | ||
def sqrt_impl(context, builder, sig, args): | ||
@overload(cmath.sqrt) | ||
def sqrt_impl(z): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this return None
if z
is not a complex?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's one test in parfors that call cmath.sqrt
with an integer. I think I remember why I included the code below:
theargflt = z.underlying_float if isinstance(z, types.Complex) else z
Should numba cast the integer to a complex value?
gpuci run tests |
The CI failure is probably related to one of the parfor tests calling |
Calling any cmath function with a non-complex value should be valid. I'll create an issue to track this and change |
This is more of an exploratory work, and it is not ready yet.The idea is to replace all occurrences ofcompile_internal
bycall_overload
, introduced in this PR. Some of the motivation for this change is the ability to useprint
inside compiled function and dynamic exceptions.Replaces all occurrences of
context.compile_internal
by@overload
incmathimpl.py