I want to predict my model using pytorch C++ api, and I want to access one model attribute. Model definition is like:
class MyModule(torch.jit.ScriptModule):
    __constants__ = ['mods']
    def __init__(self, N, M):
        super(MyModule, self).__init__()
        self.linear = nn.Linear(N, M)
        self.mods = N

    @torch.jit.script_method
    def forward(self, inputs):
        output = self.linear(inputs)
        return output

And I want to get “mods” in c++. However, when I use the following code, It doesn’t work:
std::shared_ptr<torch::jit::script::Module> module = torch::jit::load(argv[1]);

int mods = module->mods;

So, what could I do to access the model attribute using c++ api?