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

Function annotate_index

backends/samsung/quantizer/annotator.py:553–572  ·  view source on GitHub ↗
(node: Node, quant_config: QuantizationConfig)

Source from the content-addressed store, hash-verified

551# CASE 4: One value input + one index input with Shared Quant
552@register_annotator([torch.ops.aten.index.Tensor])
553def annotate_index(node: Node, quant_config: QuantizationConfig) -> None:
554 input_qspec_map = {}
555 input = node.args[0]
556 assert isinstance(input, Node)
557
558 if _is_annotated([node]) or not _is_float_tensor(input):
559 return
560
561 # get QuantAnnt from the input path
562 shared_quant_node = _get_quantization_annotation(input)
563 if shared_quant_node:
564 shared_qspec = SharedQuantizationSpec((shared_quant_node, node))
565 input_qspec_map[input] = quant_config.input_activation
566
567 # sharing QuantAnnot with the parent
568 node.meta["quantization_annotation"] = QuantizationAnnotation(
569 input_qspec_map=input_qspec_map,
570 output_qspec=shared_qspec,
571 _annotated=True,
572 )
573
574
575# CASE 5 input + index + value & output with Shared Quant

Callers

nothing calls this directly

Calls 3

_is_annotatedFunction · 0.70
_is_float_tensorFunction · 0.70

Tested by

no test coverage detected