@jit runs uncompiled code at first execution
This ticket is related to this stackoverflow question.
I use an adapted version of the bug.py from #40 (closed) .
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.