Commit c968907
Fixes #8599.
### Description
`PersistentDataset` currently casts all `MetaTensor` objects to
`torch.Tensor` objects and forces the use of `torch.load` with
`weights_only=True`. This makes it impossible to save or load metadata
to cached files, which may be necessary for accurate post-transform
operations.
To address this, this PR introduces the `track_meta` and `weights_only`
arguments directly to `PersistentDataset`. They are internally passed to
`convert_to_tensor` and `torch.load`, respectively. A `ValueError` is
raised when `track_meta=True` and `weights_only=True`, since
`MetaTensor` objects cannot be loaded with `weights_only=True` and the
cached files would be continually deleted and rewritten.
These changes restore the ability to cache `MetaTensor` objects by
allowing explicit control over data casting and `torch.load` behavior.
The default values of `track_meta=False` and `weights_only=True` will
preserve the current behavior of `PersistentDataset`.
### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [x] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [x] In-line docstrings updated.
- [x] Documentation updated, tested `make html` command in the `docs/`
folder.
---------
Signed-off-by: Mason Cleveland <[email protected]>
Signed-off-by: Mason C. Cleveland <[email protected]>
Signed-off-by: mccle <[email protected]>
Co-authored-by: Eric Kerfoot <[email protected]>
Co-authored-by: YunLiu <[email protected]>
1 parent 806c0e8 commit c968907
2 files changed
+57
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
| 233 | + | |
| 234 | + | |
233 | 235 | | |
234 | 236 | | |
235 | 237 | | |
| |||
264 | 266 | | |
265 | 267 | | |
266 | 268 | | |
267 | | - | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
268 | 280 | | |
269 | 281 | | |
270 | 282 | | |
| |||
280 | 292 | | |
281 | 293 | | |
282 | 294 | | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
283 | 302 | | |
284 | 303 | | |
285 | 304 | | |
| |||
377 | 396 | | |
378 | 397 | | |
379 | 398 | | |
380 | | - | |
| 399 | + | |
381 | 400 | | |
382 | 401 | | |
383 | 402 | | |
| |||
398 | 417 | | |
399 | 418 | | |
400 | 419 | | |
401 | | - | |
| 420 | + | |
402 | 421 | | |
403 | 422 | | |
404 | 423 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | | - | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
46 | 54 | | |
47 | | - | |
48 | 55 | | |
| 56 | + | |
49 | 57 | | |
50 | 58 | | |
51 | 59 | | |
| |||
55 | 63 | | |
56 | 64 | | |
57 | 65 | | |
58 | | - | |
59 | 66 | | |
60 | 67 | | |
61 | 68 | | |
| |||
168 | 175 | | |
169 | 176 | | |
170 | 177 | | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
171 | 203 | | |
172 | 204 | | |
173 | 205 | | |
0 commit comments