(node: Node, quant_config: QuantizationConfig)
| 649 | ] |
| 650 | ) |
| 651 | def annotate_conv2d(node: Node, quant_config: QuantizationConfig) -> None: |
| 652 | # skipping quantization if weights are not float |
| 653 | if _is_annotated([node]) or not _is_float_tensor(node.args[1]): |
| 654 | return |
| 655 | |
| 656 | input = node.args[0] |
| 657 | # input & weight (or bias) setting for Conv node(producer_node) |
| 658 | quantization_annotation = node.meta.get( |
| 659 | "quantization_annotation", QuantizationAnnotation() |
| 660 | ) |
| 661 | if quantization_annotation.input_qspec_map is None: |
| 662 | quantization_annotation.input_qspec_map = {} |
| 663 | |
| 664 | shared_quant_node = _get_quantization_annotation(input) |
| 665 | if shared_quant_node: |
| 666 | quantization_annotation.input_qspec_map[input] = SharedQuantizationSpec( |
| 667 | shared_quant_node |
| 668 | ) |
| 669 | else: |
| 670 | quantization_annotation.input_qspec_map[input] = quant_config.input_activation |
| 671 | quantization_annotation.input_qspec_map[node.args[1]] = quant_config.weight |
| 672 | if len(node.args) > 2 and quant_config.bias is not None: |
| 673 | quantization_annotation.input_qspec_map[node.args[2]] = quant_config.bias |
| 674 | quantization_annotation.output_qspec = quant_config.output_activation |
| 675 | |
| 676 | node.meta["quantization_annotation"] = quantization_annotation |
| 677 | node.meta["quantization_annotation"]._annotated = True |
| 678 | |
| 679 | |
| 680 | # CASE 8: embedding |
nothing calls this directly
no test coverage detected