MCPcopy Create free account
hub / github.com/pytorch/executorch / register_test

Function register_test

backends/mlx/test/test_utils.py:753–784  ·  view source on GitHub ↗

Class decorator to register a test class. The test class must have: - A class attribute `name` (str) - the base test name - A class method `get_test_configs()` that returns a list of OpTestCase instances Test instances are created LAZILY when tests are actually run, not at imp

(test_class: type)

Source from the content-addressed store, hash-verified

751
752
753def register_test(test_class: type) -> type:
754 """
755 Class decorator to register a test class.
756
757 The test class must have:
758 - A class attribute `name` (str) - the base test name
759 - A class method `get_test_configs()` that returns a list of OpTestCase instances
760
761 Test instances are created LAZILY when tests are actually run, not at import time.
762 This avoids creating random tensors at import time and keeps memory usage low.
763
764 Example:
765 @register_test
766 class AddTest(OpTestCase):
767 name = "add"
768
769 @classmethod
770 def get_test_configs(cls) -> List["OpTestCase"]:
771 return [
772 cls(), # default config
773 cls(scalar=2.5), # scalar variant
774 ]
775 """
776 if not hasattr(test_class, "name"):
777 raise ValueError(
778 f"Test class {test_class.__name__} must have a 'name' attribute"
779 )
780
781 base_name = test_class.name
782 _TEST_REGISTRY[base_name] = test_class
783
784 return test_class
785
786
787def get_registered_tests() -> Dict[str, List[Tuple[str, "OpTestCase"]]]:

Callers 1

test_ops.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected