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
transform_for_annotation
def transform_for_annotation(self, model: torch.fx.GraphModule) -> torch.fx.GraphModule:for quantizer in self.quantizers:model = quantizer.transform_for_annotation(model)return model
2
6
2
36
0
77
82
77
null
[]
None
null
0
0
0
null
0
null
The function (transform_for_annotation) defined within the public class called public.The function start at line 77 and ends at 82. It contains 6 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [77.0] and does not return any value..
pytorch_ao
public
public
0
0
validate
def validate(self, model: torch.fx.GraphModule) -> None:pass
1
2
2
16
0
84
85
84
null
[]
None
null
0
0
0
null
0
null
The function (validate) defined within the public class called public.The function start at line 84 and ends at 85. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [84.0] and does not return any value..
pytorch_ao
public
public
0
0
_maybe_duplicate_dq.maybe_replace_node
def maybe_replace_node(n: torch.fx.Node) -> torch.fx.Node:if n == dq_node:return new_nodeelse:return n
2
5
1
28
0
47
51
47
null
[]
None
null
0
0
0
null
0
null
The function (_maybe_duplicate_dq.maybe_replace_node) defined within the public class called public.The function start at line 47 and ends at 51. 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
_maybe_duplicate_dq
def _maybe_duplicate_dq(gm: torch.fx.GraphModule, dq_node: torch.fx.Node, user: torch.fx.Node):annotation = user.meta.get(Q_ANNOTATION_KEY, None)if not is_valid_annotation(annotation):returnwith gm.graph.inserting_after(dq_node):new_node = gm.graph.node_copy(dq_node)def maybe_replace_node(n: torch.fx.Node) -> torch.fx....
2
13
3
99
4
38
56
38
null
['annotation', 'new_args', 'new_node', 'new_kwargs']
None
null
0
0
0
null
0
null
The function (_maybe_duplicate_dq) defined within the public class called public.The function start at line 38 and ends at 56. It contains 13 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [38.0] and does not return any value..
pytorch_ao
public
public
0
0
call
def call(self, graph_module: torch.fx.GraphModule) -> PassResult:for node in graph_module.graph.nodes:if node.op == "call_function" and node.target in _DEQUANTIZE_OPS:dq_users = _filter_sym_size_users(node)if len(dq_users) <= 1:continue# Do not duplicate dq for dynamic quantization# Pattern: choose_qparam - getitem - q...
14
27
2
188
0
60
88
60
null
[]
None
null
0
0
0
null
0
null
The function (call) defined within the public class called public.The function start at line 60 and ends at 88. It contains 27 lines of code and it has a cyclomatic complexity of 14. It takes 2 parameters, represented as [60.0] and does not return any value..
pytorch_ao
public
public
0
0
get_embedding_operators_config
def get_embedding_operators_config() -> OperatorConfig:weight_quantization_spec = QuantizationSpec(dtype=torch.uint8,qscheme=torch.per_channel_affine_float_qparams,ch_axis=0,observer_or_fake_quant_ctr=PerChannelMinMaxObserver.with_args(eps=2**-12),)quantization_config = QuantizationConfig(None, None, weight_quantizatio...
1
14
0
98
3
32
45
32
null
['quantization_config', 'supported_config_and_operators', 'weight_quantization_spec']
None
null
0
0
0
null
0
null
The function (get_embedding_operators_config) defined within the public class called public.The function start at line 32 and ends at 45. It contains 14 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
__init__
def __init__(self) -> None:super().__init__()
1
2
1
14
0
49
50
49
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 49 and ends at 50. 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_supported_quantization_configs
def get_supported_quantization_configs(cls) -> list[QuantizationConfig]:op_configs: set[QuantizationConfig] = {spec for spec, _ in cls.get_supported_operators()}return list(op_configs)
2
5
1
35
0
53
57
53
null
[]
None
null
0
0
0
null
0
null
The function (get_supported_quantization_configs) defined within the public class called public.The function start at line 53 and ends at 57. 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
get_supported_operator_for_quantization_config
def get_supported_operator_for_quantization_config(cls, quantization_config: QuantizationConfig) -> list[OperatorPatternType]:for config, ops in cls.get_supported_operators():# note: this assumes each entry in cls.supported_spec_and_operators# corresponds to one spec, e.g. we don't have# [(spec1, op_list1), (spec1, op_...
3
7
2
35
0
60
71
60
null
[]
None
null
0
0
0
null
0
null
The function (get_supported_operator_for_quantization_config) defined within the public class called public.The function start at line 60 and ends at 71. It contains 7 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [60.0] and does not return any value..
pytorch_ao
public
public
0
0
annotate
def annotate(self, model: torch.fx.GraphModule) -> torch.fx.GraphModule:"""just handling global spec for now"""self._annotate_embedding_ops(model.graph)return model
1
3
2
30
0
73
76
73
null
[]
None
null
0
0
0
null
0
null
The function (annotate) defined within the public class called public.The function start at line 73 and ends at 76. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [73.0] and does not return any value..
pytorch_ao
public
public
0
0
_annotate_embedding_ops
def _annotate_embedding_ops(self, graph: torch.fx.Graph) -> None:embedding_config: OperatorConfig = get_embedding_operators_config()for node in graph.nodes:# Keep node parsing based annotations instead of module partitioners# just as an example of alternate ways of annotatingif (node.op == "call_function"and node.targe...
5
16
2
93
0
78
95
78
null
[]
None
null
0
0
0
null
0
null
The function (_annotate_embedding_ops) defined within the public class called public.The function start at line 78 and ends at 95. It contains 16 lines of code and it has a cyclomatic complexity of 5. It takes 2 parameters, represented as [78.0] and does not return any value..
pytorch_ao
public
public
0
0
validate
def validate(self, model: torch.fx.GraphModule) -> None:pass
1
2
2
16
0
97
98
97
null
[]
None
null
0
0
0
null
0
null
The function (validate) defined within the public class called public.The function start at line 97 and ends at 98. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [97.0] and does not return any value..
pytorch_ao
public
public
0
0
get_supported_operators
def get_supported_operators(cls) -> list[OperatorConfig]:return [get_embedding_operators_config()]
1
2
1
16
0
101
102
101
null
[]
None
null
0
0
0
null
0
null
The function (get_supported_operators) defined within the public class called public.The function start at line 101 and ends at 102. 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
_add_metadata
def _add_metadata(to_node: torch.fx.Node, from_node: torch.fx.Node) -> None:from_meta = from_node.metafor meta_name in _METADATA_TO_PORT:if meta_name in from_meta:to_node.meta[meta_name] = from_meta[meta_name]
3
5
2
47
1
53
57
53
null
['from_meta']
None
null
0
0
0
null
0
null
The function (_add_metadata) defined within the public class called public.The function start at line 53 and ends at 57. It contains 5 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [53.0] and does not return any value..
pytorch_ao
public
public
0
0
_has_quant_annotation
def _has_quant_annotation(node: torch.fx.Node) -> bool:return Q_ANNOTATION_KEY in node.meta
1
2
1
19
0
60
61
60
null
[]
None
null
0
0
0
null
0
null
The function (_has_quant_annotation) defined within the public class called public.The function start at line 60 and ends at 61. 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
_find_choose_qparams_node
def _find_choose_qparams_node(node: torch.fx.Node) -> Optional[torch.fx.Node]:# BFS to look for choose qparamsfrom collections import dequequeue = deque(list(node.users.keys()))while len(queue):n = queue.popleft()if n.op == "output":continueif n.op == "call_function" and n.target in _CHOOSE_QPARAMS_OPS:return nfor k in...
6
12
1
94
2
64
77
64
null
['queue', 'n']
None
null
0
0
0
null
0
null
The function (_find_choose_qparams_node) defined within the public class called public.The function start at line 64 and ends at 77. It contains 12 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_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
80
94
80
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 80 and ends at 94. It contains 10 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [80.0] and does not return any value..
pytorch_ao
public
public
0
0
_find_q_dq_node_for_user
def _find_q_dq_node_for_user(produer: torch.fx.Node, user: torch.fx.Node) -> tuple[Any, Any]:"""Find q, dq pair corresponding to [producer -> q -> dq -> user]Utils works by finding dq arg of user and ensuring it is connected toproducer"""dq_node = Nonefor n in user.args:if (isinstance(n, torch.fx.Node)and n.op == "call...
15
32
2
178
2
97
134
97
null
['dq_node', 'q_node']
None
null
0
0
0
null
0
null
The function (_find_q_dq_node_for_user) defined within the public class called public.The function start at line 97 and ends at 134. It contains 32 lines of code and it has a cyclomatic complexity of 15. It takes 2 parameters, represented as [97.0] and does not return any value..
pytorch_ao
public
public
0
0
_port_metadata_for_input_quant_nodes
def _port_metadata_for_input_quant_nodes(input_node: torch.fx.Node,node: torch.fx.Node,qspec: Optional[QuantizationSpecBase],):if qspec is None:returnis_dynamic_quant = getattr(qspec, "is_dynamic", None)if is_dynamic_quant is not None and is_dynamic_quant is True:choose_qparams_node = _find_choose_qparams_node(input_no...
15
55
3
384
9
137
194
137
null
['choose_qparams_node', 'choose_qparam_users', 'q_node_input', 'q_to_get_attr_nodes', 'is_dynamic_quant', 'dynamic_q_node', 'dynamic_dq_node', 'scale_node', 'dynamic_q_node_users']
None
null
0
0
0
null
0
null
The function (_port_metadata_for_input_quant_nodes) defined within the public class called public.The function start at line 137 and ends at 194. It contains 55 lines of code and it has a cyclomatic complexity of 15. It takes 3 parameters, represented as [137.0] and does not return any value..
pytorch_ao
public
public
0
0
_port_metadata_for_output_quant_nodes
def _port_metadata_for_output_quant_nodes(node: torch.fx.Node, qspec: Optional[QuantizationSpecBase]):if qspec is None:returnnode_users = _filter_sym_size_users(node)if len(node.users) == 0:returnif len(node_users) != 1:logger.warning(f"Expecting {node} to have single user")# noqa: G004q_node = node_users.pop()if q_nod...
6
17
2
91
2
197
215
197
null
['q_node', 'node_users']
None
null
0
0
0
null
0
null
The function (_port_metadata_for_output_quant_nodes) defined within the public class called public.The function start at line 197 and ends at 215. It contains 17 lines of code and it has a cyclomatic complexity of 6. It takes 2 parameters, represented as [197.0] and does not return any value..
pytorch_ao
public
public
0
0
call
def call(self, graph_module: torch.fx.GraphModule) -> PassResult:for node in graph_module.graph.nodes:annotation = node.meta.get(Q_ANNOTATION_KEY, None)if is_valid_annotation(annotation):input_qspec_map = node.meta[Q_ANNOTATION_KEY].input_qspec_mapoutput_qspec = node.meta[Q_ANNOTATION_KEY].output_qspecfor input_node, q...
4
10
2
94
0
272
281
272
null
[]
None
null
0
0
0
null
0
null
The function (call) defined within the public class called public.The function start at line 272 and ends at 281. It contains 10 lines of code and it has a cyclomatic complexity of 4. It takes 2 parameters, represented as [272.0] and does not return any value..
pytorch_ao
public
public
0
0
__post_init__
def __post_init__(self):# TODO: add init for quant_min/quant_max# quant_min must be less than quant_maxif (self.quant_min is not Noneand self.quant_max is not Noneand self.quant_min > self.quant_max):raise ValueError(f"quant_min {self.quant_min} must be <= quant_max {self.quant_max}.")# ch_axis must be less than the nu...
6
11
1
55
0
60
75
60
null
[]
None
null
0
0
0
null
0
null
The function (__post_init__) defined within the public class called public.The function start at line 60 and ends at 75. 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
transform_for_annotation
def transform_for_annotation(self, model: torch.fx.GraphModule) -> torch.fx.GraphModule:"""Allows for user defined transforms to run before annotating the graph.This allows quantizer to allow quantizing part of the model that are otherwise not quantizable.For example quantizer cana) decompose a compound operator like s...
1
4
2
22
0
149
161
149
null
[]
None
null
0
0
0
null
0
null
The function (transform_for_annotation) defined within the public class called public.The function start at line 149 and ends at 161. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [149.0] and does not return any value..
pytorch_ao
public
public
0
0
annotate
def annotate(self, model: torch.fx.GraphModule) -> torch.fx.GraphModule:pass
1
2
2
20
0
166
167
166
null
[]
None
null
0
0
0
null
0
null
The function (annotate) defined within the public class called public.The function start at line 166 and ends at 167. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [166.0] and does not return any value..
pytorch_ao
public
public
0
0
validate
def validate(self, model: torch.fx.GraphModule) -> None:pass
1
2
2
16
0
171
172
171
null
[]
None
null
0
0
0
null
0
null
The function (validate) defined within the public class called public.The function start at line 171 and ends at 172. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [171.0] and does not return any value..
pytorch_ao
public
public
0
0
prepare_obs_or_fq_callback
def prepare_obs_or_fq_callback(self,model: torch.fx.GraphModule,edge_or_node_to_obs_or_fq: dict[EdgeOrNode, ObserverOrFakeQuantize],) -> None:"""A callback that will be called after the observers or fake quants are createdfor each sharing group, but before they are inserted into the graph. Thecallback can be used to ma...
1
6
3
27
0
174
192
174
null
[]
None
null
0
0
0
null
0
null
The function (prepare_obs_or_fq_callback) defined within the public class called public.The function start at line 174 and ends at 192. It contains 6 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [174.0] and does not return any value..
pytorch_ao
public
public
0
0
get_input_act_qspec
def get_input_act_qspec(quantization_config: Optional[QuantizationConfig]):if quantization_config is None:return Noneif quantization_config.input_activation is None:return Nonequantization_spec: QuantizationSpec = quantization_config.input_activationassert quantization_spec.qscheme in [torch.per_tensor_affine,torch.per...
3
11
1
50
0
50
60
50
null
[]
None
null
0
0
0
null
0
null
The function (get_input_act_qspec) defined within the public class called public.The function start at line 50 and ends at 60. It contains 11 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_output_act_qspec
def get_output_act_qspec(quantization_config: Optional[QuantizationConfig]):if quantization_config is None:return Noneif quantization_config.output_activation is None:return Nonequantization_spec: QuantizationSpec = quantization_config.output_activationassert quantization_spec.qscheme in [torch.per_tensor_affine,torch....
3
11
1
50
0
63
73
63
null
[]
None
null
0
0
0
null
0
null
The function (get_output_act_qspec) defined within the public class called public.The function start at line 63 and ends at 73. It contains 11 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_weight_qspec
def get_weight_qspec(quantization_config: Optional[QuantizationConfig]):if quantization_config is None:return Noneassert quantization_config is not Noneif quantization_config.weight is None:return Nonequantization_spec: QuantizationSpec = quantization_config.weightif quantization_spec.qscheme not in [torch.per_tensor_s...
4
16
1
65
0
76
91
76
null
[]
None
null
0
0
0
null
0
null
The function (get_weight_qspec) defined within the public class called public.The function start at line 76 and ends at 91. It contains 16 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_bias_qspec
def get_bias_qspec(quantization_config: Optional[QuantizationConfig]):if quantization_config is None:return Noneassert quantization_config is not Noneif quantization_config.bias is None:return Nonequantization_spec: QuantizationSpec = quantization_config.biasassert quantization_spec.dtype == torch.float, ("Only float d...
3
11
1
52
0
94
104
94
null
[]
None
null
0
0
0
null
0
null
The function (get_bias_qspec) defined within the public class called public.The function start at line 94 and ends at 104. It contains 11 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
annotate_input_qspec_map
def annotate_input_qspec_map(node: Node, input_node: Node, qspec):quantization_annotation = node.meta.get(Q_ANNOTATION_KEY, QuantizationAnnotation())if quantization_annotation.input_qspec_map is None:quantization_annotation.input_qspec_map = {}quantization_annotation.input_qspec_map[input_node] = qspecnode.meta[Q_ANNOT...
2
6
3
56
1
107
112
107
null
['quantization_annotation']
None
null
0
0
0
null
0
null
The function (annotate_input_qspec_map) defined within the public class called public.The function start at line 107 and ends at 112. It contains 6 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [107.0] and does not return any value..
pytorch_ao
public
public
0
0
annotate_output_qspec
def annotate_output_qspec(node: Node, qspec):quantization_annotation = node.meta.get(Q_ANNOTATION_KEY, QuantizationAnnotation())quantization_annotation.output_qspec = qspecnode.meta[Q_ANNOTATION_KEY] = quantization_annotation
1
4
2
36
1
115
118
115
null
['quantization_annotation']
None
null
0
0
0
null
0
null
The function (annotate_output_qspec) defined within the public class called public.The function start at line 115 and ends at 118. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [115.0] and does not return any value..
pytorch_ao
public
public
0
0
get_module_name_filter.get_module_name_filter.module_name_filter._normalize_path
def _normalize_path(n):prefix = 0# TODO This is non standard behavior and should be removed when we migrate off capture_pre_autograd_graph.if n.startswith("L['self']."):prefix = len("L['self'].")return n[prefix:]
2
5
1
28
0
142
147
142
null
[]
None
null
0
0
0
null
0
null
The function (get_module_name_filter.get_module_name_filter.module_name_filter._normalize_path) defined within the public class called public.The function start at line 142 and ends at 147. 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...
pytorch_ao
public
public
0
0
get_module_name_filter.module_name_filter
def module_name_filter(n: Node) -> bool:# example: {#'L__self___sub': ("L['self'].sub", <class '....Sub'>),#'L__self___sub_linear': ("L['self'].sub.linear", <class 'torch.nn.modules.linear.Linear'>)# }# get_attr nodes doesn't have nn_module_stack?nn_module_stack = n.meta.get("nn_module_stack", {})def _normalize_path(n)...
2
5
1
46
0
134
150
134
null
[]
None
null
0
0
0
null
0
null
The function (get_module_name_filter.module_name_filter) defined within the public class called public.The function start at line 134 and ends at 150. 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
get_module_name_filter
def get_module_name_filter(module_name: str):"""Get the module_name_filter function for a given module name, the filter acceptsa node and checks if the node comes from a module that has certain module nameFor example:node: linear_op = call_function[...](...)# comes from a module with name blocks.sub.linear1>> module_na...
1
3
1
12
3
121
152
121
null
['prefix', 'nn_module_stack', 'names']
None
null
0
0
0
null
0
null
The function (get_module_name_filter) defined within the public class called public.The function start at line 121 and ends at 152. 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
is_valid_annotation
def is_valid_annotation(annotation: QuantizationAnnotation) -> bool:if annotation is None:return Falseinput_qspec_map = annotation.input_qspec_mapoutput_qspec = annotation.output_qspecif len(input_qspec_map) == 0 and output_qspec is None:return Falsereturn True
4
8
1
42
2
155
162
155
null
['input_qspec_map', 'output_qspec']
None
null
0
0
0
null
0
null
The function (is_valid_annotation) defined within the public class called public.The function start at line 155 and ends at 162. It contains 8 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
_skip_annotate
def _skip_annotate(nodes: list[Node], filter_fn: Optional[FilterFn] = None) -> bool:"""Determine whether to skip annotation for a list of nodes."""# 1) Skip annotate if any node is already annotatedif _is_any_annotated(nodes):return True# 2) Proceed annotate if a) a filter function is provided# and b) the given nodes l...
4
6
2
42
0
104
116
104
null
[]
None
null
0
0
0
null
0
null
The function (_skip_annotate) defined within the public class called public.The function start at line 104 and ends at 116. It contains 6 lines of code and it has a cyclomatic complexity of 4. It takes 2 parameters, represented as [104.0] and does not return any value..
pytorch_ao
public
public
0
0
_create_module_name_filter.check_all_nodes_from_module
def check_all_nodes_from_module(nodes: list[Node]) -> bool:all_nodes_from_module_name: bool = all(filter_fn(n) for n in nodes)return all_nodes_from_module_name
2
3
1
29
0
136
138
136
null
[]
None
null
0
0
0
null
0
null
The function (_create_module_name_filter.check_all_nodes_from_module) defined within the public class called public.The function start at line 136 and ends at 138. It contains 3 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
_create_module_name_filter
def _create_module_name_filter(module_name: str) -> FilterFn:"""Create a filter function for a given module name.The filter function takes a list of nodes (as determined by the annotate function)and return True if *all* nodes come from the specified module name, False otherwise.For example:linear_1: "f32[3, 10]" = torc...
1
4
1
20
1
119
140
119
null
['filter_fn']
None
null
0
0
0
null
0
null
The function (_create_module_name_filter) defined within the public class called public.The function start at line 119 and ends at 140. 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_operator_type_filter.operator_type_filter
def operator_type_filter(nodes: list[Node]):num_nodes_with_operator_type = sum(node.target == operator_type for node in nodes)if num_nodes_with_operator_type > 1:raise NotImplementedError(f"Several nodes within a single pattern are {operator_type}.")return num_nodes_with_operator_type == 1
3
9
1
39
0
160
168
160
null
[]
None
null
0
0
0
null
0
null
The function (_create_operator_type_filter.operator_type_filter) defined within the public class called public.The function start at line 160 and ends at 168. It contains 9 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
_create_operator_type_filter
def _create_operator_type_filter(operator_type: Callable,) -> FilterFn:"""Create a filter function for a given operator type.The filter function takes a list of nodes and returns True if it containsexactly one node with the specified operator type, False otherwise.For example:linear_1: "f32[3, 10]" = torch.ops.aten.lin...
1
5
1
15
1
143
170
143
null
['num_nodes_with_operator_type']
None
null
0
0
0
null
0
null
The function (_create_operator_type_filter) defined within the public class called public.The function start at line 143 and ends at 170. It contains 5 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
_global_config_filter
def _global_config_filter(nodes: list[Node]) -> bool:"""Filter function for global configuration.This filter function takes a list of nodes and returns True if there is exactly one nodein the list that is a default quantizable operation, False otherwise."""num_nodes_in_default_quantizable_ops = sum(node.target in defau...
3
9
1
41
1
173
186
173
null
['num_nodes_in_default_quantizable_ops']
None
null
0
0
0
null
0
null
The function (_global_config_filter) defined within the public class called public.The function start at line 173 and ends at 186. It contains 9 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
_map_module_function_to_aten_operator_type
def _map_module_function_to_aten_operator_type():module_function_to_aten_operator: dict[Callable, torch._ops.OpOverloadPacket] = {}map_list = (([torch.nn.Conv2d, F.conv1d], torch.ops.aten.conv1d.default),([torch.nn.Conv2d, F.conv2d], torch.ops.aten.conv2d.default),([torch.nn.Linear, F.linear], torch.ops.aten.linear.def...
2
40
0
274
1
189
228
189
null
['map_list']
None
null
0
0
0
null
0
null
The function (_map_module_function_to_aten_operator_type) defined within the public class called public.The function start at line 189 and ends at 228. It contains 40 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
_mark_nodes_as_annotated
def _mark_nodes_as_annotated(nodes: list[Node]):for node in nodes:if node is not None:if QUANT_ANNOTATION_KEY not in node.meta:node.meta[QUANT_ANNOTATION_KEY] = _X86InductorQuantizationAnnotation()node.meta[QUANT_ANNOTATION_KEY]._annotated = True
4
6
1
49
0
231
236
231
null
[]
None
null
0
0
0
null
0
null
The function (_mark_nodes_as_annotated) defined within the public class called public.The function start at line 231 and ends at 236. It contains 6 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_node_annotated
def _is_node_annotated(_node):"""return True if the node is annotated, otherwise return False"""return (QUANT_ANNOTATION_KEY in _node.metaand _node.meta[QUANT_ANNOTATION_KEY]._annotated)
2
5
1
23
0
239
246
239
null
[]
None
null
0
0
0
null
0
null
The function (_is_node_annotated) defined within the public class called public.The function start at line 239 and ends at 246. 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
_is_any_annotated
def _is_any_annotated(nodes: list[Node]):"""Given a list of nodes (that represents an operator pattern),check if any of the node is annotated, return True if any of the nodeis annotated, otherwise return False."""return any(_is_node_annotated(node) for node in nodes)
2
2
1
23
0
249
255
249
null
[]
None
null
0
0
0
null
0
null
The function (_is_any_annotated) defined within the public class called public.The function start at line 249 and ends at 255. 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_all_annotated
def _is_all_annotated(nodes: list[Node]):"""Given a list of nodes (that represents an operator pattern),return True if all of the node is annotated, otherwise return False."""return all(_is_node_annotated(node) for node in nodes)
2
2
1
23
0
258
263
258
null
[]
None
null
0
0
0
null
0
null
The function (_is_all_annotated) defined within the public class called public.The function start at line 258 and ends at 263. 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_quantized_op_pt2e
def _is_quantized_op_pt2e(node: torch.fx.Node):"""Used for pt2e flow to check if the node is a quantized node:Case1: the node has been annotated as output node of a fusion pattern.Case2: the node has been annotated as single quantized node."""if not _is_any_annotated([node]):# The node has not been annotated, directly ...
2
6
1
46
1
266
277
266
null
['quantization_annotation']
None
null
0
0
0
null
0
null
The function (_is_quantized_op_pt2e) defined within the public class called public.The function start at line 266 and ends at 277. 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
get_default_x86_inductor_quantization_config
def get_default_x86_inductor_quantization_config(is_qat: bool = False,is_dynamic: bool = False,reduce_range: bool = False,):"""reduce_range is False by default. Set it to True on earlier CPUs without VNNI to avoid accuracy issue."""extra_args: dict[str, Any] = {"eps": 2**-12}if is_qat:if is_dynamic:act_observer_or_fake...
7
55
3
210
6
281
343
281
null
['act_quantization_spec', 'act_observer_or_fake_quant_ctr', 'quantization_config', 'bias_quantization_spec', 'dynamic_quant_observer', 'weight_quantization_spec']
None
null
0
0
0
null
0
null
The function (get_default_x86_inductor_quantization_config) defined within the public class called public.The function start at line 281 and ends at 343. It contains 55 lines of code and it has a cyclomatic complexity of 7. It takes 3 parameters, represented as [281.0] and does not return any value..
pytorch_ao
public
public
0
0
get_x86_inductor_linear_dynamic_fp16_config
def get_x86_inductor_linear_dynamic_fp16_config():"""For linear_dynamic_fp16. The name may be confusing.The op's behavior is fp32_input * (fp16_weight -> to_fp32) -> fp32_output."""weight_quantization_spec = QuantizationSpec(dtype=torch.float16,observer_or_fake_quant_ctr=PlaceholderObserver,)quantization_config = Quant...
1
12
0
35
2
347
362
347
null
['quantization_config', 'weight_quantization_spec']
None
null
0
0
0
null
0
null
The function (get_x86_inductor_linear_dynamic_fp16_config) defined within the public class called public.The function start at line 347 and ends at 362. It contains 12 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
_annotate_nodes_not_quantize
def _annotate_nodes_not_quantize(nodes: Union[Node, list[Node]]) -> None:"""Annotate nodes to exclude them from quantization (their `quantization_config` is `None`)."""if not isinstance(nodes, list):nodes = [nodes]for node in nodes:node.meta[QUANT_ANNOTATION_KEY] = _X86InductorQuantizationAnnotation(_annotated=True)
3
7
1
50
1
365
372
365
null
['nodes']
None
null
0
0
0
null
0
null
The function (_annotate_nodes_not_quantize) defined within the public class called public.The function start at line 365 and ends at 372. It contains 7 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
_config_checker.wrapper
def wrapper(quantizer: "X86InductorQuantizer",name: Any,quantization_config: Optional["QuantizationConfig"],) -> "X86InductorQuantizer":if quantizer._need_skip_config(quantization_config):warnings.warn(f"Skip the quantization config for {name}.",)return quantizerreturn method(quantizer, name, quantization_config)
2
11
3
48
0
377
387
377
null
[]
None
null
0
0
0
null
0
null
The function (_config_checker.wrapper) defined within the public class called public.The function start at line 377 and ends at 387. It contains 11 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [377.0] and does not return any value..
pytorch_ao
public
public
0
0
_config_checker
def _config_checker(method: Callable) -> Callable:@functools.wraps(method)def wrapper(quantizer: "X86InductorQuantizer",name: Any,quantization_config: Optional["QuantizationConfig"],) -> "X86InductorQuantizer":if quantizer._need_skip_config(quantization_config):warnings.warn(f"Skip the quantization config for {name}.",...
1
4
1
20
0
375
389
375
null
[]
None
null
0
0
0
null
0
null
The function (_config_checker) defined within the public class called public.The function start at line 375 and ends at 389. 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
__init__
def __init__(self) -> None:super().__init__()self.global_config: Optional[QuantizationConfig] = Noneself.operator_type_qconfig: dict[torch._ops.OpOverloadPacket, Optional[QuantizationConfig]] = {}self.module_name_qconfig: dict[str, Optional[QuantizationConfig]] = {}
1
7
1
60
0
414
420
414
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 414 and ends at 420. It contains 7 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_current_quantization_mode
def _get_current_quantization_mode(self) -> _CurrentQuantizationMode:"""Retrieves the current quantization mode based on all configurations."""qat_state = Nonedynamic_state = None# As we use `_need_skip_config` to skip all invalid configurations,# we can safely assume that the all existing non-None configurations# have...
6
28
1
125
0
422
456
422
null
[]
None
null
0
0
0
null
0
null
The function (_get_current_quantization_mode) defined within the public class called public.The function start at line 422 and ends at 456. It contains 28 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
_need_skip_config
def _need_skip_config(self, quantization_config: Optional[QuantizationConfig]) -> bool:"""Check if the provided quantization config is valid for X86InductorQuantizer.Mixed static/dynamic configurations or mixed QAT/non-QAT configurations are not supported.To avoid such a mix, we compare the incoming configuration with ...
7
24
2
99
0
458
488
458
null
[]
None
null
0
0
0
null
0
null
The function (_need_skip_config) defined within the public class called public.The function start at line 458 and ends at 488. It contains 24 lines of code and it has a cyclomatic complexity of 7. It takes 2 parameters, represented as [458.0] and does not return any value..
pytorch_ao
public
public
0
0
set_global
def set_global(self, quantization_config: QuantizationConfig):if self._need_skip_config(quantization_config):warnings.warn("Skip the global quantization config.")return selfself.global_config = quantization_configreturn self
2
6
2
32
0
490
495
490
null
[]
None
null
0
0
0
null
0
null
The function (set_global) defined within the public class called public.The function start at line 490 and ends at 495. It contains 6 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [490.0] and does not return any value..
pytorch_ao
public
public
0
0
get_global_quantization_config
def get_global_quantization_config(self):if not isinstance(self.global_config, QuantizationConfig):warnings.warn("The global_config for X86InductorQuantizer is currently invalid. \Please ensure that you use set_global to establish the global quantization configuration.")return self.global_config
2
7
1
26
0
497
503
497
null
[]
None
null
0
0
0
null
0
null
The function (get_global_quantization_config) defined within the public class called public.The function start at line 497 and ends at 503. It contains 7 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
set_function_type_qconfig
def set_function_type_qconfig(self,function_type: Callable,quantization_config: Optional[QuantizationConfig],) -> "X86InductorQuantizer":if function_type in X86InductorQuantizer.module_function_to_aten_operator_type:self._set_aten_operator_qconfig(X86InductorQuantizer.module_function_to_aten_operator_type[function_type...
2
17
3
51
0
506
522
506
null
[]
None
null
0
0
0
null
0
null
The function (set_function_type_qconfig) defined within the public class called public.The function start at line 506 and ends at 522. It contains 17 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [506.0] and does not return any value..
pytorch_ao
public
public
0
0
set_module_type_qconfig
def set_module_type_qconfig(self,module_type: torch.nn.Module,quantization_config: Optional[QuantizationConfig],) -> "X86InductorQuantizer":if module_type in X86InductorQuantizer.module_function_to_aten_operator_type:self._set_aten_operator_qconfig(X86InductorQuantizer.module_function_to_aten_operator_type[module_type]...
2
15
3
55
0
525
539
525
null
[]
None
null
0
0
0
null
0
null
The function (set_module_type_qconfig) defined within the public class called public.The function start at line 525 and ends at 539. It contains 15 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [525.0] and does not return any value..
pytorch_ao
public
public
0
0
set_module_name_qconfig
def set_module_name_qconfig(self, module_name: str, quantization_config: Optional[QuantizationConfig]):"""Set quantization_config for a submodule with name: `module_name`, for example:quantizer.set_module_name_qconfig("blocks.sub"), it will quantize all supported operator/operatorpatterns in the submodule with this mod...
1
5
3
27
0
542
552
542
null
[]
None
null
0
0
0
null
0
null
The function (set_module_name_qconfig) defined within the public class called public.The function start at line 542 and ends at 552. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [542.0] and does not return any value..
pytorch_ao
public
public
0
0
_set_aten_operator_qconfig
def _set_aten_operator_qconfig(self,operator_type: torch._ops.OpOverloadPacket,quantization_config: Optional[QuantizationConfig],) -> "X86InductorQuantizer":if operator_type in quantizable_ops:self.operator_type_qconfig[operator_type] = quantization_configelse:warnings.warn(f"operator: Unable to quantize {operator} by ...
2
12
3
47
0
554
565
554
null
[]
None
null
0
0
0
null
0
null
The function (_set_aten_operator_qconfig) defined within the public class called public.The function start at line 554 and ends at 565. It contains 12 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [554.0] and does not return any value..
pytorch_ao
public
public
0
0
_annotate_conv_node_helper
def _annotate_conv_node_helper(self,conv_node: torch.fx.Node,annotate_output: bool,quantization_config: Optional[QuantizationConfig],) -> None:"""Helper function to annotate the conv node"""if quantization_config is None:_annotate_nodes_not_quantize(conv_node)returninput_qspec_map = {}input_node = conv_node.args[0]asse...
5
30
4
171
0
567
597
567
null
[]
None
null
0
0
0
null
0
null
The function (_annotate_conv_node_helper) defined within the public class called public.The function start at line 567 and ends at 597. It contains 30 lines of code and it has a cyclomatic complexity of 5. It takes 4 parameters, represented as [567.0] and does not return any value..
pytorch_ao
public
public
0
0
_annotate_linear_node_helper
def _annotate_linear_node_helper(self,linear_node: torch.fx.Node,annotate_output: bool,quantization_config: Optional[QuantizationConfig],) -> None:"""Helper function to annotate the linear node"""if quantization_config is None:_annotate_nodes_not_quantize(linear_node)returninput_qspec_map = {}assert linear_node.target ...
5
34
4
199
0
599
637
599
null
[]
None
null
0
0
0
null
0
null
The function (_annotate_linear_node_helper) defined within the public class called public.The function start at line 599 and ends at 637. It contains 34 lines of code and it has a cyclomatic complexity of 5. It takes 4 parameters, represented as [599.0] and does not return any value..
pytorch_ao
public
public
0
0
_get_output_nodes_of_partitions
def _get_output_nodes_of_partitions(self,partition_list: list[SourcePartition],) -> list[torch.fx.Node]:"""Helper function to get the output node list from partition list"""output_node_list = []for partition in partition_list:if len(partition.output_nodes) > 1:raise ValueError("Input partition has more than one output ...
4
16
2
86
0
639
655
639
null
[]
None
null
0
0
0
null
0
null
The function (_get_output_nodes_of_partitions) defined within the public class called public.The function start at line 639 and ends at 655. It contains 16 lines of code and it has a cyclomatic complexity of 4. It takes 2 parameters, represented as [639.0] and does not return any value..
pytorch_ao
public
public
0
0
_get_input_idx_for_binary_node
def _get_input_idx_for_binary_node(self,conv_gemm_node: torch.fx.Node,binary_node: torch.fx.Node,):"""Helper function to check conv_gemm and extra input node indexfor binary node fused with conv_gemm."""conv_gemm_node_idx = Noneextra_input_node_idx = Noneif (binary_node.args[0].op == "call_function") and (# type: ignor...
5
20
3
110
0
657
679
657
null
[]
None
null
0
0
0
null
0
null
The function (_get_input_idx_for_binary_node) defined within the public class called public.The function start at line 657 and ends at 679. It contains 20 lines of code and it has a cyclomatic complexity of 5. It takes 3 parameters, represented as [657.0] and does not return any value..
pytorch_ao
public
public
0
0
annotate
def annotate(self, model: torch.fx.GraphModule) -> torch.fx.GraphModule:"""Annotate the given model with quantization configurations.Annotation contracts:1. Annotate each node according to the user's qconfig in the following order:`module_name_qconfig`, `operator_type_qconfig`, and `global_config`.2. Avoid re-annotatin...
4
17
2
98
0
681
720
681
null
[]
None
null
0
0
0
null
0
null
The function (annotate) defined within the public class called public.The function start at line 681 and ends at 720. It contains 17 lines of code and it has a cyclomatic complexity of 4. It takes 2 parameters, represented as [681.0] and does not return any value..
pytorch_ao
public
public
0
0
_annotate_with_config
def _annotate_with_config(self,model: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: FilterFn,) -> None:"""Annotate the model with the given quantization configuration.High-level description of quantization recipe for X86 Inductor Backend:Step 1: Apply quantization recipe for fusion p...
1
13
4
78
0
722
750
722
null
[]
None
null
0
0
0
null
0
null
The function (_annotate_with_config) defined within the public class called public.The function start at line 722 and ends at 750. It contains 13 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [722.0] and does not return any value..
pytorch_ao
public
public
0
0
_annotate_qat_conv2d_fusion_pattern
def _annotate_qat_conv2d_fusion_pattern(self,model: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[FilterFn] = None,):# Annotate QAT Specific patternsself._annotate_qat_conv2d_bn_binary_unary(model, quantization_config, filter_fn)self._annotate_qat_conv2d_bn_binary(model, qua...
1
10
4
70
0
752
762
752
null
[]
None
null
0
0
0
null
0
null
The function (_annotate_qat_conv2d_fusion_pattern) defined within the public class called public.The function start at line 752 and ends at 762. It contains 10 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [752.0] and does not return any value..
pytorch_ao
public
public
0
0
_annotate_qat_conv2d_bn_binary_unary
def _annotate_qat_conv2d_bn_binary_unary(self,gm: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[FilterFn] = None,) -> None:fused_partitions = find_sequential_partitions(gm, [torch.nn.Conv2d, torch.nn.BatchNorm2d, operator.add, torch.nn.ReLU])for fused_partition in fused_part...
10
70
4
340
0
764
840
764
null
[]
None
null
0
0
0
null
0
null
The function (_annotate_qat_conv2d_bn_binary_unary) defined within the public class called public.The function start at line 764 and ends at 840. It contains 70 lines of code and it has a cyclomatic complexity of 10. It takes 4 parameters, represented as [764.0] and does not return any value..
pytorch_ao
public
public
0
0
_annotate_qat_conv2d_bn_binary
def _annotate_qat_conv2d_bn_binary(self,gm: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[FilterFn] = None,) -> None:fused_partitions = find_sequential_partitions(gm, [torch.nn.Conv2d, torch.nn.BatchNorm2d, operator.add])for fused_partition in fused_partitions:conv_partition...
10
56
4
292
0
842
904
842
null
[]
None
null
0
0
0
null
0
null
The function (_annotate_qat_conv2d_bn_binary) defined within the public class called public.The function start at line 842 and ends at 904. It contains 56 lines of code and it has a cyclomatic complexity of 10. It takes 4 parameters, represented as [842.0] and does not return any value..
pytorch_ao
public
public
0
0
_annotate_qat_conv2d_bn_unary
def _annotate_qat_conv2d_bn_unary(self,gm: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[FilterFn] = None,) -> None:fused_partitions = []unary_patterns = [[torch.nn.Conv2d, torch.nn.BatchNorm2d, torch.nn.ReLU],[torch.nn.Conv2d, torch.nn.BatchNorm2d, torch.nn.Hardtanh],[torch...
8
49
4
317
0
906
960
906
null
[]
None
null
0
0
0
null
0
null
The function (_annotate_qat_conv2d_bn_unary) defined within the public class called public.The function start at line 906 and ends at 960. It contains 49 lines of code and it has a cyclomatic complexity of 8. It takes 4 parameters, represented as [906.0] and does not return any value..
pytorch_ao
public
public
0
0
_annotate_qat_conv2d_bn
def _annotate_qat_conv2d_bn(self,gm: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[FilterFn] = None,) -> None:fused_partitions = find_sequential_partitions(gm, [torch.nn.Conv2d, torch.nn.BatchNorm2d])for fused_partition in fused_partitions:conv_partition, bn_partition = fuse...
6
35
4
185
0
962
1,000
962
null
[]
None
null
0
0
0
null
0
null
The function (_annotate_qat_conv2d_bn) defined within the public class called public.The function start at line 962 and ends at 1000. It contains 35 lines of code and it has a cyclomatic complexity of 6. It takes 4 parameters, represented as [962.0] and does not return any value..
pytorch_ao
public
public
0
0
_annotate_conv2d_fusion_pattern
def _annotate_conv2d_fusion_pattern(self,model: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[FilterFn] = None,):if (quantization_config is None) or (quantization_config.is_qat):# Annotate QAT specific pattern: mainly due to BN not folded in prepare_qatself._annotate_qat_con...
3
14
4
93
0
1,002
1,016
1,002
null
[]
None
null
0
0
0
null
0
null
The function (_annotate_conv2d_fusion_pattern) defined within the public class called public.The function start at line 1002 and ends at 1016. It contains 14 lines of code and it has a cyclomatic complexity of 3. It takes 4 parameters, represented as [1002.0] and does not return any value..
pytorch_ao
public
public
0
0
_annotate_linear_fusion_pattern
def _annotate_linear_fusion_pattern(self,model: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[FilterFn] = None,):self._annotate_linear_binary_unary(model, quantization_config, filter_fn)self._annotate_linear_unary(model, quantization_config, filter_fn)self._annotate_linear(m...
1
9
4
60
0
1,018
1,026
1,018
null
[]
None
null
0
0
0
null
0
null
The function (_annotate_linear_fusion_pattern) defined within the public class called public.The function start at line 1018 and ends at 1026. It contains 9 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [1018.0] and does not return any value..
pytorch_ao
public
public
0
0
_annotate_matmul
def _annotate_matmul(self,model: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[FilterFn] = None,):for node in model.graph.nodes:if node.target != torch.ops.aten.matmul.default:continueif _skip_annotate([node], filter_fn):continueif quantization_config is None:_annotate_nodes...
6
23
4
121
0
1,028
1,052
1,028
null
[]
None
null
0
0
0
null
0
null
The function (_annotate_matmul) defined within the public class called public.The function start at line 1028 and ends at 1052. It contains 23 lines of code and it has a cyclomatic complexity of 6. It takes 4 parameters, represented as [1028.0] and does not return any value..
pytorch_ao
public
public
0
0
_annotate_conv2d_binary_unary
def _annotate_conv2d_binary_unary(self,gm: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[FilterFn] = None,) -> None:# Conv2d + add + unary opfused_partitions = find_sequential_partitions(gm, [torch.nn.Conv2d, operator.add, torch.nn.ReLU])for fused_partition in fused_partitio...
10
47
4
261
0
1,054
1,105
1,054
null
[]
None
null
0
0
0
null
0
null
The function (_annotate_conv2d_binary_unary) defined within the public class called public.The function start at line 1054 and ends at 1105. It contains 47 lines of code and it has a cyclomatic complexity of 10. It takes 4 parameters, represented as [1054.0] and does not return any value..
pytorch_ao
public
public
0
0
_annotate_conv2d_binary
def _annotate_conv2d_binary(self,gm: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[FilterFn] = None,) -> None:# Conv2d + addfused_partitions = find_sequential_partitions(gm, [torch.nn.Conv2d, operator.add])for fused_partition in fused_partitions:conv_partition, binary_partit...
10
45
4
238
0
1,107
1,156
1,107
null
[]
None
null
0
0
0
null
0
null
The function (_annotate_conv2d_binary) defined within the public class called public.The function start at line 1107 and ends at 1156. It contains 45 lines of code and it has a cyclomatic complexity of 10. It takes 4 parameters, represented as [1107.0] and does not return any value..
pytorch_ao
public
public
0
0
_annotate_conv2d_unary
def _annotate_conv2d_unary(self,gm: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[FilterFn] = None,) -> None:fused_partitions = []unary_patterns = [[torch.nn.Conv2d, torch.nn.ReLU],[torch.nn.Conv2d, torch.nn.Hardtanh],[torch.nn.Conv2d, torch.nn.Hardswish],[torch.nn.Conv2d, t...
8
39
4
261
0
1,158
1,200
1,158
null
[]
None
null
0
0
0
null
0
null
The function (_annotate_conv2d_unary) defined within the public class called public.The function start at line 1158 and ends at 1200. It contains 39 lines of code and it has a cyclomatic complexity of 8. It takes 4 parameters, represented as [1158.0] and does not return any value..
pytorch_ao
public
public
0
0
_annotate_conv2d
def _annotate_conv2d(self,gm: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[FilterFn] = None,) -> None:conv_partitions = get_source_partitions(gm.graph, [torch.nn.Conv2d, torch.nn.functional.conv2d])conv_partitions = list(itertools.chain.from_iterable(conv_partitions.values(...
6
22
4
151
0
1,202
1,224
1,202
null
[]
None
null
0
0
0
null
0
null
The function (_annotate_conv2d) defined within the public class called public.The function start at line 1202 and ends at 1224. It contains 22 lines of code and it has a cyclomatic complexity of 6. It takes 4 parameters, represented as [1202.0] and does not return any value..
pytorch_ao
public
public
0
0
_annotate_maxpool2d
def _annotate_maxpool2d(self,node: Node,quantization_config: Optional[QuantizationConfig],) -> None:if node.target is not torch.ops.aten.max_pool2d.default:returnif quantization_config is None:_annotate_nodes_not_quantize(node)returnmaxpool_node = nodeif _is_any_annotated([maxpool_node,]):returninput_node = maxpool_nod...
4
26
3
109
0
1,226
1,253
1,226
null
[]
None
null
0
0
0
null
0
null
The function (_annotate_maxpool2d) defined within the public class called public.The function start at line 1226 and ends at 1253. It contains 26 lines of code and it has a cyclomatic complexity of 4. It takes 3 parameters, represented as [1226.0] and does not return any value..
pytorch_ao
public
public
0
0
_annotate_cat
def _annotate_cat(self, node: Node, quantization_config: QuantizationConfig) -> None:if quantization_config is None:_annotate_nodes_not_quantize(node)returncat_node = nodeinput_nodes = cat_node.args[0]assert isinstance(input_nodes, Sequence)first_input_node = input_nodes[0]input_qspec_map = {}assert isinstance(first_in...
4
26
3
136
0
1,255
1,283
1,255
null
[]
None
null
0
0
0
null
0
null
The function (_annotate_cat) defined within the public class called public.The function start at line 1255 and ends at 1283. It contains 26 lines of code and it has a cyclomatic complexity of 4. It takes 3 parameters, represented as [1255.0] and does not return any value..
pytorch_ao
public
public
0
0
_annotate_propagation_quantizable_pattern_entry
def _annotate_propagation_quantizable_pattern_entry(self,gm: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[FilterFn] = None,):for node in gm.graph.nodes:self._annotate_propagation_quantizable_pattern(node, quantization_config, filter_fn)
2
10
4
49
0
1,285
1,294
1,285
null
[]
None
null
0
0
0
null
0
null
The function (_annotate_propagation_quantizable_pattern_entry) defined within the public class called public.The function start at line 1285 and ends at 1294. It contains 10 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [1285.0] and does not return any value..
pytorch_ao
public
public
0
0
_annotate_propagation_quantizable_pattern.is_all_inputs_connected_to_quantized_op
def is_all_inputs_connected_to_quantized_op(input_nodes):# Ensure all the inputs connect to fusion pattern or quantized nodefor input_node in input_nodes:if not _is_quantized_op_pt2e(input_node):return Falsereturn True
3
5
1
21
0
1,306
1,311
1,306
null
[]
None
null
0
0
0
null
0
null
The function (_annotate_propagation_quantizable_pattern.is_all_inputs_connected_to_quantized_op) defined within the public class called public.The function start at line 1306 and ends at 1311. It contains 5 lines of code and it has a cyclomatic complexity of 3. The function does not take any parameters and does not ret...
pytorch_ao
public
public
0
0
_annotate_propagation_quantizable_pattern
def _annotate_propagation_quantizable_pattern(self, node: Node, quantization_config, filter_fn) -> None:# Propagate annotation to quantizable patterns.if ((node.target in propagation_quantizable_ops)and (not _is_any_annotated([node]))and (node.op == "call_function")):def is_all_inputs_connected_to_quantized_op(input_no...
16
53
4
262
0
1,296
1,361
1,296
null
[]
None
null
0
0
0
null
0
null
The function (_annotate_propagation_quantizable_pattern) defined within the public class called public.The function start at line 1296 and ends at 1361. It contains 53 lines of code and it has a cyclomatic complexity of 16. It takes 4 parameters, represented as [1296.0] and does not return any value..
pytorch_ao
public
public
0
0
_annotate_output_share_observer_as_input
def _annotate_output_share_observer_as_input(self, input_node: Node, source_node: Node):source_node_quantization_annotation = (source_node.meta[QUANT_ANNOTATION_KEY]if QUANT_ANNOTATION_KEY in source_node.metaelse None)if (source_node_quantization_annotationand source_node_quantization_annotation._is_output_of_quantized...
4
17
3
56
0
1,363
1,379
1,363
null
[]
None
null
0
0
0
null
0
null
The function (_annotate_output_share_observer_as_input) defined within the public class called public.The function start at line 1363 and ends at 1379. It contains 17 lines of code and it has a cyclomatic complexity of 4. It takes 3 parameters, represented as [1363.0] and does not return any value..
pytorch_ao
public
public
0
0
_annotate_output_for_int8_in_int8_out_pattern_entry
def _annotate_output_for_int8_in_int8_out_pattern_entry(self,model: torch.fx.GraphModule,):for node in model.graph.nodes:self._annotate_output_for_int8_in_int8_out_pattern(node)
2
6
2
29
0
1,381
1,386
1,381
null
[]
None
null
0
0
0
null
0
null
The function (_annotate_output_for_int8_in_int8_out_pattern_entry) defined within the public class called public.The function start at line 1381 and ends at 1386. It contains 6 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [1381.0] and does not return any value..
pytorch_ao
public
public
0
0
_annotate_output_for_int8_in_int8_out_pattern
def _annotate_output_for_int8_in_int8_out_pattern(self,node: Node,) -> None:r"""Check and insert observer at output of node in int8_in_int8_out_ops if needed.Recipe refers to https://github.com/intel/intel-extension-for-pytorch/blob/90d19323d96afc53fcc22ba5a7bb3fb07fdd6c1c/intel_extension_for_pytorch/quantization/_util...
8
34
2
154
0
1,388
1,429
1,388
null
[]
None
null
0
0
0
null
0
null
The function (_annotate_output_for_int8_in_int8_out_pattern) defined within the public class called public.The function start at line 1388 and ends at 1429. It contains 34 lines of code and it has a cyclomatic complexity of 8. It takes 2 parameters, represented as [1388.0] and does not return any value..
pytorch_ao
public
public
0
0
_annotate_linear
def _annotate_linear(self,gm: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[FilterFn] = None,) -> None:linear_partitions = get_source_partitions(gm.graph, [torch.nn.Linear, torch.nn.functional.linear])linear_partitions = list(itertools.chain.from_iterable(linear_partitions.v...
6
25
4
153
0
1,431
1,456
1,431
null
[]
None
null
0
0
0
null
0
null
The function (_annotate_linear) defined within the public class called public.The function start at line 1431 and ends at 1456. It contains 25 lines of code and it has a cyclomatic complexity of 6. It takes 4 parameters, represented as [1431.0] and does not return any value..
pytorch_ao
public
public
0
0
_annotate_linear_unary
def _annotate_linear_unary(self,gm: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[FilterFn] = None,) -> None:postop_list = [torch.nn.ReLU,torch.nn.LeakyReLU,torch.nn.Tanh,torch.nn.GELU,]fused_partitions: list[tuple] = []for postop in postop_list:fused_partitions = fused_part...
7
36
4
197
0
1,458
1,495
1,458
null
[]
None
null
0
0
0
null
0
null
The function (_annotate_linear_unary) defined within the public class called public.The function start at line 1458 and ends at 1495. It contains 36 lines of code and it has a cyclomatic complexity of 7. It takes 4 parameters, represented as [1458.0] and does not return any value..
pytorch_ao
public
public
0
0
_annotate_linear_binary_unary
def _annotate_linear_binary_unary(self,gm: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[FilterFn] = None,) -> None:# linear + binary_op + (optional) unary opbinary_op_list = [operator.add]unary_op_list = [torch.nn.ReLU, None]combinations = itertools.product(binary_op_list, ...
15
80
4
359
0
1,497
1,582
1,497
null
[]
None
null
0
0
0
null
0
null
The function (_annotate_linear_binary_unary) defined within the public class called public.The function start at line 1497 and ends at 1582. It contains 80 lines of code and it has a cyclomatic complexity of 15. It takes 4 parameters, represented as [1497.0] and does not return any value..
pytorch_ao
public
public
0
0
_annotate_mul_tensor._is_tensor
def _is_tensor(n: Node):return isinstance(n, Node) and isinstance(n.meta["val"], torch._subclasses.fake_tensor.FakeTensor)
2
4
1
32
0
1,590
1,593
1,590
null
[]
None
null
0
0
0
null
0
null
The function (_annotate_mul_tensor._is_tensor) defined within the public class called public.The function start at line 1590 and ends at 1593. It contains 4 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
_annotate_mul_tensor._same_shape
def _same_shape(n1: Node, n2: Node):return n1.meta["val"].shape == n2.meta["val"].shape
1
2
2
29
0
1,595
1,596
1,595
null
[]
None
null
0
0
0
null
0
null
The function (_annotate_mul_tensor._same_shape) defined within the public class called public.The function start at line 1595 and ends at 1596. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [1595.0] and does not return any value..
pytorch_ao
public
public
0
0
_annotate_mul_tensor
def _annotate_mul_tensor(self,model: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[FilterFn] = None,):def _is_tensor(n: Node):return isinstance(n, Node) and isinstance(n.meta["val"], torch._subclasses.fake_tensor.FakeTensor)def _same_shape(n1: Node, n2: Node):return n1.meta[...
9
30
4
179
0
1,584
1,624
1,584
null
[]
None
null
0
0
0
null
0
null
The function (_annotate_mul_tensor) defined within the public class called public.The function start at line 1584 and ends at 1624. It contains 30 lines of code and it has a cyclomatic complexity of 9. It takes 4 parameters, represented as [1584.0] and does not return any value..
pytorch_ao
public
public
0
0
validate
def validate(self, model: torch.fx.GraphModule) -> None:pass
1
2
2
16
0
1,626
1,627
1,626
null
[]
None
null
0
0
0
null
0
null
The function (validate) defined within the public class called public.The function start at line 1626 and ends at 1627. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [1626.0] and does not return any value..
pytorch_ao
public
public
0
0
get_default_xpu_inductor_quantization_config
def get_default_xpu_inductor_quantization_config():extra_args: dict[str, Any] = {"eps": 2**-12}act_observer_or_fake_quant_ctr = HistogramObserveract_quantization_spec = QuantizationSpec(dtype=torch.int8,quant_min=-128,quant_max=127,qscheme=torch.per_tensor_affine,is_dynamic=False,observer_or_fake_quant_ctr=act_observer...
1
36
0
135
5
39
77
39
null
['act_quantization_spec', 'act_observer_or_fake_quant_ctr', 'quantization_config', 'bias_quantization_spec', 'weight_quantization_spec']
None
null
0
0
0
null
0
null
The function (get_default_xpu_inductor_quantization_config) defined within the public class called public.The function start at line 39 and ends at 77. It contains 36 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
__init__
def __init__(self) -> None:super().__init__()
1
2
1
14
0
89
90
89
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 89 and ends at 90. 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
_annotate_qat_conv2d_fusion_pattern
def _annotate_qat_conv2d_fusion_pattern(self,model: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[FilterFn] = None,):pass
1
7
4
31
0
102
108
102
null
[]
None
null
0
0
0
null
0
null
The function (_annotate_qat_conv2d_fusion_pattern) defined within the public class called public.The function start at line 102 and ends at 108. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [102.0] and does not return any value..
pytorch_ao
public
public
0
0
_annotate_maxpool2d
def _annotate_maxpool2d(self,node: Node,quantization_config: Optional[QuantizationConfig],) -> None:"""Here we skip the annotate logic for maxpool at XPU backendas the quantized::max_pool2d is only implemented for CPU."""return
1
6
3
21
0
110
119
110
null
[]
None
null
0
0
0
null
0
null
The function (_annotate_maxpool2d) defined within the public class called public.The function start at line 110 and ends at 119. It contains 6 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [110.0] and does not return any value..
pytorch_ao
public
public
0
0
_annotate_output_for_int8_in_int8_out_pattern
def _annotate_output_for_int8_in_int8_out_pattern(self,node: Node,) -> None:if (node.target in int8_in_int8_out_ops) and (_is_any_annotated([node])):if node.target == torch.ops.aten.max_pool2d.default:returnelse:input_node = node.all_input_nodes[0]self._annotate_output_share_observer_as_input(input_node, node)return
4
11
2
65
0
121
131
121
null
[]
None
null
0
0
0
null
0
null
The function (_annotate_output_for_int8_in_int8_out_pattern) defined within the public class called public.The function start at line 121 and ends at 131. It contains 11 lines of code and it has a cyclomatic complexity of 4. It takes 2 parameters, represented as [121.0] and does not return any value..