The workaround is to not store any refs to the resnet layers in the model itself. Instead we have to directly pull the input tensors through the resnet layers in the forward pass.
This will change the .pth file format. We could work around that by loading the serialized state dict in non-strict fashion in the export tool. But then we are opening up the door to letting actual errors going through.
The PyTorch tracing model exporter has an issue with shared weights / refs to layers, see
https://github.com/pytorch/pytorch/issues/8392
The workaround is to not store any refs to the resnet layers in the model itself. Instead we have to directly pull the input tensors through the resnet layers in the forward pass.
This will change the
.pth
file format. We could work around that by loading the serialized state dict in non-strict fashion in the export tool. But then we are opening up the door to letting actual errors going through.Note: we need to fix the FPN pull request in a similar way https://github.com/mapbox/robosat/pull/75
cc @bkowshik @maning