From 1bd0c36f3d1bc42d2eef75ea8234422c066bcaaf Mon Sep 17 00:00:00 2001 From: paugier Date: Thu, 22 Aug 2024 17:48:06 +0200 Subject: [PATCH 01/12] Metadata in functions --- src/transonic/aheadoftime.py | 26 +++++++++++++++++++++----- src/transonic/backends/base.py | 16 +++++++++------- src/transonic/backends/pythran.py | 4 ++-- 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/src/transonic/aheadoftime.py b/src/transonic/aheadoftime.py index e65bdff..31ed216 100644 --- a/src/transonic/aheadoftime.py +++ b/src/transonic/aheadoftime.py @@ -56,6 +56,19 @@ modules = modules_backends[backend_default] +def _get_data_from_func_or_data(data_or_func): + """ + Before 0.7.2, some metadata was saved in module variables, + which leads to issue with Pythran on Windows. + They are now saved in functions, but we continue supporting the "old" extensions. + """ + try: + return data_or_func() + except TypeError: + # extension compiled with Transonic < 0.7.2 + return data_or_func + + def _get_transonic_calling_module(backend_name: str = None): """Get the Transonic instance corresponding to the calling module @@ -337,11 +350,13 @@ def __init__( if module is not None: if backend.name == "pythran": module.__pythran__ = self.module_backend.__pythran__ - module.__transonic__ = self.module_backend.__transonic__ + module.__transonic__ = _get_data_from_func_or_data( + self.module_backend.__transonic__ + ) if hasattr(self.module_backend, "arguments_blocks"): - self.arguments_blocks = getattr( - self.module_backend, "arguments_blocks" + self.arguments_blocks = _get_data_from_func_or_data( + getattr(self.module_backend, "arguments_blocks") ) modules[module_name] = self @@ -468,9 +483,10 @@ def transonic_class(self, cls: type): try: backend_func = getattr(self.module_backend, name_backend_func) - code_new_method = getattr( - self.module_backend, name_var_code_new_method + code_new_method = _get_data_from_func_or_data( + getattr(self.module_backend, name_var_code_new_method) ) + except AttributeError: # TODO: improve what happens in this case raise RuntimeError( diff --git a/src/transonic/backends/base.py b/src/transonic/backends/base.py index aa53e33..8b96a40 100644 --- a/src/transonic/backends/base.py +++ b/src/transonic/backends/base.py @@ -217,12 +217,12 @@ def _make_backend_code(self, path_py, analysis, **kwargs): if code: code = self._make_beginning_code() + code - self._append_line_header_variable(lines_header, "__transonic__") - code += f'\n\n__transonic__ = "{transonic.__version__}"' + self._append_line_export_func_no_arg(lines_header, "__transonic__") + code += f'\n\ndef __transonic__(): return "{transonic.__version__}"' return format_str(code), codes_ext, "\n".join(lines_header).strip() + "\n" - def _append_line_header_variable(self, lines_header, name_variable): + def _append_line_export_func_no_arg(self, lines_header, name_variable): pass def _make_code_blocks(self, blocks): @@ -252,10 +252,12 @@ def _make_code_blocks(self, blocks): } if arguments_blocks: - self._append_line_header_variable( + self._append_line_export_func_no_arg( signatures_blocks, "arguments_blocks" ) - code.append(f"arguments_blocks = {str(arguments_blocks)}\n") + code.append( + f"def arguments_blocks(): return {str(arguments_blocks)}\n" + ) return signatures_blocks, code def _make_code_methods(self, boosted_dicts, annotations, path_py): @@ -336,11 +338,11 @@ def _make_code_method( name_var_code_new_method = f"__code_new_method__{class_name}__{meth_name}" - self._append_line_header_variable( + self._append_line_export_func_no_arg( signatures_method, name_var_code_new_method ) python_code += ( - f'\n{name_var_code_new_method} = """\n\n' + f'\ndef {name_var_code_new_method}(): return """\n\n' f"def new_method(self, {str_args_value_func}):\n" f" return backend_func({str_args_backend_func})" '\n\n"""\n' diff --git a/src/transonic/backends/pythran.py b/src/transonic/backends/pythran.py index 0127767..8222308 100644 --- a/src/transonic/backends/pythran.py +++ b/src/transonic/backends/pythran.py @@ -22,8 +22,8 @@ class PythranBackend(BackendAOT): def check_if_compiled(self, module): return hasattr(module, "__pythran__") - def _append_line_header_variable(self, lines_header, name_variable): - lines_header.append(f"export {name_variable}\n") + def _append_line_export_func_no_arg(self, lines_header, name_variable): + lines_header.append(f"export {name_variable}()\n") def _make_header_from_fdef_signatures( self, fdef, signatures_as_lists_strings, locals_types=None, returns=None From 6e97a30e7ebb629705dcb57e2bb7216aa836cf92 Mon Sep 17 00:00:00 2001 From: paugier Date: Thu, 22 Aug 2024 17:49:58 +0200 Subject: [PATCH 02/12] Modify saved files for Python backend --- .../saved__backend__/python/add_inline.py | 3 ++- .../python/assign_func_boost.py | 3 ++- .../saved__backend__/python/block_fluidsim.py | 17 +++++++++++++---- .../python/blocks_type_hints.py | 7 +++++-- .../python/boosted_class_use_import.py | 7 +++++-- .../python/boosted_func_use_import.py | 3 ++- .../saved__backend__/python/class_blocks.py | 7 +++++-- .../saved__backend__/python/class_rec_calls.py | 7 +++++-- data_tests/saved__backend__/python/classic.py | 3 ++- .../saved__backend__/python/default_params.py | 3 ++- data_tests/saved__backend__/python/methods.py | 7 +++++-- .../python/mixed_classic_type_hint.py | 3 ++- data_tests/saved__backend__/python/no_arg.py | 3 ++- .../saved__backend__/python/row_sum_boost.py | 3 ++- .../saved__backend__/python/subpackages.py | 5 +++-- .../python/type_hint_notemplate.py | 3 ++- 16 files changed, 59 insertions(+), 25 deletions(-) diff --git a/data_tests/saved__backend__/python/add_inline.py b/data_tests/saved__backend__/python/add_inline.py index 34e1eb8..906de87 100644 --- a/data_tests/saved__backend__/python/add_inline.py +++ b/data_tests/saved__backend__/python/add_inline.py @@ -9,4 +9,5 @@ def use_add(n=10000): return tmp -__transonic__ = ("0.3.2",) +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/python/assign_func_boost.py b/data_tests/saved__backend__/python/assign_func_boost.py index 8cc9285..5af9293 100644 --- a/data_tests/saved__backend__/python/assign_func_boost.py +++ b/data_tests/saved__backend__/python/assign_func_boost.py @@ -2,4 +2,5 @@ def func(x): return x**2 -__transonic__ = ("0.3.0.post0",) +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/python/block_fluidsim.py b/data_tests/saved__backend__/python/block_fluidsim.py index eca7324..d08bc5b 100644 --- a/data_tests/saved__backend__/python/block_fluidsim.py +++ b/data_tests/saved__backend__/python/block_fluidsim.py @@ -9,8 +9,17 @@ def rk2_step0(state_spect_n12, state_spect, tendencies_n, diss2, dt): state_spect_n12[:] = (state_spect + dt / 2 * tendencies_n) * diss2 -arguments_blocks = { - "rk2_step0": ["state_spect_n12", "state_spect", "tendencies_n", "diss2", "dt"] -} +def arguments_blocks(): + return { + "rk2_step0": [ + "state_spect_n12", + "state_spect", + "tendencies_n", + "diss2", + "dt", + ] + } -__transonic__ = ("0.3.0.post0",) + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/python/blocks_type_hints.py b/data_tests/saved__backend__/python/blocks_type_hints.py index ef0e1aa..cd7d954 100644 --- a/data_tests/saved__backend__/python/blocks_type_hints.py +++ b/data_tests/saved__backend__/python/blocks_type_hints.py @@ -12,6 +12,9 @@ def block0(a, b, n): return result -arguments_blocks = {"block0": ["a", "b", "n"]} +def arguments_blocks(): + return {"block0": ["a", "b", "n"]} -__transonic__ = ("0.3.0.post0",) + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/python/boosted_class_use_import.py b/data_tests/saved__backend__/python/boosted_class_use_import.py index c7c16f5..c35377b 100644 --- a/data_tests/saved__backend__/python/boosted_class_use_import.py +++ b/data_tests/saved__backend__/python/boosted_class_use_import.py @@ -6,11 +6,14 @@ def __for_method__MyClass2__myfunc(self_attr0, self_attr1, arg): return self_attr1 + self_attr0 + np.abs(arg) + func_import() -__code_new_method__MyClass2__myfunc = """ +def __code_new_method__MyClass2__myfunc(): + return """ def new_method(self, arg): return backend_func(self.attr0, self.attr1, arg) """ -__transonic__ = ("0.3.0.post0",) + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/python/boosted_func_use_import.py b/data_tests/saved__backend__/python/boosted_func_use_import.py index 3de2681..7b92b09 100644 --- a/data_tests/saved__backend__/python/boosted_func_use_import.py +++ b/data_tests/saved__backend__/python/boosted_func_use_import.py @@ -6,4 +6,5 @@ def func(a, b): return (a * np.log(b)).max() + func_import() -__transonic__ = ("0.3.0.post0",) +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/python/class_blocks.py b/data_tests/saved__backend__/python/class_blocks.py index 2f24cc1..5302846 100644 --- a/data_tests/saved__backend__/python/class_blocks.py +++ b/data_tests/saved__backend__/python/class_blocks.py @@ -36,6 +36,9 @@ def block1(a, b, n): return result -arguments_blocks = {"block0": ["a", "b", "n"], "block1": ["a", "b", "n"]} +def arguments_blocks(): + return {"block0": ["a", "b", "n"], "block1": ["a", "b", "n"]} -__transonic__ = ("0.3.0.post0",) + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/python/class_rec_calls.py b/data_tests/saved__backend__/python/class_rec_calls.py index 598f4f1..64dd8dc 100644 --- a/data_tests/saved__backend__/python/class_rec_calls.py +++ b/data_tests/saved__backend__/python/class_rec_calls.py @@ -12,11 +12,14 @@ def __for_method__Myclass__func(self_attr, self_attr2, arg): ) -__code_new_method__Myclass__func = """ +def __code_new_method__Myclass__func(): + return """ def new_method(self, arg): return backend_func(self.attr, self.attr2, arg) """ -__transonic__ = ("0.3.0.post0",) + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/python/classic.py b/data_tests/saved__backend__/python/classic.py index 3143cff..fc20a23 100644 --- a/data_tests/saved__backend__/python/classic.py +++ b/data_tests/saved__backend__/python/classic.py @@ -5,4 +5,5 @@ def func(a, b): return (a * np.log(b)).max() -__transonic__ = ("0.3.0.post0",) +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/python/default_params.py b/data_tests/saved__backend__/python/default_params.py index 972b5f0..a3b878c 100644 --- a/data_tests/saved__backend__/python/default_params.py +++ b/data_tests/saved__backend__/python/default_params.py @@ -3,4 +3,5 @@ def func(a=1, b=None, c=1.0): return a + c -__transonic__ = ("0.4.0",) +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/python/methods.py b/data_tests/saved__backend__/python/methods.py index f0f1557..70545cf 100644 --- a/data_tests/saved__backend__/python/methods.py +++ b/data_tests/saved__backend__/python/methods.py @@ -6,11 +6,14 @@ def __for_method__Transmitter____call__(self_arr, self_freq, inp): return (inp * np.exp(np.arange(len(inp)) * self_freq * 1j), self_arr) -__code_new_method__Transmitter____call__ = """ +def __code_new_method__Transmitter____call__(): + return """ def new_method(self, inp): return backend_func(self.arr, self.freq, inp) """ -__transonic__ = ("0.3.0.post0",) + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/python/mixed_classic_type_hint.py b/data_tests/saved__backend__/python/mixed_classic_type_hint.py index 3caad4a..973c99d 100644 --- a/data_tests/saved__backend__/python/mixed_classic_type_hint.py +++ b/data_tests/saved__backend__/python/mixed_classic_type_hint.py @@ -9,4 +9,5 @@ def func1(a, b): return a * np.cos(b) -__transonic__ = ("0.3.0.post0",) +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/python/no_arg.py b/data_tests/saved__backend__/python/no_arg.py index 7768f86..c7b6f01 100644 --- a/data_tests/saved__backend__/python/no_arg.py +++ b/data_tests/saved__backend__/python/no_arg.py @@ -6,4 +6,5 @@ def func2(): return 1 -__transonic__ = ("0.3.0.post0",) +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/python/row_sum_boost.py b/data_tests/saved__backend__/python/row_sum_boost.py index f2bc0c7..c5ed910 100644 --- a/data_tests/saved__backend__/python/row_sum_boost.py +++ b/data_tests/saved__backend__/python/row_sum_boost.py @@ -18,4 +18,5 @@ def row_sum_loops(arr, columns): return res -__transonic__ = ("0.3.3.post0",) +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/python/subpackages.py b/data_tests/saved__backend__/python/subpackages.py index 65517b6..a93e30c 100644 --- a/data_tests/saved__backend__/python/subpackages.py +++ b/data_tests/saved__backend__/python/subpackages.py @@ -10,7 +10,7 @@ def test_np_fft(u): def test_np_linalg_random(u): - (nx, ny) = u.shape + nx, ny = u.shape u[:] = randn(nx, ny) u2 = u.T * u u4 = matrix_power(u2, 2) @@ -21,4 +21,5 @@ def test_sp_special(v, x): return jv(v, x) -__transonic__ = ("0.4.2",) +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/python/type_hint_notemplate.py b/data_tests/saved__backend__/python/type_hint_notemplate.py index 13ca209..4915e30 100644 --- a/data_tests/saved__backend__/python/type_hint_notemplate.py +++ b/data_tests/saved__backend__/python/type_hint_notemplate.py @@ -6,4 +6,5 @@ def compute(a, b, c, d, e): return tmp -__transonic__ = ("0.3.0.post0",) +def __transonic__(): + return "0.7.1" From cb5db7f3cc8769e301284c2dd26936ce07d74ef6 Mon Sep 17 00:00:00 2001 From: paugier Date: Mon, 26 Aug 2024 14:28:34 +0200 Subject: [PATCH 03/12] Jax in data_tests/Makefile --- data_tests/Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/data_tests/Makefile b/data_tests/Makefile index cb7dafd..b0d9ef2 100644 --- a/data_tests/Makefile +++ b/data_tests/Makefile @@ -1,12 +1,13 @@ clean: - rm -rf __cython__ __numba__ __pythran__ __python__ + rm -rf __cython__ __numba__ __pythran__ __python__ __jax__ all: transonic -b pythran -nc *.py transonic -b python -nc *.py transonic -b cython -nc *.py transonic -b numba -nc *.py + transonic -b jax -nc *.py meld_pythran: meld __pythran__ saved__backend__/pythran @@ -20,6 +21,9 @@ meld_cython: meld_numba: meld __numba__ saved__backend__/numba +meld_jax: + meld __numba__ saved__backend__/numba + saved__backend__/%: __%__ FORCE rsync -aP $< $@ From 9c6745b1ef19044a7ee379596c998ee8ecb46ddb Mon Sep 17 00:00:00 2001 From: paugier Date: Mon, 26 Aug 2024 14:25:23 +0200 Subject: [PATCH 04/12] Modify saved files for Pythran backend --- .../saved__backend__/pythran/add_inline.py | 3 ++- .../saved__backend__/pythran/add_inline.pythran | 2 +- .../pythran/assign_func_boost.py | 3 ++- .../pythran/assign_func_boost.pythran | 2 +- .../saved__backend__/pythran/block_fluidsim.py | 17 +++++++++++++---- .../pythran/block_fluidsim.pythran | 4 ++-- .../pythran/blocks_type_hints.py | 7 +++++-- .../pythran/blocks_type_hints.pythran | 4 ++-- .../pythran/boosted_class_use_import.py | 7 +++++-- .../pythran/boosted_class_use_import.pythran | 4 ++-- .../pythran/boosted_func_use_import.py | 3 ++- .../pythran/boosted_func_use_import.pythran | 2 +- .../saved__backend__/pythran/class_blocks.py | 7 +++++-- .../pythran/class_blocks.pythran | 4 ++-- .../saved__backend__/pythran/class_rec_calls.py | 7 +++++-- .../pythran/class_rec_calls.pythran | 4 ++-- data_tests/saved__backend__/pythran/classic.py | 3 ++- .../saved__backend__/pythran/classic.pythran | 2 +- .../saved__backend__/pythran/default_params.py | 3 ++- .../pythran/default_params.pythran | 2 +- data_tests/saved__backend__/pythran/methods.py | 7 +++++-- .../saved__backend__/pythran/methods.pythran | 4 ++-- .../pythran/mixed_classic_type_hint.py | 3 ++- .../pythran/mixed_classic_type_hint.pythran | 2 +- data_tests/saved__backend__/pythran/no_arg.py | 3 ++- .../saved__backend__/pythran/no_arg.pythran | 2 +- .../saved__backend__/pythran/row_sum_boost.py | 3 ++- .../pythran/row_sum_boost.pythran | 2 +- .../saved__backend__/pythran/subpackages.py | 5 +++-- .../pythran/subpackages.pythran | 2 +- .../pythran/type_hint_notemplate.py | 3 ++- .../pythran/type_hint_notemplate.pythran | 2 +- 32 files changed, 81 insertions(+), 47 deletions(-) diff --git a/data_tests/saved__backend__/pythran/add_inline.py b/data_tests/saved__backend__/pythran/add_inline.py index 34e1eb8..906de87 100644 --- a/data_tests/saved__backend__/pythran/add_inline.py +++ b/data_tests/saved__backend__/pythran/add_inline.py @@ -9,4 +9,5 @@ def use_add(n=10000): return tmp -__transonic__ = ("0.3.2",) +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/pythran/add_inline.pythran b/data_tests/saved__backend__/pythran/add_inline.pythran index 2a4a925..0111504 100644 --- a/data_tests/saved__backend__/pythran/add_inline.pythran +++ b/data_tests/saved__backend__/pythran/add_inline.pythran @@ -3,4 +3,4 @@ export add(int, int) export use_add() export use_add(int) -export __transonic__ +export __transonic__() diff --git a/data_tests/saved__backend__/pythran/assign_func_boost.py b/data_tests/saved__backend__/pythran/assign_func_boost.py index 1a37494..5af9293 100644 --- a/data_tests/saved__backend__/pythran/assign_func_boost.py +++ b/data_tests/saved__backend__/pythran/assign_func_boost.py @@ -2,4 +2,5 @@ def func(x): return x**2 -__transonic__ = ("0.3.0",) +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/pythran/assign_func_boost.pythran b/data_tests/saved__backend__/pythran/assign_func_boost.pythran index 1ee7db4..740cc03 100644 --- a/data_tests/saved__backend__/pythran/assign_func_boost.pythran +++ b/data_tests/saved__backend__/pythran/assign_func_boost.pythran @@ -1,3 +1,3 @@ export func(int) -export __transonic__ +export __transonic__() diff --git a/data_tests/saved__backend__/pythran/block_fluidsim.py b/data_tests/saved__backend__/pythran/block_fluidsim.py index 52316a4..d08bc5b 100644 --- a/data_tests/saved__backend__/pythran/block_fluidsim.py +++ b/data_tests/saved__backend__/pythran/block_fluidsim.py @@ -9,8 +9,17 @@ def rk2_step0(state_spect_n12, state_spect, tendencies_n, diss2, dt): state_spect_n12[:] = (state_spect + dt / 2 * tendencies_n) * diss2 -arguments_blocks = { - "rk2_step0": ["state_spect_n12", "state_spect", "tendencies_n", "diss2", "dt"] -} +def arguments_blocks(): + return { + "rk2_step0": [ + "state_spect_n12", + "state_spect", + "tendencies_n", + "diss2", + "dt", + ] + } -__transonic__ = ("0.3.0",) + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/pythran/block_fluidsim.pythran b/data_tests/saved__backend__/pythran/block_fluidsim.pythran index 9aabc14..ce4dfae 100644 --- a/data_tests/saved__backend__/pythran/block_fluidsim.pythran +++ b/data_tests/saved__backend__/pythran/block_fluidsim.pythran @@ -1,5 +1,5 @@ export rk2_step0(complex128[:, :, :], complex128[:, :, :], complex128[:, :, :], float64[:, :], float64) -export arguments_blocks +export arguments_blocks() -export __transonic__ +export __transonic__() diff --git a/data_tests/saved__backend__/pythran/blocks_type_hints.py b/data_tests/saved__backend__/pythran/blocks_type_hints.py index 2aed8f0..cd7d954 100644 --- a/data_tests/saved__backend__/pythran/blocks_type_hints.py +++ b/data_tests/saved__backend__/pythran/blocks_type_hints.py @@ -12,6 +12,9 @@ def block0(a, b, n): return result -arguments_blocks = {"block0": ["a", "b", "n"]} +def arguments_blocks(): + return {"block0": ["a", "b", "n"]} -__transonic__ = ("0.3.0",) + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/pythran/blocks_type_hints.pythran b/data_tests/saved__backend__/pythran/blocks_type_hints.pythran index f33757d..5430602 100644 --- a/data_tests/saved__backend__/pythran/blocks_type_hints.pythran +++ b/data_tests/saved__backend__/pythran/blocks_type_hints.pythran @@ -4,6 +4,6 @@ export block0(float64[:, :], float64[:, :, :], int) export block0(float64[:], float64[:, :], int) export block0(int[:], int[:], float64) -export arguments_blocks +export arguments_blocks() -export __transonic__ +export __transonic__() diff --git a/data_tests/saved__backend__/pythran/boosted_class_use_import.py b/data_tests/saved__backend__/pythran/boosted_class_use_import.py index 7f9cef4..c35377b 100644 --- a/data_tests/saved__backend__/pythran/boosted_class_use_import.py +++ b/data_tests/saved__backend__/pythran/boosted_class_use_import.py @@ -6,11 +6,14 @@ def __for_method__MyClass2__myfunc(self_attr0, self_attr1, arg): return self_attr1 + self_attr0 + np.abs(arg) + func_import() -__code_new_method__MyClass2__myfunc = """ +def __code_new_method__MyClass2__myfunc(): + return """ def new_method(self, arg): return backend_func(self.attr0, self.attr1, arg) """ -__transonic__ = ("0.3.0",) + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/pythran/boosted_class_use_import.pythran b/data_tests/saved__backend__/pythran/boosted_class_use_import.pythran index 7feecf1..9f57866 100644 --- a/data_tests/saved__backend__/pythran/boosted_class_use_import.pythran +++ b/data_tests/saved__backend__/pythran/boosted_class_use_import.pythran @@ -1,5 +1,5 @@ export __for_method__MyClass2__myfunc(int, int, int) -export __code_new_method__MyClass2__myfunc +export __code_new_method__MyClass2__myfunc() -export __transonic__ +export __transonic__() diff --git a/data_tests/saved__backend__/pythran/boosted_func_use_import.py b/data_tests/saved__backend__/pythran/boosted_func_use_import.py index 6c139fb..7b92b09 100644 --- a/data_tests/saved__backend__/pythran/boosted_func_use_import.py +++ b/data_tests/saved__backend__/pythran/boosted_func_use_import.py @@ -6,4 +6,5 @@ def func(a, b): return (a * np.log(b)).max() + func_import() -__transonic__ = ("0.3.0",) +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/pythran/boosted_func_use_import.pythran b/data_tests/saved__backend__/pythran/boosted_func_use_import.pythran index f6e9de6..8495fa7 100644 --- a/data_tests/saved__backend__/pythran/boosted_func_use_import.pythran +++ b/data_tests/saved__backend__/pythran/boosted_func_use_import.pythran @@ -1,4 +1,4 @@ export func(float64[:, :], float64[:, :]) export func(int[:, :], float64[:, :]) -export __transonic__ +export __transonic__() diff --git a/data_tests/saved__backend__/pythran/class_blocks.py b/data_tests/saved__backend__/pythran/class_blocks.py index 8ac715f..5302846 100644 --- a/data_tests/saved__backend__/pythran/class_blocks.py +++ b/data_tests/saved__backend__/pythran/class_blocks.py @@ -36,6 +36,9 @@ def block1(a, b, n): return result -arguments_blocks = {"block0": ["a", "b", "n"], "block1": ["a", "b", "n"]} +def arguments_blocks(): + return {"block0": ["a", "b", "n"], "block1": ["a", "b", "n"]} -__transonic__ = ("0.3.0",) + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/pythran/class_blocks.pythran b/data_tests/saved__backend__/pythran/class_blocks.pythran index 953fd03..4eb424f 100644 --- a/data_tests/saved__backend__/pythran/class_blocks.pythran +++ b/data_tests/saved__backend__/pythran/class_blocks.pythran @@ -4,6 +4,6 @@ export block0(float64[:, :], float64[:, :], int) export block1(float64[:, :, :], float64[:, :, :], int) export block1(float64[:, :], float64[:, :], int) -export arguments_blocks +export arguments_blocks() -export __transonic__ +export __transonic__() diff --git a/data_tests/saved__backend__/pythran/class_rec_calls.py b/data_tests/saved__backend__/pythran/class_rec_calls.py index 8a716ac..64dd8dc 100644 --- a/data_tests/saved__backend__/pythran/class_rec_calls.py +++ b/data_tests/saved__backend__/pythran/class_rec_calls.py @@ -12,11 +12,14 @@ def __for_method__Myclass__func(self_attr, self_attr2, arg): ) -__code_new_method__Myclass__func = """ +def __code_new_method__Myclass__func(): + return """ def new_method(self, arg): return backend_func(self.attr, self.attr2, arg) """ -__transonic__ = ("0.3.0",) + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/pythran/class_rec_calls.pythran b/data_tests/saved__backend__/pythran/class_rec_calls.pythran index 9c3271c..d12ca74 100644 --- a/data_tests/saved__backend__/pythran/class_rec_calls.pythran +++ b/data_tests/saved__backend__/pythran/class_rec_calls.pythran @@ -1,5 +1,5 @@ export __for_method__Myclass__func(int, int, int) -export __code_new_method__Myclass__func +export __code_new_method__Myclass__func() -export __transonic__ +export __transonic__() diff --git a/data_tests/saved__backend__/pythran/classic.py b/data_tests/saved__backend__/pythran/classic.py index 67f2d04..fc20a23 100644 --- a/data_tests/saved__backend__/pythran/classic.py +++ b/data_tests/saved__backend__/pythran/classic.py @@ -5,4 +5,5 @@ def func(a, b): return (a * np.log(b)).max() -__transonic__ = ("0.3.0",) +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/pythran/classic.pythran b/data_tests/saved__backend__/pythran/classic.pythran index f6e9de6..8495fa7 100644 --- a/data_tests/saved__backend__/pythran/classic.pythran +++ b/data_tests/saved__backend__/pythran/classic.pythran @@ -1,4 +1,4 @@ export func(float64[:, :], float64[:, :]) export func(int[:, :], float64[:, :]) -export __transonic__ +export __transonic__() diff --git a/data_tests/saved__backend__/pythran/default_params.py b/data_tests/saved__backend__/pythran/default_params.py index 972b5f0..a3b878c 100644 --- a/data_tests/saved__backend__/pythran/default_params.py +++ b/data_tests/saved__backend__/pythran/default_params.py @@ -3,4 +3,5 @@ def func(a=1, b=None, c=1.0): return a + c -__transonic__ = ("0.4.0",) +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/pythran/default_params.pythran b/data_tests/saved__backend__/pythran/default_params.pythran index 3144b6f..36f5d79 100644 --- a/data_tests/saved__backend__/pythran/default_params.pythran +++ b/data_tests/saved__backend__/pythran/default_params.pythran @@ -5,4 +5,4 @@ export func(int, None, float64) export func(int, str) export func(int, str, float64) -export __transonic__ +export __transonic__() diff --git a/data_tests/saved__backend__/pythran/methods.py b/data_tests/saved__backend__/pythran/methods.py index a8ea0ef..70545cf 100644 --- a/data_tests/saved__backend__/pythran/methods.py +++ b/data_tests/saved__backend__/pythran/methods.py @@ -6,11 +6,14 @@ def __for_method__Transmitter____call__(self_arr, self_freq, inp): return (inp * np.exp(np.arange(len(inp)) * self_freq * 1j), self_arr) -__code_new_method__Transmitter____call__ = """ +def __code_new_method__Transmitter____call__(): + return """ def new_method(self, inp): return backend_func(self.arr, self.freq, inp) """ -__transonic__ = ("0.3.0",) + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/pythran/methods.pythran b/data_tests/saved__backend__/pythran/methods.pythran index 4ff3e58..ef78359 100644 --- a/data_tests/saved__backend__/pythran/methods.pythran +++ b/data_tests/saved__backend__/pythran/methods.pythran @@ -1,5 +1,5 @@ export __for_method__Transmitter____call__(float64[:, :], float64, float64[:]) -export __code_new_method__Transmitter____call__ +export __code_new_method__Transmitter____call__() -export __transonic__ +export __transonic__() diff --git a/data_tests/saved__backend__/pythran/mixed_classic_type_hint.py b/data_tests/saved__backend__/pythran/mixed_classic_type_hint.py index 148db2e..973c99d 100644 --- a/data_tests/saved__backend__/pythran/mixed_classic_type_hint.py +++ b/data_tests/saved__backend__/pythran/mixed_classic_type_hint.py @@ -9,4 +9,5 @@ def func1(a, b): return a * np.cos(b) -__transonic__ = ("0.3.0",) +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/pythran/mixed_classic_type_hint.pythran b/data_tests/saved__backend__/pythran/mixed_classic_type_hint.pythran index 0f6a254..dac1d91 100644 --- a/data_tests/saved__backend__/pythran/mixed_classic_type_hint.pythran +++ b/data_tests/saved__backend__/pythran/mixed_classic_type_hint.pythran @@ -4,4 +4,4 @@ export func(int[:, :], float64[:, :]) export func1(int, float64) -export __transonic__ +export __transonic__() diff --git a/data_tests/saved__backend__/pythran/no_arg.py b/data_tests/saved__backend__/pythran/no_arg.py index ed4cf79..c7b6f01 100644 --- a/data_tests/saved__backend__/pythran/no_arg.py +++ b/data_tests/saved__backend__/pythran/no_arg.py @@ -6,4 +6,5 @@ def func2(): return 1 -__transonic__ = ("0.3.0",) +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/pythran/no_arg.pythran b/data_tests/saved__backend__/pythran/no_arg.pythran index 37cc23b..45f1aa4 100644 --- a/data_tests/saved__backend__/pythran/no_arg.pythran +++ b/data_tests/saved__backend__/pythran/no_arg.pythran @@ -2,4 +2,4 @@ export func() export func2() -export __transonic__ +export __transonic__() diff --git a/data_tests/saved__backend__/pythran/row_sum_boost.py b/data_tests/saved__backend__/pythran/row_sum_boost.py index f2bc0c7..c5ed910 100644 --- a/data_tests/saved__backend__/pythran/row_sum_boost.py +++ b/data_tests/saved__backend__/pythran/row_sum_boost.py @@ -18,4 +18,5 @@ def row_sum_loops(arr, columns): return res -__transonic__ = ("0.3.3.post0",) +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/pythran/row_sum_boost.pythran b/data_tests/saved__backend__/pythran/row_sum_boost.pythran index 23432f5..66ccfae 100644 --- a/data_tests/saved__backend__/pythran/row_sum_boost.pythran +++ b/data_tests/saved__backend__/pythran/row_sum_boost.pythran @@ -2,4 +2,4 @@ export row_sum(int64[:, :], int32[:]) export row_sum_loops(int64[:, :], int32[:]) -export __transonic__ +export __transonic__() diff --git a/data_tests/saved__backend__/pythran/subpackages.py b/data_tests/saved__backend__/pythran/subpackages.py index 65517b6..a93e30c 100644 --- a/data_tests/saved__backend__/pythran/subpackages.py +++ b/data_tests/saved__backend__/pythran/subpackages.py @@ -10,7 +10,7 @@ def test_np_fft(u): def test_np_linalg_random(u): - (nx, ny) = u.shape + nx, ny = u.shape u[:] = randn(nx, ny) u2 = u.T * u u4 = matrix_power(u2, 2) @@ -21,4 +21,5 @@ def test_sp_special(v, x): return jv(v, x) -__transonic__ = ("0.4.2",) +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/pythran/subpackages.pythran b/data_tests/saved__backend__/pythran/subpackages.pythran index 0cd86ab..00872a3 100644 --- a/data_tests/saved__backend__/pythran/subpackages.pythran +++ b/data_tests/saved__backend__/pythran/subpackages.pythran @@ -4,4 +4,4 @@ export test_np_linalg_random(float64[:, :]) export test_sp_special(int, float64) -export __transonic__ +export __transonic__() diff --git a/data_tests/saved__backend__/pythran/type_hint_notemplate.py b/data_tests/saved__backend__/pythran/type_hint_notemplate.py index a000662..4915e30 100644 --- a/data_tests/saved__backend__/pythran/type_hint_notemplate.py +++ b/data_tests/saved__backend__/pythran/type_hint_notemplate.py @@ -6,4 +6,5 @@ def compute(a, b, c, d, e): return tmp -__transonic__ = ("0.3.0",) +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/pythran/type_hint_notemplate.pythran b/data_tests/saved__backend__/pythran/type_hint_notemplate.pythran index 3d36bd1..575f487 100644 --- a/data_tests/saved__backend__/pythran/type_hint_notemplate.pythran +++ b/data_tests/saved__backend__/pythran/type_hint_notemplate.pythran @@ -15,4 +15,4 @@ export compute(int[:], int[:], complex128, int[:], str) export compute(int[:], int[:], int, float32[:, :], str) export compute(int[:], int[:], int, int[:], str) -export __transonic__ +export __transonic__() From 148f58b31286f52a18480fd39c82e5dfd3bbf37a Mon Sep 17 00:00:00 2001 From: paugier Date: Mon, 26 Aug 2024 14:31:35 +0200 Subject: [PATCH 05/12] Modify saved files for Cython backend --- .../saved__backend__/cython/add_inline.py | 3 ++- .../cython/assign_func_boost.py | 3 ++- .../saved__backend__/cython/block_fluidsim.py | 17 +++++++++++++---- .../cython/blocks_type_hints.py | 7 +++++-- .../cython/boosted_class_use_import.py | 7 +++++-- .../cython/boosted_func_use_import.py | 3 ++- .../saved__backend__/cython/class_blocks.py | 7 +++++-- .../saved__backend__/cython/class_rec_calls.py | 7 +++++-- data_tests/saved__backend__/cython/classic.py | 3 ++- .../saved__backend__/cython/default_params.py | 3 ++- data_tests/saved__backend__/cython/methods.py | 7 +++++-- .../cython/mixed_classic_type_hint.py | 3 ++- data_tests/saved__backend__/cython/no_arg.py | 3 ++- .../saved__backend__/cython/row_sum_boost.py | 3 ++- .../saved__backend__/cython/subpackages.py | 5 +++-- .../cython/type_hint_notemplate.py | 3 ++- 16 files changed, 59 insertions(+), 25 deletions(-) diff --git a/data_tests/saved__backend__/cython/add_inline.py b/data_tests/saved__backend__/cython/add_inline.py index 843eb6b..85d58b0 100644 --- a/data_tests/saved__backend__/cython/add_inline.py +++ b/data_tests/saved__backend__/cython/add_inline.py @@ -15,4 +15,5 @@ def use_add(n=10000): return tmp -__transonic__ = ("0.3.3",) +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/cython/assign_func_boost.py b/data_tests/saved__backend__/cython/assign_func_boost.py index b4b6658..f58d325 100644 --- a/data_tests/saved__backend__/cython/assign_func_boost.py +++ b/data_tests/saved__backend__/cython/assign_func_boost.py @@ -8,4 +8,5 @@ def func(x): return x**2 -__transonic__ = ("0.3.3",) +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/cython/block_fluidsim.py b/data_tests/saved__backend__/cython/block_fluidsim.py index 354b19c..01866f7 100644 --- a/data_tests/saved__backend__/cython/block_fluidsim.py +++ b/data_tests/saved__backend__/cython/block_fluidsim.py @@ -15,8 +15,17 @@ def rk2_step0(state_spect_n12, state_spect, tendencies_n, diss2, dt): state_spect_n12[:] = (state_spect + dt / 2 * tendencies_n) * diss2 -arguments_blocks = { - "rk2_step0": ["state_spect_n12", "state_spect", "tendencies_n", "diss2", "dt"] -} +def arguments_blocks(): + return { + "rk2_step0": [ + "state_spect_n12", + "state_spect", + "tendencies_n", + "diss2", + "dt", + ] + } -__transonic__ = ("0.3.3",) + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/cython/blocks_type_hints.py b/data_tests/saved__backend__/cython/blocks_type_hints.py index 2c65c48..5615e11 100644 --- a/data_tests/saved__backend__/cython/blocks_type_hints.py +++ b/data_tests/saved__backend__/cython/blocks_type_hints.py @@ -18,6 +18,9 @@ def block0(a, b, n): return result -arguments_blocks = {"block0": ["a", "b", "n"]} +def arguments_blocks(): + return {"block0": ["a", "b", "n"]} -__transonic__ = ("0.3.3",) + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/cython/boosted_class_use_import.py b/data_tests/saved__backend__/cython/boosted_class_use_import.py index 0fd2d88..030d9e3 100644 --- a/data_tests/saved__backend__/cython/boosted_class_use_import.py +++ b/data_tests/saved__backend__/cython/boosted_class_use_import.py @@ -11,11 +11,14 @@ def __for_method__MyClass2__myfunc(self_attr0, self_attr1, arg): return self_attr1 + self_attr0 + np.abs(arg) + func_import() -__code_new_method__MyClass2__myfunc = """ +def __code_new_method__MyClass2__myfunc(): + return """ def new_method(self, arg): return backend_func(self.attr0, self.attr1, arg) """ -__transonic__ = ("0.3.3",) + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/cython/boosted_func_use_import.py b/data_tests/saved__backend__/cython/boosted_func_use_import.py index 5e69c5a..056a85f 100644 --- a/data_tests/saved__backend__/cython/boosted_func_use_import.py +++ b/data_tests/saved__backend__/cython/boosted_func_use_import.py @@ -11,4 +11,5 @@ def func(a, b): return (a * np.log(b)).max() + func_import() -__transonic__ = ("0.3.3",) +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/cython/class_blocks.py b/data_tests/saved__backend__/cython/class_blocks.py index 2742c9c..52c4dbc 100644 --- a/data_tests/saved__backend__/cython/class_blocks.py +++ b/data_tests/saved__backend__/cython/class_blocks.py @@ -41,6 +41,9 @@ def block1(a, b, n): return result -arguments_blocks = {"block0": ["a", "b", "n"], "block1": ["a", "b", "n"]} +def arguments_blocks(): + return {"block0": ["a", "b", "n"], "block1": ["a", "b", "n"]} -__transonic__ = ("0.3.3",) + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/cython/class_rec_calls.py b/data_tests/saved__backend__/cython/class_rec_calls.py index 60719cf..3081649 100644 --- a/data_tests/saved__backend__/cython/class_rec_calls.py +++ b/data_tests/saved__backend__/cython/class_rec_calls.py @@ -18,11 +18,14 @@ def __for_method__Myclass__func(self_attr, self_attr2, arg): ) -__code_new_method__Myclass__func = """ +def __code_new_method__Myclass__func(): + return """ def new_method(self, arg): return backend_func(self.attr, self.attr2, arg) """ -__transonic__ = ("0.3.3",) + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/cython/classic.py b/data_tests/saved__backend__/cython/classic.py index 1caef16..ff4bc7d 100644 --- a/data_tests/saved__backend__/cython/classic.py +++ b/data_tests/saved__backend__/cython/classic.py @@ -10,4 +10,5 @@ def func(a, b): return (a * np.log(b)).max() -__transonic__ = ("0.3.3",) +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/cython/default_params.py b/data_tests/saved__backend__/cython/default_params.py index 1c86c7d..fe3e477 100644 --- a/data_tests/saved__backend__/cython/default_params.py +++ b/data_tests/saved__backend__/cython/default_params.py @@ -9,4 +9,5 @@ def func(a=1, b=None, c=1.0): return a + c -__transonic__ = ("0.4.0",) +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/cython/methods.py b/data_tests/saved__backend__/cython/methods.py index 358bffb..33f5afd 100644 --- a/data_tests/saved__backend__/cython/methods.py +++ b/data_tests/saved__backend__/cython/methods.py @@ -11,11 +11,14 @@ def __for_method__Transmitter____call__(self_arr, self_freq, inp): return (inp * np.exp(np.arange(len(inp)) * self_freq * 1j), self_arr) -__code_new_method__Transmitter____call__ = """ +def __code_new_method__Transmitter____call__(): + return """ def new_method(self, inp): return backend_func(self.arr, self.freq, inp) """ -__transonic__ = ("0.3.3",) + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/cython/mixed_classic_type_hint.py b/data_tests/saved__backend__/cython/mixed_classic_type_hint.py index df0e567..e0ae360 100644 --- a/data_tests/saved__backend__/cython/mixed_classic_type_hint.py +++ b/data_tests/saved__backend__/cython/mixed_classic_type_hint.py @@ -14,4 +14,5 @@ def func1(a, b): return a * np.cos(b) -__transonic__ = ("0.3.3",) +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/cython/no_arg.py b/data_tests/saved__backend__/cython/no_arg.py index 55ad594..1eec9e8 100644 --- a/data_tests/saved__backend__/cython/no_arg.py +++ b/data_tests/saved__backend__/cython/no_arg.py @@ -12,4 +12,5 @@ def func2(): return 1 -__transonic__ = ("0.3.3",) +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/cython/row_sum_boost.py b/data_tests/saved__backend__/cython/row_sum_boost.py index 253b644..42c879f 100644 --- a/data_tests/saved__backend__/cython/row_sum_boost.py +++ b/data_tests/saved__backend__/cython/row_sum_boost.py @@ -27,4 +27,5 @@ def row_sum_loops(arr, columns): return res -__transonic__ = ("0.3.3",) +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/cython/subpackages.py b/data_tests/saved__backend__/cython/subpackages.py index af0d9e0..5fbc4d9 100644 --- a/data_tests/saved__backend__/cython/subpackages.py +++ b/data_tests/saved__backend__/cython/subpackages.py @@ -15,7 +15,7 @@ def test_np_fft(u): def test_np_linalg_random(u): - (nx, ny) = u.shape + nx, ny = u.shape u[:] = randn(nx, ny) u2 = u.T * u u4 = matrix_power(u2, 2) @@ -26,4 +26,5 @@ def test_sp_special(v, x): return jv(v, x) -__transonic__ = ("0.4.2",) +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/cython/type_hint_notemplate.py b/data_tests/saved__backend__/cython/type_hint_notemplate.py index 4ccfda2..a0637fa 100644 --- a/data_tests/saved__backend__/cython/type_hint_notemplate.py +++ b/data_tests/saved__backend__/cython/type_hint_notemplate.py @@ -12,4 +12,5 @@ def compute(a, b, c, d, e): return tmp -__transonic__ = ("0.3.3",) +def __transonic__(): + return "0.7.1" From 9c48b574d9d0cc509ea93cf08b06607956a3ed18 Mon Sep 17 00:00:00 2001 From: paugier Date: Mon, 26 Aug 2024 14:32:38 +0200 Subject: [PATCH 06/12] Modify saved files for Numba backend --- .../saved__backend__/numba/add_inline.py | 6 ++++- .../numba/assign_func_boost.py | 6 ++++- .../saved__backend__/numba/block_fluidsim.py | 24 +++++++++++++++---- .../numba/blocks_type_hints.py | 14 +++++++++-- .../numba/boosted_class_use_import.py | 14 +++++++++-- .../numba/boosted_func_use_import.py | 6 ++++- .../saved__backend__/numba/class_blocks.py | 14 +++++++++-- .../saved__backend__/numba/class_rec_calls.py | 14 +++++++++-- data_tests/saved__backend__/numba/classic.py | 6 ++++- .../saved__backend__/numba/default_params.py | 6 ++++- data_tests/saved__backend__/numba/methods.py | 14 +++++++++-- .../numba/mixed_classic_type_hint.py | 6 ++++- data_tests/saved__backend__/numba/no_arg.py | 6 ++++- .../saved__backend__/numba/row_sum_boost.py | 6 ++++- .../saved__backend__/numba/subpackages.py | 8 +++++-- .../numba/type_hint_notemplate.py | 6 ++++- 16 files changed, 131 insertions(+), 25 deletions(-) diff --git a/data_tests/saved__backend__/numba/add_inline.py b/data_tests/saved__backend__/numba/add_inline.py index a2f71a3..69bd712 100644 --- a/data_tests/saved__backend__/numba/add_inline.py +++ b/data_tests/saved__backend__/numba/add_inline.py @@ -16,4 +16,8 @@ def use_add(n=10000): return tmp -__transonic__ = ("0.4.7",) +# __protected__ @njit(cache=True, fastmath=True) + + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/numba/assign_func_boost.py b/data_tests/saved__backend__/numba/assign_func_boost.py index c18a754..ce54a0e 100644 --- a/data_tests/saved__backend__/numba/assign_func_boost.py +++ b/data_tests/saved__backend__/numba/assign_func_boost.py @@ -6,4 +6,8 @@ def func(x): return x**2 -__transonic__ = ("0.4.7",) +# __protected__ @njit(cache=True, fastmath=True) + + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/numba/block_fluidsim.py b/data_tests/saved__backend__/numba/block_fluidsim.py index 93a95a2..85ca7f4 100644 --- a/data_tests/saved__backend__/numba/block_fluidsim.py +++ b/data_tests/saved__backend__/numba/block_fluidsim.py @@ -12,7 +12,23 @@ def rk2_step0(state_spect_n12, state_spect, tendencies_n, diss2, dt): state_spect_n12[:] = (state_spect + dt / 2 * tendencies_n) * diss2 -arguments_blocks = { - "rk2_step0": ["state_spect_n12", "state_spect", "tendencies_n", "diss2", "dt"] -} -__transonic__ = ("0.4.7",) +# __protected__ @njit(cache=True, fastmath=True) + + +def arguments_blocks(): + return { + "rk2_step0": [ + "state_spect_n12", + "state_spect", + "tendencies_n", + "diss2", + "dt", + ] + } + + +# __protected__ @njit(cache=True, fastmath=True) + + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/numba/blocks_type_hints.py b/data_tests/saved__backend__/numba/blocks_type_hints.py index 59c656a..12caab5 100644 --- a/data_tests/saved__backend__/numba/blocks_type_hints.py +++ b/data_tests/saved__backend__/numba/blocks_type_hints.py @@ -15,5 +15,15 @@ def block0(a, b, n): return result -arguments_blocks = {"block0": ["a", "b", "n"]} -__transonic__ = ("0.4.7",) +# __protected__ @njit(cache=True, fastmath=True) + + +def arguments_blocks(): + return {"block0": ["a", "b", "n"]} + + +# __protected__ @njit(cache=True, fastmath=True) + + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/numba/boosted_class_use_import.py b/data_tests/saved__backend__/numba/boosted_class_use_import.py index efeb5e1..af1959f 100644 --- a/data_tests/saved__backend__/numba/boosted_class_use_import.py +++ b/data_tests/saved__backend__/numba/boosted_class_use_import.py @@ -9,5 +9,15 @@ def __for_method__MyClass2__myfunc(self_attr0, self_attr1, arg): return self_attr1 + self_attr0 + np.abs(arg) + func_import() -__code_new_method__MyClass2__myfunc = "\n\ndef new_method(self, arg):\n return backend_func(self.attr0, self.attr1, arg)\n\n" -__transonic__ = ("0.4.7",) +# __protected__ @njit(cache=True, fastmath=True) + + +def __code_new_method__MyClass2__myfunc(): + return "\n\ndef new_method(self, arg):\n return backend_func(self.attr0, self.attr1, arg)\n\n" + + +# __protected__ @njit(cache=True, fastmath=True) + + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/numba/boosted_func_use_import.py b/data_tests/saved__backend__/numba/boosted_func_use_import.py index 77e4a64..d95aef2 100644 --- a/data_tests/saved__backend__/numba/boosted_func_use_import.py +++ b/data_tests/saved__backend__/numba/boosted_func_use_import.py @@ -9,4 +9,8 @@ def func(a, b): return (a * np.log(b)).max() + func_import() -__transonic__ = ("0.4.7",) +# __protected__ @njit(cache=True, fastmath=True) + + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/numba/class_blocks.py b/data_tests/saved__backend__/numba/class_blocks.py index ebed48a..95dce88 100644 --- a/data_tests/saved__backend__/numba/class_blocks.py +++ b/data_tests/saved__backend__/numba/class_blocks.py @@ -40,5 +40,15 @@ def block1(a, b, n): return result -arguments_blocks = {"block0": ["a", "b", "n"], "block1": ["a", "b", "n"]} -__transonic__ = ("0.4.7",) +# __protected__ @njit(cache=True, fastmath=True) + + +def arguments_blocks(): + return {"block0": ["a", "b", "n"], "block1": ["a", "b", "n"]} + + +# __protected__ @njit(cache=True, fastmath=True) + + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/numba/class_rec_calls.py b/data_tests/saved__backend__/numba/class_rec_calls.py index 3624698..ee4d42a 100644 --- a/data_tests/saved__backend__/numba/class_rec_calls.py +++ b/data_tests/saved__backend__/numba/class_rec_calls.py @@ -16,5 +16,15 @@ def __for_method__Myclass__func(self_attr, self_attr2, arg): ) -__code_new_method__Myclass__func = "\n\ndef new_method(self, arg):\n return backend_func(self.attr, self.attr2, arg)\n\n" -__transonic__ = ("0.4.7",) +# __protected__ @njit(cache=True, fastmath=True) + + +def __code_new_method__Myclass__func(): + return "\n\ndef new_method(self, arg):\n return backend_func(self.attr, self.attr2, arg)\n\n" + + +# __protected__ @njit(cache=True, fastmath=True) + + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/numba/classic.py b/data_tests/saved__backend__/numba/classic.py index 6231bc0..33ace7f 100644 --- a/data_tests/saved__backend__/numba/classic.py +++ b/data_tests/saved__backend__/numba/classic.py @@ -8,4 +8,8 @@ def func(a, b): return (a * np.log(b)).max() -__transonic__ = ("0.4.7",) +# __protected__ @njit(cache=True, fastmath=True) + + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/numba/default_params.py b/data_tests/saved__backend__/numba/default_params.py index c7899b1..7e3dd78 100644 --- a/data_tests/saved__backend__/numba/default_params.py +++ b/data_tests/saved__backend__/numba/default_params.py @@ -7,4 +7,8 @@ def func(a=1, b=None, c=1.0): return a + c -__transonic__ = ("0.4.7",) +# __protected__ @njit(cache=True, fastmath=True) + + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/numba/methods.py b/data_tests/saved__backend__/numba/methods.py index df9bdc1..36894df 100644 --- a/data_tests/saved__backend__/numba/methods.py +++ b/data_tests/saved__backend__/numba/methods.py @@ -9,5 +9,15 @@ def __for_method__Transmitter____call__(self_arr, self_freq, inp): return (inp * np.exp(np.arange(len(inp)) * self_freq * 1j), self_arr) -__code_new_method__Transmitter____call__ = "\n\ndef new_method(self, inp):\n return backend_func(self.arr, self.freq, inp)\n\n" -__transonic__ = ("0.4.7",) +# __protected__ @njit(cache=True, fastmath=True) + + +def __code_new_method__Transmitter____call__(): + return "\n\ndef new_method(self, inp):\n return backend_func(self.arr, self.freq, inp)\n\n" + + +# __protected__ @njit(cache=True, fastmath=True) + + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/numba/mixed_classic_type_hint.py b/data_tests/saved__backend__/numba/mixed_classic_type_hint.py index 977cac4..5a6e513 100644 --- a/data_tests/saved__backend__/numba/mixed_classic_type_hint.py +++ b/data_tests/saved__backend__/numba/mixed_classic_type_hint.py @@ -15,4 +15,8 @@ def func1(a, b): return a * np.cos(b) -__transonic__ = ("0.4.7",) +# __protected__ @njit(cache=True, fastmath=True) + + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/numba/no_arg.py b/data_tests/saved__backend__/numba/no_arg.py index bc52321..3de89b2 100644 --- a/data_tests/saved__backend__/numba/no_arg.py +++ b/data_tests/saved__backend__/numba/no_arg.py @@ -13,4 +13,8 @@ def func2(): return 1 -__transonic__ = ("0.4.7",) +# __protected__ @njit(cache=True, fastmath=True) + + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/numba/row_sum_boost.py b/data_tests/saved__backend__/numba/row_sum_boost.py index 770b2bc..841870e 100644 --- a/data_tests/saved__backend__/numba/row_sum_boost.py +++ b/data_tests/saved__backend__/numba/row_sum_boost.py @@ -24,4 +24,8 @@ def row_sum_loops(arr, columns): return res -__transonic__ = ("0.4.7",) +# __protected__ @njit(cache=True, fastmath=True) + + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/numba/subpackages.py b/data_tests/saved__backend__/numba/subpackages.py index 97ed9e1..553a193 100644 --- a/data_tests/saved__backend__/numba/subpackages.py +++ b/data_tests/saved__backend__/numba/subpackages.py @@ -16,7 +16,7 @@ def test_np_fft(u): def test_np_linalg_random(u): - (nx, ny) = u.shape + nx, ny = u.shape u[:] = randn(nx, ny) u2 = u.T * u u4 = matrix_power(u2, 2) @@ -30,4 +30,8 @@ def test_sp_special(v, x): return jv(v, x) -__transonic__ = ("0.4.7",) +# __protected__ @njit(cache=True, fastmath=True) + + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/numba/type_hint_notemplate.py b/data_tests/saved__backend__/numba/type_hint_notemplate.py index 9c25c1d..089a118 100644 --- a/data_tests/saved__backend__/numba/type_hint_notemplate.py +++ b/data_tests/saved__backend__/numba/type_hint_notemplate.py @@ -10,4 +10,8 @@ def compute(a, b, c, d, e): return tmp -__transonic__ = ("0.4.7",) +# __protected__ @njit(cache=True, fastmath=True) + + +def __transonic__(): + return "0.7.1" From e319326440eaadd8c76dbbc916193153f7105938 Mon Sep 17 00:00:00 2001 From: paugier Date: Mon, 26 Aug 2024 14:33:18 +0200 Subject: [PATCH 07/12] Modify saved files for Jax backend --- data_tests/saved__backend__/jax/add_inline.py | 6 ++++- .../saved__backend__/jax/assign_func_boost.py | 6 ++++- .../saved__backend__/jax/block_fluidsim.py | 24 +++++++++++++++---- .../saved__backend__/jax/blocks_type_hints.py | 14 +++++++++-- .../jax/boosted_class_use_import.py | 14 +++++++++-- .../jax/boosted_func_use_import.py | 6 ++++- .../saved__backend__/jax/class_blocks.py | 14 +++++++++-- .../saved__backend__/jax/class_rec_calls.py | 14 +++++++++-- data_tests/saved__backend__/jax/classic.py | 6 ++++- .../saved__backend__/jax/default_params.py | 6 ++++- data_tests/saved__backend__/jax/methods.py | 14 +++++++++-- .../jax/mixed_classic_type_hint.py | 6 ++++- data_tests/saved__backend__/jax/no_arg.py | 6 ++++- .../saved__backend__/jax/row_sum_boost.py | 6 ++++- .../saved__backend__/jax/subpackages.py | 8 +++++-- .../jax/type_hint_notemplate.py | 6 ++++- 16 files changed, 131 insertions(+), 25 deletions(-) diff --git a/data_tests/saved__backend__/jax/add_inline.py b/data_tests/saved__backend__/jax/add_inline.py index 09065a2..e98cc20 100644 --- a/data_tests/saved__backend__/jax/add_inline.py +++ b/data_tests/saved__backend__/jax/add_inline.py @@ -16,4 +16,8 @@ def use_add(n=10000): return tmp -__transonic__ = "0.6.4" +# __protected__ @jit + + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/jax/assign_func_boost.py b/data_tests/saved__backend__/jax/assign_func_boost.py index a0d21a0..a5a19fb 100644 --- a/data_tests/saved__backend__/jax/assign_func_boost.py +++ b/data_tests/saved__backend__/jax/assign_func_boost.py @@ -6,4 +6,8 @@ def func(x): return x**2 -__transonic__ = "0.6.4" +# __protected__ @jit + + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/jax/block_fluidsim.py b/data_tests/saved__backend__/jax/block_fluidsim.py index 3ca3746..6ced9ae 100644 --- a/data_tests/saved__backend__/jax/block_fluidsim.py +++ b/data_tests/saved__backend__/jax/block_fluidsim.py @@ -12,7 +12,23 @@ def rk2_step0(state_spect_n12, state_spect, tendencies_n, diss2, dt): state_spect_n12[:] = (state_spect + dt / 2 * tendencies_n) * diss2 -arguments_blocks = { - "rk2_step0": ["state_spect_n12", "state_spect", "tendencies_n", "diss2", "dt"] -} -__transonic__ = "0.6.4" +# __protected__ @jit + + +def arguments_blocks(): + return { + "rk2_step0": [ + "state_spect_n12", + "state_spect", + "tendencies_n", + "diss2", + "dt", + ] + } + + +# __protected__ @jit + + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/jax/blocks_type_hints.py b/data_tests/saved__backend__/jax/blocks_type_hints.py index 880e5fd..1c03920 100644 --- a/data_tests/saved__backend__/jax/blocks_type_hints.py +++ b/data_tests/saved__backend__/jax/blocks_type_hints.py @@ -15,5 +15,15 @@ def block0(a, b, n): return result -arguments_blocks = {"block0": ["a", "b", "n"]} -__transonic__ = "0.6.4" +# __protected__ @jit + + +def arguments_blocks(): + return {"block0": ["a", "b", "n"]} + + +# __protected__ @jit + + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/jax/boosted_class_use_import.py b/data_tests/saved__backend__/jax/boosted_class_use_import.py index 787ba8d..3e1f18f 100644 --- a/data_tests/saved__backend__/jax/boosted_class_use_import.py +++ b/data_tests/saved__backend__/jax/boosted_class_use_import.py @@ -9,5 +9,15 @@ def __for_method__MyClass2__myfunc(self_attr0, self_attr1, arg): return self_attr1 + self_attr0 + np.abs(arg) + func_import() -__code_new_method__MyClass2__myfunc = "\n\ndef new_method(self, arg):\n return backend_func(self.attr0, self.attr1, arg)\n\n" -__transonic__ = "0.6.4" +# __protected__ @jit + + +def __code_new_method__MyClass2__myfunc(): + return "\n\ndef new_method(self, arg):\n return backend_func(self.attr0, self.attr1, arg)\n\n" + + +# __protected__ @jit + + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/jax/boosted_func_use_import.py b/data_tests/saved__backend__/jax/boosted_func_use_import.py index 9ee6a4b..6b9721f 100644 --- a/data_tests/saved__backend__/jax/boosted_func_use_import.py +++ b/data_tests/saved__backend__/jax/boosted_func_use_import.py @@ -9,4 +9,8 @@ def func(a, b): return (a * np.log(b)).max() + func_import() -__transonic__ = "0.6.4" +# __protected__ @jit + + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/jax/class_blocks.py b/data_tests/saved__backend__/jax/class_blocks.py index 97c9342..b3230a9 100644 --- a/data_tests/saved__backend__/jax/class_blocks.py +++ b/data_tests/saved__backend__/jax/class_blocks.py @@ -40,5 +40,15 @@ def block1(a, b, n): return result -arguments_blocks = {"block0": ["a", "b", "n"], "block1": ["a", "b", "n"]} -__transonic__ = "0.6.4" +# __protected__ @jit + + +def arguments_blocks(): + return {"block0": ["a", "b", "n"], "block1": ["a", "b", "n"]} + + +# __protected__ @jit + + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/jax/class_rec_calls.py b/data_tests/saved__backend__/jax/class_rec_calls.py index 944af25..bafa4a4 100644 --- a/data_tests/saved__backend__/jax/class_rec_calls.py +++ b/data_tests/saved__backend__/jax/class_rec_calls.py @@ -16,5 +16,15 @@ def __for_method__Myclass__func(self_attr, self_attr2, arg): ) -__code_new_method__Myclass__func = "\n\ndef new_method(self, arg):\n return backend_func(self.attr, self.attr2, arg)\n\n" -__transonic__ = "0.6.4" +# __protected__ @jit + + +def __code_new_method__Myclass__func(): + return "\n\ndef new_method(self, arg):\n return backend_func(self.attr, self.attr2, arg)\n\n" + + +# __protected__ @jit + + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/jax/classic.py b/data_tests/saved__backend__/jax/classic.py index 97ac465..e9f2d40 100644 --- a/data_tests/saved__backend__/jax/classic.py +++ b/data_tests/saved__backend__/jax/classic.py @@ -8,4 +8,8 @@ def func(a, b): return (a * np.log(b)).max() -__transonic__ = "0.6.4" +# __protected__ @jit + + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/jax/default_params.py b/data_tests/saved__backend__/jax/default_params.py index 2dacf60..50def82 100644 --- a/data_tests/saved__backend__/jax/default_params.py +++ b/data_tests/saved__backend__/jax/default_params.py @@ -7,4 +7,8 @@ def func(a=1, b=None, c=1.0): return a + c -__transonic__ = "0.6.4" +# __protected__ @jit + + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/jax/methods.py b/data_tests/saved__backend__/jax/methods.py index 153f306..6da0ef8 100644 --- a/data_tests/saved__backend__/jax/methods.py +++ b/data_tests/saved__backend__/jax/methods.py @@ -9,5 +9,15 @@ def __for_method__Transmitter____call__(self_arr, self_freq, inp): return (inp * np.exp(np.arange(len(inp)) * self_freq * 1j), self_arr) -__code_new_method__Transmitter____call__ = "\n\ndef new_method(self, inp):\n return backend_func(self.arr, self.freq, inp)\n\n" -__transonic__ = "0.6.4" +# __protected__ @jit + + +def __code_new_method__Transmitter____call__(): + return "\n\ndef new_method(self, inp):\n return backend_func(self.arr, self.freq, inp)\n\n" + + +# __protected__ @jit + + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/jax/mixed_classic_type_hint.py b/data_tests/saved__backend__/jax/mixed_classic_type_hint.py index f81d991..ffa0a87 100644 --- a/data_tests/saved__backend__/jax/mixed_classic_type_hint.py +++ b/data_tests/saved__backend__/jax/mixed_classic_type_hint.py @@ -15,4 +15,8 @@ def func1(a, b): return a * np.cos(b) -__transonic__ = "0.6.4" +# __protected__ @jit + + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/jax/no_arg.py b/data_tests/saved__backend__/jax/no_arg.py index 23a841b..d187182 100644 --- a/data_tests/saved__backend__/jax/no_arg.py +++ b/data_tests/saved__backend__/jax/no_arg.py @@ -13,4 +13,8 @@ def func2(): return 1 -__transonic__ = "0.6.4" +# __protected__ @jit + + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/jax/row_sum_boost.py b/data_tests/saved__backend__/jax/row_sum_boost.py index e5b2683..984525e 100644 --- a/data_tests/saved__backend__/jax/row_sum_boost.py +++ b/data_tests/saved__backend__/jax/row_sum_boost.py @@ -24,4 +24,8 @@ def row_sum_loops(arr, columns): return res -__transonic__ = "0.6.4" +# __protected__ @jit + + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/jax/subpackages.py b/data_tests/saved__backend__/jax/subpackages.py index c8696ca..3e2df02 100644 --- a/data_tests/saved__backend__/jax/subpackages.py +++ b/data_tests/saved__backend__/jax/subpackages.py @@ -16,7 +16,7 @@ def test_np_fft(u): def test_np_linalg_random(u): - (nx, ny) = u.shape + nx, ny = u.shape u[:] = randn(nx, ny) u2 = u.T * u u4 = matrix_power(u2, 2) @@ -30,4 +30,8 @@ def test_sp_special(v, x): return jv(v, x) -__transonic__ = "0.6.4" +# __protected__ @jit + + +def __transonic__(): + return "0.7.1" diff --git a/data_tests/saved__backend__/jax/type_hint_notemplate.py b/data_tests/saved__backend__/jax/type_hint_notemplate.py index 225cdbb..5cf4432 100644 --- a/data_tests/saved__backend__/jax/type_hint_notemplate.py +++ b/data_tests/saved__backend__/jax/type_hint_notemplate.py @@ -10,4 +10,8 @@ def compute(a, b, c, d, e): return tmp -__transonic__ = "0.6.4" +# __protected__ @jit + + +def __transonic__(): + return "0.7.1" From a1af8247ce5845e6df61ebc10b79be9437644faa Mon Sep 17 00:00:00 2001 From: paugier Date: Mon, 26 Aug 2024 14:35:35 +0200 Subject: [PATCH 08/12] Modif test_run.py --- tests/test_run.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_run.py b/tests/test_run.py index 203d844..201b215 100644 --- a/tests/test_run.py +++ b/tests/test_run.py @@ -62,8 +62,8 @@ def test_create_pythran_files(): if path.name == "subpackages.py": saved_code = saved_code.replace("(nx, ny) =", "nx, ny =") - code = code.split("__transonic__ = ", 1)[0] - saved_code = saved_code.split("__transonic__ = ", 1)[0] + code = code.split("def __transonic__():", 1)[0] + saved_code = saved_code.split("def __transonic__()", 1)[0] if backend_default in header_suffixes: suffix = header_suffixes[backend_default] From 688652e728d488342a864b40bab0dac9076fbe43 Mon Sep 17 00:00:00 2001 From: paugier Date: Mon, 26 Aug 2024 14:54:39 +0200 Subject: [PATCH 09/12] Prepare 0.7.2 --- CHANGES.md | 7 ++++++- pyproject.toml | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index d25f044..0609532 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,7 +1,11 @@ # Release notes See also the -[unreleased changes](https://foss.heptapod.net/fluiddyn/transonic/-/compare/0.7.1...branch%2Fdefault). +[unreleased changes](https://foss.heptapod.net/fluiddyn/transonic/-/compare/0.7.2...branch%2Fdefault). + +## [0.7.2] (2024-08-26) + +- Metadata stored in functions to avoid issues with Pythran on Windows ## [0.7.1] (2024-07-24) @@ -280,3 +284,4 @@ See also the [0.6.4]: https://foss.heptapod.net/fluiddyn/transonic/-/compare/0.6.3...0.6.4 [0.7.0]: https://foss.heptapod.net/fluiddyn/transonic/-/compare/0.6.4...0.7.0 [0.7.1]: https://foss.heptapod.net/fluiddyn/transonic/-/compare/0.7.0...0.7.1 +[0.7.2]: https://foss.heptapod.net/fluiddyn/transonic/-/compare/0.7.1...0.7.2 diff --git a/pyproject.toml b/pyproject.toml index e9de96d..36c40eb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "pdm.backend" [project] name = "transonic" -version = "0.7.1" +version = "0.7.2" description = "Make your Python code fly at transonic speeds!" authors = [ { name = "Pierre Augier", email = "pierre.augier@univ-grenoble-alpes.fr" }, From 714474eafa90787cb88fadeb5438814f83661555 Mon Sep 17 00:00:00 2001 From: paugier Date: Mon, 26 Aug 2024 15:51:24 +0200 Subject: [PATCH 10/12] Fix Numba --- data_tests/saved__backend__/numba/add_inline.py | 3 --- data_tests/saved__backend__/numba/assign_func_boost.py | 3 --- data_tests/saved__backend__/numba/block_fluidsim.py | 6 ------ data_tests/saved__backend__/numba/blocks_type_hints.py | 6 ------ .../saved__backend__/numba/boosted_class_use_import.py | 6 ------ .../saved__backend__/numba/boosted_func_use_import.py | 3 --- data_tests/saved__backend__/numba/class_blocks.py | 6 ------ data_tests/saved__backend__/numba/class_rec_calls.py | 6 ------ data_tests/saved__backend__/numba/classic.py | 3 --- data_tests/saved__backend__/numba/default_params.py | 3 --- data_tests/saved__backend__/numba/methods.py | 6 ------ .../saved__backend__/numba/mixed_classic_type_hint.py | 3 --- data_tests/saved__backend__/numba/no_arg.py | 3 --- data_tests/saved__backend__/numba/row_sum_boost.py | 3 --- data_tests/saved__backend__/numba/subpackages.py | 3 --- .../saved__backend__/numba/type_hint_notemplate.py | 3 --- src/transonic/aheadoftime.py | 4 ++-- src/transonic/backends/numba.py | 10 +++++++++- 18 files changed, 11 insertions(+), 69 deletions(-) diff --git a/data_tests/saved__backend__/numba/add_inline.py b/data_tests/saved__backend__/numba/add_inline.py index 69bd712..53019fe 100644 --- a/data_tests/saved__backend__/numba/add_inline.py +++ b/data_tests/saved__backend__/numba/add_inline.py @@ -16,8 +16,5 @@ def use_add(n=10000): return tmp -# __protected__ @njit(cache=True, fastmath=True) - - def __transonic__(): return "0.7.1" diff --git a/data_tests/saved__backend__/numba/assign_func_boost.py b/data_tests/saved__backend__/numba/assign_func_boost.py index ce54a0e..201613b 100644 --- a/data_tests/saved__backend__/numba/assign_func_boost.py +++ b/data_tests/saved__backend__/numba/assign_func_boost.py @@ -6,8 +6,5 @@ def func(x): return x**2 -# __protected__ @njit(cache=True, fastmath=True) - - def __transonic__(): return "0.7.1" diff --git a/data_tests/saved__backend__/numba/block_fluidsim.py b/data_tests/saved__backend__/numba/block_fluidsim.py index 85ca7f4..5039d0a 100644 --- a/data_tests/saved__backend__/numba/block_fluidsim.py +++ b/data_tests/saved__backend__/numba/block_fluidsim.py @@ -12,9 +12,6 @@ def rk2_step0(state_spect_n12, state_spect, tendencies_n, diss2, dt): state_spect_n12[:] = (state_spect + dt / 2 * tendencies_n) * diss2 -# __protected__ @njit(cache=True, fastmath=True) - - def arguments_blocks(): return { "rk2_step0": [ @@ -27,8 +24,5 @@ def arguments_blocks(): } -# __protected__ @njit(cache=True, fastmath=True) - - def __transonic__(): return "0.7.1" diff --git a/data_tests/saved__backend__/numba/blocks_type_hints.py b/data_tests/saved__backend__/numba/blocks_type_hints.py index 12caab5..bff3b74 100644 --- a/data_tests/saved__backend__/numba/blocks_type_hints.py +++ b/data_tests/saved__backend__/numba/blocks_type_hints.py @@ -15,15 +15,9 @@ def block0(a, b, n): return result -# __protected__ @njit(cache=True, fastmath=True) - - def arguments_blocks(): return {"block0": ["a", "b", "n"]} -# __protected__ @njit(cache=True, fastmath=True) - - def __transonic__(): return "0.7.1" diff --git a/data_tests/saved__backend__/numba/boosted_class_use_import.py b/data_tests/saved__backend__/numba/boosted_class_use_import.py index af1959f..5209cea 100644 --- a/data_tests/saved__backend__/numba/boosted_class_use_import.py +++ b/data_tests/saved__backend__/numba/boosted_class_use_import.py @@ -9,15 +9,9 @@ def __for_method__MyClass2__myfunc(self_attr0, self_attr1, arg): return self_attr1 + self_attr0 + np.abs(arg) + func_import() -# __protected__ @njit(cache=True, fastmath=True) - - def __code_new_method__MyClass2__myfunc(): return "\n\ndef new_method(self, arg):\n return backend_func(self.attr0, self.attr1, arg)\n\n" -# __protected__ @njit(cache=True, fastmath=True) - - def __transonic__(): return "0.7.1" diff --git a/data_tests/saved__backend__/numba/boosted_func_use_import.py b/data_tests/saved__backend__/numba/boosted_func_use_import.py index d95aef2..0eea6b5 100644 --- a/data_tests/saved__backend__/numba/boosted_func_use_import.py +++ b/data_tests/saved__backend__/numba/boosted_func_use_import.py @@ -9,8 +9,5 @@ def func(a, b): return (a * np.log(b)).max() + func_import() -# __protected__ @njit(cache=True, fastmath=True) - - def __transonic__(): return "0.7.1" diff --git a/data_tests/saved__backend__/numba/class_blocks.py b/data_tests/saved__backend__/numba/class_blocks.py index 95dce88..41a3259 100644 --- a/data_tests/saved__backend__/numba/class_blocks.py +++ b/data_tests/saved__backend__/numba/class_blocks.py @@ -40,15 +40,9 @@ def block1(a, b, n): return result -# __protected__ @njit(cache=True, fastmath=True) - - def arguments_blocks(): return {"block0": ["a", "b", "n"], "block1": ["a", "b", "n"]} -# __protected__ @njit(cache=True, fastmath=True) - - def __transonic__(): return "0.7.1" diff --git a/data_tests/saved__backend__/numba/class_rec_calls.py b/data_tests/saved__backend__/numba/class_rec_calls.py index ee4d42a..2bc50e0 100644 --- a/data_tests/saved__backend__/numba/class_rec_calls.py +++ b/data_tests/saved__backend__/numba/class_rec_calls.py @@ -16,15 +16,9 @@ def __for_method__Myclass__func(self_attr, self_attr2, arg): ) -# __protected__ @njit(cache=True, fastmath=True) - - def __code_new_method__Myclass__func(): return "\n\ndef new_method(self, arg):\n return backend_func(self.attr, self.attr2, arg)\n\n" -# __protected__ @njit(cache=True, fastmath=True) - - def __transonic__(): return "0.7.1" diff --git a/data_tests/saved__backend__/numba/classic.py b/data_tests/saved__backend__/numba/classic.py index 33ace7f..0ae2b79 100644 --- a/data_tests/saved__backend__/numba/classic.py +++ b/data_tests/saved__backend__/numba/classic.py @@ -8,8 +8,5 @@ def func(a, b): return (a * np.log(b)).max() -# __protected__ @njit(cache=True, fastmath=True) - - def __transonic__(): return "0.7.1" diff --git a/data_tests/saved__backend__/numba/default_params.py b/data_tests/saved__backend__/numba/default_params.py index 7e3dd78..360ca3f 100644 --- a/data_tests/saved__backend__/numba/default_params.py +++ b/data_tests/saved__backend__/numba/default_params.py @@ -7,8 +7,5 @@ def func(a=1, b=None, c=1.0): return a + c -# __protected__ @njit(cache=True, fastmath=True) - - def __transonic__(): return "0.7.1" diff --git a/data_tests/saved__backend__/numba/methods.py b/data_tests/saved__backend__/numba/methods.py index 36894df..30978e6 100644 --- a/data_tests/saved__backend__/numba/methods.py +++ b/data_tests/saved__backend__/numba/methods.py @@ -9,15 +9,9 @@ def __for_method__Transmitter____call__(self_arr, self_freq, inp): return (inp * np.exp(np.arange(len(inp)) * self_freq * 1j), self_arr) -# __protected__ @njit(cache=True, fastmath=True) - - def __code_new_method__Transmitter____call__(): return "\n\ndef new_method(self, inp):\n return backend_func(self.arr, self.freq, inp)\n\n" -# __protected__ @njit(cache=True, fastmath=True) - - def __transonic__(): return "0.7.1" diff --git a/data_tests/saved__backend__/numba/mixed_classic_type_hint.py b/data_tests/saved__backend__/numba/mixed_classic_type_hint.py index 5a6e513..bb5f8eb 100644 --- a/data_tests/saved__backend__/numba/mixed_classic_type_hint.py +++ b/data_tests/saved__backend__/numba/mixed_classic_type_hint.py @@ -15,8 +15,5 @@ def func1(a, b): return a * np.cos(b) -# __protected__ @njit(cache=True, fastmath=True) - - def __transonic__(): return "0.7.1" diff --git a/data_tests/saved__backend__/numba/no_arg.py b/data_tests/saved__backend__/numba/no_arg.py index 3de89b2..d5291fb 100644 --- a/data_tests/saved__backend__/numba/no_arg.py +++ b/data_tests/saved__backend__/numba/no_arg.py @@ -13,8 +13,5 @@ def func2(): return 1 -# __protected__ @njit(cache=True, fastmath=True) - - def __transonic__(): return "0.7.1" diff --git a/data_tests/saved__backend__/numba/row_sum_boost.py b/data_tests/saved__backend__/numba/row_sum_boost.py index 841870e..cc0cc6f 100644 --- a/data_tests/saved__backend__/numba/row_sum_boost.py +++ b/data_tests/saved__backend__/numba/row_sum_boost.py @@ -24,8 +24,5 @@ def row_sum_loops(arr, columns): return res -# __protected__ @njit(cache=True, fastmath=True) - - def __transonic__(): return "0.7.1" diff --git a/data_tests/saved__backend__/numba/subpackages.py b/data_tests/saved__backend__/numba/subpackages.py index 553a193..7a40a7b 100644 --- a/data_tests/saved__backend__/numba/subpackages.py +++ b/data_tests/saved__backend__/numba/subpackages.py @@ -30,8 +30,5 @@ def test_sp_special(v, x): return jv(v, x) -# __protected__ @njit(cache=True, fastmath=True) - - def __transonic__(): return "0.7.1" diff --git a/data_tests/saved__backend__/numba/type_hint_notemplate.py b/data_tests/saved__backend__/numba/type_hint_notemplate.py index 089a118..587d937 100644 --- a/data_tests/saved__backend__/numba/type_hint_notemplate.py +++ b/data_tests/saved__backend__/numba/type_hint_notemplate.py @@ -10,8 +10,5 @@ def compute(a, b, c, d, e): return tmp -# __protected__ @njit(cache=True, fastmath=True) - - def __transonic__(): return "0.7.1" diff --git a/src/transonic/aheadoftime.py b/src/transonic/aheadoftime.py index 31ed216..3fb2642 100644 --- a/src/transonic/aheadoftime.py +++ b/src/transonic/aheadoftime.py @@ -62,9 +62,9 @@ def _get_data_from_func_or_data(data_or_func): which leads to issue with Pythran on Windows. They are now saved in functions, but we continue supporting the "old" extensions. """ - try: + if callable(data_or_func): return data_or_func() - except TypeError: + else: # extension compiled with Transonic < 0.7.2 return data_or_func diff --git a/src/transonic/backends/numba.py b/src/transonic/backends/numba.py index 80e1c93..6192648 100644 --- a/src/transonic/backends/numba.py +++ b/src/transonic/backends/numba.py @@ -28,7 +28,15 @@ def add_numba_comments(code): new_body = [CommentLine("# __protected__ from numba import njit")] for node in mod.body: - if isinstance(node, gast.FunctionDef): + if ( + isinstance(node, gast.FunctionDef) + and node.name + not in ( + "arguments_blocks", + "__transonic__", + ) + and not node.name.startswith("__code_new_method__") + ): new_body.append( CommentLine("# __protected__ @njit(cache=True, fastmath=True)") ) From b8989ba1639e01b396cd7edd84b4b6530df3c0c2 Mon Sep 17 00:00:00 2001 From: paugier Date: Mon, 26 Aug 2024 16:13:23 +0200 Subject: [PATCH 11/12] Fix test_run subpackages.py --- tests/test_run.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_run.py b/tests/test_run.py index 201b215..013cc8a 100644 --- a/tests/test_run.py +++ b/tests/test_run.py @@ -58,9 +58,9 @@ def test_create_pythran_files(): with open(saved_path) as file: saved_code = file.read() - if sys.version_info[:2] > (3, 10): + if sys.version_info[:2] < (3, 11): if path.name == "subpackages.py": - saved_code = saved_code.replace("(nx, ny) =", "nx, ny =") + saved_code = saved_code.replace("nx, ny =", "(nx, ny) =") code = code.split("def __transonic__():", 1)[0] saved_code = saved_code.split("def __transonic__()", 1)[0] From 161a31b4204a423eec2d62dac18ea9c7742a432d Mon Sep 17 00:00:00 2001 From: paugier Date: Mon, 26 Aug 2024 16:31:44 +0200 Subject: [PATCH 12/12] Jax: no @jit for 'internal' functions --- data_tests/saved__backend__/jax/add_inline.py | 3 --- data_tests/saved__backend__/jax/assign_func_boost.py | 3 --- data_tests/saved__backend__/jax/block_fluidsim.py | 6 ------ data_tests/saved__backend__/jax/blocks_type_hints.py | 6 ------ .../saved__backend__/jax/boosted_class_use_import.py | 6 ------ .../saved__backend__/jax/boosted_func_use_import.py | 3 --- data_tests/saved__backend__/jax/class_blocks.py | 6 ------ data_tests/saved__backend__/jax/class_rec_calls.py | 6 ------ data_tests/saved__backend__/jax/classic.py | 3 --- data_tests/saved__backend__/jax/default_params.py | 3 --- data_tests/saved__backend__/jax/methods.py | 6 ------ .../saved__backend__/jax/mixed_classic_type_hint.py | 3 --- data_tests/saved__backend__/jax/no_arg.py | 3 --- data_tests/saved__backend__/jax/row_sum_boost.py | 3 --- data_tests/saved__backend__/jax/subpackages.py | 3 --- .../saved__backend__/jax/type_hint_notemplate.py | 3 --- src/transonic/backends/jax.py | 10 +++++++++- 17 files changed, 9 insertions(+), 67 deletions(-) diff --git a/data_tests/saved__backend__/jax/add_inline.py b/data_tests/saved__backend__/jax/add_inline.py index e98cc20..e790547 100644 --- a/data_tests/saved__backend__/jax/add_inline.py +++ b/data_tests/saved__backend__/jax/add_inline.py @@ -16,8 +16,5 @@ def use_add(n=10000): return tmp -# __protected__ @jit - - def __transonic__(): return "0.7.1" diff --git a/data_tests/saved__backend__/jax/assign_func_boost.py b/data_tests/saved__backend__/jax/assign_func_boost.py index a5a19fb..73994d3 100644 --- a/data_tests/saved__backend__/jax/assign_func_boost.py +++ b/data_tests/saved__backend__/jax/assign_func_boost.py @@ -6,8 +6,5 @@ def func(x): return x**2 -# __protected__ @jit - - def __transonic__(): return "0.7.1" diff --git a/data_tests/saved__backend__/jax/block_fluidsim.py b/data_tests/saved__backend__/jax/block_fluidsim.py index 6ced9ae..56f319d 100644 --- a/data_tests/saved__backend__/jax/block_fluidsim.py +++ b/data_tests/saved__backend__/jax/block_fluidsim.py @@ -12,9 +12,6 @@ def rk2_step0(state_spect_n12, state_spect, tendencies_n, diss2, dt): state_spect_n12[:] = (state_spect + dt / 2 * tendencies_n) * diss2 -# __protected__ @jit - - def arguments_blocks(): return { "rk2_step0": [ @@ -27,8 +24,5 @@ def arguments_blocks(): } -# __protected__ @jit - - def __transonic__(): return "0.7.1" diff --git a/data_tests/saved__backend__/jax/blocks_type_hints.py b/data_tests/saved__backend__/jax/blocks_type_hints.py index 1c03920..e41b2fa 100644 --- a/data_tests/saved__backend__/jax/blocks_type_hints.py +++ b/data_tests/saved__backend__/jax/blocks_type_hints.py @@ -15,15 +15,9 @@ def block0(a, b, n): return result -# __protected__ @jit - - def arguments_blocks(): return {"block0": ["a", "b", "n"]} -# __protected__ @jit - - def __transonic__(): return "0.7.1" diff --git a/data_tests/saved__backend__/jax/boosted_class_use_import.py b/data_tests/saved__backend__/jax/boosted_class_use_import.py index 3e1f18f..1ee794f 100644 --- a/data_tests/saved__backend__/jax/boosted_class_use_import.py +++ b/data_tests/saved__backend__/jax/boosted_class_use_import.py @@ -9,15 +9,9 @@ def __for_method__MyClass2__myfunc(self_attr0, self_attr1, arg): return self_attr1 + self_attr0 + np.abs(arg) + func_import() -# __protected__ @jit - - def __code_new_method__MyClass2__myfunc(): return "\n\ndef new_method(self, arg):\n return backend_func(self.attr0, self.attr1, arg)\n\n" -# __protected__ @jit - - def __transonic__(): return "0.7.1" diff --git a/data_tests/saved__backend__/jax/boosted_func_use_import.py b/data_tests/saved__backend__/jax/boosted_func_use_import.py index 6b9721f..b7e287b 100644 --- a/data_tests/saved__backend__/jax/boosted_func_use_import.py +++ b/data_tests/saved__backend__/jax/boosted_func_use_import.py @@ -9,8 +9,5 @@ def func(a, b): return (a * np.log(b)).max() + func_import() -# __protected__ @jit - - def __transonic__(): return "0.7.1" diff --git a/data_tests/saved__backend__/jax/class_blocks.py b/data_tests/saved__backend__/jax/class_blocks.py index b3230a9..7cfcf38 100644 --- a/data_tests/saved__backend__/jax/class_blocks.py +++ b/data_tests/saved__backend__/jax/class_blocks.py @@ -40,15 +40,9 @@ def block1(a, b, n): return result -# __protected__ @jit - - def arguments_blocks(): return {"block0": ["a", "b", "n"], "block1": ["a", "b", "n"]} -# __protected__ @jit - - def __transonic__(): return "0.7.1" diff --git a/data_tests/saved__backend__/jax/class_rec_calls.py b/data_tests/saved__backend__/jax/class_rec_calls.py index bafa4a4..17b6141 100644 --- a/data_tests/saved__backend__/jax/class_rec_calls.py +++ b/data_tests/saved__backend__/jax/class_rec_calls.py @@ -16,15 +16,9 @@ def __for_method__Myclass__func(self_attr, self_attr2, arg): ) -# __protected__ @jit - - def __code_new_method__Myclass__func(): return "\n\ndef new_method(self, arg):\n return backend_func(self.attr, self.attr2, arg)\n\n" -# __protected__ @jit - - def __transonic__(): return "0.7.1" diff --git a/data_tests/saved__backend__/jax/classic.py b/data_tests/saved__backend__/jax/classic.py index e9f2d40..c4d5017 100644 --- a/data_tests/saved__backend__/jax/classic.py +++ b/data_tests/saved__backend__/jax/classic.py @@ -8,8 +8,5 @@ def func(a, b): return (a * np.log(b)).max() -# __protected__ @jit - - def __transonic__(): return "0.7.1" diff --git a/data_tests/saved__backend__/jax/default_params.py b/data_tests/saved__backend__/jax/default_params.py index 50def82..34edd51 100644 --- a/data_tests/saved__backend__/jax/default_params.py +++ b/data_tests/saved__backend__/jax/default_params.py @@ -7,8 +7,5 @@ def func(a=1, b=None, c=1.0): return a + c -# __protected__ @jit - - def __transonic__(): return "0.7.1" diff --git a/data_tests/saved__backend__/jax/methods.py b/data_tests/saved__backend__/jax/methods.py index 6da0ef8..b9d5155 100644 --- a/data_tests/saved__backend__/jax/methods.py +++ b/data_tests/saved__backend__/jax/methods.py @@ -9,15 +9,9 @@ def __for_method__Transmitter____call__(self_arr, self_freq, inp): return (inp * np.exp(np.arange(len(inp)) * self_freq * 1j), self_arr) -# __protected__ @jit - - def __code_new_method__Transmitter____call__(): return "\n\ndef new_method(self, inp):\n return backend_func(self.arr, self.freq, inp)\n\n" -# __protected__ @jit - - def __transonic__(): return "0.7.1" diff --git a/data_tests/saved__backend__/jax/mixed_classic_type_hint.py b/data_tests/saved__backend__/jax/mixed_classic_type_hint.py index ffa0a87..429e524 100644 --- a/data_tests/saved__backend__/jax/mixed_classic_type_hint.py +++ b/data_tests/saved__backend__/jax/mixed_classic_type_hint.py @@ -15,8 +15,5 @@ def func1(a, b): return a * np.cos(b) -# __protected__ @jit - - def __transonic__(): return "0.7.1" diff --git a/data_tests/saved__backend__/jax/no_arg.py b/data_tests/saved__backend__/jax/no_arg.py index d187182..39976a0 100644 --- a/data_tests/saved__backend__/jax/no_arg.py +++ b/data_tests/saved__backend__/jax/no_arg.py @@ -13,8 +13,5 @@ def func2(): return 1 -# __protected__ @jit - - def __transonic__(): return "0.7.1" diff --git a/data_tests/saved__backend__/jax/row_sum_boost.py b/data_tests/saved__backend__/jax/row_sum_boost.py index 984525e..6fb6e6c 100644 --- a/data_tests/saved__backend__/jax/row_sum_boost.py +++ b/data_tests/saved__backend__/jax/row_sum_boost.py @@ -24,8 +24,5 @@ def row_sum_loops(arr, columns): return res -# __protected__ @jit - - def __transonic__(): return "0.7.1" diff --git a/data_tests/saved__backend__/jax/subpackages.py b/data_tests/saved__backend__/jax/subpackages.py index 3e2df02..a0738ad 100644 --- a/data_tests/saved__backend__/jax/subpackages.py +++ b/data_tests/saved__backend__/jax/subpackages.py @@ -30,8 +30,5 @@ def test_sp_special(v, x): return jv(v, x) -# __protected__ @jit - - def __transonic__(): return "0.7.1" diff --git a/data_tests/saved__backend__/jax/type_hint_notemplate.py b/data_tests/saved__backend__/jax/type_hint_notemplate.py index 5cf4432..6ac4e6b 100644 --- a/data_tests/saved__backend__/jax/type_hint_notemplate.py +++ b/data_tests/saved__backend__/jax/type_hint_notemplate.py @@ -10,8 +10,5 @@ def compute(a, b, c, d, e): return tmp -# __protected__ @jit - - def __transonic__(): return "0.7.1" diff --git a/src/transonic/backends/jax.py b/src/transonic/backends/jax.py index fb96549..0d20c96 100644 --- a/src/transonic/backends/jax.py +++ b/src/transonic/backends/jax.py @@ -43,7 +43,15 @@ def add_jax_comments(code): node.module = "jax.numpy" # Add JIT decorator - if isinstance(node, gast.FunctionDef): + if ( + isinstance(node, gast.FunctionDef) + and node.name + not in ( + "arguments_blocks", + "__transonic__", + ) + and not node.name.startswith("__code_new_method__") + ): new_body.append(CommentLine("# __protected__ @jit")) new_body.append(node)