Make call operator on module holder call forward (#15831)
authorPeter Goldsborough <psag@fb.com>
Mon, 14 Jan 2019 22:32:32 +0000 (14:32 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Mon, 14 Jan 2019 22:40:33 +0000 (14:40 -0800)
commit4bdaca827cc7b71b33210c0ed4f202540d6719f7
treed775047f39c56d057f8fc5b842603f244d087421
parentc6207251770ccf8a936a17d988dc42f3741d7a99
Make call operator on module holder call forward (#15831)

Summary:
In Python, you can use the call operator to invoke the `forward()` method of a module. In C++ this was currently not possible, because I couldn't figure out how to deduce the return type of a module's `forward()` method under the constraint that `forward()` may not exist at all (since the base module class in C++ does not mandate a `forward()` method). I now figured it out, so the call operator can be used.

ezyang ebetica
Pull Request resolved: https://github.com/pytorch/pytorch/pull/15831

Differential Revision: D13652676

Pulled By: goldsborough

fbshipit-source-id: ccab45a15215dda56460e560f0038781b539135f
test/cpp/api/module.cpp
test/cpp/api/modules.cpp
test/cpp/api/static.cpp
torch/csrc/api/include/torch/nn/pimpl-inl.h
torch/csrc/api/include/torch/nn/pimpl.h