When moving a ParameterList or ParameterDict Module, the registered values get moved but the field doesn't get the updated values.
For example, in the case below, the output would be Float32. If you would inspect the _internal_params list you would see that the parameter there is actually Float16.
This also means that the garbage collector will never dispose of the old parameter since they are both being referenced.
Example code:
private class TestModule1 : Module {
public TestModule1() : base("TestModule1") {
list.append(Parameter(torch.rand(10)));
}
public ParameterList list = new ParameterList();
}
private static void Test() {
var m = new TestModule1(torch.randn(2, 2), true);
m.to(ScalarType.Float16);
Console.WriteLine(m.list[0].dtype);
}