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

pt: rename atomic_virial to atom_virial in the model output #3226

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions deepmd/pt/infer/deep_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,9 @@
batch_output["force"].reshape(nframes, natoms, 3).detach().cpu().numpy()
)
virial_out = batch_output["virial"].reshape(nframes, 9).detach().cpu().numpy()
if "atomic_virial" in batch_output:
if "atom_virial" in batch_output:
atomic_virial_out = (
batch_output["atomic_virial"]
batch_output["atom_virial"]
.reshape(nframes, natoms, 9)
.detach()
.cpu()
Expand Down Expand Up @@ -326,9 +326,9 @@
force_out.append(batch_output["force"].detach().cpu().numpy())
if "virial" in batch_output:
virial_out.append(batch_output["virial"].detach().cpu().numpy())
if "atomic_virial" in batch_output:
if "atom_virial" in batch_output:

Check warning on line 329 in deepmd/pt/infer/deep_eval.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/infer/deep_eval.py#L329

Added line #L329 was not covered by tests
atomic_virial_out.append(
batch_output["atomic_virial"].detach().cpu().numpy()
batch_output["atom_virial"].detach().cpu().numpy()
)
if "updated_coord" in batch_output:
updated_coord_out.append(
Expand All @@ -345,8 +345,8 @@
force_out.append(batch_output["force"])
if "virial" in batch_output:
virial_out.append(batch_output["virial"])
if "atomic_virial" in batch_output:
atomic_virial_out.append(batch_output["atomic_virial"])
if "atom_virial" in batch_output:
atomic_virial_out.append(batch_output["atom_virial"])

Check warning on line 349 in deepmd/pt/infer/deep_eval.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/infer/deep_eval.py#L349

Added line #L349 was not covered by tests
if "updated_coord" in batch_output:
updated_coord_out.append(batch_output["updated_coord"])
if "logits" in batch_output:
Expand Down
2 changes: 1 addition & 1 deletion deepmd/pt/model/model/ener.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def forward(
if self.do_grad("energy"):
model_predict["force"] = model_ret["energy_derv_r"].squeeze(-2)
if do_atomic_virial:
model_predict["atomic_virial"] = model_ret["energy_derv_c"].squeeze(
model_predict["atom_virial"] = model_ret["energy_derv_c"].squeeze(
-3
)
model_predict["virial"] = model_ret["energy_derv_c_redu"].squeeze(-3)
Expand Down
10 changes: 5 additions & 5 deletions source/tests/pt/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def get_intermediate_state(self, num_steps=1):
"energy": model_pred["energy"],
"force": model_pred["force"],
"virial": model_pred["virial"],
"atomic_virial": model_pred["atom_virial"],
"atom_virial": model_pred["atom_virial"],
}

# Get statistics of each component
Expand Down Expand Up @@ -359,7 +359,7 @@ def test_consistency(self):
model_predict["energy"],
model_predict["force"],
model_predict["virial"],
model_predict["atomic_virial"],
model_predict["atom_virial"],
)
cur_lr = my_lr.value(self.wanted_step)
model_pred = {
Expand Down Expand Up @@ -395,10 +395,10 @@ def test_consistency(self):
.detach()
.numpy(),
)
self.assertIsNone(model_predict_1.get("atomic_virial", None))
self.assertIsNone(model_predict_1.get("atom_virial", None))
np.testing.assert_allclose(
head_dict["atomic_virial"],
p_atomic_virial.view(*head_dict["atomic_virial"].shape)
head_dict["atom_virial"],
p_atomic_virial.view(*head_dict["atom_virial"].shape)
.cpu()
.detach()
.numpy(),
Expand Down
Loading