MCPcopy Create free account
hub / github.com/pytorch/pytorch / test_has_decomposition

Method test_has_decomposition

test/test_decomp.py:967–993  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

965 raise
966
967 def test_has_decomposition(self):
968
969 def all_aten_overloads():
970 for name in torch._C._dispatch_get_all_op_names():
971 if not name.startswith("aten::"):
972 continue
973
974 name = name[6:]
975 if "." in name:
976 packet_name, overload_name = name.split(".")
977 else:
978 packet_name, overload_name = name, "default"
979
980 packet = getattr(aten, packet_name)
981 assert isinstance(packet, torch._ops.OpOverloadPacket)
982 op = getattr(packet, overload_name)
983 yield op
984
985 # This is for operators that are only registered in some CI
986 # configurations, so would cause the test to fail
987 allow_list = {aten.get_gradients.default}
988
989 overloads_wanting_decomp = {op for op in all_aten_overloads()
990 if self._can_appear_in_trace(op)}
991 ops_missing_decomp = overloads_wanting_decomp - decomposition_table.keys()
992 ops_missing_decomp -= allow_list
993 self.assertExpected("".join(sorted(op.name() + "\n" for op in ops_missing_decomp)))
994
995 def test_aten_core_operators(self):
996 # If a decomposition isn't included in the core decompositions,

Callers

nothing calls this directly

Calls 5

_can_appear_in_traceMethod · 0.95
assertExpectedMethod · 0.80
keysMethod · 0.45
joinMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected