Statically linking custom ops in C++

Hi,
I am using torch_scatter and torch_sparse in my project. Currently they are compiled as shared library and linked against my program for runtime custom ops.

I would like to include the torch_sparse and torch_scatter in my program to reduce runtime dependency. I managed to compile it, but at runtime I get an error:

Could not find any similar ops to torch_sparse::ptr2ind. This op may not exist or may not be currently supported in TorchScript.

See discussion here.

How can I make torch read the custom ops from a static binary?