|
58 | 58 | CadenceNopQuantizer, # No-op quantizer, doesn't annotate anything |
59 | 59 | CadenceW8A32MixedQuantizer, # TODO: T247438158 Add test coverage |
60 | 60 | CadenceRmsNormNopQuantizer, # No-op quantizer, doesn't annotate anything, preserves rms_norm from decomposition |
61 | | - CadenceWakeWordQuantizer, # TODO: T247438162 Add test coverage |
62 | 61 | } |
63 | 62 |
|
64 | 63 |
|
|
129 | 128 | # For layer_norm: only input_activation (weights/bias are passed as others) |
130 | 129 | [qconfig_A8W8.input_activation], |
131 | 130 | ), |
| 131 | + ( |
| 132 | + "add_A8W8", |
| 133 | + lambda self: self._build_add_graph(), |
| 134 | + CadenceWakeWordQuantizer(), |
| 135 | + torch.ops.aten.add.Tensor, |
| 136 | + qconfig_A8W8.output_activation, |
| 137 | + # For add: both inputs are activations |
| 138 | + [qconfig_A8W8.input_activation, qconfig_A8W8.input_activation], |
| 139 | + ), |
132 | 140 | ] |
133 | 141 |
|
134 | 142 | # Derive the set of tested quantizer classes from the test cases. |
@@ -279,6 +287,28 @@ def _build_layer_norm_graph(self) -> tuple[torch.fx.GraphModule, torch.fx.Node]: |
279 | 287 | ] |
280 | 288 | return gm, layer_norm_nodes[0] |
281 | 289 |
|
| 290 | + def _build_add_graph(self) -> tuple[torch.fx.GraphModule, torch.fx.Node]: |
| 291 | + """Build a simple graph with an add operation.""" |
| 292 | + builder = GraphBuilder() |
| 293 | + x = builder.placeholder("x", torch.randn(1, 10)) |
| 294 | + y = builder.placeholder("y", torch.randn(1, 10)) |
| 295 | + add = builder.call_operator( |
| 296 | + op=torch.ops.aten.add.Tensor, |
| 297 | + args=(x, y), |
| 298 | + meta=NodeMetadata( |
| 299 | + {"source_fn_stack": [("add", torch.ops.aten.add.Tensor)]} |
| 300 | + ), |
| 301 | + ) |
| 302 | + builder.output([add]) |
| 303 | + gm = builder.get_graph_module() |
| 304 | + |
| 305 | + add_nodes = gm.graph.find_nodes( |
| 306 | + op="call_function", |
| 307 | + target=torch.ops.aten.add.Tensor, |
| 308 | + ) |
| 309 | + self.assertEqual(len(add_nodes), 1, "Should find exactly one add node") |
| 310 | + return gm, add_nodes[0] |
| 311 | + |
282 | 312 | @parameterized.expand(QUANTIZER_ANNOTATION_TEST_CASES) |
283 | 313 | def test_quantizer_annotation( |
284 | 314 | self, |
|
0 commit comments