I was able to reproduce your error on my system: Unknown type name '__torch__.torch.classes.mycustomop.CustomComputer':
I managed to fix it and sucessfully load the model by linking the CustomComputer class during the build of the C++ binaries. In my case, when using CMake, adding the .cpp file with the CustomComputer implementation to the executables allows me to correctly load the model.
Maybe you can share exactly how you’re building your binaries, so we can take a closer look at where’s the issue.
Thank you for the response! My custom class is being used as part of a larger project so the cmakelists.txt is rather long and complicated, i.e., it likely is a linking problem. Is it possible for you to show the solution for your minimal example? That will probably allow me to debug on my end. Thank you!
Sure, no problem. This is my CMakeLists.txt, where computer.cpp contains the implementation of the CustomComputer class as well as the TORCH_LIBRARY definition, which is the same as the one you shared earlier. main.cpp the is where model is loaded with torch::jit::load.
I managed to reproduce the error by removing computer.cpp from the add_executable line, which led me to believe that it stems from linking issues. Hope this helps.