|
3 | 3 | Any, |
4 | 4 | ) |
5 | 5 |
|
6 | | -from packaging.version import ( |
7 | | - Version, |
8 | | -) |
9 | | - |
| 6 | +import deepmd.jax.atomic_model.dp_atomic_model as _jax_dp_atomic_model # noqa: F401 |
| 7 | +import deepmd.jax.atomic_model.pairtab_atomic_model as _jax_pairtab_model # noqa: F401 |
| 8 | +import deepmd.jax.utils.exclude_mask as _jax_exclude_mask # noqa: F401 |
10 | 9 | from deepmd.dpmodel.atomic_model.linear_atomic_model import ( |
11 | 10 | DPZBLLinearEnergyAtomicModel as DPZBLLinearEnergyAtomicModelDP, |
12 | 11 | ) |
13 | | -from deepmd.jax.atomic_model.base_atomic_model import ( |
14 | | - base_atomic_model_set_attr, |
15 | | -) |
16 | | -from deepmd.jax.atomic_model.dp_atomic_model import ( |
17 | | - DPAtomicModel, |
18 | | -) |
19 | | -from deepmd.jax.atomic_model.pairtab_atomic_model import ( |
20 | | - PairTabAtomicModel, |
21 | | -) |
22 | 12 | from deepmd.jax.common import ( |
23 | | - ArrayAPIVariable, |
24 | 13 | flax_module, |
25 | | - to_jax_array, |
26 | 14 | ) |
27 | 15 | from deepmd.jax.env import ( |
28 | | - flax_version, |
29 | 16 | jax, |
30 | 17 | jnp, |
31 | | - nnx, |
32 | 18 | ) |
33 | 19 |
|
34 | 20 |
|
35 | 21 | @flax_module |
36 | 22 | class DPZBLLinearEnergyAtomicModel(DPZBLLinearEnergyAtomicModelDP): |
37 | 23 | def __setattr__(self, name: str, value: Any) -> None: |
38 | | - value = base_atomic_model_set_attr(name, value) |
39 | | - if name == "mapping_list": |
40 | | - value = [ArrayAPIVariable(to_jax_array(vv)) for vv in value] |
41 | | - if Version(flax_version) >= Version("0.12.0"): |
42 | | - value = nnx.List([nnx.data(item) for item in value]) |
43 | | - elif name == "zbl_weight": |
| 24 | + if name == "zbl_weight": |
44 | 25 | # discard since it's only used in tests |
45 | 26 | # to fix flax.errors.TraceContextError: Cannot mutate 'FlaxModule' from different trace level |
46 | 27 | return |
47 | | - elif name == "models": |
48 | | - value = [ |
49 | | - DPAtomicModel.deserialize(value[0].serialize()), |
50 | | - PairTabAtomicModel.deserialize(value[1].serialize()), |
51 | | - ] |
52 | | - if Version(flax_version) >= Version("0.12.0"): |
53 | | - value = nnx.List([nnx.data(item) for item in value]) |
54 | 28 | return super().__setattr__(name, value) |
55 | 29 |
|
56 | 30 | def forward_common_atomic( |
|
0 commit comments