How to use the transonic.jit function in transonic

To help you get started, we’ve selected a few transonic examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fluiddyn / transonic / _transonic_testing / for_test_justintime.py View on Github external
    @jit
    def myfunc1(self):
        return self.attr0

    def check(self):
        assert self.myfunc(1) == 3


# FIXME support multilevel imported jitted function call in a jitted function
from .for_test_exterior_import_jit import foo, func_import, func_import2
from numpy import pi

const = 1

jitted_func_import = jit(func_import)
jitted_func_import2 = jit(func_import2)


@jit
def main(add: int):
    return (
        add
        + foo
        + pi
        - pi
        - jitted_func_import()
        + func_import2()
        + func0_jitted(1 / 2)
        + const
    )
github fluiddyn / transonic / _transonic_testing / for_test_justintime.py View on Github external
@jit
def main(add: int):
    return (
        add
        + foo
        + pi
        - pi
        - jitted_func_import()
        + func_import2()
        + func0_jitted(1 / 2)
        + const
    )
github fluiddyn / transonic / _transonic_testing / for_test_justintime.py View on Github external
@jit
def func_dict(d: "str: float dict"):
    return d.popitem()
github fluiddyn / transonic / doc / examples / bench_row_sum / row_sum_jit.py View on Github external
@jit(native=True, xsimd=True)
def row_sum(arr, columns):
    return arr.T[columns].sum(0)
github fluiddyn / transonic / doc / examples / writing_benchmarks / bench_jit.py View on Github external
from transonic import jit
import numba

from pure_numpy import laplace_numpy, laplace_loops

laplace_transonic_pythran = jit(native=True, xsimd=True)(laplace_numpy)
laplace_transonic_python = jit(backend="python")(laplace_numpy)
laplace_transonic_numba = jit(backend="numba")(laplace_numpy)
laplace_numba = numba.njit(laplace_numpy)

laplace_transonic_pythran_loops = jit(native=True, xsimd=True)(laplace_loops)
laplace_transonic_python_loops = jit(backend="python")(laplace_loops)
laplace_transonic_numba_loops = jit(backend="numba")(laplace_loops)
laplace_numba_loops = numba.njit(laplace_loops)

if __name__ == "__main__":
    from transonic import wait_for_all_extensions

    from skimage.data import astronaut
    from skimage.color import rgb2gray

    image = astronaut()
    image = rgb2gray(image)

    # warm the functions
    laplace_transonic_python(image)
    laplace_transonic_pythran(image)
    laplace_transonic_pythran_loops(image)
    laplace_transonic_numba(image)
github fluiddyn / transonic / doc / examples / writing_benchmarks / bench_jit.py View on Github external
from transonic import jit
import numba

from pure_numpy import laplace_numpy, laplace_loops

laplace_transonic_pythran = jit(native=True, xsimd=True)(laplace_numpy)
laplace_transonic_python = jit(backend="python")(laplace_numpy)
laplace_transonic_numba = jit(backend="numba")(laplace_numpy)
laplace_numba = numba.njit(laplace_numpy)

laplace_transonic_pythran_loops = jit(native=True, xsimd=True)(laplace_loops)
laplace_transonic_python_loops = jit(backend="python")(laplace_loops)
laplace_transonic_numba_loops = jit(backend="numba")(laplace_loops)
laplace_numba_loops = numba.njit(laplace_loops)

if __name__ == "__main__":
    from transonic import wait_for_all_extensions

    from skimage.data import astronaut
    from skimage.color import rgb2gray

    image = astronaut()
    image = rgb2gray(image)
github fluiddyn / transonic / doc / examples / writing_benchmarks / bench_jit.py View on Github external
from transonic import jit
import numba

from pure_numpy import laplace_numpy, laplace_loops

laplace_transonic_pythran = jit(native=True, xsimd=True)(laplace_numpy)
laplace_transonic_python = jit(backend="python")(laplace_numpy)
laplace_transonic_numba = jit(backend="numba")(laplace_numpy)
laplace_numba = numba.njit(laplace_numpy)

laplace_transonic_pythran_loops = jit(native=True, xsimd=True)(laplace_loops)
laplace_transonic_python_loops = jit(backend="python")(laplace_loops)
laplace_transonic_numba_loops = jit(backend="numba")(laplace_loops)
laplace_numba_loops = numba.njit(laplace_loops)

if __name__ == "__main__":
    from transonic import wait_for_all_extensions

    from skimage.data import astronaut
    from skimage.color import rgb2gray

    image = astronaut()
    image = rgb2gray(image)
github fluiddyn / transonic / doc / examples / methods_jit.py View on Github external
    @jit
    def calcul(self, a, b):
        return a * self.attr0 + b * self.attr1