chainer-pytorch-migration
chainer-pytorch-migration copied to clipboard
Add `chainer_torch_function` and `TorchCainerFunction`
This allows to call a PyTorch function and combine it with chainer functions and the opposite.
The backprop of both Chainer and PyTorch is mixed, being the backprop of torch performed inside the chainer graph.
The main difference with TorchModule
is that the latter only holds one graph in PyTorch and the changes are reflected in the parameters of a chainer link. This PR allows us to construct mixed graphs. The same is done for the opposite user case.
This is useful when doing migrations since it allows us to replace functions in the model part by part.
Thanks for the PR. As long as I tested, this function works pretty well. It would be helpful for other users also.