Is there any way to convert jit::script::Module to nn::Module

I rencently tried to load a trained Pytorch model which could do “Image Style transfer” to a C++ model.
The style transfer needs the gradient of loss w.r.t the input tensor, but it seems that the jit::script::Module can’t pass the gradients to the input tensor.

So I’d like to know is there any way to convert a jit::script::Module to nn::Moudle conveniently?

Many thanks!

Hi, there is no way to convert a jit:script::Module to an nn::Module. However, we should work on making it so that jit::script::Module can be used interchangeably. Can you comment on C++ API: Training and inference of torchscript modules on multiple GPU · Issue #46460 · pytorch/pytorch · GitHub with your specific use case ? Thanks.