Skip to content

Commit b37ddb8

Browse files
committed
fix(pt): pass device and dtype in SeZMDeNSFittingNet.deserialize
safe_numpy_to_tensor takes `device` and `dtype` as required keyword-only arguments, so SeZMDeNSFittingNet.deserialize raised TypeError. Rebuild the state dict from the instantiated module's own state_dict, matching the other sezm_nn deserialize implementations. Signed-off-by: Anai-Guo <antai12232931@outlook.com>
1 parent be1a636 commit b37ddb8

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

  • deepmd/pt/model/descriptor/sezm_nn

deepmd/pt/model/descriptor/sezm_nn/dens.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,12 @@ def deserialize(cls, data: dict[str, Any]) -> SeZMDeNSFittingNet:
746746
config = data.pop("config")
747747
variables = data.pop("@variables")
748748
obj = cls(**config)
749-
state = {key: safe_numpy_to_tensor(value) for key, value in variables.items()}
749+
template = obj.state_dict()
750+
state = {
751+
key: safe_numpy_to_tensor(
752+
value, device=template[key].device, dtype=template[key].dtype
753+
)
754+
for key, value in variables.items()
755+
}
750756
obj.load_state_dict(state)
751757
return obj

0 commit comments

Comments
 (0)