returnn 1.20251023.135024__py3-none-any.whl → 1.20251024.124744__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 returnn might be problematic. Click here for more details.
- returnn/PKG-INFO +1 -1
- returnn/_setup_info_generated.py +2 -2
- returnn/frontend/module.py +8 -1
- returnn/util/collect_outputs_dict.py +79 -0
- {returnn-1.20251023.135024.dist-info → returnn-1.20251024.124744.dist-info}/METADATA +1 -1
- {returnn-1.20251023.135024.dist-info → returnn-1.20251024.124744.dist-info}/RECORD +9 -8
- {returnn-1.20251023.135024.dist-info → returnn-1.20251024.124744.dist-info}/LICENSE +0 -0
- {returnn-1.20251023.135024.dist-info → returnn-1.20251024.124744.dist-info}/WHEEL +0 -0
- {returnn-1.20251023.135024.dist-info → returnn-1.20251024.124744.dist-info}/top_level.txt +0 -0
returnn/PKG-INFO
CHANGED
returnn/_setup_info_generated.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
version = '1.
|
|
2
|
-
long_version = '1.
|
|
1
|
+
version = '1.20251024.124744'
|
|
2
|
+
long_version = '1.20251024.124744+git.ebcf811'
|
returnn/frontend/module.py
CHANGED
|
@@ -274,10 +274,17 @@ class Functional(Module):
|
|
|
274
274
|
(This is often not necessary, but sometimes useful.)
|
|
275
275
|
"""
|
|
276
276
|
|
|
277
|
-
def __init__(self, func):
|
|
277
|
+
def __init__(self, func, *, attribs: Optional[Dict[str, Any]] = None):
|
|
278
|
+
"""
|
|
279
|
+
:param func: callable. you might want to use functools.partial if you want to fix some arguments.
|
|
280
|
+
:param attribs: optional dict of attributes to set on this module. e.g. ``out_dim``.
|
|
281
|
+
"""
|
|
278
282
|
super().__init__()
|
|
279
283
|
assert callable(func)
|
|
280
284
|
self.func = func
|
|
285
|
+
if attribs:
|
|
286
|
+
for k, v in attribs.items():
|
|
287
|
+
setattr(self, k, v)
|
|
281
288
|
|
|
282
289
|
def __repr__(self):
|
|
283
290
|
return f"{self.__class__.__name__}({self.func.__qualname__})"
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Customized (derived) dict to pass as ``collected_outputs`` to some of the RF modules,
|
|
3
|
+
or potential other use cases.
|
|
4
|
+
|
|
5
|
+
You can predefine (by pattern) what kind of outputs you want to collect and store in this dict.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from typing import Optional, Union, Sequence
|
|
9
|
+
import fnmatch
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class CollectOutputsDict(dict):
|
|
13
|
+
"""
|
|
14
|
+
Customized (derived) dict, where you can predefine (by key pattern)
|
|
15
|
+
what kind of keys you want to collect and store in this dict.
|
|
16
|
+
Other keys will be ignored.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
def __init__(self, *args, allowed_key_patterns: Optional[Sequence[str]] = None, **kwargs):
|
|
20
|
+
"""
|
|
21
|
+
Initialize the CollectOutputsDict.
|
|
22
|
+
|
|
23
|
+
:param allowed_key_patterns:
|
|
24
|
+
List of key patterns (with wildcards) that are allowed to be stored in the dict.
|
|
25
|
+
If None, all keys are allowed.
|
|
26
|
+
"""
|
|
27
|
+
super().__init__(*args, **kwargs)
|
|
28
|
+
self.allowed_key_patterns = allowed_key_patterns
|
|
29
|
+
|
|
30
|
+
def __setitem__(self, key, value):
|
|
31
|
+
"""
|
|
32
|
+
Set an item in the dict if the key matches allowed patterns.
|
|
33
|
+
"""
|
|
34
|
+
if self.is_key_allowed(key):
|
|
35
|
+
super().__setitem__(key, value)
|
|
36
|
+
|
|
37
|
+
def setdefault(self, key, default=None):
|
|
38
|
+
"""
|
|
39
|
+
Set default value for a key if it matches allowed patterns.
|
|
40
|
+
"""
|
|
41
|
+
if self.is_key_allowed(key):
|
|
42
|
+
return super().setdefault(key, default)
|
|
43
|
+
return None
|
|
44
|
+
|
|
45
|
+
def update(self, mapping, **kwargs):
|
|
46
|
+
"""
|
|
47
|
+
Update the dict with another mapping, only adding allowed keys.
|
|
48
|
+
"""
|
|
49
|
+
assert not kwargs
|
|
50
|
+
for key, value in mapping.items():
|
|
51
|
+
if self.is_key_allowed(key):
|
|
52
|
+
super().__setitem__(key, value)
|
|
53
|
+
|
|
54
|
+
def is_key_allowed(self, key: str) -> bool:
|
|
55
|
+
"""
|
|
56
|
+
Check if the key matches any of the allowed patterns.
|
|
57
|
+
|
|
58
|
+
:param key:
|
|
59
|
+
:return: True if the key is allowed, False otherwise.
|
|
60
|
+
"""
|
|
61
|
+
if self.allowed_key_patterns is None:
|
|
62
|
+
return True # If no patterns defined, allow all keys
|
|
63
|
+
for pattern in self.allowed_key_patterns:
|
|
64
|
+
if fnmatch.fnmatch(key, pattern):
|
|
65
|
+
return True
|
|
66
|
+
return False
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def is_key_allowed_in_collect_outputs_dict(collect_outputs: Union[CollectOutputsDict, dict], key: str) -> bool:
|
|
70
|
+
"""
|
|
71
|
+
Check if a key is allowed in the given CollectOutputsDict.
|
|
72
|
+
|
|
73
|
+
:param collect_outputs:
|
|
74
|
+
:param key:
|
|
75
|
+
:return: True if the key is allowed, False otherwise.
|
|
76
|
+
"""
|
|
77
|
+
if isinstance(collect_outputs, CollectOutputsDict):
|
|
78
|
+
return collect_outputs.is_key_allowed(key)
|
|
79
|
+
return True # If it's a regular dict, all keys are allowed
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
returnn/PKG-INFO,sha256=
|
|
1
|
+
returnn/PKG-INFO,sha256=mPJhzhXIhpwh3WIjFcIwZHmWC2erdQLCkd1AA2rEFFY,5215
|
|
2
2
|
returnn/__init__.py,sha256=biBtRsM0WZ406vShaeH-9WFoqJ8XwTbn6g0EeFJ7l8E,1012
|
|
3
3
|
returnn/__main__.py,sha256=lHyZcu_0yc9f7Vf_Kfdy9PmeU0T76XVXnpalHi5WKro,31740
|
|
4
4
|
returnn/__old_mod_loader__.py,sha256=nvsNY-xELdS_IPNkv66Q9Rmvg4dbGW0-EBRDcCmctos,7654
|
|
5
5
|
returnn/__setup__.py,sha256=22kQn2fh11iPM0hLb2Fy5sLmoU1JGvmDxXRYuRgQkwU,4659
|
|
6
|
-
returnn/_setup_info_generated.py,sha256=
|
|
6
|
+
returnn/_setup_info_generated.py,sha256=0MbBh8R3JZrhYH-T7SYNZDNSH65Sf4lzR_WXDcNRrjs,77
|
|
7
7
|
returnn/config.py,sha256=3tmKhB6FnQZaNdtcYsiB61JnEY--iZ2qmJ4yq0b6tE0,29140
|
|
8
8
|
returnn/forward_iface.py,sha256=A_OJiaXsX4MlXQRzST86ylyxSUZbC402PQL1REcqHjM,911
|
|
9
9
|
returnn/learning_rate_control.py,sha256=ZvWryAn_tv9DhV8sh1LV3eE34Yltl3On3mYZAG4hR9s,34684
|
|
@@ -104,7 +104,7 @@ returnn/frontend/loop.py,sha256=t-z6ke1X03I2aPUEqLYmVZWyMzfW3IedFvKUGc-TCX8,1616
|
|
|
104
104
|
returnn/frontend/loss.py,sha256=uSvou2MPd13JiLAg_OIQ3AyyLvD3RHjMEVgFEN0gKqU,7440
|
|
105
105
|
returnn/frontend/math_.py,sha256=A_RkZ5lH2uXMchfPIH3itraWtMNNCVckQHHpf7aIIZQ,17295
|
|
106
106
|
returnn/frontend/matmul.py,sha256=xkueyxzSDz8MsYaWxPSjmV2Yy-tcaiOQDXbFt1IQM2A,1944
|
|
107
|
-
returnn/frontend/module.py,sha256=
|
|
107
|
+
returnn/frontend/module.py,sha256=nt35I9xyHuH42qobLHGUFoNI5-mVieAtA36SqK6NhpY,11065
|
|
108
108
|
returnn/frontend/nested.py,sha256=PKsKWHwE2SI19DjZ9vRI8q4-ywIGMK3-TTUuqdXrVlM,15592
|
|
109
109
|
returnn/frontend/normalization.py,sha256=NrIIaZ3c2yf-WH2R9lPaL2TAq4IcNQc4OE5kFYdoihw,14139
|
|
110
110
|
returnn/frontend/parameter.py,sha256=zvrkhSYC1c_O9kVwgHvOtOnWNurl5J28lkS0i1LQpWU,10627
|
|
@@ -237,6 +237,7 @@ returnn/util/__init__.py,sha256=UIG1qw4idqhW71BV60ha7h9PktxvEVcBIu0lYRossK8,336
|
|
|
237
237
|
returnn/util/basic.py,sha256=MBbyYddO0aJj8Xcb9RbQ5VeunC7htc9IGex09eao67o,143323
|
|
238
238
|
returnn/util/better_exchook.py,sha256=39yvRecluDgYhViwSkaQ8crJ_cBWI63KeEGuK4RKe5w,70843
|
|
239
239
|
returnn/util/bpe.py,sha256=LWFhICZsEOnMwNws0lybPNzKRX6rSr8yKCvP65vjl9Y,19656
|
|
240
|
+
returnn/util/collect_outputs_dict.py,sha256=CjpsftoMgmvyE4wNKTO6F-QQ_44QHXcOZIXMUMQVZ-8,2637
|
|
240
241
|
returnn/util/debug.py,sha256=wuRzdg9zB84WWCGyTjmRR_zYypu8gXxlc0nZ6si9OC8,28224
|
|
241
242
|
returnn/util/debug_helpers.py,sha256=0EINLK4uLtoSt5_kHs1M2NIFpMd0S7i4c4rx90U4fJk,2914
|
|
242
243
|
returnn/util/file_cache.py,sha256=Wyx9u1P59PAo4HouVPh6uaGQeFIXGZHshDyvcRn4YlM,28786
|
|
@@ -254,8 +255,8 @@ returnn/util/sig_proc.py,sha256=Tjz0VOAVyqu2qDCF5HZ1JjALjcFsHcNkcd96WgZeKfE,7265
|
|
|
254
255
|
returnn/util/task_system.py,sha256=y4sMVXQ25Qd2z0rx03uOlXlkE-jbCYC1Sjfn-XlraVU,26003
|
|
255
256
|
returnn/util/train_proc_manager.py,sha256=Pjht28k6uz6BNQ47uW6Gf880iyq5q4wx7P_K2tmoAM8,3266
|
|
256
257
|
returnn/util/watch_memory.py,sha256=BR5P2kvBN6UI81cE0_1WAA6Hd1SByLbBaiDxvLhPOew,4213
|
|
257
|
-
returnn-1.
|
|
258
|
-
returnn-1.
|
|
259
|
-
returnn-1.
|
|
260
|
-
returnn-1.
|
|
261
|
-
returnn-1.
|
|
258
|
+
returnn-1.20251024.124744.dist-info/LICENSE,sha256=ywBD_U2aD4vpuoIgNAsjIGBYydl0tVKll3De0Z8s77c,11041
|
|
259
|
+
returnn-1.20251024.124744.dist-info/METADATA,sha256=mPJhzhXIhpwh3WIjFcIwZHmWC2erdQLCkd1AA2rEFFY,5215
|
|
260
|
+
returnn-1.20251024.124744.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
|
|
261
|
+
returnn-1.20251024.124744.dist-info/top_level.txt,sha256=Lsn4WZc5Pbfk0-xDQOgnFCxOoqxL4CyeM3N1TFbJncw,8
|
|
262
|
+
returnn-1.20251024.124744.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|