Skip to content

Commit 5ca780b

Browse files
committed
Fixed parts of issue #56
1 parent fdad986 commit 5ca780b

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
.pytest_cache/
33
__pycache__/
44
*.egg-info/*
5+
.venv

README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,63 @@ Migration guide:
108108
This function is deprecated. Use the `torch.nn.attention.sdpa_kernel` context manager instead.
109109

110110
Migration guide:
111+
111112
Each boolean input parameter (defaulting to true unless specified) of `sdp_kernel` corresponds to a `SDPBackened`. If the input parameter is true, the corresponding backend should be added to the input list of `sdpa_kernel`.
112113

114+
### TOR102 Unsafe use of `torch.load` without weights only parameter
115+
116+
The use of `torch.load` without the `weights_only` parameter is unsafe. Loading an untrusted pickle file may lead to the execution of arbitrary malicious code and potential security issues.
117+
118+
Migration Guide:
119+
120+
Explicitly set `weights_only=False` only if you trust the data you load and full pickle functionality is needed,
121+
122+
```
123+
torch.load('<path_to_file>', weights_only=False)
124+
```
125+
otherwise set `weights_only=True`.
126+
```
127+
torch.load('<path_to_file>', weights_only=True)
128+
```
129+
130+
### TOR104 Use of non-public function
131+
132+
#### torch.utils.data._utils.collate.default_collate
133+
134+
Public functions are well-documented and supported by the library maintainers and the use of the non-public function `torch.utils.data._utils.collate.default_collate` is discouraged as it can can change without notice in future versions, leading to potential breakage in your code.
135+
136+
Migration Guide:
137+
138+
For better maintainability and compatibility, please use the public function `torch.utils.data.dataloader.default_collate` instead.
139+
140+
### TOR201 Parameter `pretrained` is deprecated, please use `weights` instead.
141+
142+
The parameter `pretrained` has been deprecated in TorchVision models since PyTorch version 1.12.0. The `weights` parameter should be used instead.
143+
144+
```
145+
model = SomeModel(weights='<path_or_identifier_to_weights>')
146+
```
147+
148+
### TOR202 The transform `v2.ToTensor()` is deprecated and will be removed in a future release.
149+
150+
The `transform v2.ToTensor()` is deprecated and will be removed in a future release. Instead, please use `v2.Compose([v2.ToImage(), v2.ToDtype(torch.float32, scale=True)])`.
151+
152+
```
153+
transform = v2.Compose([v2.ToImage(),v2.ToDtype(torch.float32, scale=True)])
154+
```
155+
156+
### TOR203 Consider replacing `import torchvision.models as models` with `from torchvision import models`.
157+
158+
Consider replacing `import torchvision.models as models` with `from torchvision import models` to improve clarity, maintainability, and adhere to best practices and reducing potential confusion with other modules or variables named `models`.
159+
This can lead to namespace conflicts and explicit import style helps avoid such issues.
160+
161+
### TOR401 Detected DataLoader running with synchronized implementation
162+
163+
Running synchronized implementations on `DataLoader` can lead to loss in data loading performance, especially when dealing with large datasets. A viable solution is to set the `num_workers` parameter to be greater than 0 when initializing the DataLoader class. This would parallelize the loading operations and would significantly increase performance.
164+
165+
```
166+
train_loader = DataLoader(dataset, batch_size=32, shuffle=True, num_workers=4)
167+
```
168+
113169
## License
114170
TorchFix is BSD License licensed, as found in the LICENSE file.

0 commit comments

Comments
 (0)