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

Method get_anchors

backends/nxp/quantizer/patterns.py:382–412  ·  view source on GitHub ↗
(
        self, gm: fx.GraphModule, fused_partition: list[fx.GraphModule]
    )

Source from the content-addressed store, hash-verified

380 return [torch.ops.aten.cat.default]
381
382 def get_anchors(
383 self, gm: fx.GraphModule, fused_partition: list[fx.GraphModule]
384 ) -> PartitionAnchors | None:
385 node = fused_partition[0].nodes[-1]
386
387 quantized_input = None
388 for prev_node in node.args[0]:
389 if "quantization_annotation" in prev_node.meta:
390 quantized_input = prev_node
391 break
392
393 if quantized_input is not None:
394 inputs = []
395 for idx, _ in enumerate(node.args[0]):
396 inputs.append(
397 (node, NodeArgsIdx(0, idx), SharedQuantizationSpec(quantized_input))
398 )
399 outputs = [(node, SharedQuantizationSpec(quantized_input))]
400
401 else:
402 # No previous node was quantized => we are not able to share q-params. The conversion to IR will have to
403 # re-quantize the inputs if necessary.
404 inputs = [(node, NodeArgsIdx(0, idx)) for idx in range(len(node.args[0]))]
405 outputs = [(node,)]
406
407 return PartitionAnchors(
408 inputs=inputs,
409 weights=[],
410 biases=[],
411 output=outputs,
412 )
413
414
415class ClampPattern(SingleInputBasicPattern):

Callers

nothing calls this directly

Calls 3

NodeArgsIdxClass · 0.85
PartitionAnchorsClass · 0.70
appendMethod · 0.45

Tested by

no test coverage detected