project_name string | class_name string | class_modifiers string | class_implements int64 | class_extends int64 | function_name string | function_body string | cyclomatic_complexity int64 | NLOC int64 | num_parameter int64 | num_token int64 | num_variable int64 | start_line int64 | end_line int64 | function_index int64 | function_params string | function_variable string | function_return_type string | function_body_line_type string | function_num_functions int64 | function_num_lines int64 | outgoing_function_count int64 | outgoing_function_names string | incoming_function_count int64 | incoming_function_names string | lexical_representation string |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
pytorch_ao | public | public | 0 | 0 | _get_conv_bn_pattern | def _get_conv_bn_pattern(conv_fn: Callable) -> Callable:def _conv_bn_pattern(x: torch.Tensor,conv_weight: torch.Tensor,conv_bias: torch.Tensor,bn_weight: torch.Tensor,bn_bias: torch.Tensor,bn_running_mean: torch.Tensor,bn_running_var: torch.Tensor,) -> torch.Tensor:x = conv_fn(x, conv_weight, conv_bias)x = F.batch_norm... | 1 | 3 | 1 | 16 | 1 | 69 | 85 | 69 | null | ['x'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_get_conv_bn_pattern) defined within the public class called public.The function start at line 69 and ends at 85. It contains 3 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _get_qat_conv_bn_pattern._qat_conv_bn_pattern | def _qat_conv_bn_pattern(x: torch.Tensor,conv_weight: torch.Tensor,conv_bias: torch.Tensor,bn_weight: torch.Tensor,bn_bias: torch.Tensor,bn_running_mean: torch.Tensor,bn_running_var: torch.Tensor,) -> torch.Tensor:"""Approximated method to fuse conv and bn. It requires only one forward pass.conv_orig = conv / scale_fac... | 2 | 32 | 7 | 200 | 0 | 90 | 127 | 90 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_get_qat_conv_bn_pattern._qat_conv_bn_pattern) defined within the public class called public.The function start at line 90 and ends at 127. It contains 32 lines of code and it has a cyclomatic complexity of 2. It takes 7 parameters, represented as [90.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _get_qat_conv_bn_pattern | def _get_qat_conv_bn_pattern(conv_fn: Callable) -> Callable:def _qat_conv_bn_pattern(x: torch.Tensor,conv_weight: torch.Tensor,conv_bias: torch.Tensor,bn_weight: torch.Tensor,bn_bias: torch.Tensor,bn_running_mean: torch.Tensor,bn_running_var: torch.Tensor,) -> torch.Tensor:"""Approximated method to fuse conv and bn. It... | 1 | 3 | 1 | 16 | 9 | 89 | 129 | 89 | null | ['running_std', 'bn_eps', 'scaled_weight', 'weight_in_channel_axis', 'weight_shape', 'x', 'scale_factor', 'zero_bias', 'bias_shape'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_get_qat_conv_bn_pattern) defined within the public class called public.The function start at line 89 and ends at 129. It contains 3 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _get_qat_conv_bn_pattern_no_conv_bias._qat_conv_bn_pattern_no_conv_bias | def _qat_conv_bn_pattern_no_conv_bias(x: torch.Tensor,conv_weight: torch.Tensor,# Not used, only for matching convenienceconv_bias: torch.Tensor,bn_weight: torch.Tensor,bn_bias: torch.Tensor,bn_running_mean: torch.Tensor,bn_running_var: torch.Tensor,) -> torch.Tensor:"""Same as `_get_qat_conv_bn_pattern`, but handles t... | 2 | 30 | 7 | 176 | 0 | 133 | 167 | 133 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_get_qat_conv_bn_pattern_no_conv_bias._qat_conv_bn_pattern_no_conv_bias) defined within the public class called public.The function start at line 133 and ends at 167. It contains 30 lines of code and it has a cyclomatic complexity of 2. It takes 7 parameters, represented as [133.0] and does not return any... |
pytorch_ao | public | public | 0 | 0 | _get_qat_conv_bn_pattern_no_conv_bias | def _get_qat_conv_bn_pattern_no_conv_bias(conv_fn: Callable) -> Callable:def _qat_conv_bn_pattern_no_conv_bias(x: torch.Tensor,conv_weight: torch.Tensor,# Not used, only for matching convenienceconv_bias: torch.Tensor,bn_weight: torch.Tensor,bn_bias: torch.Tensor,bn_running_mean: torch.Tensor,bn_running_var: torch.Tens... | 1 | 3 | 1 | 16 | 8 | 132 | 169 | 132 | null | ['running_std', 'bn_eps', 'scaled_weight', 'weight_in_channel_axis', 'weight_shape', 'x', 'scale_factor', 'bias_shape'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_get_qat_conv_bn_pattern_no_conv_bias) defined within the public class called public.The function start at line 132 and ends at 169. It contains 3 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _append_qdq | def _append_qdq(x, is_per_channel, is_bias, kwargs):"""Helper function to append q-dq ops after `x`, using dummy values for the qparamsand qmin/qmax. We use dummy values here because we match with `ignore_literals=True`and will manually replace these values after subgraph rewriting.Return the dq node."""# Dummy args to... | 6 | 17 | 4 | 153 | 10 | 172 | 197 | 172 | null | ['qd', 'zp', 'scale', 'x', 'dtype', 'per_channel_axis', 'qmax', 'scale_key', 'zp_key', 'qmin'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_append_qdq) defined within the public class called public.The function start at line 172 and ends at 197. It contains 17 lines of code and it has a cyclomatic complexity of 6. It takes 4 parameters, represented as [172.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _get_quantized_qat_conv_bn_pattern._quantized_qat_conv_bn_pattern | def _quantized_qat_conv_bn_pattern(x: torch.Tensor,conv_weight: torch.Tensor,bn_weight: torch.Tensor,bn_bias: torch.Tensor,bn_running_mean: torch.Tensor,bn_running_var: torch.Tensor,**kwargs,) -> torch.Tensor:running_std = torch.sqrt(bn_running_var + bn_eps)scale_factor = bn_weight / running_stdweight_shape = [1] * len... | 4 | 47 | 7 | 242 | 0 | 217 | 263 | 217 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_get_quantized_qat_conv_bn_pattern._quantized_qat_conv_bn_pattern) defined within the public class called public.The function start at line 217 and ends at 263. It contains 47 lines of code and it has a cyclomatic complexity of 4. It takes 7 parameters, represented as [217.0] and does not return any value... |
pytorch_ao | public | public | 0 | 0 | _get_quantized_qat_conv_bn_pattern | def _get_quantized_qat_conv_bn_pattern(is_per_channel: bool,has_bias: bool,bias_is_quantized: bool,conv_fn: Callable,bn_is_training: bool,) -> Callable:"""Return the quantized version of QAT conv + BN pattern.This is based on `nniqat.ConvBn2d._forward_approximate`,used in QAT convert. We first match this pattern and re... | 1 | 10 | 5 | 39 | 8 | 200 | 265 | 200 | null | ['running_std', 'bn_eps', 'scaled_weight', 'weight_shape', 'x', 'scale_factor', 'zero_bias', 'bias_shape'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_get_quantized_qat_conv_bn_pattern) defined within the public class called public.The function start at line 200 and ends at 265. It contains 10 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [200.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _get_folded_quantized_qat_conv_bn_pattern._folded_quantized_qat_conv_bn_pattern | def _folded_quantized_qat_conv_bn_pattern(x: torch.Tensor,conv_weight: torch.Tensor,bn_weight: torch.Tensor,bn_bias: torch.Tensor,bn_running_mean: torch.Tensor,bn_running_var: torch.Tensor,**kwargs,) -> torch.Tensor:conv_weight = _append_qdq(conv_weight,is_per_channel,is_bias=False,kwargs=kwargs,)if has_bias:bias = kwa... | 3 | 37 | 7 | 135 | 0 | 281 | 317 | 281 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_get_folded_quantized_qat_conv_bn_pattern._folded_quantized_qat_conv_bn_pattern) defined within the public class called public.The function start at line 281 and ends at 317. It contains 37 lines of code and it has a cyclomatic complexity of 3. It takes 7 parameters, represented as [281.0] and does not re... |
pytorch_ao | public | public | 0 | 0 | _get_folded_quantized_qat_conv_bn_pattern | def _get_folded_quantized_qat_conv_bn_pattern(is_per_channel: bool,has_bias: bool,bias_is_quantized: bool,conv_fn: Callable,bn_is_training: bool,) -> Callable:"""Quantized QAT conv - bn pattern with bn weights being folded into conv."""# TODO: allow setting epsbn_eps = 1e-5def _folded_quantized_qat_conv_bn_pattern(x: t... | 1 | 10 | 5 | 39 | 4 | 268 | 319 | 268 | null | ['conv_weight', 'x', 'bn_eps', 'bias'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_get_folded_quantized_qat_conv_bn_pattern) defined within the public class called public.The function start at line 268 and ends at 319. It contains 10 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [268.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _has_conv_bias_filter | def _has_conv_bias_filter(match: "InternalMatch",original_graph: Graph,pattern_graph: Graph,) -> bool:"""Match filter for the subgraph rewriter that returns True if the conv node inthe original graph has bias."""for n in match.nodes_map.values():if _is_conv_or_conv_transpose_node(n):return len(n.args) > 2 and n.args[2]... | 4 | 9 | 3 | 60 | 0 | 322 | 334 | 322 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_has_conv_bias_filter) defined within the public class called public.The function start at line 322 and ends at 334. It contains 9 lines of code and it has a cyclomatic complexity of 4. It takes 3 parameters, represented as [322.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _no_conv_bias_filter | def _no_conv_bias_filter(match: "InternalMatch",original_graph: Graph,pattern_graph: Graph,) -> bool:"""Match filter for the subgraph rewriter that returns True if the conv node inthe original graph does NOT have bias."""return not _has_conv_bias_filter(match, original_graph, pattern_graph) | 1 | 6 | 3 | 29 | 0 | 337 | 346 | 337 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_no_conv_bias_filter) defined within the public class called public.The function start at line 337 and ends at 346. It contains 6 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [337.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _is_quantize | def _is_quantize(n: Node) -> bool:return n.target in [torch.ops.quantized_decomposed.quantize_per_tensor.default,torch.ops.quantized_decomposed.quantize_per_tensor.tensor,torch.ops.quantized_decomposed.quantize_per_channel.default,] | 1 | 6 | 1 | 46 | 0 | 349 | 354 | 349 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_is_quantize) defined within the public class called public.The function start at line 349 and ends at 354. It contains 6 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _is_dequantize | def _is_dequantize(n: Node) -> bool:return n.target in [torch.ops.quantized_decomposed.dequantize_per_tensor.default,torch.ops.quantized_decomposed.dequantize_per_tensor.tensor,torch.ops.quantized_decomposed.dequantize_per_channel.default,] | 1 | 6 | 1 | 46 | 0 | 357 | 362 | 357 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_is_dequantize) defined within the public class called public.The function start at line 357 and ends at 362. It contains 6 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _get_conv_bn_pattern_nodes._get_nodes | def _get_nodes(nodes: list[Node]) -> tuple[Node, Node, Optional[Node]]:"""Return a 3-tuple of (conv_node, bn_node, getitem_node).This asserts that the match contains exactly one of each node."""conv_node, bn_node, getitem_node = None, None, Nonefor n in nodes:if n.op != "call_function":continueif _is_conv_or_conv_trans... | 6 | 17 | 1 | 107 | 0 | 382 | 402 | 382 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_get_conv_bn_pattern_nodes._get_nodes) defined within the public class called public.The function start at line 382 and ends at 402. It contains 17 lines of code and it has a cyclomatic complexity of 6. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _get_conv_bn_pattern_nodes._get_q_dq_nodes | def _get_q_dq_nodes(n: Node) -> tuple[Node, Node, Node]:"""Return a 3-tuple of (orig_node, q_node, dq_node)."""assert _is_dequantize(n)q_node = n.args[0]assert isinstance(q_node, Node)assert _is_quantize(q_node)orig_node = q_node.args[0]assert isinstance(orig_node, Node)return (orig_node, q_node, n) | 1 | 8 | 1 | 65 | 0 | 404 | 414 | 404 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_get_conv_bn_pattern_nodes._get_q_dq_nodes) defined within the public class called public.The function start at line 404 and ends at 414. It contains 8 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _get_conv_bn_pattern_nodes | def _get_conv_bn_pattern_nodes(r: ReplacedPatterns) -> dict[str, tuple[Node, Node]]:"""Helper function to extract the nodes in the conv-bn fusion pattern aftersubgraph rewriting, in the form of a map:{name: (original_node, replacement_node)}The following names must exist in the map:"conv", "conv_weight", "conv_input", ... | 5 | 51 | 1 | 407 | 16 | 365 | 475 | 365 | null | ['mapping', 'o_conv_input', 'o_conv_bias_dq', 'orig_node', 'r_conv_bias', 'bn_node', 'conv_node', 'o_conv_weight_q', 'p_conv_bias', 'o_conv_bias_q', 'o_conv_weight', 'o_conv_bias', 'original_nodes', 'o_conv_weight_dq', 'getitem_node', 'q_node'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_get_conv_bn_pattern_nodes) defined within the public class called public.The function start at line 365 and ends at 475. It contains 51 lines of code and it has a cyclomatic complexity of 5. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _filter_nodes_map | def _filter_nodes_map(nodes_map: dict[Node, Node]) -> dict[Node, Node]:"""Return a filtered `nodes_map` returned from the subgraph rewriter.The filtered `nodes_map` will contain only nodes that are actuallymatched in the pattern, excluding None or placeholder nodes."""new_nodes_map: dict[Node, Node] = {}for pattern_nod... | 4 | 9 | 1 | 64 | 0 | 478 | 493 | 478 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_filter_nodes_map) defined within the public class called public.The function start at line 478 and ends at 493. It contains 9 lines of code and it has a cyclomatic complexity of 4. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _copy_over_literal_conv_args | def _copy_over_literal_conv_args(original_node: Node, new_node: Node):"""Copy over literal args in conv, such as stride and padding, from the matched nodein the original graph to its replacement in the new graph.This is needed due to the following limitation in the subgraph rewriter when usedwith dynamo export: literal... | 2 | 7 | 2 | 64 | 1 | 497 | 519 | 497 | null | ['new_args'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_copy_over_literal_conv_args) defined within the public class called public.The function start at line 497 and ends at 519. It contains 7 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [497.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _update_conv_input_qspec_map_after_replacement | def _update_conv_input_qspec_map_after_replacement(original_node: Node, replacement_node: Node):"""Update the `input_qspec_map` in the annotation after subgraph rewriting.The original annotation referred to the nodes in the original graph,so the keys in the `input_qspec_map` will need to be updated to reflectthe corres... | 4 | 17 | 2 | 133 | 3 | 522 | 551 | 522 | null | ['input_qspec_map', 'original_input_qspec_map', 'all_configs'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_update_conv_input_qspec_map_after_replacement) defined within the public class called public.The function start at line 522 and ends at 551. It contains 17 lines of code and it has a cyclomatic complexity of 4. It takes 2 parameters, represented as [522.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _update_special_qspecs_after_replacement._get_new_edge_or_node | def _get_new_edge_or_node(edge_or_node: EdgeOrNode):if isinstance(edge_or_node, Node):_node = edge_or_nodereturn original_to_replacement_node.get(_node, _node)elif (isinstance(edge_or_node, tuple)and len(edge_or_node) == 2and all(isinstance(x, Node) for x in edge_or_node)):src, dest = edge_or_nodereturn (original_to_re... | 6 | 16 | 1 | 96 | 0 | 567 | 582 | 567 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_update_special_qspecs_after_replacement._get_new_edge_or_node) defined within the public class called public.The function start at line 567 and ends at 582. It contains 16 lines of code and it has a cyclomatic complexity of 6. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _update_special_qspecs_after_replacement._get_new_qspec | def _get_new_qspec(qspec: QuantizationSpecBase):if isinstance(qspec, SharedQuantizationSpec):new_edge_or_node = _get_new_edge_or_node(qspec.edge_or_node)return SharedQuantizationSpec(new_edge_or_node)elif isinstance(qspec, DerivedQuantizationSpec):new_derived_from = [_get_new_edge_or_node(x) for x in qspec.derived_from... | 4 | 9 | 1 | 65 | 0 | 584 | 592 | 584 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_update_special_qspecs_after_replacement._get_new_qspec) defined within the public class called public.The function start at line 584 and ends at 592. It contains 9 lines of code and it has a cyclomatic complexity of 4. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _update_special_qspecs_after_replacement | def _update_special_qspecs_after_replacement(node: Node,original_to_replacement_node: dict[Node, Node],):"""Update the `SharedQuantizationSpec`s and `DerivedQuantizationSpec`sused in `node`'s quantization annotation after subgraph rewriting.The original annotation referred to the nodes in the original graph,so the node... | 3 | 12 | 2 | 73 | 4 | 554 | 599 | 554 | null | ['_node', 'new_edge_or_node', 'annotation', 'new_derived_from'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_update_special_qspecs_after_replacement) defined within the public class called public.The function start at line 554 and ends at 599. It contains 12 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [554.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _fuse_conv_bn_qat | def _fuse_conv_bn_qat(m: GraphModule) -> GraphModule:# Example inputs for conv-bn1d patterns_conv1d_bn_example_inputs = (torch.randn(1, 1, 3),# xtorch.randn(1, 1, 1),# conv_weighttorch.randn(1),# conv_biastorch.randn(1),# bn_weighttorch.randn(1),# bn_biastorch.randn(1),# bn_running_meantorch.randn(1),# bn_running_var)#... | 5 | 37 | 1 | 248 | 5 | 602 | 642 | 602 | null | ['has_bn', 'm', 'is_cuda_options', '_conv1d_bn_example_inputs', '_conv2d_bn_example_inputs'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_fuse_conv_bn_qat) defined within the public class called public.The function start at line 602 and ends at 642. It contains 37 lines of code and it has a cyclomatic complexity of 5. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _fuse_conv_bn_qat_helper | def _fuse_conv_bn_qat_helper(m: GraphModule,conv_fn: Callable,example_inputs: tuple[Any, ...],is_cuda: bool,) -> GraphModule:"""Given a graph of decomposed aten ops, replace the (conv + bn) pattern withthe fused QAT subgraph equivalent. The input graph should already be annotated.The annotations in the original nodes w... | 8 | 64 | 4 | 275 | 11 | 645 | 755 | 645 | null | ['replacement_pattern_with_conv_bias', 'replacement_pattern_no_conv_bias', 'qat_conv_bn_pattern', 'qat_conv_bn_pattern_no_conv_bias', 'conv_nn_module', 'conv_bn_pattern', 'all_original_to_replacement_nodes', 'replacements_with_conv_bias', 'match_pattern', 'replacement_dict', 'replacements_no_conv_bias'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_fuse_conv_bn_qat_helper) defined within the public class called public.The function start at line 645 and ends at 755. It contains 64 lines of code and it has a cyclomatic complexity of 8. It takes 4 parameters, represented as [645.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _duplicate_dequantize_node | def _duplicate_dequantize_node(m: GraphModule):"""Helper function to duplicate all dequantize nodes in the graph if thenode has more than one user. For example:Before:quantize -> dequantize -> a\\--> b\\--> cAfter:quantize -> dequantize_1 -> a\\--> dequantize_2 -> b\\--> dequantize_3 -> cThis is useful for subgraph rew... | 6 | 11 | 1 | 110 | 2 | 758 | 787 | 758 | null | ['new_node', 'dq_op'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_duplicate_dequantize_node) defined within the public class called public.The function start at line 758 and ends at 787. It contains 11 lines of code and it has a cyclomatic complexity of 6. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _remove_extra_dequantize | def _remove_extra_dequantize(m: GraphModule):"""Removes duplicate dequant nodes in the graph, for an operator that hasmultiple dequant nodes as a user, replace them with a single dequant nodethat can be shared across all the uses. This should be seen as the "reverse"of `_duplicate_dequantize_node`."""dq_op = torch.ops.... | 7 | 17 | 1 | 116 | 3 | 790 | 812 | 790 | null | ['dq_users', 'new_node', 'dq_op'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_remove_extra_dequantize) defined within the public class called public.The function start at line 790 and ends at 812. It contains 17 lines of code and it has a cyclomatic complexity of 7. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _copy_over_q_dq_args | def _copy_over_q_dq_args(original_node: Node, replacement_node: Node):"""Given a pair of quantize or dequantize nodes, copy over all literal argsfrom the original node to the replacement node."""# For quantize_per_tensor, scale and zp are literals and need to be copied# For quantize_per_channel, scale and zp are get_at... | 3 | 20 | 2 | 111 | 1 | 815 | 842 | 815 | null | ['start_copy_arg_index'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_copy_over_q_dq_args) defined within the public class called public.The function start at line 815 and ends at 842. It contains 20 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [815.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _fold_conv_bn_qat | def _fold_conv_bn_qat(m: GraphModule) -> GraphModule:# Example inputs for quantized and folded conv-bn1d patterns used in convert_quantized_conv1d_bn_example_inputs = (torch.randn(1, 1, 3),# xtorch.randn(1, 1, 1),# conv_weighttorch.randn(1),# bn_weighttorch.randn(1),# bn_biastorch.randn(1),# bn_running_meantorch.randn(... | 11 | 46 | 1 | 326 | 5 | 845 | 898 | 845 | null | ['has_bn', '_quantized_conv1d_bn_example_inputs', '_quantized_conv2d_bn_example_inputs', 'm', 'is_cuda_options'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_fold_conv_bn_qat) defined within the public class called public.The function start at line 845 and ends at 898. It contains 46 lines of code and it has a cyclomatic complexity of 11. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _fold_conv_bn_qat_helper | def _fold_conv_bn_qat_helper(m: GraphModule,conv_fn: Callable,example_inputs: tuple[Any, ...],is_cuda: bool,) -> GraphModule:"""Replace the quantized (conv + bn) pattern with conv with bn weights folded into the weights of conv."""m.graph.eliminate_dead_code()m.recompile()_duplicate_dequantize_node(m)# Step (1): Replac... | 10 | 78 | 4 | 365 | 7 | 901 | 996 | 901 | null | ['conv_bias', 'kwargs', 'replacement_options', 'replacements', 'match_pattern', 'replacement_pattern', 'node_map'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_fold_conv_bn_qat_helper) defined within the public class called public.The function start at line 901 and ends at 996. It contains 78 lines of code and it has a cyclomatic complexity of 10. It takes 4 parameters, represented as [901.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | prepare_pt2e | def prepare_pt2e(model: GraphModule,quantizer: Union[Quantizer, torch.ao.quantization.quantizer.quantizer.Quantizer],) -> GraphModule:"""Prepare a model for post training quantizationArgs:* `model` (torch.fx.GraphModule): a model captured by `torch.export.export` API.* `quantizer`: A backend specific quantizer that con... | 2 | 25 | 2 | 148 | 3 | 42 | 127 | 42 | null | ['original_graph_meta', 'node_name_to_scope', 'model'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (prepare_pt2e) defined within the public class called public.The function start at line 42 and ends at 127. It contains 25 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [42.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | prepare_qat_pt2e | def prepare_qat_pt2e(model: GraphModule,quantizer: Union[Quantizer, torch.ao.quantization.quantizer.quantizer.Quantizer],) -> GraphModule:"""Prepare a model for quantization aware trainingArgs:* `model` (torch.fx.GraphModule): see :func:`~torchao.quantization.pt2e.quantize_pt2e.prepare_pt2e`* `quantizer`: see :func:`~t... | 2 | 25 | 2 | 148 | 3 | 130 | 213 | 130 | null | ['original_graph_meta', 'node_name_to_scope', 'model'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (prepare_qat_pt2e) defined within the public class called public.The function start at line 130 and ends at 213. It contains 25 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [130.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _quant_node_constraint | def _quant_node_constraint(n: Node) -> bool:"""If there is any pure ops between get_attr and quantize op they will be const propagatede.g. get_attr(weight) -> transpose -> quantize -> dequantize*(Note: dequantize op is not going to be constant propagated)This filter is added because we don't want to constant fold the t... | 2 | 2 | 1 | 22 | 0 | 224 | 232 | 224 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_quant_node_constraint) defined within the public class called public.The function start at line 224 and ends at 232. It contains 2 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _is_torchao_prepared_do_not_use_outside_this_file | def _is_torchao_prepared_do_not_use_outside_this_file(model):from torchao.quantization.pt2e.fake_quantize import (FakeQuantize as torchao_FakeQuantize,)from torchao.quantization.pt2e.observer import (AffineQuantizedObserverBase as torchao_AffineQuantizedObserverBase,)from torchao.quantization.pt2e.observer import Obser... | 10 | 32 | 1 | 164 | 2 | 235 | 269 | 235 | null | ['is_torch_ao_prepared', 'is_torchao_prepared'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_is_torchao_prepared_do_not_use_outside_this_file) defined within the public class called public.The function start at line 235 and ends at 269. It contains 32 lines of code and it has a cyclomatic complexity of 10. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | convert_pt2e | def convert_pt2e(model: GraphModule,use_reference_representation: bool = False,fold_quantize: bool = True,) -> GraphModule:"""Convert a calibrated/trained model to a quantized modelArgs:* `model` (torch.fx.GraphModule): calibrated/trained model* `use_reference_representation` (bool): boolean flag to indicate whether to... | 6 | 30 | 3 | 170 | 3 | 272 | 331 | 272 | null | ['original_graph_meta', 'pm', 'model'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (convert_pt2e) defined within the public class called public.The function start at line 272 and ends at 331. It contains 30 lines of code and it has a cyclomatic complexity of 6. It takes 3 parameters, represented as [272.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _qdq_quantized_linear | def _qdq_quantized_linear(x_i8,x_scale,x_zero_point,x_quant_min,x_quant_max,weight_i8,weight_scale,weight_zero_point,weight_quant_min,weight_quant_max,bias_fp32,out_scale,out_zero_point,out_quant_min,out_quant_max,):x_fp32 = torch.ops.quantized_decomposed.dequantize_per_tensor(x_i8, x_scale, x_zero_point, x_quant_min, ... | 1 | 33 | 15 | 127 | 4 | 44 | 76 | 44 | null | ['x_fp32', 'out_i8', 'weight_fp32', 'out_fp32'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_qdq_quantized_linear) defined within the public class called public.The function start at line 44 and ends at 76. It contains 33 lines of code and it has a cyclomatic complexity of 1. It takes 15 parameters, represented as [44.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _reference_quantized_linear | def _reference_quantized_linear(x_i8,x_scale,x_zero_point,x_quant_min,x_quant_max,weight_i8,weight_scale,weight_zero_point,weight_quant_min,weight_quant_max,bias_fp32,out_scale,out_zero_point,out_quant_min,out_quant_max,):# without using quant_min/max in clamp, the traced graph will not have quant_mi/max args.# This re... | 1 | 42 | 15 | 203 | 8 | 79 | 129 | 79 | null | ['bias_i32', 'weight_i8', 'x_i16', 'weight_i16', 'bias_scale', 'acc_i32', 'out_i8', 'x_i8'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_reference_quantized_linear) defined within the public class called public.The function start at line 79 and ends at 129. It contains 42 lines of code and it has a cyclomatic complexity of 1. It takes 15 parameters, represented as [79.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _qdq_dynamic_quantized_linear | def _qdq_dynamic_quantized_linear(x_fp32,x_quant_min,x_quant_max,x_eps,weight_i8,weight_scale,weight_zero_point,weight_quant_min,weight_quant_max,bias_fp32,):x_scale, x_zero_point = torch.ops.quantized_decomposed.choose_qparams(x_fp32, x_quant_min, x_quant_max, x_eps, torch.int8)x_i8 = torch.ops.quantized_decomposed.qu... | 1 | 31 | 10 | 141 | 4 | 132 | 162 | 132 | null | ['out_fp32', 'x_fp32', 'weight_fp32', 'x_i8'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_qdq_dynamic_quantized_linear) defined within the public class called public.The function start at line 132 and ends at 162. It contains 31 lines of code and it has a cyclomatic complexity of 1. It takes 10 parameters, represented as [132.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _reference_dynamic_quantized_linear | def _reference_dynamic_quantized_linear(x_fp32,x_quant_min,x_quant_max,x_eps,weight_i8,weight_scale,weight_zero_point,weight_quant_min,weight_quant_max,bias_fp32,):x_scale, x_zero_point = torch.ops.quantized_decomposed.choose_qparams(x_fp32, x_quant_min, x_quant_max, x_eps, torch.int8)# decomposed representation for qu... | 1 | 36 | 10 | 210 | 10 | 165 | 209 | 165 | null | ['x_i32', 'bias_i32', 'out_fp32', 'weight_i8', 'x_i16', 'weight_i16', 'x_fp32', 'bias_scale', 'acc_i32', 'x_i8'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_reference_dynamic_quantized_linear) defined within the public class called public.The function start at line 165 and ends at 209. It contains 36 lines of code and it has a cyclomatic complexity of 1. It takes 10 parameters, represented as [165.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _qdq_dynamic_quantized_linear_4bit_groupwise | def _qdq_dynamic_quantized_linear_4bit_groupwise(x_fp32,x_eps,weight_i4,weight_scale,weight_zero_point,bias_fp32,group_size,):# Dynamic quantization of activationx_mapping_type = MappingType.ASYMMETRICper_token_block_size = _get_per_token_block_size(x_fp32)x_quant_min = -128x_quant_max = 127x_scale, x_zero_point = torc... | 1 | 60 | 7 | 219 | 9 | 212 | 274 | 212 | null | ['out_fp32', 'x_quant_max', 'per_token_block_size', 'x_mapping_type', 'block_size', 'x_quant_min', 'x_fp32', 'weight_fp32', 'x_i8'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_qdq_dynamic_quantized_linear_4bit_groupwise) defined within the public class called public.The function start at line 212 and ends at 274. It contains 60 lines of code and it has a cyclomatic complexity of 1. It takes 7 parameters, represented as [212.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _reference_dqlinear_int4 | def _reference_dqlinear_int4(x_fp32: torch.Tensor,x_eps: float,weight_i4: torch.Tensor,weight_scale: torch.Tensor,weight_zero_point: torch.Tensor,# Not used because assuming weight is symmetricbias_fp32: Optional[torch.Tensor],group_size: List[int],) -> torch.Tensor:"""Reference implementation for dynamically quantized... | 4 | 78 | 7 | 471 | 25 | 278 | 404 | 278 | null | ['x_i8_grouped', 'x_scale_multiplier', 'weight_i4_grouped', 'per_token_block_size', 'x_mapping_type', 'k_dim', 'weight_i32_grouped', 'out_fp32', 'weight_group', 'weight_scale_group', 'batch_size', 'x_i8', 'x_group', 'group_acc', 'x_orig_shape', 'num_groups', 'x_quant_min', 'out_shape', 'x_i32_grouped', 'x_quant_max', '... | None | null | 0 | 0 | 0 | null | 0 | null | The function (_reference_dqlinear_int4) defined within the public class called public.The function start at line 278 and ends at 404. It contains 78 lines of code and it has a cyclomatic complexity of 4. It takes 7 parameters, represented as [278.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _reference_dynamic_quantized_linear_4bit_groupwise | def _reference_dynamic_quantized_linear_4bit_groupwise(x_fp32,x_eps,weight_i4,weight_scale,weight_zero_point,# Not used because assuming weight is symmetricbias_fp32,group_size,):"""Reference implementation for dynamically quantized linear 4-bit groupwise operation.This function now delegates to the custom op implement... | 1 | 18 | 7 | 47 | 0 | 407 | 428 | 407 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_reference_dynamic_quantized_linear_4bit_groupwise) defined within the public class called public.The function start at line 407 and ends at 428. It contains 18 lines of code and it has a cyclomatic complexity of 1. It takes 7 parameters, represented as [407.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _filter_fn_for_dynamic_quantized_linear_4bit_groupwise | def _filter_fn_for_dynamic_quantized_linear_4bit_groupwise(match,original_graph,pattern_graph,) -> bool:weight_is_int4 = Falseact_quant_is_int8 = Falsefor node in match.nodes_map.values():if (isinstance(node, torch.fx.Node)and node.op == "call_function"and node.target == torch.ops.torchao.dequantize_affine.default):arg... | 12 | 25 | 3 | 153 | 3 | 431 | 455 | 431 | null | ['act_quant_is_int8', 'weight_is_int4', 'args'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_filter_fn_for_dynamic_quantized_linear_4bit_groupwise) defined within the public class called public.The function start at line 431 and ends at 455. It contains 25 lines of code and it has a cyclomatic complexity of 12. It takes 3 parameters, represented as [431.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _port_metadata_for_dynamic_quantized_linear_4bit_groupwise | def _port_metadata_for_dynamic_quantized_linear_4bit_groupwise(replacement_pattern: ReplacedPatterns,):"""Port metadata for dynamically quantized linear 4-bit groupwise operation.It custom_op node's metadata with corresponding linear node's metadata."""from torch.fx.traceback import NodeSource, NodeSourceActionlinear_n... | 6 | 21 | 1 | 118 | 2 | 458 | 483 | 458 | null | ['linear_node', 'int4_custom_op_node'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_port_metadata_for_dynamic_quantized_linear_4bit_groupwise) defined within the public class called public.The function start at line 458 and ends at 483. It contains 21 lines of code and it has a cyclomatic complexity of 6. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _qdq_quantized_conv2d | def _qdq_quantized_conv2d(x_i8,x_scale,x_zero_point,x_quant_min,x_quant_max,weight_i8,weight_scale,weight_zero_point,weight_quant_min,weight_quant_max,bias_fp32,out_scale,out_zero_point,out_quant_min,out_quant_max,):stride = [1, 1]padding = [0, 0]dilation = [1, 1]transposed = Falseoutput_padding = [0, 0]groups = 1x_fp3... | 1 | 49 | 15 | 174 | 10 | 486 | 534 | 486 | null | ['groups', 'dilation', 'output_padding', 'padding', 'transposed', 'weight_fp32', 'x_fp32', 'out_i8', 'stride', 'out_fp32'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_qdq_quantized_conv2d) defined within the public class called public.The function start at line 486 and ends at 534. It contains 49 lines of code and it has a cyclomatic complexity of 1. It takes 15 parameters, represented as [486.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _reference_quantized_conv2d | def _reference_quantized_conv2d(x_i8,x_scale,x_zero_point,x_quant_min,x_quant_max,weight_i8,weight_scale,weight_zero_point,weight_quant_min,weight_quant_max,bias_fp32,out_scale,out_zero_point,out_quant_min,out_quant_max,):stride = [1, 1]padding = [0, 0]dilation = [1, 1]transposed = Falseoutput_padding = [0, 0]groups = ... | 1 | 56 | 15 | 267 | 14 | 537 | 616 | 537 | null | ['bias_i32', 'groups', 'dilation', 'output_padding', 'padding', 'weight_i8', 'transposed', 'x_i16', 'weight_i16', 'bias_scale', 'acc_i32', 'out_i8', 'stride', 'x_i8'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_reference_quantized_conv2d) defined within the public class called public.The function start at line 537 and ends at 616. It contains 56 lines of code and it has a cyclomatic complexity of 1. It takes 15 parameters, represented as [537.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _qdq_quantized_add_relu | def _qdq_quantized_add_relu(x_i8,x_scale,x_zero_point,y_i8,y_scale,y_zero_point,out_scale,out_zero_point,quant_min,quant_max,):x_fp32 = torch.ops.quantized_decomposed.dequantize_per_tensor(x_i8, x_scale, x_zero_point, quant_min, quant_max, torch.int8)y_fp32 = torch.ops.quantized_decomposed.dequantize_per_tensor(y_i8, y... | 1 | 24 | 10 | 115 | 4 | 619 | 642 | 619 | null | ['x_fp32', 'out_i8', 'y_fp32', 'out_fp32'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_qdq_quantized_add_relu) defined within the public class called public.The function start at line 619 and ends at 642. It contains 24 lines of code and it has a cyclomatic complexity of 1. It takes 10 parameters, represented as [619.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _reference_quantized_add_relu | def _reference_quantized_add_relu(x_i8,x_scale,x_zero_point,y_i8,y_scale,y_zero_point,out_scale,out_zero_point,quant_min,quant_max,):"""See comments for `_reference_quantized_add` for more information onhow to derive the formula for out_i8 based on x_i8 and y_i8"""x_i32 = x_i8.to(torch.int32)y_i32 = y_i8.to(torch.int32... | 1 | 29 | 10 | 139 | 4 | 645 | 679 | 645 | null | ['y_i32', 'out_i8', 'out_i32', 'x_i32'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_reference_quantized_add_relu) defined within the public class called public.The function start at line 645 and ends at 679. It contains 29 lines of code and it has a cyclomatic complexity of 1. It takes 10 parameters, represented as [645.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _qdq_quantized_add | def _qdq_quantized_add(x_i8,x_scale,x_zero_point,y_i8,y_scale,y_zero_point,out_scale,out_zero_point,quant_min,quant_max,):x_fp32 = torch.ops.quantized_decomposed.dequantize_per_tensor(x_i8, x_scale, x_zero_point, quant_min, quant_max, torch.int8)y_fp32 = torch.ops.quantized_decomposed.dequantize_per_tensor(y_i8, y_scal... | 1 | 23 | 10 | 103 | 4 | 682 | 704 | 682 | null | ['x_fp32', 'out_i8', 'y_fp32', 'out_fp32'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_qdq_quantized_add) defined within the public class called public.The function start at line 682 and ends at 704. It contains 23 lines of code and it has a cyclomatic complexity of 1. It takes 10 parameters, represented as [682.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _reference_quantized_add | def _reference_quantized_add(x_i8,x_scale,x_zero_point,y_i8,y_scale,y_zero_point,out_scale,out_zero_point,quant_min,quant_max,):"""# How to Derive the formula for out_i8 based on x_i8 and y_i8# (since quantized add takes x_i8, y_i8 and their quantization parameters, and produce an out_i8)# out_i8 is quantized output, w... | 1 | 21 | 10 | 134 | 6 | 707 | 745 | 707 | null | ['x_i32', 'out_i32', 'quant_max', 'quant_min', 'out_i8', 'y_i32'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_reference_quantized_add) defined within the public class called public.The function start at line 707 and ends at 745. It contains 21 lines of code and it has a cyclomatic complexity of 1. It takes 10 parameters, represented as [707.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _qdq_quantized_max_pool2d | def _qdq_quantized_max_pool2d(x_i8,x_scale,x_zero_point,x_quant_min,x_quant_max,out_scale,out_zero_point,out_quant_min,out_quant_max,):kernel_size = 1stride = 1padding = 0dilation = 1ceil_mode = Falsex_fp32 = torch.ops.quantized_decomposed.dequantize_per_tensor(x_i8, x_scale, x_zero_point, x_quant_min, x_quant_max, tor... | 1 | 26 | 9 | 113 | 7 | 748 | 773 | 748 | null | ['kernel_size', 'dilation', 'ceil_mode', 'padding', 'x_fp32', 'out_i8', 'stride'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_qdq_quantized_max_pool2d) defined within the public class called public.The function start at line 748 and ends at 773. It contains 26 lines of code and it has a cyclomatic complexity of 1. It takes 9 parameters, represented as [748.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _reference_quantized_max_pool2d | def _reference_quantized_max_pool2d(x_i8,x_scale,x_zero_point,x_quant_min,x_quant_max,out_scale,out_zero_point,out_quant_min,out_quant_max,):kernel_size = 1stride = 1padding = 0dilation = 1ceil_mode = False# to preserve x_quant_min, x_quant_max in the graph for pattern matchingx_i8 = torch.clamp(x_i8, x_quant_min, x_qu... | 1 | 25 | 9 | 122 | 9 | 776 | 801 | 776 | null | ['x_i32', 'out_fp32', 'kernel_size', 'dilation', 'ceil_mode', 'padding', 'out_i8', 'stride', 'x_i8'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_reference_quantized_max_pool2d) defined within the public class called public.The function start at line 776 and ends at 801. It contains 25 lines of code and it has a cyclomatic complexity of 1. It takes 9 parameters, represented as [776.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _quantize_per_tensor_int8 | def _quantize_per_tensor_int8(x_fp32, scale, zero_point, quant_min, quant_max):x = torch.ops.quantized_decomposed.quantize_per_tensor(x_fp32, scale, zero_point, quant_min, quant_max, torch.int8)return x | 1 | 5 | 5 | 39 | 1 | 804 | 808 | 804 | null | ['x'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_quantize_per_tensor_int8) defined within the public class called public.The function start at line 804 and ends at 808. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [804.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _reference_quantize_per_tensor_int8 | def _reference_quantize_per_tensor_int8(x_fp32, scale, zero_point, quant_min, quant_max):# TODO: use out_dtype(mul, ...) here when the op is readyx = x_fp32 / scale# fp32# round modes might be different here# pytorch is rounding to even, which is also common for most of the backendsx = torch.round(x)# fp32x = x.to(dtyp... | 1 | 10 | 5 | 69 | 1 | 811 | 824 | 811 | null | ['x'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_reference_quantize_per_tensor_int8) defined within the public class called public.The function start at line 811 and ends at 824. It contains 10 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [811.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _dequantize_per_tensor_int8 | def _dequantize_per_tensor_int8(x_i8, scale, zero_point, quant_min, quant_max):x_fp32 = torch.ops.quantized_decomposed.dequantize_per_tensor(x_i8, scale, zero_point, quant_min, quant_max, torch.int8)return x_fp32 | 1 | 5 | 5 | 39 | 1 | 827 | 831 | 827 | null | ['x_fp32'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_dequantize_per_tensor_int8) defined within the public class called public.The function start at line 827 and ends at 831. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [827.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _reference_dequantize_per_tensor_int8 | def _reference_dequantize_per_tensor_int8(x_i8, scale, zero_point, quant_min, quant_max):# without using quant_min/max in clamp, the traced graph will not have quant_mi/max args.# This results in failure to match the pattern.# Therefore, we call a torch.ops.aten.clamp herex_i8 = torch.ops.aten.clamp(x_i8, quant_min, qu... | 1 | 5 | 5 | 55 | 1 | 834 | 844 | 834 | null | ['x_i8'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_reference_dequantize_per_tensor_int8) defined within the public class called public.The function start at line 834 and ends at 844. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [834.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _quantize_per_channel_int8 | def _quantize_per_channel_int8(x_fp32, scales, zero_points, ch_axis, quant_min, quant_max):out_i8 = torch.ops.quantized_decomposed.quantize_per_channel(x_fp32, scales, zero_points, ch_axis, quant_min, quant_max, torch.int8)return out_i8 | 1 | 7 | 6 | 43 | 1 | 847 | 853 | 847 | null | ['out_i8'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_quantize_per_channel_int8) defined within the public class called public.The function start at line 847 and ends at 853. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 6 parameters, represented as [847.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _reference_quantize_per_channel_int8 | def _reference_quantize_per_channel_int8(x_fp32, scales, zero_points, ch_axis, quant_min, quant_max):x_fp32 = torch.transpose(x_fp32, ch_axis, -1)out_i32 = torch.ops.aten.clamp(torch.round(x_fp32 / scales).to(torch.int32) + zero_points, quant_min, quant_max)out_i32 = torch.transpose(out_i32, ch_axis, -1)return out_i32.... | 1 | 9 | 6 | 82 | 2 | 856 | 864 | 856 | null | ['x_fp32', 'out_i32'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_reference_quantize_per_channel_int8) defined within the public class called public.The function start at line 856 and ends at 864. It contains 9 lines of code and it has a cyclomatic complexity of 1. It takes 6 parameters, represented as [856.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _dequantize_per_channel_int8 | def _dequantize_per_channel_int8(x_i8, scales, zero_points, ch_axis, quant_min, quant_max):# the following will be replaced as placeholdersout_fp32 = torch.ops.quantized_decomposed.dequantize_per_channel(x_i8, scales, zero_points, ch_axis, quant_min, quant_max, torch.int8)return out_fp32 | 1 | 7 | 6 | 43 | 1 | 867 | 874 | 867 | null | ['out_fp32'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_dequantize_per_channel_int8) defined within the public class called public.The function start at line 867 and ends at 874. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 6 parameters, represented as [867.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _reference_dequantize_per_channel_int8 | def _reference_dequantize_per_channel_int8(x_i8, scales, zero_points, ch_axis, quant_min, quant_max):# the following will be replaced as placeholders# in order to preserve the quant_min/quant_max args for pattern matching (e.g. matching for int4 quantized ops)# we call a torch.ops.aten.clamp herex_i8 = torch.ops.aten.c... | 1 | 9 | 6 | 85 | 3 | 877 | 888 | 877 | null | ['out_fp32', 'x_i32', 'x_i8'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_reference_dequantize_per_channel_int8) defined within the public class called public.The function start at line 877 and ends at 888. It contains 9 lines of code and it has a cyclomatic complexity of 1. It takes 6 parameters, represented as [877.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _replace_ph_qdq_per_channel_replacement | def _replace_ph_qdq_per_channel_replacement(gm: torch.fx.GraphModule):return _replace_literals_with_existing_placeholders(gm, exclude_literals=[-1], literal_to_ph_idx={1: 3, -128: 4, 127: 5}) | 1 | 4 | 1 | 40 | 0 | 891 | 894 | 891 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_replace_ph_qdq_per_channel_replacement) defined within the public class called public.The function start at line 891 and ends at 894. It contains 4 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | reference_representation_rewrite | def reference_representation_rewrite(model: GraphModule) -> GraphModule:_QUANTIZED_LINEAR_EXAMPLE_INPUTS = (torch.randint(-128, 127, (2, 5), dtype=torch.int8),torch.randn(1, dtype=torch.float),torch.zeros(1, dtype=torch.int),torch.tensor([-128], dtype=torch.int),torch.tensor([127], dtype=torch.int),torch.randint(-128, ... | 6 | 267 | 1 | 1,993 | 18 | 917 | 1,198 | 917 | null | ['matches', '_DYNAMIC_QUANTIZED_LINEAR_EXAMPLE_INPUTS', '_QUANTIZED_LINEAR_EXAMPLE_INPUTS', '_QUANTIZE_PER_TENSOR_INT8_EXAMPLE_INPUTS', '_QUANTIZED_MAX_POOL2D_EXAMPLE_INPUTS', '_QUANTIZED_CONV2d_EXAMPLE_INPUTS', 'pattern', '_DEQUANTIZE_PER_TENSOR_INT8_EXAMPLE_INPUTS', '_QUANTIZED_ADD_OR_ADD_RELU_EXAMPLE_INPUTS', '_DEQU... | None | null | 0 | 0 | 0 | null | 0 | null | The function (reference_representation_rewrite) defined within the public class called public.The function start at line 917 and ends at 1198. It contains 267 lines of code and it has a cyclomatic complexity of 6. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | is_per_tensor | def is_per_tensor(qscheme):return qscheme == torch.per_tensor_affine or qscheme == torch.per_tensor_symmetric | 2 | 2 | 1 | 17 | 0 | 58 | 59 | 58 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (is_per_tensor) defined within the public class called public.The function start at line 58 and ends at 59. It contains 2 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | is_per_channel | def is_per_channel(qscheme):return qscheme in [torch.per_channel_affine,torch.per_channel_affine_float_qparams,torch.per_channel_symmetric,] | 1 | 6 | 1 | 22 | 0 | 62 | 67 | 62 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (is_per_channel) defined within the public class called public.The function start at line 62 and ends at 67. It contains 6 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | getattr_from_fqn | def getattr_from_fqn(obj: Any, fqn: str) -> Any:"""Given an obj and a fqn such as "foo.bar.baz", returns gm.foo.bar.baz."""return functools.reduce(getattr, fqn.split("."), obj) | 1 | 2 | 2 | 30 | 0 | 70 | 74 | 70 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (getattr_from_fqn) defined within the public class called public.The function start at line 70 and ends at 74. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [70.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | to_underlying_dtype | def to_underlying_dtype(qdtype):DTYPE_MAPPING = {torch.quint8: torch.uint8,torch.qint8: torch.int8,torch.qint32: torch.int32,torch.quint4x2: torch.uint8,torch.quint2x4: torch.uint8,torch.uint8: torch.uint8,torch.int8: torch.int8,torch.uint16: torch.uint16,torch.int16: torch.int16,torch.int32: torch.int32,torch.float8_e... | 1 | 17 | 1 | 121 | 1 | 77 | 93 | 77 | null | ['DTYPE_MAPPING'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (to_underlying_dtype) defined within the public class called public.The function start at line 77 and ends at 93. It contains 17 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_qparam_dict | def get_qparam_dict(observer_or_fake_quant):from torchao.quantization.pt2e.observer import PlaceholderObserverqscheme = getattr(observer_or_fake_quant, "qscheme", None)dtype = observer_or_fake_quant.dtypeqparams = {"qscheme": qscheme, "dtype": dtype}if not qscheme or isinstance(observer_or_fake_quant, PlaceholderObserv... | 8 | 24 | 1 | 168 | 3 | 96 | 129 | 96 | null | ['qparams', 'dtype', 'qscheme'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_qparam_dict) defined within the public class called public.The function start at line 96 and ends at 129. It contains 24 lines of code and it has a cyclomatic complexity of 8. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | check_min_max_valid | def check_min_max_valid(min_val: torch.Tensor, max_val: torch.Tensor) -> bool:"""Checks if the given minimum and maximum values are valid, meaning thatthey exist and the min value is less than the max value."""if min_val.numel() == 0 or max_val.numel() == 0:warnings.warn("must run observer before calling calculate_qpar... | 7 | 20 | 2 | 112 | 0 | 132 | 158 | 132 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (check_min_max_valid) defined within the public class called public.The function start at line 132 and ends at 158. It contains 20 lines of code and it has a cyclomatic complexity of 7. It takes 2 parameters, represented as [132.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | calculate_qmin_qmax | def calculate_qmin_qmax(quant_min: int,quant_max: int,has_customized_qrange: bool,dtype: torch.dtype,reduce_range: bool,) -> tuple[int, int]:r"""Calculates actual qmin and qmax based on the quantization range,observer datatype and if range is reduced."""# TODO(jerryzh): Figure out why custom quant_min/quant_max are sti... | 15 | 49 | 5 | 322 | 1 | 161 | 220 | 161 | null | ['qrange_len'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (calculate_qmin_qmax) defined within the public class called public.The function start at line 161 and ends at 220. It contains 49 lines of code and it has a cyclomatic complexity of 15. It takes 5 parameters, represented as [161.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _parent_name | def _parent_name(target):"""Turn 'foo.bar' into ['foo', 'bar']"""r = target.rsplit(".", 1)if len(r) == 1:return "", r[0]else:return r[0], r[1] | 2 | 6 | 1 | 43 | 1 | 223 | 231 | 223 | null | ['r'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_parent_name) defined within the public class called public.The function start at line 223 and ends at 231. It contains 6 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | has_no_children_ignoring_parametrizations | def has_no_children_ignoring_parametrizations(module):"""Checks if module._modules is empty orif module is a parametrization, checks that module._modules only hasthe 'parametrizations' module"""if len(module._modules) == 0:return Trueelif is_parametrized(module):return len(module._modules) == 1 and "parametrizations" i... | 4 | 7 | 1 | 43 | 0 | 234 | 245 | 234 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (has_no_children_ignoring_parametrizations) defined within the public class called public.The function start at line 234 and ends at 245. It contains 7 lines of code and it has a cyclomatic complexity of 4. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _get_path_of_module | def _get_path_of_module(root: torch.nn.Module, submodule: torch.nn.Module) -> Optional[str]:"""Get the path (fully qualified name) of a submoduleExample::>> class M(torch.nn.Module): def __init__(self) -> None: self.linear = torch.nn.Linear(5, 5) def forward(self, x): return self.linear(x)>> m = M()>> l = m.linear>> _g... | 3 | 7 | 2 | 45 | 0 | 248 | 269 | 248 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_get_path_of_module) defined within the public class called public.The function start at line 248 and ends at 269. It contains 7 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [248.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _get_signature_locals | def _get_signature_locals(f: Callable, loc: dict[str, Any]) -> dict[str, Any]:"""Get local keyword argumentsExample::>> def f(self, a, b=9): pass>> loc = {"a": 6, "c": 7}>> _get_signature_locals(f, loc){"a": 6}"""return {k: v for k, v in loc.items() if k in signature(f).parameters} | 3 | 2 | 2 | 49 | 0 | 272 | 283 | 272 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_get_signature_locals) defined within the public class called public.The function start at line 272 and ends at 283. It contains 2 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [272.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _get_default_kwargs | def _get_default_kwargs(f: Callable) -> "OrderedDict[str, Any]":"""Get all default keyword arguments from function signatureExample::>> def f(self, a, b=9): pass>> _get_default_kwargs(f){"b": 9}"""kwargs = {}for name, param in signature(f).parameters.items():if param.default is not param.empty:kwargs[name] = param.defa... | 5 | 10 | 1 | 85 | 1 | 286 | 304 | 286 | null | ['kwargs'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_get_default_kwargs) defined within the public class called public.The function start at line 286 and ends at 304. It contains 10 lines of code and it has a cyclomatic complexity of 5. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _normalize_kwargs | def _normalize_kwargs(func: Callable, loc: dict[str, Any]) -> "OrderedDict[str, Any]":"""Given a function and local function arguments, normalize the keywordarguments by filling in default arguments from function signatureExample::>> def f(self, key1=3, key2=3): pass>> loc = {"key2": 6}>> _normalize_kwargs(f, loc){"key... | 3 | 8 | 2 | 64 | 3 | 307 | 326 | 307 | null | ['local_kwargs', 'normalized_kwargs', 'default_kwargs'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_normalize_kwargs) defined within the public class called public.The function start at line 307 and ends at 326. It contains 8 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [307.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | validate_qmin_qmax | def validate_qmin_qmax(quant_min: int, quant_max: int) -> None:r"""Validates that the user-specified quantization range is properly initializedand within the given bound supported by the observer dtype.To accommodate lower-bit quantization with respect to the existing torch.qint8 andtorch.quint8 datatypes, the user can... | 1 | 7 | 2 | 33 | 0 | 329 | 350 | 329 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (validate_qmin_qmax) defined within the public class called public.The function start at line 329 and ends at 350. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [329.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | determine_qparams | def determine_qparams(min_val: torch.Tensor,max_val: torch.Tensor,quant_min: int,quant_max: int,dtype: torch.dtype,eps: torch.Tensor,has_customized_qrange: bool,qscheme: torch.qscheme = torch.per_tensor_affine,) -> tuple[torch.Tensor, torch.Tensor]:r"""Calculates the quantization parameters, given min and maxvalue tens... | 10 | 51 | 8 | 513 | 6 | 357 | 432 | 357 | null | ['max_val_pos', 'zero_point', 'device', 'eps', 'scale', 'min_val_neg'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (determine_qparams) defined within the public class called public.The function start at line 357 and ends at 432. It contains 51 lines of code and it has a cyclomatic complexity of 10. It takes 8 parameters, represented as [357.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _get_num_pos_args | def _get_num_pos_args(f: Callable) -> int:"""Get number of positional args for a functionExample::>> def f(self, key1=3, key2=3): pass>> _get_num_pos_args(f)3"""return len(getfullargspec(f).args) | 1 | 2 | 1 | 20 | 0 | 435 | 445 | 435 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_get_num_pos_args) defined within the public class called public.The function start at line 435 and ends at 445. It contains 2 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_fqn_to_example_inputs._patched_module_call | def _patched_module_call(self, *args, **kwargs):submodule_example_inputs = list(args).copy()normalized_kwargs = _normalize_kwargs(self.forward, kwargs)# minus 1 to skipping counting `self`num_args = _get_num_pos_args(self.forward) - 1num_to_pop = num_args - len(submodule_example_inputs)while num_to_pop and normalized_k... | 4 | 14 | 3 | 112 | 0 | 479 | 493 | 479 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_fqn_to_example_inputs._patched_module_call) defined within the public class called public.The function start at line 479 and ends at 493. It contains 14 lines of code and it has a cyclomatic complexity of 4. It takes 3 parameters, represented as [479.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_fqn_to_example_inputs | def get_fqn_to_example_inputs(model: torch.nn.Module, example_inputs: tuple[Any, ...]) -> dict[str, tuple[Any, ...]]:"""Given a model and its example inputs, return a dictionary fromfully qualified name of submodules to example_inputs for that submodule,e.g. {"linear1": (tensor1,), "linear2": (tensor2,), "sub": (tensor... | 2 | 13 | 2 | 80 | 9 | 448 | 502 | 448 | null | ['orig_module_call', 'normalized_kwargs', 'submodule_example_inputs', 'submodule_example_inputs_tuple', 'num_to_pop', 'num_args', 'fqn', 'root', 'fqn_to_example_inputs'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_fqn_to_example_inputs) defined within the public class called public.The function start at line 448 and ends at 502. It contains 13 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [448.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_new_attr_name_with_prefix.get_new_attr_name_with_prefix.get_new_attr_name.get_attr_name | def get_attr_name(i: int):return prefix + str(i) | 1 | 2 | 1 | 14 | 0 | 514 | 515 | 514 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_new_attr_name_with_prefix.get_new_attr_name_with_prefix.get_new_attr_name.get_attr_name) defined within the public class called public.The function start at line 514 and ends at 515. It contains 2 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does... |
pytorch_ao | public | public | 0 | 0 | get_new_attr_name_with_prefix.get_new_attr_name | def get_new_attr_name(module: torch.nn.Module):def get_attr_name(i: int):return prefix + str(i)i = 0attr_name = get_attr_name(i)while hasattr(module, attr_name):i += 1attr_name = get_attr_name(i)return attr_name | 2 | 8 | 1 | 41 | 0 | 513 | 522 | 513 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_new_attr_name_with_prefix.get_new_attr_name) defined within the public class called public.The function start at line 513 and ends at 522. It contains 8 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_new_attr_name_with_prefix | def get_new_attr_name_with_prefix(prefix: str) -> Callable:prefix = prefix.replace(".", "_")def get_new_attr_name(module: torch.nn.Module):def get_attr_name(i: int):return prefix + str(i)i = 0attr_name = get_attr_name(i)while hasattr(module, attr_name):i += 1attr_name = get_attr_name(i)return attr_namereturn get_new_at... | 1 | 4 | 1 | 23 | 3 | 510 | 524 | 510 | null | ['prefix', 'i', 'attr_name'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_new_attr_name_with_prefix) defined within the public class called public.The function start at line 510 and ends at 524. It contains 4 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | create_getattr_from_value | def create_getattr_from_value(module: torch.nn.Module,graph: Graph,prefix: str,value: Any,device: Optional[torch.device] = None,) -> Node:"""Given a value of any type, creates a getattr node corresponding to the value andregisters the value as a buffer to the module."""get_new_attr_name = get_new_attr_name_with_prefix(... | 3 | 19 | 5 | 114 | 5 | 527 | 550 | 527 | null | ['attr_node', 'device', 'get_new_attr_name', 'new_value', 'attr_name'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (create_getattr_from_value) defined within the public class called public.The function start at line 527 and ends at 550. It contains 19 lines of code and it has a cyclomatic complexity of 3. It takes 5 parameters, represented as [527.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _is_connected | def _is_connected(source: torch.fx.Node, dest: torch.fx.Node) -> bool:"""Assuming dest is one of the ops inserted by quant workflow, this functionfinds if source and dest are connected. Assumption is that only quant workflowinserted ops exist between source and dest"""quant_workflow_ops = _QUANTIZE_OPS + _DEQUANTIZE_OP... | 3 | 10 | 2 | 84 | 2 | 567 | 581 | 567 | null | ['dest', 'quant_workflow_ops'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_is_connected) defined within the public class called public.The function start at line 567 and ends at 581. It contains 10 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [567.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _get_tensor_constant_from_node | def _get_tensor_constant_from_node(node, m):if node is None:return Noneassert node.op == "get_attr"target_atoms = node.target.split(".")attr_itr = mfor i, atom in enumerate(target_atoms):if not hasattr(attr_itr, atom):raise RuntimeError(f"Node referenced nonexistent target {'.'.join(target_atoms[:i])}")attr_itr = getat... | 4 | 13 | 2 | 68 | 2 | 584 | 596 | 584 | null | ['attr_itr', 'target_atoms'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_get_tensor_constant_from_node) defined within the public class called public.The function start at line 584 and ends at 596. It contains 13 lines of code and it has a cyclomatic complexity of 4. It takes 2 parameters, represented as [584.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _get_all_arguments | def _get_all_arguments(orig_args, orig_kwargs, args_schema):all_args = []for i, schema in enumerate(args_schema):if schema.name in orig_kwargs:all_args.append(orig_kwargs[schema.name])elif not schema.kwarg_only and i < len(orig_args):all_args.append(orig_args[i])else:all_args.append(schema.default_value)return all_args | 5 | 10 | 3 | 75 | 1 | 599 | 608 | 599 | null | ['all_args'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_get_all_arguments) defined within the public class called public.The function start at line 599 and ends at 608. It contains 10 lines of code and it has a cyclomatic complexity of 5. It takes 3 parameters, represented as [599.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _is_supported_batch_norm_for_training | def _is_supported_batch_norm_for_training(node: Node):"""Return True if the given node refers to an aten batch norm op QAT supports."""supported_ops = [torch.ops.aten.batch_norm.default,torch.ops.aten._native_batch_norm_legit.default,# Note: we won't need this op anymore after batch norm consolidation# For now, we need... | 1 | 8 | 1 | 58 | 1 | 611 | 624 | 611 | null | ['supported_ops'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_is_supported_batch_norm_for_training) defined within the public class called public.The function start at line 611 and ends at 624. It contains 8 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _is_conv_node | def _is_conv_node(n: Node):"""Return whether the node refers to an aten conv op."""return n.op == "call_function" and n.target in [torch.ops.aten.conv1d.default,torch.ops.aten.conv1d.padding,torch.ops.aten.conv2d.default,torch.ops.aten.conv2d.padding,torch.ops.aten.conv3d.default,torch.ops.aten.conv3d.padding,] | 2 | 9 | 1 | 81 | 0 | 627 | 638 | 627 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_is_conv_node) defined within the public class called public.The function start at line 627 and ends at 638. It contains 9 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _is_conv_transpose_node | def _is_conv_transpose_node(n: Node):"""Return whether the node refers to an aten conv_transpose op."""return n.op == "call_function" and n.target in [torch.ops.aten.conv_transpose1d,torch.ops.aten.conv_transpose1d.default,torch.ops.aten.conv_transpose2d,torch.ops.aten.conv_transpose2d.input,torch.ops.aten.conv_transpo... | 2 | 9 | 1 | 75 | 0 | 641 | 652 | 641 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_is_conv_transpose_node) defined within the public class called public.The function start at line 641 and ends at 652. It contains 9 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _is_conv_or_conv_transpose_node | def _is_conv_or_conv_transpose_node(n: Node):"""Return whether the node refers to an aten conv or conv transpose op."""return _is_conv_node(n) or _is_conv_transpose_node(n) | 2 | 2 | 1 | 18 | 0 | 655 | 659 | 655 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_is_conv_or_conv_transpose_node) defined within the public class called public.The function start at line 655 and ends at 659. It contains 2 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _is_conv_transpose_fn | def _is_conv_transpose_fn(conv_fn: Callable):return conv_fn in [F.conv_transpose1d, F.conv_transpose2d, F.conv_transpose3d] | 1 | 2 | 1 | 23 | 0 | 662 | 663 | 662 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_is_conv_transpose_fn) defined within the public class called public.The function start at line 662 and ends at 663. It contains 2 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _is_bn_node | def _is_bn_node(n: Node):return (_is_supported_batch_norm_for_training(n)or n.target == torch.ops.aten._native_batch_norm_legit_no_training.default) | 2 | 5 | 1 | 28 | 0 | 666 | 670 | 666 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_is_bn_node) defined within the public class called public.The function start at line 666 and ends at 670. It contains 5 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | fold_bn_weights_into_conv_node | def fold_bn_weights_into_conv_node(conv_node: Node,conv_weight_node: Node,conv_bias_node: Optional[Node],bn_node: Node,m: GraphModule,fake_fuse: bool = False,# removes the BN nodes but doesn't change the conv weights) -> None:# conv args: input, weight, bias, stride, padding, dilation, ...conv_w = _get_tensor_constant_... | 13 | 66 | 6 | 471 | 15 | 673 | 778 | 673 | null | ['bn_args', 'bn_eps', 'weight_attr_name', 'bn_b', 'conv_b', 'bias_attr_name', 'bn_rm', 'bn_rv', 'eps_arg_index', 'get_bias_node', 'bn_args_schema', 'conv_w', 'transpose', 'bn_w', 'conv_args'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (fold_bn_weights_into_conv_node) defined within the public class called public.The function start at line 673 and ends at 778. It contains 66 lines of code and it has a cyclomatic complexity of 13. It takes 6 parameters, represented as [673.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _fuse_conv_bn_ | def _fuse_conv_bn_(m: GraphModule) -> None:has_bn = any(_is_bn_node(n) for n in m.graph.nodes)if not has_bn:return# track which conv weights have been fused to avoid double fusingfused_convs_weight_nodes = set()for n in m.graph.nodes:if n.op != "call_function" or n.target not in (torch.ops.aten._native_batch_norm_legit... | 8 | 29 | 1 | 167 | 7 | 782 | 812 | 782 | null | ['has_bn', 'fused_convs_weight_nodes', 'conv_bias_node', 'n', 'conv_node', 'bn_node', 'conv_weight_node'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_fuse_conv_bn_) defined within the public class called public.The function start at line 782 and ends at 812. It contains 29 lines of code and it has a cyclomatic complexity of 8. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _get_node_name_to_scope | def _get_node_name_to_scope(model: GraphModule) -> dict[str, tuple[str, type]]:# TODO: move this information to fx node itselfnode_name_to_scope: dict[str, tuple[str, type]] = {}for n in model.graph.nodes:nn_module_stack = n.meta.get("nn_module_stack", None)current_scope = ("", type(None))if nn_module_stack:bt = list(n... | 3 | 10 | 1 | 115 | 3 | 815 | 825 | 815 | null | ['current_scope', 'nn_module_stack', 'bt'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_get_node_name_to_scope) defined within the public class called public.The function start at line 815 and ends at 825. It contains 10 lines of code and it has a cyclomatic complexity of 3. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _get_aten_graph_module_for_pattern | def _get_aten_graph_module_for_pattern(pattern: Callable,example_inputs: tuple[Any, ...],is_cuda: bool = False,**kwargs,) -> GraphModule:"""Convert the pattern to an FX graph with decomposed aten ops."""if is_cuda:example_inputs = tuple([x.cuda() if isinstance(x, torch.Tensor) else x for x in example_inputs])aten_patte... | 8 | 28 | 4 | 157 | 2 | 828 | 865 | 828 | null | ['example_inputs', 'aten_pattern'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_get_aten_graph_module_for_pattern) defined within the public class called public.The function start at line 828 and ends at 865. It contains 28 lines of code and it has a cyclomatic complexity of 8. It takes 4 parameters, represented as [828.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | remove_tensor_overload_for_qdq_ops | def remove_tensor_overload_for_qdq_ops(match_pattern: GraphModule) -> None:"""Remove .tensor overload for quantize/dequantize ops so that we canuse the match_pattern that we get from torchdynamo export to match the output of convert_pt2e"""_MAP = {torch.ops.quantized_decomposed.quantize_per_tensor.default: torch.ops.qu... | 4 | 17 | 1 | 210 | 1 | 868 | 887 | 868 | null | ['_MAP'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (remove_tensor_overload_for_qdq_ops) defined within the public class called public.The function start at line 868 and ends at 887. It contains 17 lines of code and it has a cyclomatic complexity of 4. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _is_literal | def _is_literal(arg):if isinstance(arg, (int, float)):return Trueif isinstance(arg, (tuple, list)):return all(map(_is_literal, arg))return False | 3 | 6 | 1 | 43 | 0 | 890 | 895 | 890 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_is_literal) defined within the public class called public.The function start at line 890 and ends at 895. It contains 6 lines of code and it has a cyclomatic complexity of 3. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _replace_literals_with_new_placeholders | def _replace_literals_with_new_placeholders(gm: torch.fx.GraphModule,merge_dup: bool = False,exclude_literals: Optional[list[Any]] = None,):"""Replace the literals in the graph with placeholder nodes that's created on the fly while wetraverse the graph, so that the literal arguments in the graph can be matched and repl... | 10 | 37 | 3 | 228 | 7 | 898 | 985 | 898 | null | ['in_spec', 'cnt', 'last_ph', 'exclude_literals', 'args_spec', 'ph_node', 'new_args'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_replace_literals_with_new_placeholders) defined within the public class called public.The function start at line 898 and ends at 985. It contains 37 lines of code and it has a cyclomatic complexity of 10. It takes 3 parameters, represented as [898.0] and does not return any value.. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.