Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: raise error for non mixed type model #3759

Merged
merged 10 commits into from
May 9, 2024
9 changes: 9 additions & 0 deletions deepmd/dpmodel/atomic_model/linear_atomic_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ def __init__(
):
super().__init__(type_map, **kwargs)
super().init_out_stat()

# check all sub models are of mixed type.
model_mixed_type = []
for m in models:
if not m.mixed_types():
model_mixed_type.append(m)
if len(model_mixed_type) > 0:
raise ValueError(f"LinearAtomicModel only supports AtomicModel of mixed type, the following models are not mixed type: {err_msg}.")
anyangml marked this conversation as resolved.
Show resolved Hide resolved

self.models = models
sub_model_type_maps = [md.get_type_map() for md in models]
err_msg = []
Expand Down
9 changes: 9 additions & 0 deletions deepmd/pt/model/atomic_model/linear_atomic_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ def __init__(
):
super().__init__(type_map, **kwargs)
super().init_out_stat()

# check all sub models are of mixed type.
model_mixed_type = []
for m in models:
if not m.mixed_types():
model_mixed_type.append(m)
if len(model_mixed_type) > 0:
raise ValueError(f"LinearAtomicModel only supports AtomicModel of mixed type, the following models are not mixed type: {err_msg}.")
anyangml marked this conversation as resolved.
Show resolved Hide resolved

self.models = torch.nn.ModuleList(models)
sub_model_type_maps = [md.get_type_map() for md in models]
err_msg = []
Expand Down
Loading