This is what the graph of a simple linear op looks like: fn_weight = self.fn_weight fn_bias = self.fn_bias permute_copy = torch.ops.aten.permute_copy.default(fn_weight, [1, 0]); fn_weight = None addmm = torch.ops.aten.addmm.default(fn_bias, arg2_1, permute_copy); fn_bias = arg
(partitions, quant_config)
| 15 | |
| 16 | |
| 17 | def _annotate_linear(partitions, quant_config): |
| 18 | """ |
| 19 | This is what the graph of a simple linear op looks like: |
| 20 | fn_weight = self.fn_weight |
| 21 | fn_bias = self.fn_bias |
| 22 | permute_copy = torch.ops.aten.permute_copy.default(fn_weight, [1, 0]); fn_weight = None |
| 23 | addmm = torch.ops.aten.addmm.default(fn_bias, arg2_1, permute_copy); fn_bias = arg2_1 = permute_copy = None |
| 24 | """ |
| 25 | linear_node = partitions[0].output_nodes[0] |
| 26 | if _nodes_are_annotated([linear_node]): |
| 27 | return |
| 28 | |
| 29 | input_node = linear_node.args[0] |
| 30 | # permute_node = linear_node.args[1] |
| 31 | # print("permute_node: ", permute_node, " args: ", permute_node.args, " target: ", permute_node.target) |
| 32 | weight_node = linear_node.args[1] |
| 33 | print( |
| 34 | "weight_node: ", |
| 35 | weight_node, |
| 36 | " args: ", |
| 37 | weight_node.args, |
| 38 | " target: ", |
| 39 | weight_node.target, |
| 40 | ) |
| 41 | # Unused. |
| 42 | # bias_node = output_node.args[0] |
| 43 | |
| 44 | # if _nodes_are_annotated([linear_node, permute_node]): |
| 45 | # return |
| 46 | |
| 47 | _annotate_nodes( |
| 48 | [(linear_node, input_node)], quant_config.input_quant_spec, input_node=True |
| 49 | ) |
| 50 | _annotate_nodes( |
| 51 | [(linear_node, weight_node)], quant_config.weight_quant_spec, input_node=True |
| 52 | ) |
| 53 | _annotate_nodes([(linear_node,)], quant_config.output_quant_spec) |
| 54 | |
| 55 | |
| 56 | @dataclass |
nothing calls this directly
no test coverage detected