Pytorch C++ frontend register_forward_hook

Job ID: 35899020

Budget: $50 – $0 USD

We are translating inference program from Pytorch to Pytorch C++ frontend. The only thing is not implemented in C++ frontend is register_forward_hook function in the torch::nn::module part. It was requested years before but was triaged "not urgent and not important" by dev team.

The goal is to implement this feature so that we could use it in our project.
You can see status of API parity for Python and C++ with implementation notes here: https://github.com/pytorch/pytorch/issues/25883

The interesting issues and PR from github is here:
https://github.com/pytorch/pytorch/issues/25888 -> Here is where you can see the prioritization from developers.
https://github.com/pytorch/pytorch/pull/26568 -> Here you find how register_hook for at:Tensor implemented in C++ API

https://github.com/pytorch/pytorch/issues/29037 -> register_forward_hook support for TorchScript.

https://github.com/pytorch/pytorch/pull/30484 -> register_forward_pre_hook PR example (failed to merge with master)

for more information please see this

https://pytorch.org/cppdocs/

If you dive into this archive you can see that there are only C++ headers and natively compiled libraries

https://download.pytorch.org/libtorch/nightly/cpu/libtorch-shared-with-deps-latest.zip
Related categories: C Programming Python C++ Programming Pytorch