Skip to content
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
9 changes: 9 additions & 0 deletions deepmd/tf2/infer/deep_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,15 @@ def __init__(
) -> None:
if not model_file.endswith(".savedmodeltf"):
raise ValueError("TF2 backend only supports .savedmodeltf files")
if neighbor_list is not None:
# SavedModel lower calls accept extended tensors, but this wrapper
# does not yet connect the existing adapter and output fold-back
# helpers to an ASE Python neighbor-list object.
raise NotImplementedError(
"TF2 SavedModel inference does not support a custom ASE "
"neighbor_list; omit neighbor_list to use the SavedModel's "
"built-in neighbor-list builder"
)
self.output_def = output_def
self.model_path = model_file
self.dp = TF2SavedModelWrapper(model_file)
Expand Down
32 changes: 32 additions & 0 deletions source/tests/tf2/test_deep_eval.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
"""Tests for the TensorFlow 2 SavedModel inference adapter."""

import os

import pytest

if os.environ.get("DP_TEST_TF2_ONLY") != "1":
pytest.skip(
"TF2 tests require DP_TEST_TF2_ONLY=1",
allow_module_level=True,
)

from deepmd.dpmodel.output_def import (
FittingOutputDef,
ModelOutputDef,
)
from deepmd.tf2.infer.deep_eval import (
Comment thread
njzjz-bot marked this conversation as resolved.
DeepEval,
)


def test_custom_neighbor_list_is_rejected_before_model_loading() -> None:
"""A custom ASE neighbor list must not be accepted as a silent no-op."""
output_def = ModelOutputDef(FittingOutputDef([]))

with pytest.raises(NotImplementedError, match="custom ASE neighbor_list"):
DeepEval(
"sentinel.savedmodeltf",
output_def,
neighbor_list=object(),
)
Loading