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

Function find_bad_operators

backends/vulkan/test/utils.py:981–1057  ·  view source on GitHub ↗

Recursively find bad operators using binary search. Returns: Tuple of (good_operators, bad_operators) from ops_to_test

(
        ops_to_test: List, known_good_ops: List
    )

Source from the content-addressed store, hash-verified

979 return False
980
981 def find_bad_operators(
982 ops_to_test: List, known_good_ops: List
983 ) -> Tuple[List, List]:
984 """
985 Recursively find bad operators using binary search.
986
987 Returns:
988 Tuple of (good_operators, bad_operators) from ops_to_test
989 """
990 if not ops_to_test:
991 return [], []
992
993 if len(ops_to_test) == 1:
994 # Base case: single operator
995 op = ops_to_test[0]
996 if test_operator_set([op], known_good_ops):
997 logger.info(f" Single operator {op.name()} is GOOD")
998 return [op], []
999 else:
1000 logger.info(f" Single operator {op.name()} is BAD")
1001 return [], [op]
1002
1003 # Split ops_to_test into two halves
1004 mid = len(ops_to_test) // 2
1005 first_half = ops_to_test[:mid] # Least frequent operators
1006 second_half = ops_to_test[mid:] # Most frequent operators
1007
1008 logger.info(
1009 f"Splitting {len(ops_to_test)} operators: {len(first_half)} + {len(second_half)}"
1010 )
1011
1012 # Log known good ops
1013 logger.info(" Known good:")
1014 for op in known_good_ops:
1015 logger.info(f" * {op.name()}")
1016
1017 # Log first half ops
1018 logger.info(" First half ops:")
1019 for op in first_half:
1020 logger.info(f" * {op.name()}")
1021
1022 # Log second half ops
1023 logger.info(" Second half ops:")
1024 for op in second_half:
1025 logger.info(f" * {op.name()}")
1026
1027 good_ops = []
1028 bad_ops = []
1029
1030 first_half_good = test_operator_set(first_half, known_good_ops)
1031 if first_half_good:
1032 logger.info(
1033 f"First half ({len(first_half)} ops) is good - adding to known good"
1034 )
1035 good_ops.extend(first_half)
1036 known_good_ops.extend(first_half)
1037
1038 second_half_good = test_operator_set(second_half, known_good_ops)

Callers 1

op_ablation_testFunction · 0.85

Calls 3

test_operator_setFunction · 0.85
infoMethod · 0.80
nameMethod · 0.80

Tested by

no test coverage detected