Skip to content

Commit

Permalink
Chore(pt): slim uts for dpa1 (deepmodeling#4244)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Tests**
- Simplified test parameters and logic for the `TestDPA1` class,
reducing complexity in test cases.
- Streamlined conditions for skipping tests based on specific
parameters, enhancing test efficiency.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Duo <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Jinzhe Zeng <[email protected]>
  • Loading branch information
3 people authored Oct 23, 2024
1 parent 0fa1b43 commit c2d0560
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions source/tests/consistent/descriptor/test_dpa1.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,22 @@
(4,), # tebd_dim
("concat", "strip"), # tebd_input_mode
(True,), # resnet_dt
(True, False), # type_one_side
(True,), # type_one_side
(20,), # attn
(0, 2), # attn_layer
(True, False), # attn_dotr
(True,), # attn_dotr
([], [[0, 1]]), # excluded_types
(0.0,), # env_protection
(True, False), # set_davg_zero
(1.0,), # scaling_factor
(True, False), # normalize
(True,), # normalize
(None, 1.0), # temperature
(1e-5,), # ln_eps
(True, False), # smooth_type_embedding
(True,), # smooth_type_embedding
(True,), # concat_output_tebd
("float64",), # precision
(True, False), # use_econf_tebd
(False, True), # use_tebd_bias
(False,), # use_tebd_bias
)
class TestDPA1(CommonTest, DescriptorTest, unittest.TestCase):
@property
Expand Down Expand Up @@ -127,11 +127,9 @@ def data(self) -> dict:
def is_meaningless_zero_attention_layer_tests(
self,
attn_layer: int,
attn_dotr: bool,
normalize: bool,
temperature: Optional[float],
) -> bool:
return attn_layer == 0 and (attn_dotr or normalize or temperature is not None)
return attn_layer == 0 and (temperature is not None)

@property
def skip_pt(self) -> bool:
Expand All @@ -158,8 +156,6 @@ def skip_pt(self) -> bool:
) = self.param
return CommonTest.skip_pt or self.is_meaningless_zero_attention_layer_tests(
attn_layer,
attn_dotr,
normalize,
temperature,
)

Expand Down Expand Up @@ -188,8 +184,6 @@ def skip_dp(self) -> bool:
) = self.param
return CommonTest.skip_dp or self.is_meaningless_zero_attention_layer_tests(
attn_layer,
attn_dotr,
normalize,
temperature,
)

Expand Down Expand Up @@ -218,8 +212,6 @@ def skip_jax(self) -> bool:
) = self.param
return not INSTALLED_JAX or self.is_meaningless_zero_attention_layer_tests(
attn_layer,
attn_dotr,
normalize,
temperature,
)

Expand Down Expand Up @@ -250,8 +242,6 @@ def skip_array_api_strict(self) -> bool:
not INSTALLED_ARRAY_API_STRICT
or self.is_meaningless_zero_attention_layer_tests(
attn_layer,
attn_dotr,
normalize,
temperature,
)
)
Expand Down Expand Up @@ -290,8 +280,6 @@ def skip_tf(self) -> bool:
)
or self.is_meaningless_zero_attention_layer_tests(
attn_layer,
attn_dotr,
normalize,
temperature,
)
)
Expand Down

0 comments on commit c2d0560

Please sign in to comment.