33 Any ,
44)
55
6- import array_api_compat
7-
86from deepmd .dpmodel .array_api import (
97 Array ,
108)
@@ -56,10 +54,6 @@ def __init__(
5654 if hasattr (self .fitting , "reinit_exclude" ):
5755 self .fitting .reinit_exclude (self .atom_exclude_types )
5856 self .type_map = type_map
59- self .enable_eval_descriptor_hook = False
60- self .enable_eval_fitting_last_layer_hook = False
61- self .eval_descriptor_list : list [Array ] = []
62- self .eval_fitting_last_layer_list : list [Array ] = []
6357 super ().init_out_stat ()
6458
6559 def fitting_output_def (self ) -> FittingOutputDef :
@@ -132,37 +126,6 @@ def enable_compression(
132126 check_frequency ,
133127 )
134128
135- def set_eval_descriptor_hook (self , enable : bool ) -> None :
136- """Set the hook for evaluating descriptor and clear the cache."""
137- self .enable_eval_descriptor_hook = enable
138- self .eval_descriptor_list .clear ()
139-
140- def eval_descriptor (self ) -> Array :
141- """Evaluate the descriptor by concatenating cached results."""
142- if not self .eval_descriptor_list :
143- raise RuntimeError (
144- "eval_descriptor_list is empty. "
145- "Call set_eval_descriptor_hook(True) and perform a forward pass first."
146- )
147- xp = array_api_compat .array_namespace (self .eval_descriptor_list [0 ])
148- return xp .concat (self .eval_descriptor_list , axis = 0 )
149-
150- def set_eval_fitting_last_layer_hook (self , enable : bool ) -> None :
151- """Set the hook for evaluating fitting last layer output and clear the cache."""
152- self .enable_eval_fitting_last_layer_hook = enable
153- self .fitting .set_return_middle_output (enable )
154- self .eval_fitting_last_layer_list .clear ()
155-
156- def eval_fitting_last_layer (self ) -> Array :
157- """Evaluate the fitting last layer output by concatenating cached results."""
158- if not self .eval_fitting_last_layer_list :
159- raise RuntimeError (
160- "eval_fitting_last_layer_list is empty. "
161- "Call set_eval_fitting_last_layer_hook(True) and perform a forward pass first."
162- )
163- xp = array_api_compat .array_namespace (self .eval_fitting_last_layer_list [0 ])
164- return xp .concat (self .eval_fitting_last_layer_list , axis = 0 )
165-
166129 def forward_atomic (
167130 self ,
168131 extended_coord : Array ,
@@ -203,8 +166,6 @@ def forward_atomic(
203166 nlist ,
204167 mapping = mapping ,
205168 )
206- if self .enable_eval_descriptor_hook :
207- self .eval_descriptor_list .append (descriptor )
208169 ret = self .fitting (
209170 descriptor ,
210171 atype ,
@@ -214,11 +175,6 @@ def forward_atomic(
214175 fparam = fparam ,
215176 aparam = aparam ,
216177 )
217- if self .enable_eval_fitting_last_layer_hook :
218- assert "middle_output" in ret , (
219- "eval_fitting_last_layer not supported for this fitting net!"
220- )
221- self .eval_fitting_last_layer_list .append (ret .pop ("middle_output" ))
222178 return ret
223179
224180 def change_type_map (
0 commit comments