Solved by yf225 in post #5 
              
              
                ModuleList doesn’t store the modules’ type information, and we need to convert the modules to the concrete types for forward to work. So instead of doing module->forward(x), we should do module->as<Linear>()(x).