numbox 0.2.3__py3-none-any.whl → 0.2.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- numbox/__init__.py +1 -1
- numbox/core/work/builder.py +25 -11
- {numbox-0.2.3.dist-info → numbox-0.2.4.dist-info}/METADATA +1 -1
- {numbox-0.2.3.dist-info → numbox-0.2.4.dist-info}/RECORD +7 -7
- {numbox-0.2.3.dist-info → numbox-0.2.4.dist-info}/LICENSE +0 -0
- {numbox-0.2.3.dist-info → numbox-0.2.4.dist-info}/WHEEL +0 -0
- {numbox-0.2.3.dist-info → numbox-0.2.4.dist-info}/top_level.txt +0 -0
numbox/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = '0.2.
|
|
1
|
+
__version__ = '0.2.4'
|
numbox/core/work/builder.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from hashlib import md5
|
|
2
|
-
from inspect import getfile, getmodule
|
|
2
|
+
from inspect import getfile, getmodule, getsource
|
|
3
3
|
from io import StringIO
|
|
4
|
+
from itertools import chain
|
|
4
5
|
from numba import njit, typeof
|
|
5
6
|
from numba.core.types import Type
|
|
6
7
|
from typing import Any, Callable, NamedTuple, Optional, Sequence, Union
|
|
@@ -31,15 +32,18 @@ class Derived(NamedTuple):
|
|
|
31
32
|
SpecTy = Derived | End
|
|
32
33
|
|
|
33
34
|
|
|
34
|
-
def _input_line(input_: End, ns):
|
|
35
|
+
def _input_line(input_: End, ns: dict, initializers: dict):
|
|
35
36
|
name_ = input_.name
|
|
36
37
|
init_ = input_.init_value
|
|
38
|
+
init_name = f"{name_}_init"
|
|
39
|
+
ns[init_name] = init_
|
|
40
|
+
initializers[init_name] = init_
|
|
37
41
|
ty_ = input_.ty
|
|
38
42
|
if ty_ is not None:
|
|
39
43
|
type_name = f"{name_}_ty"
|
|
40
44
|
ns[type_name] = ty_
|
|
41
|
-
return f"""{name_} = ll_make_work("{name_}", {
|
|
42
|
-
return f"""{name_} = ll_make_work("{name_}", {
|
|
45
|
+
return f"""{name_} = ll_make_work("{name_}", {init_name}, (), None, {type_name})"""
|
|
46
|
+
return f"""{name_} = ll_make_work("{name_}", {init_name}, (), None)"""
|
|
43
47
|
|
|
44
48
|
|
|
45
49
|
def get_ty(spec_):
|
|
@@ -57,17 +61,24 @@ def _derived_cres(ty, sources: Sequence[End], derive, jit_options=None):
|
|
|
57
61
|
return derive_cres
|
|
58
62
|
|
|
59
63
|
|
|
60
|
-
def _derived_line(
|
|
64
|
+
def _derived_line(
|
|
65
|
+
derived_: Derived, ns: dict, initializers: dict, derive_hashes: list, _make_args: list, jit_options=None
|
|
66
|
+
):
|
|
61
67
|
name_ = derived_.name
|
|
62
68
|
init_ = derived_.init_value
|
|
63
69
|
sources_ = ", ".join([s.name for s in derived_.sources])
|
|
64
70
|
sources_ = sources_ + ", " if "," not in sources_ else sources_
|
|
65
71
|
ty_ = get_ty(derived_)
|
|
66
|
-
|
|
72
|
+
derive_func = derived_.derive
|
|
73
|
+
derive_hashes.append(md5(getsource(derive_func).encode("utf-8")).hexdigest())
|
|
74
|
+
derive_ = _derived_cres(ty_, derived_.sources, derive_func, jit_options)
|
|
67
75
|
derive_name = f"{name_}_derive"
|
|
76
|
+
init_name = f"{name_}_init"
|
|
68
77
|
_make_args.append(derive_name)
|
|
69
78
|
ns[derive_name] = derive_
|
|
70
|
-
|
|
79
|
+
ns[init_name] = init_
|
|
80
|
+
initializers[init_name] = init_
|
|
81
|
+
return f"""{name_} = ll_make_work("{name_}", {init_name}, ({sources_}), {derive_name})"""
|
|
71
82
|
|
|
72
83
|
|
|
73
84
|
def _verify_access_nodes(
|
|
@@ -102,17 +113,20 @@ def make_graph(
|
|
|
102
113
|
}
|
|
103
114
|
_make_args = []
|
|
104
115
|
code_txt = StringIO()
|
|
116
|
+
initializers = {}
|
|
117
|
+
derive_hashes=[]
|
|
105
118
|
for input_ in all_inputs_:
|
|
106
|
-
line_ = _input_line(input_, ns)
|
|
119
|
+
line_ = _input_line(input_, ns, initializers)
|
|
107
120
|
code_txt.write(f"\n\t{line_}")
|
|
108
121
|
for derived_ in all_derived_:
|
|
109
|
-
line_ = _derived_line(derived_, ns, _make_args, jit_options)
|
|
122
|
+
line_ = _derived_line(derived_, ns, initializers, derive_hashes, _make_args, jit_options)
|
|
110
123
|
code_txt.write(f"\n\t{line_}")
|
|
111
|
-
|
|
124
|
+
hash_str = f"code_block = {code_txt.getvalue()} initializers = {list(initializers.values())} derive_hashes = {derive_hashes}"
|
|
125
|
+
hash_ = code_block_hash(hash_str)
|
|
112
126
|
code_txt.write(f"""\n\taccess_tuple = ({", ".join([n.name for n in access_nodes])})""")
|
|
113
127
|
code_txt.write(f"\n\treturn access_tuple")
|
|
114
128
|
code_txt = code_txt.getvalue()
|
|
115
|
-
make_params = ", ".join(_make_args)
|
|
129
|
+
make_params = ", ".join(chain(_make_args, initializers.keys()))
|
|
116
130
|
make_name = f"_make_{hash_}"
|
|
117
131
|
code_txt = f"""
|
|
118
132
|
@njit(**jit_options)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
numbox/__init__.py,sha256=
|
|
1
|
+
numbox/__init__.py,sha256=N5-p8dQB8uwuCMpS1ADLf_E6rvWovtRRp3vY9Cq2gw4,22
|
|
2
2
|
numbox/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
numbox/core/configurations.py,sha256=0bCmxXL-QMwtvyIDhpXLeT-1KJMf_QpH0wLuEvYLGxQ,68
|
|
4
4
|
numbox/core/any/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -15,7 +15,7 @@ numbox/core/bindings/utils.py,sha256=aRtN8oUYBk9vgoUGaUJosGx0Za-vvCNwwbZg_g_-LRs
|
|
|
15
15
|
numbox/core/proxy/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
16
|
numbox/core/proxy/proxy.py,sha256=kGYlEdLK40lxxu56e_S32s9YuQ6AuQnFegt5uQrUw5w,3889
|
|
17
17
|
numbox/core/work/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
|
-
numbox/core/work/builder.py,sha256=
|
|
18
|
+
numbox/core/work/builder.py,sha256=bIWOb9_mSSS4IMQ_kSPF5XlMh-nhzooZmDn_6N04r3c,4648
|
|
19
19
|
numbox/core/work/combine_utils.py,sha256=qTVGke_ydzaTQ7o29DFjZWZzKjRNKb0L3yJMaR3TLII,2430
|
|
20
20
|
numbox/core/work/loader_utils.py,sha256=g83mDWidZJ8oLWP3I3rK8aGISYOO2S-w6HDgtosCyck,1572
|
|
21
21
|
numbox/core/work/lowlevel_work_utils.py,sha256=TgRRcNfks0oaOXGXXr3ptafd_Xv_lpmH8sjBrJ9bPuI,5748
|
|
@@ -30,8 +30,8 @@ numbox/utils/lowlevel.py,sha256=ACpf8_HyOIsobPlZ31bapkEyuCsV5dojW3AFrcKykrw,1071
|
|
|
30
30
|
numbox/utils/meminfo.py,sha256=ykFi8Vt0WcHI3ztgMwvpn6NqaflDSQGL8tjI01jrzm0,1759
|
|
31
31
|
numbox/utils/timer.py,sha256=KkAkWOHQ72WtPjyiAzt_tF1q0DcOnCDkITTb85DvkUM,553
|
|
32
32
|
numbox/utils/void_type.py,sha256=IkZsjNeAIShYJtvWbvERdHnl_mbF1rCRWiM3gp6II8U,404
|
|
33
|
-
numbox-0.2.
|
|
34
|
-
numbox-0.2.
|
|
35
|
-
numbox-0.2.
|
|
36
|
-
numbox-0.2.
|
|
37
|
-
numbox-0.2.
|
|
33
|
+
numbox-0.2.4.dist-info/LICENSE,sha256=YYgNvjH_p6-1NsdrIqGJnr1GUbZzA_8DxsP6vVfM6nY,1446
|
|
34
|
+
numbox-0.2.4.dist-info/METADATA,sha256=REXHYfdLyuZ56CPvvesb9uM3bS0PDDHuGgscGDyzzm4,2792
|
|
35
|
+
numbox-0.2.4.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
|
|
36
|
+
numbox-0.2.4.dist-info/top_level.txt,sha256=A67jOkfqidCSYYm6ifjN_WZyIiR1B27fjxv6nNbPvjc,7
|
|
37
|
+
numbox-0.2.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|