How can I get atttr like stride or padding of Conv2d in cpp ScriptModule

I instantiated a model and transfrom it into ScriptMoudle using this:

alex_model = torchvision.models.AlexNet(num_classes=10)
f = torch.jit.script(alex_model)
f.save("./models/alexnet.pt")

I cannot get the attr like stride of Conv2d when I dump() the model in c++
only a constant name like this:

How can I get the value like stride or padding of Conv2d when loading the model in c++?
THANKS VERY MUCH!

Constant values are inlined directly into the code of the module, so we currently have no way of accessing them once compilation has run, and the modules in nn.Modules store all their values as constants. I opened this issue so you can track that for fixes.

As a temporary workaround, you could grab the values you care about in Python and stash them as attributes instead of constants:

class M(nn.Module):
    def __init__(self):
        super().__init__()
        self.alex_model = torchvision.models.AlexNet(num_classes=10)
        self.first_conv_stride = getattr(self.alex_model.features, '0').stride

    def forward(self, x):
        return self.alex_model(x)


sm = torch.jit.script(M())
print(sm.first_conv_stride)

and in C++

auto module = torch::jit::load("alexnet.pt");
std::cout << module.attr("first_conv_stride") << "\n";