Libtorch Save Network topology

Hey all,

I have my network topology saved in buffers, as follows:

register_buffer(“in_channels”, torch::tensor(in_channels, torch::dtype(torch::kInt64)));
register_buffer(“classes”, torch::tensor(classes, torch::dtype(torch::kInt64)));
register_buffer(“depth”, torch::tensor(depth, torch::dtype(torch::kInt64)));
register_buffer(“channel_base”, torch::tensor(channel_base, torch::dtype(torch::kInt64)));
register_buffer(“bottleneck_depth”, torch::tensor(bottleneck_depth, torch::dtype(torch::kInt64)));

After model initialisation and training, i save the model as follows:

torch::save(trained_model, model_file.generic_string());

To my supprise, the registered buffer parameters are not saved at all when i load a new model with

torch::load(inference_model, model_file.generic_string());.

How can i solve this problem? My network topology changes all the time in function of the type of images presented. it is crucial that the network topology is saved in the *.pt file itself.

Thanks in advance!
I.