returnn 1.20250812.202710__py3-none-any.whl → 1.20250817.33823__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/datasets/distrib_files.py +4 -3
- returnn/datasets/multi_proc.py +5 -4
- returnn/frontend/_backend.py +7 -0
- returnn/frontend/rand.py +14 -0
- returnn/torch/frontend/_backend.py +22 -0
- {returnn-1.20250812.202710.dist-info → returnn-1.20250817.33823.dist-info}/METADATA +1 -1
- {returnn-1.20250812.202710.dist-info → returnn-1.20250817.33823.dist-info}/RECORD +12 -12
- {returnn-1.20250812.202710.dist-info → returnn-1.20250817.33823.dist-info}/LICENSE +0 -0
- {returnn-1.20250812.202710.dist-info → returnn-1.20250817.33823.dist-info}/WHEEL +0 -0
- {returnn-1.20250812.202710.dist-info → returnn-1.20250817.33823.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.20250817.033823'
|
|
2
|
+
long_version = '1.20250817.033823+git.4f41ff3'
|
|
@@ -6,6 +6,7 @@ https://github.com/rwth-i6/returnn/issues/1519
|
|
|
6
6
|
|
|
7
7
|
from __future__ import annotations
|
|
8
8
|
|
|
9
|
+
from collections import deque
|
|
9
10
|
from typing import Union, Optional, Any, Callable, Sequence, Tuple, List, Dict
|
|
10
11
|
import os
|
|
11
12
|
import sys
|
|
@@ -636,7 +637,7 @@ def _worker_proc_loop(
|
|
|
636
637
|
dataset = init_dataset(dataset_dict)
|
|
637
638
|
|
|
638
639
|
got_init_seq_order = False
|
|
639
|
-
cache:
|
|
640
|
+
cache: deque[DatasetSeq] = deque()
|
|
640
641
|
next_seq_idx = 0
|
|
641
642
|
|
|
642
643
|
# noinspection PyShadowingNames
|
|
@@ -701,7 +702,7 @@ def _worker_proc_loop(
|
|
|
701
702
|
elif msg == "get_data_seq":
|
|
702
703
|
seq_idx = kwargs["seq_idx"]
|
|
703
704
|
while cache and cache[0].seq_idx < seq_idx:
|
|
704
|
-
cache.
|
|
705
|
+
cache.popleft()
|
|
705
706
|
res = _get(seq_idx)
|
|
706
707
|
parent_conn.send(("data_seq", res))
|
|
707
708
|
elif msg == "init_seq_order":
|
|
@@ -714,7 +715,7 @@ def _worker_proc_loop(
|
|
|
714
715
|
parent_conn.send(("num_seqs", num_seqs))
|
|
715
716
|
got_init_seq_order = True
|
|
716
717
|
next_seq_idx = 0
|
|
717
|
-
cache
|
|
718
|
+
cache.clear()
|
|
718
719
|
else:
|
|
719
720
|
raise Exception(f"unknown msg {msg!r}")
|
|
720
721
|
except KeyboardInterrupt: # when parent dies
|
returnn/datasets/multi_proc.py
CHANGED
|
@@ -3,6 +3,7 @@ Multi-processing dataset
|
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
5
|
from __future__ import annotations
|
|
6
|
+
from collections import deque
|
|
6
7
|
from typing import Optional, Any, Dict, List
|
|
7
8
|
import sys
|
|
8
9
|
import gc
|
|
@@ -234,7 +235,7 @@ class MultiProcDataset(CachedDataset2):
|
|
|
234
235
|
dataset: Optional[Dataset] = None
|
|
235
236
|
|
|
236
237
|
got_init_seq_order = False
|
|
237
|
-
cache
|
|
238
|
+
cache: deque[DatasetSeq] = deque()
|
|
238
239
|
next_seq_idx = 0
|
|
239
240
|
|
|
240
241
|
# noinspection PyShadowingNames
|
|
@@ -299,7 +300,7 @@ class MultiProcDataset(CachedDataset2):
|
|
|
299
300
|
elif msg == "get_data_seq":
|
|
300
301
|
seq_idx = kwargs["seq_idx"]
|
|
301
302
|
while cache and cache[0].seq_idx < seq_idx:
|
|
302
|
-
cache.
|
|
303
|
+
cache.popleft()
|
|
303
304
|
res = _get(seq_idx)
|
|
304
305
|
parent_conn.send(("data_seq", res))
|
|
305
306
|
elif msg == "init":
|
|
@@ -372,11 +373,11 @@ class MultiProcDataset(CachedDataset2):
|
|
|
372
373
|
raise ValueError(f"{MultiProcDataset.__name__}: unknown sharding_method: {sharding_method}")
|
|
373
374
|
got_init_seq_order = True
|
|
374
375
|
next_seq_idx = 0
|
|
375
|
-
cache
|
|
376
|
+
cache.clear()
|
|
376
377
|
elif msg == "finish_epoch":
|
|
377
378
|
got_init_seq_order = False
|
|
378
379
|
next_seq_idx = 0
|
|
379
|
-
cache
|
|
380
|
+
cache.clear()
|
|
380
381
|
if dataset:
|
|
381
382
|
dataset.finish_epoch(**kwargs)
|
|
382
383
|
if kwargs["free_resources"]:
|
returnn/frontend/_backend.py
CHANGED
|
@@ -1153,6 +1153,13 @@ class Backend(Generic[T]):
|
|
|
1153
1153
|
"""
|
|
1154
1154
|
raise NotImplementedError
|
|
1155
1155
|
|
|
1156
|
+
@staticmethod
|
|
1157
|
+
def random_choice_with_replacement(dims: Sequence[Dim], *, probs: Tensor, axis: Dim) -> Tensor:
|
|
1158
|
+
"""
|
|
1159
|
+
random choice with replacement. See `rf.random_choice_with_replacement` for details.
|
|
1160
|
+
"""
|
|
1161
|
+
raise NotImplementedError
|
|
1162
|
+
|
|
1156
1163
|
@staticmethod
|
|
1157
1164
|
def masked_select(
|
|
1158
1165
|
tensor: Tensor, *, mask: Tensor, dims: Sequence[Dim], out_dim: Optional[Dim] = None
|
returnn/frontend/rand.py
CHANGED
|
@@ -65,6 +65,7 @@ __all__ = [
|
|
|
65
65
|
"random_normal",
|
|
66
66
|
"random_truncated_normal",
|
|
67
67
|
"random_choice_without_replacement",
|
|
68
|
+
"random_choice_with_replacement",
|
|
68
69
|
]
|
|
69
70
|
|
|
70
71
|
|
|
@@ -379,3 +380,16 @@ def random_choice_without_replacement(
|
|
|
379
380
|
scores = log_probs + scores_random_sample
|
|
380
381
|
_, indices, _ = rf.top_k(scores, k_dim=num_samples_dim, axis=axis)
|
|
381
382
|
return indices
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
def random_choice_with_replacement(dims: Sequence[Dim], *, probs: Tensor, axis: Dim) -> Tensor:
|
|
386
|
+
"""
|
|
387
|
+
Randomly sample with replacement.
|
|
388
|
+
|
|
389
|
+
:param dims: {common_dims..., new_dims...}. Defines how many samples to draw. Defines the output shape.
|
|
390
|
+
:param probs: {common_dims..., axis}
|
|
391
|
+
:param axis: feature axis, where to sample from
|
|
392
|
+
:return: random indices shape dims -> axis.
|
|
393
|
+
"""
|
|
394
|
+
# noinspection PyProtectedMember
|
|
395
|
+
return probs._raw_backend.random_choice_with_replacement(dims=dims, probs=probs, axis=axis)
|
|
@@ -1718,6 +1718,28 @@ class TorchBackend(Backend[torch.Tensor]):
|
|
|
1718
1718
|
)
|
|
1719
1719
|
return out
|
|
1720
1720
|
|
|
1721
|
+
@staticmethod
|
|
1722
|
+
def random_choice_with_replacement(dims: Sequence[Dim], *, probs: Tensor, axis: Dim) -> Tensor:
|
|
1723
|
+
"""random choice with replacement"""
|
|
1724
|
+
assert all(d == axis or d in dims for d in probs.dims), (
|
|
1725
|
+
f"random_choice_with_replacement: dims {dims} not compatible with probs {probs} and axis {axis}"
|
|
1726
|
+
)
|
|
1727
|
+
common_dims = [d for d in dims if d in probs.dims]
|
|
1728
|
+
assert axis not in common_dims
|
|
1729
|
+
probs = probs.copy_transpose(common_dims + [axis])
|
|
1730
|
+
non_common_dims = [d for d in dims if d not in common_dims]
|
|
1731
|
+
num_samples = prod([d.get_dim_value() for d in non_common_dims])
|
|
1732
|
+
if len(common_dims) >= 2:
|
|
1733
|
+
probs, flat_common_dim = rf.merge_dims(probs, dims=common_dims)
|
|
1734
|
+
out_raw = torch.multinomial(probs.raw_tensor, num_samples=num_samples, replacement=True)
|
|
1735
|
+
out_raw = out_raw.reshape(
|
|
1736
|
+
[d.get_dim_value() for d in common_dims] + [d.get_dim_value() for d in non_common_dims]
|
|
1737
|
+
)
|
|
1738
|
+
out = rf.convert_to_tensor(out_raw, dims=common_dims + non_common_dims, sparse_dim=axis)
|
|
1739
|
+
out = out.copy_transpose(dims)
|
|
1740
|
+
out.name = "random_choice_with_replacement"
|
|
1741
|
+
return out
|
|
1742
|
+
|
|
1721
1743
|
@staticmethod
|
|
1722
1744
|
def masked_select(
|
|
1723
1745
|
tensor: Tensor, *, mask: Tensor, dims: Sequence[Dim], out_dim: Optional[Dim] = None
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
returnn/PKG-INFO,sha256=
|
|
1
|
+
returnn/PKG-INFO,sha256=B57ObmyaxFzp_TjsXhRqtVvzxZWq3hS54vw34tZHZsQ,5214
|
|
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=BSqlencj66qyQkfuBO7fze_8cqW9p9M0Si-qLIGy1-k,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
|
|
@@ -17,13 +17,13 @@ returnn/datasets/basic.py,sha256=_42fQztTZq7jNQrWdFBwulB1bNta17LOTyrD8XJ-7_E,730
|
|
|
17
17
|
returnn/datasets/bundle_file.py,sha256=KQNrS1MSf-4_idlK0c0KFwON-f5sEK0sWU15WpoMYpE,2380
|
|
18
18
|
returnn/datasets/cached.py,sha256=RyefRjSDdp-HveK-2vLy2C6BIHcpqQ_lNvUKlIa4QAI,25412
|
|
19
19
|
returnn/datasets/cached2.py,sha256=oJOq2lWRQpxm6kyUKW1w5qZBd4kdKEpwM7KY_QnXbq4,11922
|
|
20
|
-
returnn/datasets/distrib_files.py,sha256=
|
|
20
|
+
returnn/datasets/distrib_files.py,sha256=MA4BuqJEyen-3aA_naS9RWOHrP3OjVjP63VeWfLWigs,30233
|
|
21
21
|
returnn/datasets/generating.py,sha256=9U_w6URIrv-Rb-hDbPOzYW9qYXzJbw32N6G268IKyoM,99833
|
|
22
22
|
returnn/datasets/hdf.py,sha256=v5sjBenURR9Z-g7AQ9tsL84yDSye5RtbLpym3M6HSDE,67833
|
|
23
23
|
returnn/datasets/lm.py,sha256=rQ3jV43lSnlGkKu7m5jTTH7aK0BOMXQocsHfJ8OGec8,99950
|
|
24
24
|
returnn/datasets/map.py,sha256=kOBJVZmwDhLsOplzDNByIfa0NRSUaMo2Lsy36lBvxrM,10907
|
|
25
25
|
returnn/datasets/meta.py,sha256=6XPPxhiNSxWw9Hu5Z6wG8dD9Zk82FqiI-k9HGQSTKgw,95658
|
|
26
|
-
returnn/datasets/multi_proc.py,sha256=
|
|
26
|
+
returnn/datasets/multi_proc.py,sha256=3kZNXbwfuEdQrlOaiY-XnADrQrz7QOqZIQTZUwIWuS8,22614
|
|
27
27
|
returnn/datasets/normalization_data.py,sha256=J3njQCMvWAbIAVPepO2L_Xdau9eWYB7Zyd6STeGzTbc,14615
|
|
28
28
|
returnn/datasets/numpy_dump.py,sha256=wl8bKIKAlff2HPJPtuu5wBg3TLOf16d2wLVB4lLAwTM,5158
|
|
29
29
|
returnn/datasets/postprocessing.py,sha256=6SfT58BxbHYO2QlGzOgIV04Zqkp-kl0B85168DQaB9A,24060
|
|
@@ -75,7 +75,7 @@ returnn/extern/graph_editor/subgraph.py,sha256=q9o0zVBLDrTIidaXg5WG5daDW0mLbwv2J
|
|
|
75
75
|
returnn/extern/graph_editor/transform.py,sha256=qMGSenpbAnGqdG6QP6iWjlm6_ccySYJaZKOoAj1dbOM,29348
|
|
76
76
|
returnn/extern/graph_editor/util.py,sha256=HfRbyQPmQ6_n5-O-096n0KeJtllQXFtaurpeJS_URZ0,18706
|
|
77
77
|
returnn/frontend/__init__.py,sha256=2aS7nbxXniIrBp2DODl0xN0f3IJ_dX4Bi9ZlR7W5_DE,1472
|
|
78
|
-
returnn/frontend/_backend.py,sha256=
|
|
78
|
+
returnn/frontend/_backend.py,sha256=39l5MC1DaT0MPklMM8HXAW9nqisIIZQ9g2QSHOOtPQE,50741
|
|
79
79
|
returnn/frontend/_cache.py,sha256=JAhi7L-raQ3A-NC3JUYDtdRTwT3BGJJGGZxrZ8MfEWQ,8403
|
|
80
80
|
returnn/frontend/_numpy_backend.py,sha256=fZjks7p3dgxVZ6tSDazTTgBxNjJqXjfqgw_7mA7rDEE,9066
|
|
81
81
|
returnn/frontend/_random_journal.py,sha256=_ktP_mjgx8vtQQGX_DofdhewJj0aPiczefTWeemPkmo,5457
|
|
@@ -110,7 +110,7 @@ returnn/frontend/parameter.py,sha256=zvrkhSYC1c_O9kVwgHvOtOnWNurl5J28lkS0i1LQpWU
|
|
|
110
110
|
returnn/frontend/parametrizations.py,sha256=ptNgBw5IiPXVpB3QGse7AGAhdXp8X1rCqYUl2Mae8aI,2876
|
|
111
111
|
returnn/frontend/parametrize.py,sha256=VhgTEP7ehON950Q4bkCy8rvg9641moEKAXn0XzomK6E,7216
|
|
112
112
|
returnn/frontend/piecewise_linear.py,sha256=TdL6wzop8P1dcIZwkEbJFvSUZSI1cbhS3XKzlWQkEVI,1964
|
|
113
|
-
returnn/frontend/rand.py,sha256=
|
|
113
|
+
returnn/frontend/rand.py,sha256=2x7AHSYH_tZkzTk_q3t3GA_yYRNeKsVbJjw2InqSGDk,13542
|
|
114
114
|
returnn/frontend/rec.py,sha256=6YSsSG7fdtfvvg24vmexSg8R2aVCcKHBdGLh-Mgn9Co,8037
|
|
115
115
|
returnn/frontend/reduce.py,sha256=gRSvBJZNHa757IqBxGw4hu5eiO3pjie_ptEwUXHLSCs,10340
|
|
116
116
|
returnn/frontend/run_ctx.py,sha256=yyOMUCKTOe19C4z2Nfly4YCLBmQ9ihip6nGrkW-Y6qg,23789
|
|
@@ -216,7 +216,7 @@ returnn/torch/data/queued_data_iter.py,sha256=PoOsGHdHVZjTmcyfq_ZOw--P6hyfTdmAWI
|
|
|
216
216
|
returnn/torch/data/returnn_dataset_wrapper.py,sha256=2CaDapzrlqahANuq-nyVAtv5ENHuM8A7okORwYJDisg,8006
|
|
217
217
|
returnn/torch/data/tensor_utils.py,sha256=-Teqi--LLbt6q_5mDRdoHZHmPgSdC83W706ukif_YiU,1284
|
|
218
218
|
returnn/torch/frontend/__init__.py,sha256=AA48HZnC17ASuKA0EWy8loZ-Bib_yUtqF4T1wYvjst4,62
|
|
219
|
-
returnn/torch/frontend/_backend.py,sha256=
|
|
219
|
+
returnn/torch/frontend/_backend.py,sha256=zzKN4_NJK3_I7Ehk8VlhhaXQ_jUEx8K73br8C0Q41p0,103081
|
|
220
220
|
returnn/torch/frontend/_rand.py,sha256=1JgIkV2XmpgJD86zXZ-NCAe-QuoP2swr6NaS1oz3Qa8,1830
|
|
221
221
|
returnn/torch/frontend/bridge.py,sha256=c_mVBCBo29sjm8Bhxarv00szwGPgxjwoIqAHOmceGQw,7842
|
|
222
222
|
returnn/torch/frontend/raw_ops.py,sha256=lF0h-KtYYsdaaqQADylVZp9qzPskOOXA4MfmYDyx5IU,296
|
|
@@ -253,8 +253,8 @@ returnn/util/sig_proc.py,sha256=Tjz0VOAVyqu2qDCF5HZ1JjALjcFsHcNkcd96WgZeKfE,7265
|
|
|
253
253
|
returnn/util/task_system.py,sha256=y4sMVXQ25Qd2z0rx03uOlXlkE-jbCYC1Sjfn-XlraVU,26003
|
|
254
254
|
returnn/util/train_proc_manager.py,sha256=Pjht28k6uz6BNQ47uW6Gf880iyq5q4wx7P_K2tmoAM8,3266
|
|
255
255
|
returnn/util/watch_memory.py,sha256=BR5P2kvBN6UI81cE0_1WAA6Hd1SByLbBaiDxvLhPOew,4213
|
|
256
|
-
returnn-1.
|
|
257
|
-
returnn-1.
|
|
258
|
-
returnn-1.
|
|
259
|
-
returnn-1.
|
|
260
|
-
returnn-1.
|
|
256
|
+
returnn-1.20250817.33823.dist-info/LICENSE,sha256=ywBD_U2aD4vpuoIgNAsjIGBYydl0tVKll3De0Z8s77c,11041
|
|
257
|
+
returnn-1.20250817.33823.dist-info/METADATA,sha256=B57ObmyaxFzp_TjsXhRqtVvzxZWq3hS54vw34tZHZsQ,5214
|
|
258
|
+
returnn-1.20250817.33823.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
|
|
259
|
+
returnn-1.20250817.33823.dist-info/top_level.txt,sha256=Lsn4WZc5Pbfk0-xDQOgnFCxOoqxL4CyeM3N1TFbJncw,8
|
|
260
|
+
returnn-1.20250817.33823.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|