Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
C++ make constructor NamedAnyModule(name,any) public (pytorch#36869)
Summary: Allows creation of _NamedAnyModule_ directly from _AnyModule_, e.g. ``` auto a=torch::nn::AnyModule(torch::nn::Linear(1,2)); auto m=torch::nn::NamedAnyModule("fc", a); ``` Without the public constructor, it would be necessary to recast the AnyModule to underlying type, then have the constructor cast it back to AnyModule. With the public AnyModule constructor, possible to do ``` auto q=Sequential({m}); ``` or ``` q->push_back(m.name, m.module()); ``` (works in conjunction with PR pytorch#36720 which allowed adding _AnyModule_ directly) Pull Request resolved: pytorch#36869 Differential Revision: D21110074 Pulled By: yf225 fbshipit-source-id: aaea02282b9024824785e54d8732c0a12c850977
- Loading branch information