A VSCode(ium) extension to get instant feedback by plotting PyTorch tensors when selecting them during a debug session. The addon is using torchshow to plot the tensor.
demo.webm
-
Make sure torchshow is installed in your python project :
pip install torchshow. -
Download the latest
.vsixfrom the release page. -
In VSCode / VSCodium, in the extensions panel menu, click Install from VSIX and select the downloaded extension.
See video above,
-
Start a debug session in your PyTorch project and pause it (for e.g. with a breakpoint).
-
Double click on a tensor or select a valid expression (that resolves to a tensor). The tensor must be in a format that torchshow can recognize.
Notes :
-
If the expression is valid and resolves to a tensor that torchshow is able to plot, it will be displayed. Otherwise, it will silently fail and will not update the image. To display error messages, use the commands
DebugTShow: Debug Messages Disable&DebugTShow: Debug Messages Enable. Leave it disabled when not needed. -
The selected text can be anything, comments included. It can be useful to add temporary debug plot snippets (see video above).
-
To quickly disable / enable the extension, use the commands
DebugTShow: Disable&DebugTShow: Enable(or completely disable / uninstall it from the extension panel). -
The displayed image is saved in
_torchshow/. If using git, it is recommended to add this folder to your.gitignore.
This uses code from vscode-debug-visualizer. This repo is also under GPL.