numbox 0.2.9__py3-none-any.whl → 0.2.10__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.
Potentially problematic release.
This version of numbox might be problematic. Click here for more details.
- numbox/__init__.py +1 -1
- numbox/core/work/builder.py +6 -7
- numbox/core/work/builder_utils.py +40 -0
- numbox/core/work/lowlevel_work_utils.py +5 -5
- numbox/core/work/work.py +0 -1
- numbox/utils/highlevel.py +1 -0
- {numbox-0.2.9.dist-info → numbox-0.2.10.dist-info}/METADATA +1 -1
- {numbox-0.2.9.dist-info → numbox-0.2.10.dist-info}/RECORD +11 -10
- {numbox-0.2.9.dist-info → numbox-0.2.10.dist-info}/LICENSE +0 -0
- {numbox-0.2.9.dist-info → numbox-0.2.10.dist-info}/WHEEL +0 -0
- {numbox-0.2.9.dist-info → numbox-0.2.10.dist-info}/top_level.txt +0 -0
numbox/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = '0.2.
|
|
1
|
+
__version__ = '0.2.10'
|
numbox/core/work/builder.py
CHANGED
|
@@ -5,7 +5,7 @@ from io import StringIO
|
|
|
5
5
|
from itertools import chain
|
|
6
6
|
from numba import njit, typeof
|
|
7
7
|
from numba.core.types import Type
|
|
8
|
-
from typing import Any, Callable, Dict, NamedTuple, Optional, Sequence, Union
|
|
8
|
+
from typing import Any, Callable, Dict, NamedTuple, Optional, Sequence, Tuple as PyTuple, Union
|
|
9
9
|
|
|
10
10
|
from numbox.core.configurations import default_jit_options
|
|
11
11
|
from numbox.core.work.lowlevel_work_utils import ll_make_work
|
|
@@ -48,7 +48,7 @@ class _Derived(NamedTuple):
|
|
|
48
48
|
name: str
|
|
49
49
|
init_value: Any
|
|
50
50
|
derive: Callable
|
|
51
|
-
sources: Sequence[Union['Derived', End]]
|
|
51
|
+
sources: Sequence[Union['Derived', End]] = ()
|
|
52
52
|
registry: dict = None
|
|
53
53
|
ty: Optional[type | Type] = None
|
|
54
54
|
|
|
@@ -102,7 +102,7 @@ def _derived_line(
|
|
|
102
102
|
name_ = derived_.name
|
|
103
103
|
init_ = derived_.init_value
|
|
104
104
|
sources_ = ", ".join([s.name for s in derived_.sources])
|
|
105
|
-
sources_ = sources_ + ", " if "," not in sources_ else sources_
|
|
105
|
+
sources_ = sources_ + ", " if sources_ and "," not in sources_ else sources_
|
|
106
106
|
ty_ = get_ty(derived_)
|
|
107
107
|
derive_func = derived_.derive
|
|
108
108
|
derive_hashes.append(sha256(getsource(derive_func).encode("utf-8")).hexdigest())
|
|
@@ -132,7 +132,7 @@ def _infer_end_and_derived_nodes(spec: SpecTy, all_inputs_: Dict[str, Type], all
|
|
|
132
132
|
all_derived_[spec.name] = get_ty(spec)
|
|
133
133
|
|
|
134
134
|
|
|
135
|
-
def infer_end_and_derived_nodes(access_nodes: SpecTy
|
|
135
|
+
def infer_end_and_derived_nodes(access_nodes: PyTuple[SpecTy, ...], registry):
|
|
136
136
|
all_inputs_ = dict()
|
|
137
137
|
all_derived_ = dict()
|
|
138
138
|
for access_node in access_nodes:
|
|
@@ -143,7 +143,7 @@ def infer_end_and_derived_nodes(access_nodes: SpecTy | Sequence[SpecTy], registr
|
|
|
143
143
|
|
|
144
144
|
|
|
145
145
|
def make_graph(
|
|
146
|
-
*access_nodes: SpecTy
|
|
146
|
+
*access_nodes: SpecTy,
|
|
147
147
|
registry: Optional[dict] = None,
|
|
148
148
|
jit_options: Optional[dict] = None
|
|
149
149
|
):
|
|
@@ -170,8 +170,7 @@ def make_graph(
|
|
|
170
170
|
hash_str = f"code_block = {code_txt.getvalue()} initializers = {list(initializers.values())} derive_hashes = {derive_hashes}" # noqa: E501
|
|
171
171
|
hash_ = code_block_hash(hash_str)
|
|
172
172
|
access_nodes_names = [n.name for n in access_nodes]
|
|
173
|
-
tup_ = ", ".join(access_nodes_names)
|
|
174
|
-
tup_ = tup_ + ", " if ", " not in tup_ else tup_
|
|
173
|
+
tup_ = ", ".join(access_nodes_names) + ","
|
|
175
174
|
code_txt.write(f"""\n\taccess_tuple = ({tup_})""")
|
|
176
175
|
code_txt.write("\n\treturn access_tuple")
|
|
177
176
|
code_txt = code_txt.getvalue()
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from typing import NamedTuple, Tuple
|
|
2
|
+
|
|
3
|
+
from numbox.core.work.builder import SpecTy, End
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def _infer_sources_dependencies(spec: SpecTy, sources_dependencies_):
|
|
7
|
+
if isinstance(spec, End):
|
|
8
|
+
return
|
|
9
|
+
for source in spec.sources:
|
|
10
|
+
spec_dependencies = sources_dependencies_.setdefault(spec.name, set())
|
|
11
|
+
sources_dependencies_.setdefault(source.name, set()).add(spec.name)
|
|
12
|
+
sources_dependencies_[source.name] |= spec_dependencies
|
|
13
|
+
_infer_sources_dependencies(source, sources_dependencies_)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def infer_sources_dependencies(access_nodes: NamedTuple | Tuple):
|
|
17
|
+
"""
|
|
18
|
+
For all nodes names accessible from the given `access_nodes`,
|
|
19
|
+
return dictionary of all nodes names that depend on each of the
|
|
20
|
+
nodes in the accessible graph. For instance::
|
|
21
|
+
|
|
22
|
+
m1 -- m2 -- m3 -- m5
|
|
23
|
+
|
|
|
24
|
+
m4
|
|
25
|
+
|
|
26
|
+
will return::
|
|
27
|
+
|
|
28
|
+
{
|
|
29
|
+
"m1": set(),
|
|
30
|
+
"m2": {"m1"},
|
|
31
|
+
"m3": {"m1", "m2"},
|
|
32
|
+
"m4": {"m1"},
|
|
33
|
+
"m5": {"m1", "m2", "m3"}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
"""
|
|
37
|
+
sources_dependencies_ = {}
|
|
38
|
+
for access_node in access_nodes:
|
|
39
|
+
_infer_sources_dependencies(access_node, sources_dependencies_)
|
|
40
|
+
return sources_dependencies_
|
|
@@ -106,16 +106,16 @@ def ensure_work_boxing():
|
|
|
106
106
|
@intrinsic(prefer_literal=False)
|
|
107
107
|
def ll_make_work(typingctx, name_ty, data_ty, sources_ty, derive_ty, data_ty_ref: TypeRef = NoneType):
|
|
108
108
|
"""
|
|
109
|
-
Purely intrinsic work constructor
|
|
110
|
-
`numbox.core.work.work.Work`.
|
|
109
|
+
Purely intrinsic work constructor.
|
|
111
110
|
|
|
112
111
|
Substantially more efficient in memory use, cache disk space, and
|
|
113
112
|
compilation time for inlining multiple `Work` instantiations inside
|
|
114
113
|
jitted context (e.g., in large-graph applications).
|
|
115
114
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
115
|
+
Alternative `make_work`-like constructors with `inline="always"`
|
|
116
|
+
might save memory and cache disk space demand (when the inlining
|
|
117
|
+
directive is actually heeded by numba engine) but significantly
|
|
118
|
+
lengthen the compilation time.
|
|
119
119
|
"""
|
|
120
120
|
if data_ty_ref != NoneType:
|
|
121
121
|
data_ty = data_ty_ref.instance_type
|
numbox/core/work/work.py
CHANGED
|
@@ -210,7 +210,6 @@ _calculate_registry = {}
|
|
|
210
210
|
|
|
211
211
|
def ensure_presence_of_source_getters_in_ns(num_sources_, ns_):
|
|
212
212
|
for source_i in range(num_sources_):
|
|
213
|
-
_source_getter = _source_getter_registry.get(source_i, None)
|
|
214
213
|
source_getter_code_txt = _make_source_getter(source_i)
|
|
215
214
|
source_getter_code = compile(source_getter_code_txt, getfile(_file_anchor), mode="exec")
|
|
216
215
|
exec(source_getter_code, ns_)
|
numbox/utils/highlevel.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
numbox/__init__.py,sha256=
|
|
1
|
+
numbox/__init__.py,sha256=JYwb-C-8s4xwnUp2y3_Hp7caBJyciFJh6lKJs_WcehM,23
|
|
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,25 +15,26 @@ 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=Wt7yzswDmeQXt0yjcTcnLi2coneowSHWXy_IFpZZJMU,3612
|
|
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=d0DRwJoyskp-6tYQyV1VE-v9eX99qJbQJ_FdAFrjuiE,6273
|
|
19
|
+
numbox/core/work/builder_utils.py,sha256=z8au1x10AwnzQ0_MAbQ6DnKTp3u9HeYZ1jyfkUMYjVg,1213
|
|
19
20
|
numbox/core/work/combine_utils.py,sha256=qTVGke_ydzaTQ7o29DFjZWZzKjRNKb0L3yJMaR3TLII,2430
|
|
20
21
|
numbox/core/work/explain.py,sha256=ESwvsTgfe0w7UnM13yyVpVDtfJyAK2A1sNdF3RNb-jU,1200
|
|
21
22
|
numbox/core/work/loader_utils.py,sha256=g83mDWidZJ8oLWP3I3rK8aGISYOO2S-w6HDgtosCyck,1572
|
|
22
|
-
numbox/core/work/lowlevel_work_utils.py,sha256=
|
|
23
|
+
numbox/core/work/lowlevel_work_utils.py,sha256=ouQ9u-wb8N-x2p93H6_72_9AzYxBOvigeU79i7S9qu0,5752
|
|
23
24
|
numbox/core/work/node.py,sha256=CMolyoRQjG2A-pTQqZQ0kxKOYTKipWRC0mu8RWHuTUI,5096
|
|
24
25
|
numbox/core/work/node_base.py,sha256=uI7asM2itQcHuOByXyJtqvrd4ovW6EXDRdHYp3JVHQ0,998
|
|
25
26
|
numbox/core/work/print_tree.py,sha256=y2u7xmbHvpcA57y8PrGSqOunLNCqhgNXdVtXHqvy1M0,2340
|
|
26
|
-
numbox/core/work/work.py,sha256=
|
|
27
|
+
numbox/core/work/work.py,sha256=yISGKbXsut5ZSbRT2h6uMAAFsKDQ__fcX27HuI6ydhA,15022
|
|
27
28
|
numbox/core/work/work_utils.py,sha256=3q_nnBdzuxWWcdFpbRL2H0T9ZNkUgx1J1uhiZkX3YG4,1039
|
|
28
29
|
numbox/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
29
|
-
numbox/utils/highlevel.py,sha256=
|
|
30
|
+
numbox/utils/highlevel.py,sha256=3dEdIbk0OJcBmuWdbuwG-0v80U19sSYMIxOR8qslGsQ,8360
|
|
30
31
|
numbox/utils/lowlevel.py,sha256=ACpf8_HyOIsobPlZ31bapkEyuCsV5dojW3AFrcKykrw,10712
|
|
31
32
|
numbox/utils/meminfo.py,sha256=ykFi8Vt0WcHI3ztgMwvpn6NqaflDSQGL8tjI01jrzm0,1759
|
|
32
33
|
numbox/utils/standard.py,sha256=2fPrMlSXe2TG3CIfjJOT8LQkHEH86oOOj1AvwQkYCfA,450
|
|
33
34
|
numbox/utils/timer.py,sha256=5_d690Fb3L2axJBRxtoB0qe23exBosNR4qu6cno4QfY,641
|
|
34
35
|
numbox/utils/void_type.py,sha256=IkZsjNeAIShYJtvWbvERdHnl_mbF1rCRWiM3gp6II8U,404
|
|
35
|
-
numbox-0.2.
|
|
36
|
-
numbox-0.2.
|
|
37
|
-
numbox-0.2.
|
|
38
|
-
numbox-0.2.
|
|
39
|
-
numbox-0.2.
|
|
36
|
+
numbox-0.2.10.dist-info/LICENSE,sha256=YYgNvjH_p6-1NsdrIqGJnr1GUbZzA_8DxsP6vVfM6nY,1446
|
|
37
|
+
numbox-0.2.10.dist-info/METADATA,sha256=VYLHTb3Nzvg7thEEQ3fCKHCxmp3cjXlNEk3OZWxETfI,2936
|
|
38
|
+
numbox-0.2.10.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
|
|
39
|
+
numbox-0.2.10.dist-info/top_level.txt,sha256=A67jOkfqidCSYYm6ifjN_WZyIiR1B27fjxv6nNbPvjc,7
|
|
40
|
+
numbox-0.2.10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|