numbox 0.2.2__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/core/work/work.py +12 -9
- {numbox-0.2.2.dist-info → numbox-0.2.4.dist-info}/METADATA +1 -1
- {numbox-0.2.2.dist-info → numbox-0.2.4.dist-info}/RECORD +8 -8
- {numbox-0.2.2.dist-info → numbox-0.2.4.dist-info}/LICENSE +0 -0
- {numbox-0.2.2.dist-info → numbox-0.2.4.dist-info}/WHEEL +0 -0
- {numbox-0.2.2.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)
|
numbox/core/work/work.py
CHANGED
|
@@ -3,11 +3,12 @@ from io import StringIO
|
|
|
3
3
|
from numba import njit
|
|
4
4
|
from numba.core.errors import NumbaError
|
|
5
5
|
from numba.core.types import (
|
|
6
|
-
DictType, FunctionType,
|
|
6
|
+
boolean, DictType, FunctionType, Literal, NoneType, Tuple, unicode_type, UnicodeType
|
|
7
7
|
)
|
|
8
8
|
from numba.core.typing.context import Context
|
|
9
9
|
from numba.experimental.structref import define_boxing, new
|
|
10
10
|
from numba.extending import intrinsic, overload, overload_method
|
|
11
|
+
from numba.typed.typeddict import Dict
|
|
11
12
|
from numba.typed.typedlist import List
|
|
12
13
|
|
|
13
14
|
from numbox.core.any.erased_type import ErasedType
|
|
@@ -291,12 +292,14 @@ def _make_combine_code(num_sources):
|
|
|
291
292
|
for source_ind_ in range(num_sources):
|
|
292
293
|
code_txt.write(_make_source_getter(source_ind_))
|
|
293
294
|
code_txt.write("""
|
|
294
|
-
def _combine_(work_, data_,
|
|
295
|
-
if
|
|
296
|
-
|
|
295
|
+
def _combine_(work_, data_, harvested_=None):
|
|
296
|
+
if harvested_ is None:
|
|
297
|
+
harvested_ = Dict.empty(key_type=unicode_type, value_type=boolean)
|
|
298
|
+
if len(harvested_) == len(data_):
|
|
299
|
+
return
|
|
297
300
|
work_name = work_.name
|
|
298
301
|
if work_name in data_:
|
|
299
|
-
|
|
302
|
+
harvested_[work_name] = True
|
|
300
303
|
data_[work_name].reset(work_.data)""")
|
|
301
304
|
if num_sources > 0:
|
|
302
305
|
code_txt.write("""
|
|
@@ -304,10 +307,10 @@ def _combine_(work_, data_, ct_=0):
|
|
|
304
307
|
for source_ind_ in range(num_sources):
|
|
305
308
|
code_txt.write(f"""
|
|
306
309
|
source_{source_ind_} = _get_source_{source_ind_}(sources)
|
|
307
|
-
|
|
310
|
+
source_{source_ind_}.combine(data_, harvested_)
|
|
308
311
|
""")
|
|
309
312
|
code_txt.write("""
|
|
310
|
-
return
|
|
313
|
+
return
|
|
311
314
|
""")
|
|
312
315
|
return code_txt.getvalue()
|
|
313
316
|
|
|
@@ -316,7 +319,7 @@ _combine_registry = {}
|
|
|
316
319
|
|
|
317
320
|
|
|
318
321
|
@overload_method(WorkTypeClass, "combine", strict=False, jit_options=default_jit_options)
|
|
319
|
-
def ol_combine(work_ty, data_ty: DictType,
|
|
322
|
+
def ol_combine(work_ty, data_ty: DictType, harvested_ty=NoneType):
|
|
320
323
|
""" Harvest nodes data from the graph with the root node `work`.
|
|
321
324
|
`data` is provided as dictionary mapping node name to `Any` type
|
|
322
325
|
containing erased payload `p` to be reset to `data`. """
|
|
@@ -325,7 +328,7 @@ def ol_combine(work_ty, data_ty: DictType, ct_ty=Integer):
|
|
|
325
328
|
_combine = _combine_registry.get(num_sources, None)
|
|
326
329
|
if _combine is None:
|
|
327
330
|
code_txt = _make_combine_code(num_sources)
|
|
328
|
-
ns = getmodule(_file_anchor).__dict__
|
|
331
|
+
ns = {**getmodule(_file_anchor).__dict__, **{"boolean": boolean, "Dict": Dict}}
|
|
329
332
|
code = compile(code_txt, getfile(_file_anchor), mode="exec")
|
|
330
333
|
exec(code, ns)
|
|
331
334
|
_combine = ns["_combine_"]
|
|
@@ -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,14 +15,14 @@ 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
|
|
22
22
|
numbox/core/work/node.py,sha256=CMolyoRQjG2A-pTQqZQ0kxKOYTKipWRC0mu8RWHuTUI,5096
|
|
23
23
|
numbox/core/work/node_base.py,sha256=uI7asM2itQcHuOByXyJtqvrd4ovW6EXDRdHYp3JVHQ0,998
|
|
24
24
|
numbox/core/work/print_tree.py,sha256=y2u7xmbHvpcA57y8PrGSqOunLNCqhgNXdVtXHqvy1M0,2340
|
|
25
|
-
numbox/core/work/work.py,sha256=
|
|
25
|
+
numbox/core/work/work.py,sha256=oC71F2y-NkIF9Ox63trlv061nYBxla6R-F2Nj-7NXI4,14595
|
|
26
26
|
numbox/core/work/work_utils.py,sha256=3q_nnBdzuxWWcdFpbRL2H0T9ZNkUgx1J1uhiZkX3YG4,1039
|
|
27
27
|
numbox/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
28
28
|
numbox/utils/highlevel.py,sha256=gXYzLsFPKHQfGqaz-Z4DWcCQddv0dS6SKwIsM-_xjYg,1487
|
|
@@ -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
|