-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
As it has been migrated to https://github.com/pytorch-labs/torchfix
- Loading branch information
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1 @@ | ||
# TorchFix - a linter for PyTorch-using code with autofix support | ||
|
||
TorchFix is a Python code static analysis tool - a linter with autofix capabilities - | ||
for users of PyTorch. It can be used to find and fix issues like usage of deprecated | ||
PyTorch functions and non-public symbols, and to adopt PyTorch best practices in general. | ||
|
||
TorchFix is built upon https://github.com/Instagram/LibCST - a library to manipulate | ||
Python concrete syntax trees. LibCST enables "codemods" (autofixes) in addition to | ||
reporting issues. | ||
|
||
TorchFix can be used as a Flake8 plugin (linting only) or as a standalone | ||
program (with autofix available for a subset of the lint violations). | ||
|
||
Currently TorchFix is in a **beta version** stage, so there are still a lot of rough | ||
edges and many things can and will change. | ||
|
||
## Installation | ||
|
||
To install the latest code from GitHub, clone/download | ||
https://github.com/pytorch/test-infra/tree/main/tools/torchfix and run `pip install .` | ||
inside the directory. | ||
|
||
To install a release version from PyPI, run `pip install torchfix`. | ||
|
||
## Usage | ||
|
||
After the installation, TorchFix will be available as a Flake8 plugin, so running | ||
Flake8 normally will run the TorchFix linter. | ||
|
||
To see only TorchFix warnings without the rest of the Flake8 linters, you can run | ||
`flake8 --isolated --select=TOR0,TOR1,TOR2` | ||
|
||
TorchFix can also be run as a standalone program: `torchfix .` | ||
Add `--fix` parameter to try to autofix some of the issues (the files will be overwritten!) | ||
To see some additional debug info, add `--show-stderr` parameter. | ||
|
||
Please keep in mind that autofix is a best-effort mechanism. Given the dynamic nature of Python, | ||
and especially the beta version status of TorchFix, it's very difficult to have | ||
certainty when making changes to code, even for the seemingly trivial fixes. | ||
|
||
Warnings for issues with codes starting with TOR0, TOR1, and TOR2 are enabled by default. | ||
Warnings with other codes may be too noisy, so not enabled by default. | ||
To enable them, use standard flake8 configuration options for the plugin mode or use | ||
`torchfix --select=ALL .` for the standalone mode. | ||
|
||
|
||
## Reporting problems | ||
|
||
If you encounter a bug or some other problem with TorchFix, please file an issue on | ||
https://github.com/pytorch/test-infra/issues, mentioning [TorchFix] in the title. | ||
|
||
|
||
## Rules | ||
|
||
### TOR001 Use of removed function | ||
|
||
#### torch.solve | ||
|
||
This function was deprecated since PyTorch version 1.9 and is now removed. | ||
|
||
`torch.solve` is deprecated in favor of `torch.linalg.solve`. | ||
`torch.linalg.solve` has its arguments reversed and does not return the LU factorization. | ||
|
||
To get the LU factorization see `torch.lu`, which can be used with `torch.lu_solve` or `torch.lu_unpack`. | ||
|
||
`X = torch.solve(B, A).solution` should be replaced with `X = torch.linalg.solve(A, B)`. | ||
TorchFix moved to a separate repo - https://github.com/pytorch-labs/torchfix |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.