Using torch::nn::ModuleList(which includes different blocks)

Hi

I have some problem implement model.

I push different blocks to torch::nn::ModuleList, and now I want to get blocks from the torch::nn::ModuleList and do forward function.

However, I have no idea how to do that.
In python I just do as “x = module_list [i] (x)”.
In c++ I tried to write as “x = module_list [i] (x)” and “x = module_list [i] ->as<???>()->forward(x)”
(It can’t be compile with first one, and I don’t know which data type should be taken at ??? with second one.)

Please let me know how to solve it.

Thanks for reading.
Dongkyu

Hi @DongkyuLee

Did you solve this problem? Facing the same issue.