Skip to content
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

Error triggered when adding a different function #2013

Open
Dapid opened this issue Aug 9, 2022 · 5 comments
Open

Error triggered when adding a different function #2013

Dapid opened this issue Aug 9, 2022 · 5 comments

Comments

@Dapid
Copy link
Contributor

Dapid commented Aug 9, 2022

The following code compiles:

import numpy as np

# pythran export compute(float64[:], int)
def compute(vector: np.ndarray, k: int):
    # Select the top-k
    all_indexes = np.argsort(vector)
    sel_indexes = all_indexes[:k]

    return vector[sel_indexes].sum()

But, if we add another function,

#pythran export c2(float64[:, :],  float64[:], int)
def c2(vector2: np.ndarray, bloom2: np.ndarray, k2: int):
    all_indexes = np.argsort(vector2, axis=1)
    return bloom2[all_indexes[:, -k2:]].sum()

Pythran chokes on the first one:

$ pythran _a.py 
WARNING: Compilation error, trying hard to find its origin...
Compilation error, trying hard to find its origin...
CRITICAL: You shall not pass!
E: _a.py:9:11 error: Invalid subscripting of `int` by `slice`
----
    return vector[sel_indexes].sum()
           ^~~~ (o_0)
----

You shall not pass!
E: _a.py:9:11 error: Invalid subscripting of `int` by `slice`
----
    return vector[sel_indexes].sum()
           ^~~~ (o_0)
----

The order of the functions doesn't matter.

Compiling c2 only also fails, with Pythran calling for Jack, and threatening with flooding me with C++ errors, but never following through:

E: error: Command "gcc -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -march=native -O2 -pipe -mtune=native -fPIC -DENABLE_PYTHON_MODULE -D__PYTHRAN__=3 -DPYTHRAN_BLAS_BLAS -I/home/david/.virtualenv/py39/lib/python3.9/site-packages/pythran -I/home/david/.virtualenv/py39/lib64/python3.9/site-packages/numpy/core/include -I/usr/local/include -I/home/david/.virtualenv/py39/include -I/usr/include/python3.9 -c /tmp/tmp49me4yct.cpp -o /tmp/tmpodcacr_f/tmp/tmp49me4yct.o -std=c++11 -fno-math-errno -fvisibility=hidden -fno-wrapv -Wno-unused-function -Wno-int-in-bool-context -Wno-unknown-warning-option -march=native -O2 -pipe -mtune=native" failed with exit status 1

The functions at least are runnable:

compute(np.random.random(100), 10)
c2(np.random.random((500, 100)), np.random.random(1000), 10)
@Dapid
Copy link
Contributor Author

Dapid commented Aug 9, 2022

Forgot to add, the error happens both release and master. gcc (GCC) 12.1.1 20220507 (Red Hat 12.1.1-1) and Python 3.9.13.

@Dapid
Copy link
Contributor Author

Dapid commented Sep 28, 2022

Still present in 0.12.0.

@serge-sans-paille
Copy link
Owner

Thanks for the... reminder :-) Turns out we don't implement np.argsort along axis. I'll have a look :-)

@Dapid
Copy link
Contributor Author

Dapid commented Sep 28, 2022

But why does it crash on the other function?

@serge-sans-paille
Copy link
Owner

because type error reporting in pythran is... not that good :-/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants