transonic issueshttps://foss.heptapod.net/fluiddyn/transonic/-/issues2024-03-14T21:24:51Zhttps://foss.heptapod.net/fluiddyn/transonic/-/issues/57Implement Jax backend2024-03-14T21:24:51ZAshwin V. MohananImplement Jax backendIn the simplest terms, to support Jax we have to
* add a `@jit` decorator like in Numba and
* optimistically replace `import numpy as np` with `import jax.numpy as np`
The API has of course some deviations, but for many cases this sh...In the simplest terms, to support Jax we have to
* add a `@jit` decorator like in Numba and
* optimistically replace `import numpy as np` with `import jax.numpy as np`
The API has of course some deviations, but for many cases this should work. Shall we add it here, alongside the Numba backend implementation?
* https://jax.readthedocs.io/en/latest/notebooks/thinking_in_jax.html#jax-vs-numpy
* https://jax.readthedocs.io/en/latest/notebooks/Common_Gotchas_in_JAX.htmlAshwin V. MohananAshwin V. Mohananhttps://foss.heptapod.net/fluiddyn/transonic/-/issues/56Automatic upload of sdist and wheel on PyPI for new tag2024-01-17T12:47:58ZPierre AugierAutomatic upload of sdist and wheel on PyPI for new tagWe will soon have to release a new version of Transonic. For Transonic (and other pure Python packages of the Fluiddyn project, in particular [Fluiddyn](https://foss.heptapod.net/fluiddyn/fluiddyn)) I'd like to have this automatically do...We will soon have to release a new version of Transonic. For Transonic (and other pure Python packages of the Fluiddyn project, in particular [Fluiddyn](https://foss.heptapod.net/fluiddyn/fluiddyn)) I'd like to have this automatically done on Gitlab CI.
For pure Python packages, this is simple and we don't need Github Actions. (In contrast, I guess Github Actions are going to be useful for packages using Transonic/Pythran, like Fluidsim.)
For Transonic, I'd like to have a job building and uploading the sdist and wheel on PyPI, of course upload only when a tag is pushed.
@ogiorgis Could you please have a look at this issue? Tell me how I can be useful (for example, I guess we will need a new environment variable with a PyPI token?).giorgisgiorgishttps://foss.heptapod.net/fluiddyn/transonic/-/issues/55AttributeError: 'CommentLine' object has no attribute 'value'2023-10-06T14:51:05ZMartí BoschAttributeError: 'CommentLine' object has no attribute 'value'Hello,
pylandstats' builds started getting this "AttributeError: 'CommentLine' object has no attribute 'value'". See build logs for the full traceback at:
https://github.com/martibosch/pylandstats/actions/runs/6340622438/job/17222439515...Hello,
pylandstats' builds started getting this "AttributeError: 'CommentLine' object has no attribute 'value'". See build logs for the full traceback at:
https://github.com/martibosch/pylandstats/actions/runs/6340622438/job/17222439515?pr=45
It seems that the error is raised already when running "pip install numpy pythran 'setuptools>=61.0' 'transonic>=0.4.0' wheel".
As you can see, the error is raised by beniget but it seems related to a former issue: https://github.com/serge-sans-paille/beniget/issues/14, supposedly fixed in transonic some years ago: https://github.com/serge-sans-paille/beniget/pull/15#issuecomment-531128678.
I have not changed the build-related code. I suppose this is due to some change in pythran 0.14.0 but it is very hard for me to infer what this may be from the changelog. Any help will be greatly appreciated. Otherwise I can try upper-bounding pythran to 0.13.x
Thank you in advance. Best,
Martíhttps://foss.heptapod.net/fluiddyn/transonic/-/issues/50add black as requirement2023-08-27T19:49:34ZMartí Boschadd black as requirementstarting yesterday, my builds started failing because of a `ModuleNotFoundError: No module named 'black'`. I suppose it is because the builds started using transonic v0.5.3, nonetheless, I tried pinning transonic to v0.5.2 and still got ...starting yesterday, my builds started failing because of a `ModuleNotFoundError: No module named 'black'`. I suppose it is because the builds started using transonic v0.5.3, nonetheless, I tried pinning transonic to v0.5.2 and still got the same error (I really do not understand what happened here).
I am temporarily fixing this by adding black to my requirements, but I suppose that considering this: https://github.com/psf/black/issues/517#issuecomment-1024982817, black could be added as a transonic dependency.https://foss.heptapod.net/fluiddyn/transonic/-/issues/49FileNotFoundError when using jit2022-09-16T13:23:40ZJon LuoFileNotFoundError when using jitHi, I'm getting a FileNotFoundError when trying to jit a function in my Jupyter notebook. This is on an M2 Macbook Air on macOS 12.5. The noarch version on conda-forge is on 0.4.7, so I installed 0.5.0 with pip.
```python
import numpy a...Hi, I'm getting a FileNotFoundError when trying to jit a function in my Jupyter notebook. This is on an M2 Macbook Air on macOS 12.5. The noarch version on conda-forge is on 0.4.7, so I installed 0.5.0 with pip.
```python
import numpy as np
from transonic import jit
from transonic.util import print_versions
def somefunc(a, b):
return a[:, np.newaxis] * b
print_versions()
somefunc_jit = jit(backend="pythran")(somefunc)
```
```python
Transonic 0.5.0
Pythran 0.11.0
Numba not importable
Cython not importable
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
File /opt/homebrew/Caskroom/mambaforge/base/envs/firthlogist/lib/python3.10/site-packages/transonic/justintime.py:147, in ModuleJIT.get_source(self)
146 try:
--> 147 mod = sys.modules[self.module_name]
148 except KeyError:
KeyError: '3113780246'
During handling of the above exception, another exception occurred:
FileNotFoundError Traceback (most recent call last)
Input In [15], in <cell line: 9>()
3 from transonic.util import print_versions
5 # def br(X, rootW):
6 # z = rootW[:, np.newaxis] * X
7 # return z
9 @jit
---> 10 def somefunc(a, b):
11 return a[:, np.newaxis] * b
13 print_versions()
File /opt/homebrew/Caskroom/mambaforge/base/envs/firthlogist/lib/python3.10/site-packages/transonic/justintime.py:188, in jit(func, backend, native, xsimd, openmp)
184 """Decorator to record that the function has to be jit compiled
185
186 """
187 frame = get_frame(1)
--> 188 decor = JIT(frame, backend=backend, native=native, xsimd=xsimd, openmp=openmp)
189 if callable(func):
190 return decor(func)
File /opt/homebrew/Caskroom/mambaforge/base/envs/firthlogist/lib/python3.10/site-packages/transonic/justintime.py:203, in JIT.__init__(self, frame, backend, native, xsimd, openmp)
199 def __init__(
200 self, frame, backend: str, native=False, xsimd=False, openmp=False
201 ):
--> 203 self.mod = _get_module_jit(backend, frame=frame)
205 self.backend = self.mod.backend
206 self.native = native
File /opt/homebrew/Caskroom/mambaforge/base/envs/firthlogist/lib/python3.10/site-packages/transonic/justintime.py:180, in _get_module_jit(backend_name, depth_frame, frame)
178 return modules[module_name]
179 else:
--> 180 return ModuleJIT(backend_name=backend_name, frame=frame)
File /opt/homebrew/Caskroom/mambaforge/base/envs/firthlogist/lib/python3.10/site-packages/transonic/justintime.py:117, in ModuleJIT.__init__(self, backend_name, frame)
108 self.used_functions = {}
109 self.jit_functions = {}
111 (
112 jitted_dicts,
113 codes_dependance,
114 codes_dependance_classes,
115 code_ext,
116 special,
--> 117 ) = analysis_jit(self.get_source(), self.filename, backend_name)
119 self.info_analysis = {
120 "jitted_dicts": jitted_dicts,
121 "codes_dependance": codes_dependance,
122 "codes_dependance_classes": codes_dependance_classes,
123 "special": special,
124 }
126 self.backend = backend = backends[backend_name]
File /opt/homebrew/Caskroom/mambaforge/base/envs/firthlogist/lib/python3.10/site-packages/transonic/justintime.py:149, in ModuleJIT.get_source(self)
147 mod = sys.modules[self.module_name]
148 except KeyError:
--> 149 with open(self.filename) as file:
150 return file.read()
151 else:
FileNotFoundError: [Errno 2] No such file or directory: '/var/folders/31/h99fpx813jz___z01ln52hw80000gn/T/ipykernel_82978/3113780246.py'
```https://foss.heptapod.net/fluiddyn/transonic/-/issues/48NotImplementedError: self.call1 used but call1 not in class annotations2022-03-09T05:57:47ZNeal BeckerNotImplementedError: self.call1 used but call1 not in class annotationsThis code results in the error when compiled:
https://gist.github.com/nbecker/66b76d4464352eb8669903d0b77396d4
NotImplementedError: self.call1 used but call1 not in class annotations
Does the code need some modification?This code results in the error when compiled:
https://gist.github.com/nbecker/66b76d4464352eb8669903d0b77396d4
NotImplementedError: self.call1 used but call1 not in class annotations
Does the code need some modification?https://foss.heptapod.net/fluiddyn/transonic/-/issues/47boundscheck ignored?2021-12-29T12:38:13ZNeal Beckerboundscheck ignored?In this test, it seems boundscheck is ignored?
A "constellation" object is created, which is basically just a numpy array. It overloads __call__, which just redirects to __getitem__. When called with a scalar arg (no __len__), it shoul...In this test, it seems boundscheck is ignored?
A "constellation" object is created, which is basically just a numpy array. It overloads __call__, which just redirects to __getitem__. When called with a scalar arg (no __len__), it should call call1, which should have boundscheck. It does not appear to work. In the last test case in test_constellation.py, we have an array of size 2, but calling c[10] returns random data instead of an error.
https://gist.github.com/nbecker/76ac6e37652e7b0424886f5c9cbfa33dhttps://foss.heptapod.net/fluiddyn/transonic/-/issues/46Codecov Python package deprecated2021-12-01T10:10:27ZAshwin V. MohananCodecov Python package deprecatedThe codecov Python uploader will be discontinued in a few months. See
- https://docs.codecov.com/docs/codecov-uploader
- https://about.codecov.io/blog/introducing-codecovs-new-uploader/
This can be also fixed in !95 or laterThe codecov Python uploader will be discontinued in a few months. See
- https://docs.codecov.com/docs/codecov-uploader
- https://about.codecov.io/blog/introducing-codecovs-new-uploader/
This can be also fixed in !95 or laterMaintainencehttps://foss.heptapod.net/fluiddyn/transonic/-/issues/45Example `doc/ipynb/executed/bench_fxfy.ipynb` does not execute in Binder2021-12-03T12:29:32ZAshwin V. MohananExample `doc/ipynb/executed/bench_fxfy.ipynb` does not execute in BinderSeems to be related to having no access to the `/tmp` directory.Seems to be related to having no access to the `/tmp` directory.https://foss.heptapod.net/fluiddyn/transonic/-/issues/44Rendering C++ generated files in Pythran.2022-02-22T08:15:53ZKhushi AgrawalRendering C++ generated files in Pythran.Command to access C++ files in Pythran not working. I'm using the following command:
```
transonic -b pythran -af="-e" python/compiled_methods.py
```
Here,
- `-b`: To set pythran as the backend to compile.
- `-af`: To access Pythran fla...Command to access C++ files in Pythran not working. I'm using the following command:
```
transonic -b pythran -af="-e" python/compiled_methods.py
```
Here,
- `-b`: To set pythran as the backend to compile.
- `-af`: To access Pythran flags. I used `-e` flag to generate C++ code.
- `python/compiled_methods.py`: Python file
I want to examine the files generated after compiling the Pythran code. This command runs well but I couldn't found the C++ files. I used `find . -name "*.cpp"` command to access C++ file.
How can I access C++ files?
Thanks!https://foss.heptapod.net/fluiddyn/transonic/-/issues/43@jit runs uncompiled code at first execution2021-05-17T16:05:15Zrqwa@jit runs uncompiled code at first executionThis ticket is related to this [stackoverflow question](https://stackoverflow.com/questions/64857530/transonic-run-python-code-instead-of-pythran).
I use an adapted version of the bug.py from #40 .
```
import numpy as np
from transonic...This ticket is related to this [stackoverflow question](https://stackoverflow.com/questions/64857530/transonic-run-python-code-instead-of-pythran).
I use an adapted version of the bug.py from #40 .
```
import numpy as np
from transonic import jit,boost
from transonic.util import timeit_verbose
def norming(np_array: "float[:,:]"):
norm_array = np.linalg.norm(np_array, axis=1)
return norm_array
norming_pythran = jit(norming)
in_arr = np.random.rand(20000, 5)
def timeit(statement, norm=None):
return timeit_verbose(statement, globals=globals(), norm=norm)
norm = timeit("norming(in_arr)")
timeit("norming_pythran(in_arr)", norm=norm)
```
I run two versions of the code, once with `in_arr = np.random.rand(20000, 5)` and once with `in_arr = np.random.rand(20000, 500)`. Between the two versions I delete ` ~/.transonic/pythran/__jit__/bug`.
Output (20000,5):
```
% python bug.py
norming : 1 * norm
norm = 0.000448 s
Schedule pythranization: norming.py
INFO: Schedule pythranization: norming.py
norming_pythran : 1.03 * norm
% python bug.py
norming : 1 * norm
norm = 0.000449 s
norming_pythran : 0.287 * norm
```
Output (20000,500):
```
% python bug.py 0 [9:44:54]
norming : 1 * norm
norm = 0.0513 s
Schedule pythranization: norming.py
INFO: Schedule pythranization: norming.py
norming_pythran : 1.03 * norm
% python bug.py 0 [9:45:03]
norming : 1 * norm
norm = 0.0673 s
norming_pythran : 0.198 * norm
```
The first code execution shows no acceleration from pyhtran. It seems like only for all following executions the compiled code is used. Is this the expected behavior?
The configuration can be found [here](https://gist.github.com/rqwa/b0e0bcbe8ec9d41563c58c8c405e1e90).https://foss.heptapod.net/fluiddyn/transonic/-/issues/42Astunparse does not work in Python 3.9, use ast.unparse instead?2021-05-03T14:54:50ZAshwin V. MohananAstunparse does not work in Python 3.9, use ast.unparse instead?This is in relation to the issue https://github.com/serge-sans-paille/gast/issues/48, that transonic fails to build with Python 3.9. While trying to install FluidSim we get:
<details>
<summary>setup traceback </summary>
```py
writing...This is in relation to the issue https://github.com/serge-sans-paille/gast/issues/48, that transonic fails to build with Python 3.9. While trying to install FluidSim we get:
<details>
<summary>setup traceback </summary>
```py
writing fluidsim.egg-info/PKG-INFO
writing dependency_links to fluidsim.egg-info/dependency_links.txt
writing entry points to fluidsim.egg-info/entry_points.txt
writing requirements to fluidsim.egg-info/requires.txt
writing top-level names to fluidsim.egg-info/top_level.txt
Traceback (most recent call last):
File "/opt/hostedtoolcache/Python/3.9.2/x64/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 280, in <module>
main()
File "/opt/hostedtoolcache/Python/3.9.2/x64/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 263, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/opt/hostedtoolcache/Python/3.9.2/x64/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 204, in build_wheel
return _build_backend().build_wheel(wheel_directory, config_settings,
File "/tmp/pip-build-env-gvs8yeep/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 216, in build_wheel
return self._build_with_temp_dir(['bdist_wheel'], '.whl',
File "/tmp/pip-build-env-gvs8yeep/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 202, in _build_with_temp_dir
self.run_setup()
File "/tmp/pip-build-env-gvs8yeep/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 145, in run_setup
exec(compile(code, __file__, 'exec'), locals())
File "setup.py", line 172, in <module>
setup(
File "/tmp/pip-build-env-gvs8yeep/overlay/lib/python3.9/site-packages/setuptools/__init__.py", line 153, in setup
return distutils.core.setup(**attrs)
File "/opt/hostedtoolcache/Python/3.9.2/x64/lib/python3.9/distutils/core.py", line 148, in setup
dist.run_commands()
File "/opt/hostedtoolcache/Python/3.9.2/x64/lib/python3.9/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/opt/hostedtoolcache/Python/3.9.2/x64/lib/python3.9/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/tmp/pip-build-env-gvs8yeep/overlay/lib/python3.9/site-packages/wheel/bdist_wheel.py", line 335, in run
self.run_command('install')
File "/opt/hostedtoolcache/Python/3.9.2/x64/lib/python3.9/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/opt/hostedtoolcache/Python/3.9.2/x64/lib/python3.9/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/tmp/pip-build-env-gvs8yeep/overlay/lib/python3.9/site-packages/setuptools/command/install.py", line 61, in run
return orig.install.run(self)
File "/opt/hostedtoolcache/Python/3.9.2/x64/lib/python3.9/distutils/command/install.py", line 558, in run
self.run_command(cmd_name)
File "/opt/hostedtoolcache/Python/3.9.2/x64/lib/python3.9/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/opt/hostedtoolcache/Python/3.9.2/x64/lib/python3.9/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/tmp/pip-build-env-gvs8yeep/overlay/lib/python3.9/site-packages/setuptools/command/install_egg_info.py", line 34, in run
self.run_command('egg_info')
File "/opt/hostedtoolcache/Python/3.9.2/x64/lib/python3.9/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/opt/hostedtoolcache/Python/3.9.2/x64/lib/python3.9/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/tmp/pip-build-env-gvs8yeep/overlay/lib/python3.9/site-packages/setuptools/command/egg_info.py", line 299, in run
self.find_sources()
File "/tmp/pip-build-env-gvs8yeep/overlay/lib/python3.9/site-packages/setuptools/command/egg_info.py", line 306, in find_sources
mm.run()
File "/tmp/pip-build-env-gvs8yeep/overlay/lib/python3.9/site-packages/setuptools/command/egg_info.py", line 541, in run
self.add_defaults()
File "/tmp/pip-build-env-gvs8yeep/overlay/lib/python3.9/site-packages/setuptools/command/egg_info.py", line 577, in add_defaults
sdist.add_defaults(self)
File "/opt/hostedtoolcache/Python/3.9.2/x64/lib/python3.9/distutils/command/sdist.py", line 228, in add_defaults
self._add_defaults_ext()
File "/opt/hostedtoolcache/Python/3.9.2/x64/lib/python3.9/distutils/command/sdist.py", line 312, in _add_defaults_ext
self.filelist.extend(build_ext.get_source_files())
File "/opt/hostedtoolcache/Python/3.9.2/x64/lib/python3.9/distutils/command/build_ext.py", line 426, in get_source_files
filenames.extend(ext.sources)
File "/tmp/pip-build-env-gvs8yeep/normal/lib/python3.9/site-packages/pythran/dist.py", line 156, in sources
tc.compile_pythranfile(source, output_file,
File "/tmp/pip-build-env-gvs8yeep/normal/lib/python3.9/site-packages/pythran/toolchain.py", line 472, in compile_pythranfile
output_file = compile_pythrancode(module_name, open(file_path).read(),
File "/tmp/pip-build-env-gvs8yeep/normal/lib/python3.9/site-packages/pythran/toolchain.py", line 394, in compile_pythrancode
module, error_checker = generate_cxx(module_name, pythrancode, specs, opts,
File "/tmp/pip-build-env-gvs8yeep/normal/lib/python3.9/site-packages/pythran/toolchain.py", line 138, in generate_cxx
pm, ir, docstrings = front_middle_end(module_name, code, optimizations,
File "/tmp/pip-build-env-gvs8yeep/normal/lib/python3.9/site-packages/pythran/toolchain.py", line 96, in front_middle_end
ir, docstrings = frontend.parse(pm, code)
File "/tmp/pip-build-env-gvs8yeep/normal/lib/python3.9/site-packages/pythran/frontend.py", line 23, in parse
ir = raw_parse(code)
File "/tmp/pip-build-env-gvs8yeep/normal/lib/python3.9/site-packages/pythran/frontend.py", line 17, in raw_parse
return ast.parse(code)
File "/tmp/pip-build-env-gvs8yeep/overlay/lib/python3.9/site-packages/gast/gast.py", line 300, in parse
return ast_to_gast(_ast.parse(*args, **kwargs))
File "/opt/hostedtoolcache/Python/3.9.2/x64/lib/python3.9/ast.py", line 50, in parse
return compile(source, filename, mode, flags,
File "<unknown>", line 22
inc_var = (var[(:, irx:n1)] - var[(:, 0:n1new)])
```
</details>
This has to do with `astunparse`'s compatibility with Python 3.9, which is clear when we use `ast` directly. The good news is the [standard library now has an `ast.unparse` method](https://github.com/python/cpython/pull/17302/files) - so why not use that?
```py
In [18]: import ast
...: from ast import unparse, dump
...: # from astunparse import unparse, dump
...:
...: code = "foo[:, b]"
...: tree = ast.parse(code)
...: code_back = unparse(tree).strip()
...:
...: node = tree.body[0]
...: subscript = node.value
...: print(dump.__module__, "dump: (subscript.slice):\n" + dump(subscript.slice))
...:
...: assert code == code_back, (code, code_back)
ast dump: (subscript.slice):
Tuple(elts=[Slice(), Name(id='b', ctx=Load())], ctx=Load())
In [19]: import ast
...: # from ast import unparse, dump
...: from astunparse import unparse, dump
...:
...: code = "foo[:, b]"
...: tree = ast.parse(code)
...: code_back = unparse(tree).strip()
...:
...: node = tree.body[0]
...: subscript = node.value
...: print(dump.__module__, "dump: (subscript.slice):\n" + dump(subscript.slice))
...:
...: assert code == code_back, (code, code_back)
astunparse dump: (subscript.slice):
Tuple(
elts=[
Slice(
lower=None,
upper=None,
step=None),
Name(
id='b',
ctx=Load())],
ctx=Load())
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-19-020b140fd5fe> in <module>
11 print(dump.__module__, "dump: (subscript.slice):\n" + dump(subscript.slice))
12
---> 13 assert code == code_back, (code, code_back)
AssertionError: ('foo[:, b]', 'foo[(:, b)]')
```https://foss.heptapod.net/fluiddyn/transonic/-/issues/41"-march=native -DUSE_XSIMD" doesn't work with polymorphism2021-02-17T08:31:50ZJingyang Wang"-march=native -DUSE_XSIMD" doesn't work with polymorphismHi Pierre,
As you have successfully predicted, I just ran into another issue again > < So basically, I compiled the following version of `transonic_test.py`:
```python
import numpy as np
from transonic import boost, Array, NDim
A = Arr...Hi Pierre,
As you have successfully predicted, I just ran into another issue again > < So basically, I compiled the following version of `transonic_test.py`:
```python
import numpy as np
from transonic import boost, Array, NDim
A = Array[float, NDim(1, 2, 3)]
@boost
def norming(np_array: A):
norm_array = np.linalg.norm(np_array, axis=-1)
return norm_array
```
with either of the following two commands:
```
transonic transonic_test.py
```
and
```
transonic transonic_test.py -af "-march=native -DUSE_XSIMD"
```
Seems the first command correctly produced the expected code, whereas the second one ran into trouble. The error message is as follows:
```
ERROR Error! File /Users/jw598/Desktop/__pythran__/transonic_test_07b266ff974f5f
d62a84a1e7eee777da.cpython-37m-darwin.so has not been created by pythran
Pythran stderr:
WARNING: Compilation error, trying hard to find its origin...
WARNING: Nop, I'm going to flood you with C++ errors!
CRITICAL: Cover me Jack. Jack? Jaaaaack!!!!
E: error: Command "g++ -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g
-fwrapv -O3 -Wall -I/Users/jw598/miniconda3/include -arch x86_64
-I/Users/jw598/miniconda3/include -arch x86_64 -I/usr/local/opt/openblas/include
-DENABLE_PYTHON_MODULE -D__PYTHRAN__=3 -DUSE_XSIMD -DPYTHRAN_BLAS_OPENBLAS
-I/usr/local/opt/openblas/include
-I/Users/jw598/miniconda3/lib/python3.7/site-packages/pythran
-I/Users/jw598/miniconda3/lib/python3.7/site-packages/numpy/core/include
-I/Users/jw598/miniconda3/include/python3.7m -c /tmp/tmpcul5xuab.cpp -o
/tmp/tmpdmlmq4my/tmp/tmpcul5xuab.o -std=c++11 -fno-math-errno -w -march=native" failed
with exit status 1
```
I'm wondering if this is a bug, or the code should not be compiled this way when `Array` type is used?
Thanks,
Jingyanghttps://foss.heptapod.net/fluiddyn/transonic/-/issues/40Unexpected behavior of @jit and @boost2021-04-16T09:52:58ZJingyang WangUnexpected behavior of @jit and @boostRecently I tested transonic with this simple code:
transonic_test.py
```python
import numpy as np
from transonic import jit,boost
#transonic def norming(float[])
@boost
def norming(np_array):
norm_array = np.linalg.norm(np_array,...Recently I tested transonic with this simple code:
transonic_test.py
```python
import numpy as np
from transonic import jit,boost
#transonic def norming(float[])
@boost
def norming(np_array):
norm_array = np.linalg.norm(np_array, axis=1)
return norm_array
```
I use this command to compile it ahead-of-time:
```bash
transonic transonic_test.py -af "-march=native -DUSE_XSIMD -Ofast"
```
which ran successfully. However, when I execute the following program
transonic_test_main.py
```python
from transonic_test import *
from timeit import default_timer as timer
start_1 = timer()
for i in range(1000):
in_arr = np.random.rand(10000, 3)
norm_arr = norming(in_arr)
end_1 = timer()
print("time spent are {}".format(end_1 - start_1))
```
with python, the output shows:
```
DEBUG Using rich for tracking progress.
WARNING Pythran file does not seem to be up-to-date:
<module '__pythran__.transonic_test_4f3187f787722cc89a00775cc0002503' from '/Users/jw598/Desktop/high_entropy_
alloy/__pythran__/transonic_test_4f3187f787722cc89a00775cc0002503.cpython-37m-darwin.so'>
func: norming
time spent are 0.3765912619999999
```
with the timing almost the same as pure python. This problem is identical to the one reported here:\
https://stackoverflow.com/questions/64857530/transonic-run-python-code-instead-of-pythran
My system configuration is:
OS: MacOS Catalina 10.15.7\
gcc: 10.2.0\
python: 3.7.7\
pythran: 0.9.8.post2\
transonic: 0.4.7.post0
Thanks a lot!
Jingyang Wanghttps://foss.heptapod.net/fluiddyn/transonic/-/issues/39Typing improvements: annotations and numpy.typing2021-02-08T09:45:40ZAshwin V. MohananTyping improvements: annotations and numpy.typingThere are two major updates:
- Type hints can be more concise due to two new PEPs. This may be handled by the AST parser, but should be checked.
- Numpy officially supports type-annotations starting v1.20. At some point we should transi...There are two major updates:
- Type hints can be more concise due to two new PEPs. This may be handled by the AST parser, but should be checked.
- Numpy officially supports type-annotations starting v1.20. At some point we should transition `transonic.typing` towards that / support them additionally.
See: https://www.scivision.dev/mypy-pep-585-604/https://foss.heptapod.net/fluiddyn/transonic/-/issues/38UI/UX using rich: progress bar, logging2020-11-13T18:31:46ZAshwin V. MohananUI/UX using rich: progress bar, loggingWe could add some visual feedback while compiling many extensions. The `rich` library is particularly good. See the [progress bar example](https://github.com/willmcgugan/rich#progress-bars). I think we can add them here: https://foss.hep...We could add some visual feedback while compiling many extensions. The `rich` library is particularly good. See the [progress bar example](https://github.com/willmcgugan/rich#progress-bars). I think we can add them here: https://foss.heptapod.net/fluiddyn/transonic/-/blob/48c5fd9224665d88fba90586edca91309f21961b/transonic/compiler.py#L77-106. Isn't it
Note that `rich` can replace the `colorlog` package as [shown here](https://github.com/willmcgugan/rich#logging-handler).MaintainenceAshwin V. MohananAshwin V. Mohananhttps://foss.heptapod.net/fluiddyn/transonic/-/issues/37User-defined types in signatures in comments2020-06-11T14:11:07ZPierre AugierUser-defined types in signatures in comments```
from transonic import boost
T = float
# transonic def func(T)
@boost
def func(a):
return 2 * a
```
leads to
```
Traceback (most recent call last):
File "/home/pierre/.pyenv/versions/3.8.2/bin/transonic", line 11, in <module>
...```
from transonic import boost
T = float
# transonic def func(T)
@boost
def func(a):
return 2 * a
```
leads to
```
Traceback (most recent call last):
File "/home/pierre/.pyenv/versions/3.8.2/bin/transonic", line 11, in <module>
load_entry_point('transonic', 'console_scripts', 'transonic')()
File "/home/pierre/Dev/transonic/transonic/run.py", line 85, in run
backend.make_backend_files(paths, force=args.force)
File "/home/pierre/Dev/transonic/transonic/backends/base.py", line 76, in make_backend_files
path_out = self.make_backend_file(path, analyse, force=force)
File "/home/pierre/Dev/transonic/transonic/backends/base.py", line 131, in make_backend_file
code_backend, codes_ext, code_header = self._make_backend_code(
File "/home/pierre/Dev/transonic/transonic/backends/base.py", line 189, in _make_backend_code
signatures_func = self._make_header_1_function(fdef, annotations)
File "/home/pierre/Dev/transonic/transonic/backends/base.py", line 460, in _make_header_1_function
return self._make_header_from_fdef_annotations(
File "/home/pierre/Dev/transonic/transonic/backends/base.py", line 472, in _make_header_from_fdef_annotations
compute_signatures_from_typeobjects(annot, self.type_formatter)
File "/home/pierre/Dev/transonic/transonic/signatures.py", line 56, in compute_signatures_from_typeobjects
type_ = str2type(type_)
File "/home/pierre/Dev/transonic/transonic/typing.py", line 922, in str2type
raise ValueError(f"Can't determine the Transonic type from '{str_type}'")
ValueError: Can't determine the Transonic type from 'T'
```
It's silly because it works fine with blocs! And it can be very useful! See https://foss.heptapod.net/fluiddyn/fluidsim/merge_requests/156
Pierre AugierPierre Augierhttps://foss.heptapod.net/fluiddyn/transonic/-/issues/36Numpy bool arrays don't work with Pythran backend2020-05-15T20:12:14ZDaniel MouritzenNumpy bool arrays don't work with Pythran backendIt doesn't seem to be possible to pass a bool array to a jit-compiled function with the Pythran backend. I didn't try with other backends. Here's an example:
```python
import numpy as np
from transonic import jit, Array, wait_for_all_ex...It doesn't seem to be possible to pass a bool array to a jit-compiled function with the Pythran backend. I didn't try with other backends. Here's an example:
```python
import numpy as np
from transonic import jit, Array, wait_for_all_extensions, typeof
@jit
def test1(a: Array[bool, "2d"]):
return np.any(a)
@jit
def test2(a: Array[np.bool_, "2d"]):
return np.any(a)
a=np.zeros((3, 3), dtype=bool)
print(typeof(a).dtype) # <class 'numpy.bool_'>
test1(a)
test2(a)
wait_for_all_extensions()
# test1(a) # RuntimeError: Error while compiling code generated by Transonic.
# test2(a) # RuntimeError: Error while compiling code generated by Transonic.
```
Here's the full error:
```
ERROR: Error! File /home/daniel/.transonic/pythran/__jit__/__ipython__2a84652c03a07addf471009730705153/test1_e01fe91fc194dbb64a836622629125ff_39043f4db47a419004b852bfb822da1d.cpython-37m-x86_64-linux-gnu.so has not been created by pythran
Pythran stderr:
CRITICAL: I am in trouble. Your input file does not seem to match Pythran's constraints...
E: Invalid Pythran spec near 'bool_' (line 2)
```https://foss.heptapod.net/fluiddyn/transonic/-/issues/35polymorphic methods supported?2020-05-05T20:41:08ZNeal Beckerpolymorphic methods supported?The following simple test seems to indicate that polymorphic class members are not supported.
It seems only the 2nd overload of __call__ works.
Is there a workaround?
---- constellation.py ---
```import numpy as np
from transonic impor...The following simple test seems to indicate that polymorphic class members are not supported.
It seems only the 2nd overload of __call__ works.
Is there a workaround?
---- constellation.py ---
```import numpy as np
from transonic import boost
A = "complex[:]"
S = "int[:]"
@boost
class constellation:
map: A
def __init__(self, map: A):
self.map = map
@boost
def __call__(self, s: int):
return self.map[s]
@boost
def __call__(self, syms: S):
out = np.empty(len(syms), dtype=complex)
for i in range (len (syms)):
out[i] = self.map[syms[i]]
return out
```
--- test_constellation.py ---
```
from constellation import constellation
import numpy as np
A = np.array
u = A([1+0j, -1+0j])
c = constellation (u)
syms = A ([0,1])
xconst = c(syms)
x = c(0)
```
```
---> 11 x = c(0)
<string> in new_method(self, syms)
TypeError: Invalid call to pythranized function `__for_method__constellation____call__(complex128[:], int)'
Candidates are:
- __for_method__constellation____call__(complex128[:], int[:])
```https://foss.heptapod.net/fluiddyn/transonic/-/issues/34Alternative to pytest-ipynb2020-10-23T13:57:16ZAshwin V. MohananAlternative to pytest-ipynbI remember there was some issue with pytest-ipynb : https://foss.heptapod.net/fluiddyn/transonic/commit/37bc59df447f793cf24fa1b202528abb72c7f817
https://github.com/computationalmodelling/nbval
Source: https://nitter.snopyta.org/andreaz...I remember there was some issue with pytest-ipynb : https://foss.heptapod.net/fluiddyn/transonic/commit/37bc59df447f793cf24fa1b202528abb72c7f817
https://github.com/computationalmodelling/nbval
Source: https://nitter.snopyta.org/andreazonca/status/1256031999615102976#m