This outlines how to propose a change to torch. For more detailed info about contributing to this, and other tidyverse packages, please see the development contributing guide.

Fixing typos

You can fix typos, spelling mistakes, or grammatical errors in the documentation directly using the GitHub web interface, as long as the changes are made in the source file. This generally means you’ll need to edit roxygen2 comments in an .R, not a .Rd file. You can find the .R file that generates the .Rd by reading the comment in the first line.

See also the [Documentation] section.

Filing bugs

If you find a bug in torch please open an issue here. Please, provide detailed information on how to reproduce the bug. It would be great to also provide a reprex.

Feature requests

Feel free to open issues here and add the feature-request tag. Try searching if there’s already an open issue for your feature-request, in this case it’s better to comment or upvote it intead of opening a new one.


We welcome contributed examples. feel free to open a PR with new examples. The examples should be placed in the vignettes/examples folder.

The examples should be an .R file and a .Rmd file with the same name that just renders the code.

See mnist-mlp.R and mnist-mlp.Rmd

One must be able to run the example without manually downloading any dataset/file. You should also add an entry to the _pkgdown.yaml file.

Code contributions

We have many open issues in the github repo if there’s one item that you want to work on, you can comment on it and ask for directions.


  • R installation
  • R Tools for compilation (only on Windows)
  • The devtools package
  • CMake to compile lantern binaries


We use devtools as the toolchain for development, but a few steps must be done before setiing up.

The first time you clone the repository, you must run:


This will compile Lantern binaries and download LibTorch and copy the binaries to deps folder in the working directory.

This command must be run everytime you modify lantern code. ie. code that lives in lantern/src.

You can the run


To load torch and test interactively. Or


To run the test suite.


We use roxygen2 to generate the documentation. IN order to update the docs, edit the file in the R directory. To regenerate and preview the docs, use the custom tools/document.R script, as we need to patch roxygen2 to avoid running the examples on CRAN.