Open sbrugman opened 3 months ago
Also #9664.
There is a flake8 plugin called TorchFix developed by the PyTorch team: https://github.com/pytorch-labs/torchfix
There is a flake8 plugin called TorchFix developed by the PyTorch team: https://github.com/pytorch-labs/torchfix
Thanks for sharing! This would be a great base to start from!
TOR008 -> Use array agnostic syntax (see also https://github.com/astral-sh/ruff/issues/8615), e.g. use x.mean() rather than torch.mean(x)
I think it would be better to move towards the Array API, which is the most "array agnostic". This eliminates any peculiarities of PyTorch versus NumPy as well. So:
xp = get_namespace(x)
xp.mean(x)
This works with NumPy, PyTorch, Jax, TensorFlow, CuPy, etc.
+1 for TorchFix. It integrates with flake8, so it should be easy to port the rules. It has been officially released now with the update to pytorch 2.5.
Introducing lints for pytorch expands
ruff
utility in the AI/machine learning space, in addition to Numpy and Spark. Detecting potential errors during linting has the potential to save costly GPU compute.