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

Function _annotate_output

backends/arm/quantizer/quantization_annotator.py:371–397  ·  view source on GitHub ↗

Annotate a node's output with the given qspec. Args: node (Node): Node whose output should be annotated. quant_property (_QuantProperty): Output index and qspec. Raises: RuntimeError: If the node is already annotated. ValueError: If ``mark_annotated`` is Tru

(node: Node, quant_property: _QuantProperty)

Source from the content-addressed store, hash-verified

369
370
371def _annotate_output(node: Node, quant_property: _QuantProperty):
372 """Annotate a node's output with the given qspec.
373
374 Args:
375 node (Node): Node whose output should be annotated.
376 quant_property (_QuantProperty): Output index and qspec.
377
378 Raises:
379 RuntimeError: If the node is already annotated.
380 ValueError: If ``mark_annotated`` is True, ``optional`` is True, or
381 ``index`` is not zero.
382
383 """
384 if is_annotated(node):
385 raise RuntimeError(
386 f"Cannot annotate output: node '{node.name}' is already annotated"
387 )
388 if quant_property.mark_annotated:
389 raise ValueError(
390 "quant_property.mark_annotated must be False for output annotation"
391 )
392 if quant_property.optional:
393 raise ValueError("quant_property.optional must be False for output annotation")
394 if quant_property.index != 0:
395 raise ValueError("Only one output annotation supported currently")
396
397 annotate_output_qspec(node, quant_property.qspec)
398
399
400def _match_pattern(

Callers 1

annotate_graphFunction · 0.85

Calls 2

annotate_output_qspecFunction · 0.90
is_annotatedFunction · 0.70

Tested by

no test coverage detected