import numba
import interpolation
grid = (
(0.0, 1.0, 10),
(0.0, 1.0, 10)
)
import numpy as np
C = np.random.random((10,10))
N = 1000000
S = np.random.random((N,2))
from interpolation import mlinterp
mlinterp(grid, C, S)
array([0.39887696, 0.46464487, 0.2931475 , ..., 0.05132932, 0.59298413, 0.68548968])
d = mlinterp.inspect_llvm()
d[[*d.keys()]]
mlinterp.inspect_types(pretty=True)
/opt/pablo/anaconda3/lib/python3.6/site-packages/numba/pretty_annotate.py:26: FutureWarning: The pretty_annotate functionality is experimental and might change API FutureWarning)
|
label 0
|
47:
N = u.shape[0]
grid = arg(0, name=grid) :: tuple((float64, float64, int64) x 2)
|
c = arg(1, name=c) :: array(float64, 2d, C)
|
u = arg(2, name=u) :: array(float64, 2d, C)
|
$0.2 = getattr(value=u, attr=shape) :: tuple(int64 x 2)
|
$const0.3 = const(int, 0) :: int64
|
$0.4 = static_getitem(value=$0.2, index=0, index_var=$const0.3) :: int64
|
del $const0.3
|
del $0.2
|
N = $0.4 :: int64
|
del $0.4
|
48:
res = np.zeros(N)
$0.5 = global(np: <module 'numpy' from '/opt/pablo/anaconda3/lib/python3.6/site-packages/numpy/__init__.py'>) :: Module(<module 'numpy' from '/opt/pablo/anaconda3/lib/python3.6/site-packages/numpy/__init__.py'>)
|
$0.6 = getattr(value=$0.5, attr=zeros) :: Function(<built-in function zeros>)
|
del $0.5
|
$0.8 = call $0.6(N, func=$0.6, args=[Var(N, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (47))], kws=(), vararg=None) :: (int64,) -> array(float64, 1d, C)
|
del $0.6
|
res = $0.8 :: array(float64, 1d, C)
|
del $0.8
|
jump 20
|
label 20
|
49:
for n in range(N):
jump 22
|
label 22
|
$22.1 = global(range: <class 'range'>) :: Function(<class 'range'>)
|
$22.3 = call $22.1(N, func=$22.1, args=[Var(N, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (47))], kws=(), vararg=None) :: (int64,) -> range_state_int64
|
del N
|
del $22.1
|
$22.4 = getiter(value=$22.3) :: range_iter_int64
|
del $22.3
|
$phi30.1 = $22.4 :: range_iter_int64
|
del $22.4
|
jump 30
|
label 30
|
$30.2 = iternext(value=$phi30.1) :: pair<int64, bool>
|
$30.3 = pair_first(value=$30.2) :: int64
|
$30.4 = pair_second(value=$30.2) :: bool
|
del $30.2
|
$phi32.1 = $30.3 :: int64
|
$phi96.1 = $30.3 :: int64
|
del $phi96.1
|
del $30.3
|
$phi96.2 = $phi30.1 :: range_iter_int64
|
del $phi96.2
|
branch $30.4, 32, 96
|
label 32
|
del $30.4
|
n = $phi32.1 :: int64
|
del $phi32.1
|
50:
uu = extract_row(u, n, grid)
$32.2 = global(extract_row: CPUDispatcher(<function extract_row at 0x7ff2779c18c8>)) :: type(CPUDispatcher(<function extract_row at 0x7ff2779c18c8>))
|
$32.6 = call $32.2(u, n, grid, func=$32.2, args=[Var(u, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (47)), Var(n, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (49)), Var(grid, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (47))], kws=(), vararg=None) :: (array(float64, 2d, C), int64, tuple((float64, float64, int64) x 2)) -> tuple(float64 x 2)
|
del $32.2
|
uu = $32.6 :: tuple(float64 x 2)
|
del $32.6
|
51:
# get indices and barycentric coordinates
52:
tmp = fmap(get_index, grid, uu)
$32.7 = global(fmap: <function fmap at 0x7ff277be11e0>) :: Function(<function fmap at 0x7ff277be11e0>)
|
$32.8 = global(get_index: CPUDispatcher(<function get_index at 0x7ff277be17b8>)) :: type(CPUDispatcher(<function get_index at 0x7ff277be17b8>))
|
$32.11 = call $32.7($32.8, grid, uu, func=$32.7, args=[Var($32.8, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (52)), Var(grid, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (47)), Var(uu, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (50))], kws=(), vararg=None) :: (type(CPUDispatcher(<function get_index at 0x7ff277be17b8>)), tuple((float64, float64, int64) x 2), tuple(float64 x 2)) -> tuple((int64, float64) x 2)
|
del uu
|
del $32.8
|
del $32.7
|
tmp = $32.11 :: tuple((int64, float64) x 2)
|
del $32.11
|
53:
indices, barycenters = funzip(tmp)
$32.12 = global(funzip: CPUDispatcher(<function funzip at 0x7ff2779c1268>)) :: type(CPUDispatcher(<function funzip at 0x7ff2779c1268>))
|
$32.14 = call $32.12(tmp, func=$32.12, args=[Var(tmp, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (52))], kws=(), vararg=None) :: (tuple((int64, float64) x 2),) -> (tuple(int64 x 2), tuple(float64 x 2))
|
del tmp
|
del $32.12
|
$32.17 = exhaust_iter(value=$32.14, count=2) :: (tuple(int64 x 2), tuple(float64 x 2))
|
del $32.14
|
$32.15 = static_getitem(value=$32.17, index=0, index_var=None) :: tuple(int64 x 2)
|
$32.16 = static_getitem(value=$32.17, index=1, index_var=None) :: tuple(float64 x 2)
|
del $32.17
|
indices = $32.15 :: tuple(int64 x 2)
|
del $32.15
|
barycenters = $32.16 :: tuple(float64 x 2)
|
del $32.16
|
54:
coeffs = get_coeffs(c, indices)
$32.18 = global(get_coeffs: CPUDispatcher(<function get_coeffs at 0x7ff2779c12f0>)) :: type(CPUDispatcher(<function get_coeffs at 0x7ff2779c12f0>))
|
$32.21 = call $32.18(c, indices, func=$32.18, args=[Var(c, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (47)), Var(indices, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (53))], kws=(), vararg=None) :: (array(float64, 2d, C), tuple(int64 x 2)) -> tuple(tuple(float64 x 2) x 2)
|
del indices
|
del $32.18
|
coeffs = $32.21 :: tuple(tuple(float64 x 2) x 2)
|
del $32.21
|
55:
res[n] = tensor_reduction(coeffs, barycenters)
$32.22 = global(tensor_reduction: CPUDispatcher(<function tensor_reduction at 0x7ff2779c1840>)) :: type(CPUDispatcher(<function tensor_reduction at 0x7ff2779c1840>))
|
$32.25 = call $32.22(coeffs, barycenters, func=$32.22, args=[Var(coeffs, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (54)), Var(barycenters, /home/pablo/Mobilhome/econforge/interpolation.py/interpolation/multilinear/mlinterp.py (53))], kws=(), vararg=None) :: (tuple(tuple(float64 x 2) x 2), tuple(float64 x 2)) -> float64
|
del coeffs
|
del barycenters
|
del $32.22
|
res[n] = $32.25 :: (array(float64, 1d, C), int64, float64) -> none
|
del n
|
del $32.25
|
jump 30
|
label 96
|
del u
|
del grid
|
del c
|
del $phi32.1
|
del $phi30.1
|
del $30.4
|
jump 98
|
label 98
|
56:
return res
$98.2 = cast(value=res) :: array(float64, 1d, C)
|
del res
|
return $98.2
|