Where can I find the Declarations.yaml for a given Pytorch version?

I’m not using Pytorch directly, but its bindings to a different language (OCaml). To compile the bindings, I presently need the Declarations.yaml file for Pytorch 2.1.2, though in the future I’ll need the declarations file for newer versions of Pytorch.

Apparently Declarations.yaml used to ship with Pytorch, but that hasn’t been the case for a while. Unfortunately, it is far from trivial to generate the file. One needs to compile Pytorch, which is not an obvious task for someone not conversant in the Python ecosystem, and which takes forever even when everything goes well.

There may be good technical reasons why the Declarations.yaml is not shipped anymore, but could this file be at least easily available for the sake of users of non-Python languages? Anyway, maybe it already is – hence my question! Does anyone know of a place where it can be found?

I’m not actually sure when Declarations.yaml did / did not ship with pytorch directly.

But you shouldn’t need to compile all of pytorch to access it - you can run the torchgen module if you have a local pytorch checkout:

git clone git@github.com:pytorch/pytorch.git
cd pytorch
# generates build/aten/src/ATen/Declarations.yaml,
# as well as many other code-generated files
# FWIW: all of the codegen machinery is driven from native_functions.yaml from source
python -m torchgen.gen
2 Likes