(
self, gm: fx.GraphModule, fused_partition: list[fx.GraphModule]
)
| 238 | return [torch.ops.aten.addmm.default] |
| 239 | |
| 240 | def get_anchors( |
| 241 | self, gm: fx.GraphModule, fused_partition: list[fx.GraphModule] |
| 242 | ) -> PartitionAnchors: |
| 243 | addmm_node = fused_partition[0].nodes[-1] |
| 244 | |
| 245 | bias_qspec = DerivedQuantizationSpec( |
| 246 | derived_from=[ |
| 247 | (addmm_node.args[1], addmm_node), |
| 248 | (addmm_node.args[2], addmm_node), |
| 249 | ], |
| 250 | derive_qparams_fn=get_bias_qparams, |
| 251 | dtype=torch.int32, |
| 252 | quant_min=-(2**31), |
| 253 | quant_max=2**31 - 1, |
| 254 | qscheme=torch.per_tensor_affine, |
| 255 | ) |
| 256 | |
| 257 | # If the following node is a fusable activation, quantize together with activation |
| 258 | output = [(addmm_node,)] |
| 259 | if len( |
| 260 | addmm_node.users |
| 261 | ) == 1 and self.neutron_target_info.is_supported_fused_activation__aten( |
| 262 | activation := next(iter(addmm_node.users)) |
| 263 | ): |
| 264 | activation_quantizer = self.neutron_quantizer.op_to_quantizer[ |
| 265 | activation.target |
| 266 | ] |
| 267 | activation_quantizer.annotate(gm) |
| 268 | output = [] |
| 269 | activation.meta["quantization_annotation"].input_qspec_map = {} |
| 270 | |
| 271 | return PartitionAnchors( |
| 272 | inputs=[(addmm_node, NodeArgsIdx(1))], |
| 273 | weights=[(addmm_node, NodeArgsIdx(2))], |
| 274 | biases=[(addmm_node, NodeArgsIdx(0), bias_qspec)], |
| 275 | output=output, |
| 276 | ) |
| 277 | |
| 278 | |
| 279 | class AddTensorPattern(QuantizationPattern): |
nothing calls this directly
no test coverage detected