mnnpy icon indicating copy to clipboard operation
mnnpy copied to clipboard

mnnpy fails to import with latest version of numba

Open sinclaircooper opened this issue 5 years ago • 5 comments

mnnpy (version 0.1.9.5) fails to import when using the latest version of numba (0.44.0). Rolling back to the previous version of numba (0.43.1) fixes this issue.

Most of the error messages seem to be related to type errors.

Python 3.6.7+ (heads/3.6:bfb8818, Dec  5 2018, 13:28:38) 
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mnnpy 
/python3.6/site-packages/mnnpy/utils.py:14: NumbaWarning: 
Compilation is falling back to object mode WITH looplifting enabled because Function "l2_norm" failed type inference due to: Invalid use of Function(<function norm at 0x7f43f913cea0>) with argument(s) of type(s): (axis=Literal[int](1), x=array(float32, 2d, A))
 * parameterized
In definition 0:
    TypeError: norm_impl() got an unexpected keyword argument 'x'
    raised from /python3.6/site-packages/numba/typing/templates.py:475
In definition 1:
    TypeError: norm_impl() got an unexpected keyword argument 'x'
    /lib/python3.6/site-packages/numba/typing/templates.py:475
This error is usually caused by passing an argument of a type that is unsupported by the named function.
[1] During: resolving callee type: Function(<function norm at 0x7f43f913cea0>)


File python3.6/site-packages/mnnpy/utils.py", line 16:
def l2_norm(in_matrix):
    return np.linalg.norm(x=in_matrix, axis=1)
    ^

sinclaircooper avatar Jun 13 '19 14:06 sinclaircooper

Having the same error - slew of error messages like this with numba=44.1

deto avatar Jul 12 '19 18:07 deto

Same issue. numba=0.44.1, llvmlite=0.29.0

vincent6liu avatar Aug 02 '19 20:08 vincent6liu

This specific one is very easy to fix: Just call norm(in_matrix, axis=1) instead of norm(x=in_matrix, axis=1)

flying-sheep avatar Jan 13 '20 10:01 flying-sheep

@flying-sheep Still results in TypeError: norm_impl() got an unexpected keyword argument 'axis'. Looks like the axis arg is removed, as the axis is inferred internally, if I interpret the source correctly?

https://github.com/numba/numba/blob/88e3dad3d43a59c79e6295f72fc344d77f13330c/numba/targets/linalg.py#L2365-L2371

However, omitting the axis arg led to other tracebacks, leading to IndexError: invalid index to scalar variable.?

chris-rands avatar Jan 13 '20 13:01 chris-rands

Well, numba doesn’t seem to support that function properly: numba/numba#2558

They should go fix it.

flying-sheep avatar Jan 13 '20 14:01 flying-sheep