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
update_equivalent_types_dict
def update_equivalent_types_dict(customized_equivalent_types=None):"""Help function for user who wants to customize the _EQUIVALENT_TYPES and _EQUIVALENT_TYPES_DICT.When customized_equivalent_types passes in,re-generate _EQUIVALENT_TYPES and _EQUIVALENT_TYPES_DICT."""if customized_equivalent_types is None:raise ValueEr...
2
7
1
30
2
57
67
57
null
['_EQUIVALENT_TYPES', '_EQUIVALENT_TYPES_DICT']
None
null
0
0
0
null
0
null
The function (update_equivalent_types_dict) defined within the public class called public.The function start at line 57 and ends at 67. 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
_partitions_sequential
def _partitions_sequential(partitions: Sequence[SourcePartition]):prev_partition = Nonefor partition in partitions:if prev_partition is not None and not check_subgraphs_connected(prev_partition, partition):return Falseprev_partition = partitionreturn True
4
9
1
39
1
70
78
70
null
['prev_partition']
None
null
0
0
0
null
0
null
The function (_partitions_sequential) defined within the public class called public.The function start at line 70 and ends at 78. 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
_get_matching_types
def _get_matching_types(partition_type):matching_types = [partition_type]if partition_type in _EQUIVALENT_TYPES_DICT:matching_types.extend(_EQUIVALENT_TYPES_DICT[partition_type])return matching_types
2
5
1
26
1
81
85
81
null
['matching_types']
None
null
0
0
0
null
0
null
The function (_get_matching_types) defined within the public class called public.The function start at line 81 and ends at 85. 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
_valid_type_sequence
def _valid_type_sequence(partition_types: list[Any]):partition_types_set = set()# type: ignore[var-annotated]for partition_type in partition_types:matching_types = _get_matching_types(partition_type)matching_types_set = set(matching_types)if len(partition_types_set & matching_types_set) > 0:return Falsepartition_types_...
3
9
1
49
3
88
96
88
null
['matching_types', 'partition_types_set', 'matching_types_set']
None
null
0
0
0
null
0
null
The function (_valid_type_sequence) defined within the public class called public.The function start at line 88 and ends at 96. 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
find_sequential_partitions
def find_sequential_partitions(gm: torch.fx.GraphModule,partition_types: list[Any],include_functional_equivalent=True,filter_fn: Optional[Callable[[Node], bool]] = None,):if not _valid_type_sequence(partition_types):raise ValueError(f"Invalid partition types: {partition_types}. Each type in the sequence must be unique"...
5
25
5
145
5
99
125
99
null
['fusion_candidates', 'types_to_match', 'typed_partitions_list', 'fused_partitions', 'partitions']
None
null
0
0
0
null
0
null
The function (find_sequential_partitions) defined within the public class called public.The function start at line 99 and ends at 125. It contains 25 lines of code and it has a cyclomatic complexity of 5. It takes 5 parameters, represented as [99.0] and does not return any value..
pytorch_ao
public
public
0
0
_get_submodule
def _get_submodule(graph_module: torch.fx.GraphModule, node: torch.fx.Node, arg_index: int) -> tuple[str, torch.nn.Module, torch.fx.Node]:submod_node = node.args[arg_index]assert isinstance(submod_node, torch.fx.Node)assert submod_node.op == "get_attr"assert isinstance(submod_node.target, str)submodule = graph_module.g...
1
9
3
92
2
128
137
128
null
['submod_node', 'submodule']
None
null
0
0
0
null
0
null
The function (_get_submodule) defined within the public class called public.The function start at line 128 and ends at 137. It contains 9 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [128.0] and does not return any value..
pytorch_ao
public
public
0
0
_get_control_flow_submodules
def _get_control_flow_submodules(graph_module: torch.fx.GraphModule,) -> list[tuple[str, torch.nn.Module, torch.fx.Node]]:"""Returns a list of submodules used for control flow operations(torch.ops.higher_order.cond/map) that are in the given toplevel graph (does not lookinto submodules). Specifically, the returned valu...
5
13
1
121
1
140
161
140
null
['control_flow_submodules']
None
null
0
0
0
null
0
null
The function (_get_control_flow_submodules) defined within the public class called public.The function start at line 140 and ends at 161. It contains 13 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
bfs_trace_with_node_process
def bfs_trace_with_node_process(model: Union[ExportedProgram, torch.fx.GraphModule], node_op: Callable) -> None:"""Traverse the graph module and apply node_op to each node."""assert isinstance(model, (ExportedProgram, torch.fx.GraphModule)), (f"Expected GraphModule or ExportedProgram, got {type(model)}")gm = model.grap...
6
19
2
120
4
164
186
164
null
['queue', 'current_graph_module', 'gm', 'control_flow_submodules']
None
null
0
0
0
null
0
null
The function (bfs_trace_with_node_process) defined within the public class called public.The function start at line 164 and ends at 186. It contains 19 lines of code and it has a cyclomatic complexity of 6. It takes 2 parameters, represented as [164.0] and does not return any value..
pytorch_ao
public
public
0
0
lower_pt2e_quantized_to_x86._post_autograd_decomp_table
def _post_autograd_decomp_table():# type: ignore[no-untyped-def]decomp_table = torch.export.default_decompositions()# if we are post-autograd, we shouldn't# decomp prim ops.for k in list(decomp_table.keys()):if not torch._export.utils._is_cia_op(k):del decomp_table[k]return decomp_table
3
6
0
45
0
30
39
30
null
[]
None
null
0
0
0
null
0
null
The function (lower_pt2e_quantized_to_x86._post_autograd_decomp_table) defined within the public class called public.The function start at line 30 and ends at 39. 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
lower_pt2e_quantized_to_x86._node_replace
def _node_replace(m):# type: ignore[no-untyped-def]# Replace aten.t(x) with aten.permute(x, [1, 0])aten = torch.ops.ateng = m.graphfor node in g.nodes:if node.target == aten.t.default:with g.inserting_before(node):x = node.args[0]dims = [1, 0]perm_node = g.call_function(aten.permute.default, args=(x, dims))node.replace...
3
13
1
100
0
41
55
41
null
[]
None
null
0
0
0
null
0
null
The function (lower_pt2e_quantized_to_x86._node_replace) defined within the public class called public.The function start at line 41 and ends at 55. It contains 13 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
lower_pt2e_quantized_to_x86
def lower_pt2e_quantized_to_x86(model: torch.fx.GraphModule,example_inputs: tuple[torch.Tensor, ...],) -> torch.fx.GraphModule:"""Lower a PT2E-qantized model to x86 backend.Args:* `model` (torch.fx.GraphModule): a model quantized by PT2E quantization flow.* `example_inputs` (tuple[torch.Tensor, ...]): example inputs fo...
1
15
2
79
7
16
65
16
null
['g', 'dims', 'decomp_table', 'lowered_model', 'x', 'perm_node', 'aten']
None
null
0
0
0
null
0
null
The function (lower_pt2e_quantized_to_x86) defined within the public class called public.The function start at line 16 and ends at 65. It contains 15 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [16.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self, p):self.p = pself.callable_args = {}
1
3
2
18
0
95
97
95
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 95 and ends at 97. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [95.0] and does not return any value..
pytorch_ao
public
public
0
0
__call__
def __call__(self, *args, **keywords):# call each arg in callable_args and add them partial, then run with keywords# skip if arg_name in keywords so its possible to overwritefor arg_name in self.callable_args:if arg_name not in keywords:keywords = {**keywords, arg_name: self.callable_args[arg_name]()}return self.p(*arg...
3
5
3
52
0
99
105
99
null
[]
None
null
0
0
0
null
0
null
The function (__call__) defined within the public class called public.The function start at line 99 and ends at 105. It contains 5 lines of code and it has a cyclomatic complexity of 3. It takes 3 parameters, represented as [99.0] and does not return any value..
pytorch_ao
public
public
0
0
__repr__
def __repr__(self):return self.p.__repr__() + self.callable_args.__repr__()
1
2
1
21
0
107
108
107
null
[]
None
null
0
0
0
null
0
null
The function (__repr__) defined within the public class called public.The function start at line 107 and ends at 108. 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
with_args
def with_args(self, **kwargs):return _with_args(self, **kwargs)
1
2
2
16
0
110
111
110
null
[]
None
null
0
0
0
null
0
null
The function (with_args) defined within the public class called public.The function start at line 110 and ends at 111. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [110.0] and does not return any value..
pytorch_ao
public
public
0
0
with_callable_args
def with_callable_args(self, **kwargs):result = PartialWrapper(p=self.p)result.callable_args = {**self.callable_args, **kwargs}return result
1
4
2
33
0
113
116
113
null
[]
None
null
0
0
0
null
0
null
The function (with_callable_args) defined within the public class called public.The function start at line 113 and ends at 116. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [113.0] and does not return any value..
pytorch_ao
public
public
0
0
_with_args
def _with_args(cls_or_self, **kwargs):r"""Wrapper that allows creation of class factories.This can be useful when there is a need to create classes with the sameconstructor arguments, but different instances. Can be used in conjunction with_callable_argsExample::>>> # xdoctest: +SKIP("Undefined vars")>>> Foo.with_args ...
1
3
2
24
1
119
137
119
null
['r']
None
null
0
0
0
null
0
null
The function (_with_args) defined within the public class called public.The function start at line 119 and ends at 137. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [119.0] and does not return any value..
pytorch_ao
public
public
0
0
_with_callable_args
def _with_callable_args(cls_or_self, **kwargs):r"""Wrapper that allows creation of class factories args that need to becalled at construction time.This can be useful when there is a need to create classes with the sameconstructor arguments, but different instances and those arguments should onlybe calculated at constru...
1
3
2
27
1
140
161
140
null
['r']
None
null
0
0
0
null
0
null
The function (_with_callable_args) defined within the public class called public.The function start at line 140 and ends at 161. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [140.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self, dtype, is_dynamic: bool = False):super().__init__()self.dtype = dtypeself.is_dynamic = is_dynamic
1
4
3
30
0
183
186
183
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 183 and ends at 186. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [183.0] and does not return any value..
pytorch_ao
public
public
0
0
forward
def forward(self, x):pass
1
2
2
8
0
189
190
189
null
[]
None
null
0
0
0
null
0
null
The function (forward) defined within the public class called public.The function start at line 189 and ends at 190. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [189.0] and does not return any value..
pytorch_ao
public
public
0
0
calculate_qparams
def calculate_qparams(self, **kwargs):pass
1
2
2
9
0
193
194
193
null
[]
None
null
0
0
0
null
0
null
The function (calculate_qparams) defined within the public class called public.The function start at line 193 and ends at 194. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [193.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self,dtype=torch.quint8,qscheme=torch.per_tensor_affine,reduce_range=False,quant_min=None,quant_max=None,factory_kwargs=None,eps=torch.finfo(torch.float32).eps,is_dynamic=False,**kwargs,) -> None:factory_kwargs = torch.nn.factory_kwargs(factory_kwargs)super().__init__(dtype=dtype, is_dynamic=is_dynamic, **...
4
59
8
265
0
247
307
247
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 247 and ends at 307. It contains 59 lines of code and it has a cyclomatic complexity of 4. It takes 8 parameters, represented as [247.0] and does not return any value..
pytorch_ao
public
public
0
0
_load_from_state_dict
def _load_from_state_dict(self,state_dict,prefix,local_metadata,strict,missing_keys,unexpected_keys,error_msgs,):version = local_metadata.get("version", None)if version is None or version == 1:# eps was moved to a buffer in version 2eps = torch.tensor([torch.finfo(torch.float32).eps])state_dict[prefix + "eps"] = epssup...
3
23
8
87
0
309
334
309
null
[]
None
null
0
0
0
null
0
null
The function (_load_from_state_dict) defined within the public class called public.The function start at line 309 and ends at 334. It contains 23 lines of code and it has a cyclomatic complexity of 3. It takes 8 parameters, represented as [309.0] and does not return any value..
pytorch_ao
public
public
0
0
_validate_qmin_qmax
def _validate_qmin_qmax(self, 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 u...
1
7
3
35
0
337
358
337
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 337 and ends at 358. It contains 7 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
_calculate_qparams
def _calculate_qparams(self, min_val: torch.Tensor, max_val: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor]:r"""Calculates the quantization parameters, given min and maxvalue tensors. Works for both per tensor and per channel casesArgs:min_val: Minimum values per channelmax_val: Maximum values per channelReturns:sc...
11
49
3
516
0
361
439
361
null
[]
None
null
0
0
0
null
0
null
The function (_calculate_qparams) defined within the public class called public.The function start at line 361 and ends at 439. It contains 49 lines of code and it has a cyclomatic complexity of 11. It takes 3 parameters, represented as [361.0] and does not return any value..
pytorch_ao
public
public
0
0
reset_min_max_vals
def reset_min_max_vals(self):raise NotImplementedError("Cannot reset min/max values in the given observer.")
1
2
1
10
0
442
443
442
null
[]
None
null
0
0
0
null
0
null
The function (reset_min_max_vals) defined within the public class called public.The function start at line 442 and ends at 443. 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
__init__
def __init__(self,dtype=torch.quint8,qscheme=torch.per_tensor_affine,reduce_range=False,quant_min=None,quant_max=None,factory_kwargs=None,eps=torch.finfo(torch.float32).eps,is_dynamic=False,**kwargs,) -> None:if not is_per_tensor(qscheme):raise NotImplementedError("MinMaxObserver's qscheme only support torch.per_tensor...
5
40
8
186
0
519
568
519
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 519 and ends at 568. It contains 40 lines of code and it has a cyclomatic complexity of 5. It takes 8 parameters, represented as [519.0] and does not return any value..
pytorch_ao
public
public
0
0
forward
def forward(self, x_orig):r"""Records the running minimum and maximum of ``x``."""if x_orig.numel() == 0:return x_origx = x_orig.detach()# avoid keeping autograd tapex = x.to(self.min_val.dtype)min_val_cur, max_val_cur = torch.aminmax(x)min_val = torch.min(min_val_cur, self.min_val)max_val = torch.max(max_val_cur, self...
2
11
2
91
0
570
581
570
null
[]
None
null
0
0
0
null
0
null
The function (forward) defined within the public class called public.The function start at line 570 and ends at 581. It contains 11 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [570.0] and does not return any value..
pytorch_ao
public
public
0
0
calculate_qparams
def calculate_qparams(self):r"""Calculates the quantization parameters."""return self._calculate_qparams(self.min_val, self.max_val)
1
2
1
20
0
584
586
584
null
[]
None
null
0
0
0
null
0
null
The function (calculate_qparams) defined within the public class called public.The function start at line 584 and ends at 586. 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
extra_repr
def extra_repr(self):return f"min_val={self.min_val}, max_val={self.max_val}"
1
2
1
8
0
589
590
589
null
[]
None
null
0
0
0
null
0
null
The function (extra_repr) defined within the public class called public.The function start at line 589 and ends at 590. 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
reset_min_max_vals
def reset_min_max_vals(self):"""Resets the min/max values."""self.min_val.copy_(torch.tensor(float("inf")))self.max_val.copy_(torch.tensor(float("-inf")))
1
3
1
38
0
593
596
593
null
[]
None
null
0
0
0
null
0
null
The function (reset_min_max_vals) defined within the public class called public.The function start at line 593 and ends at 596. 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
__init__
def __init__(self,averaging_constant=0.01,dtype=torch.quint8,qscheme=torch.per_tensor_affine,reduce_range=False,quant_min=None,quant_max=None,eps=torch.finfo(torch.float32).eps,is_dynamic=False,**kwargs,) -> None:if not is_per_tensor(qscheme):raise NotImplementedError(f"MovingAverageMinMaxObserver's qscheme only suppor...
4
34
8
130
0
645
678
645
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 645 and ends at 678. It contains 34 lines of code and it has a cyclomatic complexity of 4. It takes 8 parameters, represented as [645.0] and does not return any value..
pytorch_ao
public
public
0
0
forward
def forward(self, x_orig):if x_orig.numel() == 0:return x_origx = x_orig.detach()# avoid keeping autograd tapex = x.to(self.min_val.dtype)min_val = self.min_valmax_val = self.max_valif min_val == float("inf") and max_val == float("-inf"):min_val, max_val = torch.aminmax(x)else:min_val_cur, max_val_cur = torch.aminmax(x...
4
16
2
128
0
680
695
680
null
[]
None
null
0
0
0
null
0
null
The function (forward) defined within the public class called public.The function start at line 680 and ends at 695. It contains 16 lines of code and it has a cyclomatic complexity of 4. It takes 2 parameters, represented as [680.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self,ch_axis=0,dtype=torch.quint8,qscheme=torch.per_channel_affine,reduce_range=False,quant_min=None,quant_max=None,factory_kwargs=None,eps=torch.finfo(torch.float32).eps,is_dynamic=False,**kwargs,) -> None:if not is_per_channel(qscheme):raise NotImplementedError("PerChannelMinMaxObserver's qscheme only su...
6
45
9
199
0
729
773
729
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 729 and ends at 773. It contains 45 lines of code and it has a cyclomatic complexity of 6. It takes 9 parameters, represented as [729.0] and does not return any value..
pytorch_ao
public
public
0
0
forward
def forward(self, x_orig):return self._forward(x_orig)
1
2
2
14
0
775
776
775
null
[]
None
null
0
0
0
null
0
null
The function (forward) defined within the public class called public.The function start at line 775 and ends at 776. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [775.0] and does not return any value..
pytorch_ao
public
public
0
0
_forward
def _forward(self, x_orig):if x_orig.numel() == 0:return x_origx = x_orig.detach()# avoid keeping autograd tapemin_val = self.min_valmax_val = self.max_valx_dim = x.size()new_axis_list = [i for i in range(len(x_dim))]# noqa: C416new_axis_list[self.ch_axis] = 0new_axis_list[0] = self.ch_axisy = x.permute(new_axis_list)#...
5
24
2
210
0
778
804
778
null
[]
None
null
0
0
0
null
0
null
The function (_forward) defined within the public class called public.The function start at line 778 and ends at 804. It contains 24 lines of code and it has a cyclomatic complexity of 5. It takes 2 parameters, represented as [778.0] and does not return any value..
pytorch_ao
public
public
0
0
calculate_qparams
def calculate_qparams(self):return self._calculate_qparams(self.min_val, self.max_val)
1
2
1
18
0
807
808
807
null
[]
None
null
0
0
0
null
0
null
The function (calculate_qparams) defined within the public class called public.The function start at line 807 and ends at 808. 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
extra_repr
def extra_repr(self):return f"min_val={self.min_val}, max_val={self.max_val}"
1
2
1
8
0
810
811
589
null
[]
None
null
0
0
0
null
0
null
The function (extra_repr) defined within the public class called public.The function start at line 810 and ends at 811. 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
_load_from_state_dict
def _load_from_state_dict(self,state_dict: dict[str, Any],prefix: str,local_metadata: dict[str, torch.Tensor],strict: bool,missing_keys: list[str],unexpected_keys: list[str],error_msgs: list[str],):version = local_metadata.get("version", None)if version is not None and version < 3:local_state = ["min_vals", "max_vals"]...
12
52
8
247
0
813
871
813
null
[]
None
null
0
0
0
null
0
null
The function (_load_from_state_dict) defined within the public class called public.The function start at line 813 and ends at 871. It contains 52 lines of code and it has a cyclomatic complexity of 12. It takes 8 parameters, represented as [813.0] and does not return any value..
pytorch_ao
public
public
0
0
_load_from_state_dict_script
def _load_from_state_dict_script(self,state_dict: dict[str, Any],prefix: str,local_metadata: dict[str, torch.Tensor],strict: bool,missing_keys: list[str],unexpected_keys: list[str],error_msgs: list[str],):self._load_from_state_dict(state_dict,prefix,local_metadata,strict,missing_keys,unexpected_keys,error_msgs,)
1
19
8
74
0
873
891
873
null
[]
None
null
0
0
0
null
0
null
The function (_load_from_state_dict_script) defined within the public class called public.The function start at line 873 and ends at 891. It contains 19 lines of code and it has a cyclomatic complexity of 1. It takes 8 parameters, represented as [873.0] and does not return any value..
pytorch_ao
public
public
0
0
reset_min_max_vals
def reset_min_max_vals(self):"""Resets the min/max values."""# This used to be torch.ones but that does not work because# JIT compiler can optimize it via common subexpression elimination# in which case both min_val and max_val point to the same tensor.self.min_val = torch.rand(0,)self.max_val = torch.rand(0,)
1
7
1
28
0
894
904
894
null
[]
None
null
0
0
0
null
0
null
The function (reset_min_max_vals) defined within the public class called public.The function start at line 894 and ends at 904. 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
__init__
def __init__(self,averaging_constant=0.01,ch_axis=0,dtype=torch.quint8,qscheme=torch.per_channel_affine,reduce_range=False,quant_min=None,quant_max=None,eps=torch.finfo(torch.float32).eps,is_dynamic=False,**kwargs,) -> None:if not is_per_channel(qscheme):raise NotImplementedError("MovingAveragePerChannelMinMaxObserver'...
3
34
9
129
0
935
968
935
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 935 and ends at 968. It contains 34 lines of code and it has a cyclomatic complexity of 3. It takes 9 parameters, represented as [935.0] and does not return any value..
pytorch_ao
public
public
0
0
forward
def forward(self, x_orig):if x_orig.numel() == 0:return x_origx = x_orig.detach()# avoid keeping autograd tapex = x.to(self.min_val.dtype)min_val = self.min_valmax_val = self.max_valx_dim = x.size()new_axis_list = [i for i in range(len(x_dim))]# noqa: C416new_axis_list[self.ch_axis] = 0new_axis_list[0] = self.ch_axisy ...
5
24
2
216
0
970
994
970
null
[]
None
null
0
0
0
null
0
null
The function (forward) defined within the public class called public.The function start at line 970 and ends at 994. It contains 24 lines of code and it has a cyclomatic complexity of 5. It takes 2 parameters, represented as [970.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self,bins: int = 2048,dtype: torch.dtype = torch.quint8,qscheme=torch.per_tensor_affine,reduce_range=False,quant_min=None,quant_max=None,factory_kwargs=None,eps=torch.finfo(torch.float32).eps,is_dynamic=False,**kwargs,) -> None:if not is_per_tensor(qscheme):raise NotImplementedError("HistogramObserver's qs...
3
42
9
222
0
1,026
1,068
1,026
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 1026 and ends at 1068. It contains 42 lines of code and it has a cyclomatic complexity of 3. It takes 9 parameters, represented as [1026.0] and does not return any value..
pytorch_ao
public
public
0
0
_get_norm
def _get_norm(self, delta_begin: torch.Tensor, delta_end: torch.Tensor, density: torch.Tensor) -> torch.Tensor:r"""Compute the norm of the values uniformaly distributed betweendelta_begin and delta_end.Currently only L2 norm is supported.norm = density * (integral_{begin, end} x^2) = density * (end^3 - begin^3) / 3"""n...
1
7
4
50
0
1,070
1,084
1,070
null
[]
None
null
0
0
0
null
0
null
The function (_get_norm) defined within the public class called public.The function start at line 1070 and ends at 1084. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [1070.0] and does not return any value..
pytorch_ao
public
public
0
0
_compute_quantization_error
def _compute_quantization_error(self, next_start_bin: int, next_end_bin: int):r"""Compute the quantization error if we use start_bin to end_bin as themin and max to do the quantization."""bin_width = (self.max_val.item() - self.min_val.item()) / self.binsdst_bin_width = bin_width * (next_end_bin - next_start_bin + 1) /...
2
36
3
310
0
1,086
1,138
1,086
null
[]
None
null
0
0
0
null
0
null
The function (_compute_quantization_error) defined within the public class called public.The function start at line 1086 and ends at 1138. It contains 36 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [1086.0] and does not return any value..
pytorch_ao
public
public
0
0
_non_linear_param_search
def _non_linear_param_search(self) -> tuple[torch.Tensor, torch.Tensor]:r"""Non-linear parameter search.An approximation for L2 error minimization for selecting min/max.By selecting new min/max, we filter out outliers in input distribution.This follows the implementation of NormMinimization::NonlinearQuantizationParams...
10
39
1
262
0
1,140
1,201
1,140
null
[]
None
null
0
0
0
null
0
null
The function (_non_linear_param_search) defined within the public class called public.The function start at line 1140 and ends at 1201. It contains 39 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
_upscale_histogram
def _upscale_histogram(self,histogram: torch.Tensor,orig_min: torch.Tensor,orig_max: torch.Tensor,update_min: torch.Tensor,update_max: torch.Tensor,):# this turns the histogram into a more fine-coarsed histogram to reduce# bin quantization errorshistogram = histogram.repeat_interleave(self.upsample_rate) / self.upsampl...
1
32
6
203
0
1,203
1,242
1,203
null
[]
None
null
0
0
0
null
0
null
The function (_upscale_histogram) defined within the public class called public.The function start at line 1203 and ends at 1242. It contains 32 lines of code and it has a cyclomatic complexity of 1. It takes 6 parameters, represented as [1203.0] and does not return any value..
pytorch_ao
public
public
0
0
_combine_histograms
def _combine_histograms(self,orig_hist: torch.Tensor,orig_min: torch.Tensor,orig_max: torch.Tensor,update_hist: torch.Tensor,update_min: torch.Tensor,update_max: torch.Tensor,) -> torch.Tensor:# If the new min and max are the same as the current min and max,# we can just add the new histogram to the original histogrami...
4
28
7
131
0
1,244
1,281
1,244
null
[]
None
null
0
0
0
null
0
null
The function (_combine_histograms) defined within the public class called public.The function start at line 1244 and ends at 1281. It contains 28 lines of code and it has a cyclomatic complexity of 4. It takes 7 parameters, represented as [1244.0] and does not return any value..
pytorch_ao
public
public
0
0
reset_histogram
def reset_histogram(self, x: torch.Tensor, min_val: torch.Tensor, max_val: torch.Tensor) -> None:self.min_val.resize_(min_val.shape)self.min_val.copy_(min_val)self.max_val.resize_(max_val.shape)self.max_val.copy_(max_val)assert min_val.numel() == 1 and max_val.numel() == 1, ("histogram min/max values must be scalar.")n...
2
13
4
123
0
1,283
1,295
1,283
null
[]
None
null
0
0
0
null
0
null
The function (reset_histogram) defined within the public class called public.The function start at line 1283 and ends at 1295. It contains 13 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [1283.0] and does not return any value..
pytorch_ao
public
public
0
0
forward
def forward(self, x_orig: torch.Tensor) -> torch.Tensor:# pyre-ignore[14]if x_orig.numel() == 0:return x_origx = x_orig.detach()x_min, x_max = torch.aminmax(x)# want to ignore torch.inf since we don't actually# want to make our quantization range infinite# and in practice those values will be clampedif x_min == -torch....
9
47
2
343
0
1,297
1,352
1,297
null
[]
None
null
0
0
0
null
0
null
The function (forward) defined within the public class called public.The function start at line 1297 and ends at 1352. It contains 47 lines of code and it has a cyclomatic complexity of 9. It takes 2 parameters, represented as [1297.0] and does not return any value..
pytorch_ao
public
public
0
0
calculate_qparams
def calculate_qparams(self):is_uninitialized = self.min_val == float("inf") and self.max_val == float("-inf")if is_uninitialized:warnings.warn("must run observer before calling calculate_qparams.\Returning default scale and zero point ")return torch.tensor([1.0], device=self.min_val.device.type), torch.tensor([0], devi...
3
18
1
107
0
1,355
1,374
1,355
null
[]
None
null
0
0
0
null
0
null
The function (calculate_qparams) defined within the public class called public.The function start at line 1355 and ends at 1374. It contains 18 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
_save_to_state_dict
def _save_to_state_dict(self, destination, prefix, keep_vars):super()._save_to_state_dict(destination, prefix, keep_vars)destination[prefix + "min_val"] = self.min_valdestination[prefix + "max_val"] = self.max_val
1
4
4
43
0
1,376
1,379
1,376
null
[]
None
null
0
0
0
null
0
null
The function (_save_to_state_dict) defined within the public class called public.The function start at line 1376 and ends at 1379. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [1376.0] and does not return any value..
pytorch_ao
public
public
0
0
_load_from_state_dict
def _load_from_state_dict(self,state_dict,prefix,local_metadata,strict,missing_keys,unexpected_keys,error_msgs,):version = local_metadata.get("version", None)if version is None or version < 3:# if min_val and max_val are not initialized, update their shape# to account for the differences between v2 and v3min_val_name, ...
10
36
8
188
0
1,381
1,420
1,381
null
[]
None
null
0
0
0
null
0
null
The function (_load_from_state_dict) defined within the public class called public.The function start at line 1381 and ends at 1420. It contains 36 lines of code and it has a cyclomatic complexity of 10. It takes 8 parameters, represented as [1381.0] and does not return any value..
pytorch_ao
public
public
0
0
extra_repr
def extra_repr(self):return f"min_val={self.min_val}, max_val={self.max_val}"
1
2
1
8
0
1,422
1,423
589
null
[]
None
null
0
0
0
null
0
null
The function (extra_repr) defined within the public class called public.The function start at line 1422 and ends at 1423. 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
__init__
def __init__(self,scale,zero_point,dtype=torch.quint8,qscheme=torch.per_tensor_affine,quant_min=0,quant_max=255,is_dynamic=False,**kwargs,):if is_dynamic:raise NotImplementedError("FixedQParamsObserver doesn't support dynamic quantization")super().__init__(dtype=dtype, is_dynamic=is_dynamic, **kwargs)self.quant_min = q...
2
22
9
124
0
1,441
1,462
1,441
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 1441 and ends at 1462. It contains 22 lines of code and it has a cyclomatic complexity of 2. It takes 9 parameters, represented as [1441.0] and does not return any value..
pytorch_ao
public
public
0
0
forward
def forward(self, X):return X
1
2
2
9
0
1,464
1,465
1,464
null
[]
None
null
0
0
0
null
0
null
The function (forward) defined within the public class called public.The function start at line 1464 and ends at 1465. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [1464.0] and does not return any value..
pytorch_ao
public
public
0
0
calculate_qparams
def calculate_qparams(self):return self.scale, self.zero_point
1
2
1
13
0
1,468
1,469
1,468
null
[]
None
null
0
0
0
null
0
null
The function (calculate_qparams) defined within the public class called public.The function start at line 1468 and ends at 1469. 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
__init__
def __init__(self,dtype=torch.float32,custom_op_name="",compute_dtype=None,quant_min=None,quant_max=None,qscheme=None,eps=None,is_dynamic=False,) -> None:super().__init__(dtype=dtype, is_dynamic=is_dynamic)if qscheme is None:qscheme = torch.per_tensor_affineif eps is None:eps = torch.finfo(torch.float32).eps# dtype of ...
4
29
9
125
0
1,495
1,527
1,495
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 1495 and ends at 1527. It contains 29 lines of code and it has a cyclomatic complexity of 4. It takes 9 parameters, represented as [1495.0] and does not return any value..
pytorch_ao
public
public
0
0
forward
def forward(self, X):return X
1
2
2
9
0
1,529
1,530
1,464
null
[]
None
null
0
0
0
null
0
null
The function (forward) defined within the public class called public.The function start at line 1529 and ends at 1530. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [1464.0] and does not return any value..
pytorch_ao
public
public
0
0
extra_repr
def extra_repr(self):return f"min_val={self.min_val}, max_val={self.max_val}"
1
2
1
8
0
1,533
1,534
589
null
[]
None
null
0
0
0
null
0
null
The function (extra_repr) defined within the public class called public.The function start at line 1533 and ends at 1534. 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
calculate_qparams
def calculate_qparams(self):raise Exception(# noqa: TRY002"calculate_qparams should not be called for PlaceholderObserver")
1
4
1
10
0
1,537
1,540
1,537
null
[]
None
null
0
0
0
null
0
null
The function (calculate_qparams) defined within the public class called public.The function start at line 1537 and ends at 1540. 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, dtype=torch.quint8):super().__init__(dtype=dtype, is_dynamic=False)self.tensor_val = []
1
3
2
31
0
1,555
1,557
1,555
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 1555 and ends at 1557. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [1555.0] and does not return any value..
pytorch_ao
public
public
0
0
forward
def forward(self, x):self.tensor_val.append(x.clone())return x
1
3
2
21
0
1,559
1,561
1,559
null
[]
None
null
0
0
0
null
0
null
The function (forward) defined within the public class called public.The function start at line 1559 and ends at 1561. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [1559.0] and does not return any value..
pytorch_ao
public
public
0
0
calculate_qparams
def calculate_qparams(self):raise Exception(# noqa: TRY002"calculate_qparams should not be called for PlaceholderObserver")
1
4
1
10
0
1,564
1,567
1,537
null
[]
None
null
0
0
0
null
0
null
The function (calculate_qparams) defined within the public class called public.The function start at line 1564 and ends at 1567. 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
get_tensor_value
def get_tensor_value(self):return self.tensor_val
1
2
1
9
0
1,570
1,571
1,570
null
[]
None
null
0
0
0
null
0
null
The function (get_tensor_value) defined within the public class called public.The function start at line 1570 and ends at 1571. 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
__init__
def __init__(self, dtype=torch.float16, custom_op_name="") -> None:super().__init__(dtype=dtype, is_dynamic=False)self.dtype = dtypeself.custom_op = custom_op_name
1
4
3
41
0
1,588
1,591
1,588
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 1588 and ends at 1591. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [1588.0] and does not return any value..
pytorch_ao
public
public
0
0
forward
def forward(self, X):return X
1
2
2
9
0
1,593
1,594
1,464
null
[]
None
null
0
0
0
null
0
null
The function (forward) defined within the public class called public.The function start at line 1593 and ends at 1594. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [1464.0] and does not return any value..
pytorch_ao
public
public
0
0
calculate_qparams
def calculate_qparams(self):raise Exception(# noqa: TRY002"calculate_qparams should not be called for PlaceholderObserver")
1
4
1
10
0
1,597
1,600
1,537
null
[]
None
null
0
0
0
null
0
null
The function (calculate_qparams) defined within the public class called public.The function start at line 1597 and ends at 1600. 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__(torch.quint8, is_dynamic=False)
1
2
1
21
0
1,617
1,618
1,617
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 1617 and ends at 1618. 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
forward
def forward(self, X):return X
1
2
2
9
0
1,620
1,621
1,464
null
[]
None
null
0
0
0
null
0
null
The function (forward) defined within the public class called public.The function start at line 1620 and ends at 1621. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [1464.0] and does not return any value..
pytorch_ao
public
public
0
0
calculate_qparams
def calculate_qparams(self):raise Exception(# noqa: TRY002"calculate_qparams should not be called for PlaceholderObserver")
1
4
1
10
0
1,624
1,627
1,537
null
[]
None
null
0
0
0
null
0
null
The function (calculate_qparams) defined within the public class called public.The function start at line 1624 and ends at 1627. 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,mapping_type: MappingType,target_dtype: torch.dtype,granularity: Granularity,quant_min: Optional[int] = None,quant_max: Optional[int] = None,eps: Optional[float] = None,scale_dtype: Optional[torch.dtype] = None,zero_point_dtype: Optional[torch.dtype] = None,preserve_zero: bool = True,zero_point_domain...
1
28
12
163
0
1,703
1,733
1,703
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 1703 and ends at 1733. It contains 28 lines of code and it has a cyclomatic complexity of 1. It takes 12 parameters, represented as [1703.0] and does not return any value..
pytorch_ao
public
public
0
0
forward
def forward(self, input: torch.Tensor) -> torch.Tensor:"""forward function should take the input tensorand updates internal stats and return the original input Tensor"""
1
1
2
16
0
1,736
1,739
1,736
null
[]
None
null
0
0
0
null
0
null
The function (forward) defined within the public class called public.The function start at line 1736 and ends at 1739. It contains 1 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [1736.0] and does not return any value..
pytorch_ao
public
public
0
0
calculate_qparams
def calculate_qparams(self) -> tuple[torch.Tensor, torch.Tensor]:"""Calculate quantization parameter based on the stats attached to the observer moduleand returns a tuple of scale and zero_point Tensor"""
1
1
1
17
0
1,742
1,745
1,742
null
[]
None
null
0
0
0
null
0
null
The function (calculate_qparams) defined within the public class called public.The function start at line 1742 and ends at 1745. It contains 1 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
convert
def convert(self, model: torch.fx.GraphModule, observer_node: Node):"""Converts the observer node in the graph into its quantized representationArgs:model: graph module to conver the observer node inobserver_node: the observer node to convert"""from torchao.quantization.pt2e.utils import create_getattr_from_valuewith m...
5
72
3
352
0
1,747
1,828
1,747
null
[]
None
null
0
0
0
null
0
null
The function (convert) defined within the public class called public.The function start at line 1747 and ends at 1828. It contains 72 lines of code and it has a cyclomatic complexity of 5. It takes 3 parameters, represented as [1747.0] and does not return any value..
pytorch_ao
public
public
0
0
_is_observer_script_module
def _is_observer_script_module(mod, obs_type_name):"""Returns true if given mod is an instance of Observer script module."""if isinstance(mod, torch.jit.RecursiveScriptModule):# qualified name looks like '__torch__.torchao.quantization.pt2e.observer.___torch_mangle_2.MinMaxObserver'suffix = mod._c.qualified_name.split(...
2
6
2
56
2
1,831
1,838
1,831
null
['suffix', 'name']
None
null
0
0
0
null
0
null
The function (_is_observer_script_module) defined within the public class called public.The function start at line 1831 and ends at 1838. It contains 6 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [1831.0] and does not return any value..
pytorch_ao
public
public
0
0
_is_activation_post_process
def _is_activation_post_process(module):return isinstance(module,(torchao.quantization.pt2e.ObserverBase,torchao.quantization.pt2e.FakeQuantizeBase,AffineQuantizedObserverBase,),) or _is_observer_script_module(module, "quantization.observer")
2
9
1
39
0
1,844
1,852
1,844
null
[]
None
null
0
0
0
null
0
null
The function (_is_activation_post_process) defined within the public class called public.The function start at line 1844 and ends at 1852. 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_per_channel_script_obs_instance
def _is_per_channel_script_obs_instance(module):if isinstance(module, torch.jit.RecursiveScriptModule):return _is_observer_script_module(module, "quantization.observer.PerChannelMinMaxObserver") or _is_observer_script_module(module, "quantization.observer.MovingAveragePerChannelMinMaxObserver")return False
3
8
1
33
0
1,855
1,862
1,855
null
[]
None
null
0
0
0
null
0
null
The function (_is_per_channel_script_obs_instance) defined within the public class called public.The function start at line 1855 and ends at 1862. It contains 8 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_observer_state_dict
def get_observer_state_dict(mod):r"""Returns the state dict corresponding to the observer stats.Traverse the model state_dict and extract out the stats."""od = OrderedDict()if isinstance(mod, torch.jit.RecursiveScriptModule):for k, v in mod.state_dict().items():if "observer" in k:od[k] = velse:# path for GraphModule an...
6
12
1
91
1
1,865
1,881
1,865
null
['od']
None
null
0
0
0
null
0
null
The function (get_observer_state_dict) defined within the public class called public.The function start at line 1865 and ends at 1881. 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
load_observer_state_dict
def load_observer_state_dict(mod, obs_dict):r"""Given input model and a state_dict containing model observer stats,load the stats back into the model. The observer state_dict can be savedusing torchao.quantization.pt2e.get_observer_state_dict"""missing_keys: list[str] = []unexpected_keys: list[str] = []for name, module...
10
24
2
137
1
1,884
1,914
1,884
null
['prefix']
None
null
0
0
0
null
0
null
The function (load_observer_state_dict) defined within the public class called public.The function start at line 1884 and ends at 1914. It contains 24 lines of code and it has a cyclomatic complexity of 10. It takes 2 parameters, represented as [1884.0] and does not return any value..
pytorch_ao
public
public
0
0
_is_activation_post_process_node
def _is_activation_post_process_node(node: Node, named_modules: dict[str, torch.nn.Module]) -> bool:return (isinstance(node, torch.fx.Node)and node.op == "call_module"and _is_activation_post_process(named_modules[str(node.target)]))
3
8
2
54
0
50
57
50
null
[]
None
null
0
0
0
null
0
null
The function (_is_activation_post_process_node) defined within the public class called public.The function start at line 50 and ends at 57. It contains 8 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [50.0] and does not return any value..
pytorch_ao
public
public
0
0
_get_observer_kwargs
def _get_observer_kwargs(quant_spec: Union[QuantizationSpec, FixedQParamsQuantizationSpec],):kwargs_dict = asdict(quant_spec)return copy.deepcopy(kwargs_dict)
1
5
1
26
1
60
64
60
null
['kwargs_dict']
None
null
0
0
0
null
0
null
The function (_get_observer_kwargs) defined within the public class called public.The function start at line 60 and ends at 64. 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
_create_obs_or_fq_from_qspec
def _create_obs_or_fq_from_qspec(quantization_spec: Optional[QuantizationSpecBase],obs_or_fq_map: dict[EdgeOrNode, ObserverOrFakeQuantize],is_qat: bool,):"""Create observer or fake quantize objects based on quantization specArgs: quantization_spec: used to store parameters to create the observer or fake quantizer obs_o...
9
46
3
255
7
67
123
67
null
['obs_or_fqs', 'obs_or_fq_class', 'edge_or_node', 'kwargs', 'observer_or_fake_quant_ctr', 'observer_ctr', 'edge_or_nodes']
None
null
0
0
0
null
0
null
The function (_create_obs_or_fq_from_qspec) defined within the public class called public.The function start at line 67 and ends at 123. It contains 46 lines of code and it has a cyclomatic complexity of 9. It takes 3 parameters, represented as [67.0] and does not return any value..
pytorch_ao
public
public
0
0
_find_root_edge_or_node
def _find_root_edge_or_node(edge_or_node: EdgeOrNode, shared_with_map: dict[EdgeOrNode, EdgeOrNode]) -> EdgeOrNode:"""Find the root node for the sharing treeArgs:edge_or_node: edge/node that we want to find the rootshared_with_map: each edge/node points to the parent, the root node will points to itselfReturns:root edg...
2
9
2
48
2
126
143
126
null
['root', 'parent']
None
null
0
0
0
null
0
null
The function (_find_root_edge_or_node) defined within the public class called public.The function start at line 126 and ends at 143. It contains 9 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [126.0] and does not return any value..
pytorch_ao
public
public
0
0
_union
def _union(parent: EdgeOrNode,child: EdgeOrNode,shared_with_map: dict[EdgeOrNode, EdgeOrNode],edge_or_node_to_qspec: dict[EdgeOrNode, QuantizationSpecBase],) -> None:"""Merge the subtree for `child` with `parent`, the order is important here"""root_parent = _find_root_edge_or_node(parent, shared_with_map)root_child = _...
3
16
4
85
3
146
167
146
null
['root_child', 'root_parent', 'parent_qspec']
None
null
0
0
0
null
0
null
The function (_union) defined within the public class called public.The function start at line 146 and ends at 167. It contains 16 lines of code and it has a cyclomatic complexity of 3. It takes 4 parameters, represented as [146.0] and does not return any value..
pytorch_ao
public
public
0
0
_update_shared_with
def _update_shared_with(child: EdgeOrNode,qspec: QuantizationSpecBase,shared_with_map: dict[EdgeOrNode, EdgeOrNode],edge_or_node_to_qspec: dict[EdgeOrNode, QuantizationSpecBase],):"""Update the `shared_with_map` based on the qspec, this applies the `SharedQuantizationSpec`configuration and established the relationship ...
2
9
4
54
1
170
184
170
null
['parent']
None
null
0
0
0
null
0
null
The function (_update_shared_with) defined within the public class called public.The function start at line 170 and ends at 184. It contains 9 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [170.0] and does not return any value..
pytorch_ao
public
public
0
0
_unwrap_shared_qspec
def _unwrap_shared_qspec(qspec: QuantizationSpecBase,edge_or_node_to_qspec: dict[EdgeOrNode, QuantizationSpecBase],shared_with_map: dict[EdgeOrNode, EdgeOrNode],) -> QuantizationSpecBase:"""Unwraps qspec to get the final root qspec (non SharedQuantizationSpec)if qspec is SharedQuantizationSpec (1). tries to find the ro...
2
11
3
67
3
187
202
187
null
['sharing_with', 'root', 'qspec']
None
null
0
0
0
null
0
null
The function (_unwrap_shared_qspec) defined within the public class called public.The function start at line 187 and ends at 202. It contains 11 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [187.0] and does not return any value..
pytorch_ao
public
public
0
0
_has_same_attr
def _has_same_attr(qspec_a: QuantizationSpecBase, qspec_b: QuantizationSpecBase, attr_name: str):return (hasattr(qspec_a, attr_name)and hasattr(qspec_b, attr_name)and getattr(qspec_a, attr_name) == getattr(qspec_b, attr_name)) or (not hasattr(qspec_a, attr_name) and not hasattr(qspec_b, attr_name))
5
8
3
63
0
205
212
205
null
[]
None
null
0
0
0
null
0
null
The function (_has_same_attr) defined within the public class called public.The function start at line 205 and ends at 212. It contains 8 lines of code and it has a cyclomatic complexity of 5. It takes 3 parameters, represented as [205.0] and does not return any value..
pytorch_ao
public
public
0
0
_get_edge_or_node_to_qspec
def _get_edge_or_node_to_qspec(model: torch.fx.GraphModule,) -> dict[EdgeOrNode, QuantizationSpecBase]:"""Get a map from EdgeOrNode to quantization spec based on annotations on the nodes"""edge_or_node_to_qspec: dict[EdgeOrNode, QuantizationSpecBase] = {}for n in model.graph.nodes:if hasattr(n, "meta") and Q_ANNOTATION...
6
15
1
112
4
215
230
215
null
['qspec', 'input_edge', 'output_node', 'qa']
None
null
0
0
0
null
0
null
The function (_get_edge_or_node_to_qspec) defined within the public class called public.The function start at line 215 and ends at 230. It contains 15 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
_union_input_edge_with
def _union_input_edge_with(input_edge,input_edge_root_qspec,edge_or_node,edge_or_node_to_qspec,shared_with_map,):"""Union input edge with another edge or node, used in implicit sharing to point the current inputedge to other user edges of the producer node, or the output of producer node since these arereferring to the...
5
25
5
88
2
233
266
233
null
['qspec', 'root_qspec']
None
null
0
0
0
null
0
null
The function (_union_input_edge_with) defined within the public class called public.The function start at line 233 and ends at 266. It contains 25 lines of code and it has a cyclomatic complexity of 5. It takes 5 parameters, represented as [233.0] and does not return any value..
pytorch_ao
public
public
0
0
_get_edge_or_node_to_group_id
def _get_edge_or_node_to_group_id(edge_or_node_to_qspec: dict[EdgeOrNode, QuantizationSpecBase],) -> dict[EdgeOrNode, int]:"""Map from edge/node to the group ID, generated from quantization annotations,edge/node with the same group ID should use the same observer/fake_quant instanceThis is applying SharedQuantizationSp...
11
54
1
252
6
269
393
269
null
['cur_group_id', 'input_edge_root_qspec', 'output_node', 'arg_to_user_edge', 'root', 'input_edge']
None
null
0
0
0
null
0
null
The function (_get_edge_or_node_to_group_id) defined within the public class called public.The function start at line 269 and ends at 393. It contains 54 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
_get_obs_or_fq_map
def _get_obs_or_fq_map(edge_or_node_to_group_id: dict[EdgeOrNode, int],edge_or_node_to_qspec: dict[EdgeOrNode, QuantizationSpecBase],is_qat: bool,) -> dict[EdgeOrNode, ObserverOrFakeQuantize]:"""Generates the EdgeOrNode to observer/fake_quant instancesMakes sure that for EdgeOrNode that has the same group_id should hav...
3
15
3
103
1
396
416
396
null
['group_id']
None
null
0
0
0
null
0
null
The function (_get_obs_or_fq_map) defined within the public class called public.The function start at line 396 and ends at 416. It contains 15 lines of code and it has a cyclomatic complexity of 3. It takes 3 parameters, represented as [396.0] and does not return any value..
pytorch_ao
public
public
0
0
_maybe_insert_input_observer_for_arg_or_kwarg
def _maybe_insert_input_observer_for_arg_or_kwarg(node: Union[Node, Any],arg: Argument,qconfig: QConfigAny,model: torch.nn.Module,named_modules: dict[str, torch.nn.Module],obs_or_fq_map: dict[EdgeOrNode, ObserverOrFakeQuantize],is_qat: bool,model_device: Optional[torch.device] = None,) -> Argument:"""Given a `node` and...
12
57
8
302
8
419
503
419
null
['new_arg', 'arg_as_output_obs_or_fq', 'original_arg', 'new_inner_arg', 'input_edge_obs_or_fq', 'maybe_obs_mod', 'new_arg_to_return', 'input_edge']
None
null
0
0
0
null
0
null
The function (_maybe_insert_input_observer_for_arg_or_kwarg) defined within the public class called public.The function start at line 419 and ends at 503. It contains 57 lines of code and it has a cyclomatic complexity of 12. It takes 8 parameters, represented as [419.0] and does not return any value..
pytorch_ao
public
public
0
0
_maybe_insert_input_observers_for_node
def _maybe_insert_input_observers_for_node(node: Node,qconfig: QConfigAny,model: torch.nn.Module,named_modules: dict[str, torch.nn.Module],obs_or_fq_map: dict[EdgeOrNode, ObserverOrFakeQuantize],is_qat: bool,model_device: Optional[torch.device] = None,) -> None:"""If needed, inserts observers to the input args and kwar...
5
29
7
161
2
506
555
506
null
['new_args', 'new_arg']
None
null
0
0
0
null
0
null
The function (_maybe_insert_input_observers_for_node) defined within the public class called public.The function start at line 506 and ends at 555. It contains 29 lines of code and it has a cyclomatic complexity of 5. It takes 7 parameters, represented as [506.0] and does not return any value..
pytorch_ao
public
public
0
0
_maybe_insert_output_observer_for_node
def _maybe_insert_output_observer_for_node(node: Node,model: torch.nn.Module,named_modules: dict[str, torch.nn.Module],graph: Graph,obs_or_fq_map: dict[EdgeOrNode, ObserverOrFakeQuantize],is_qat: bool,model_device: Optional[torch.device] = None,) -> Optional[Node]:if node in obs_or_fq_map:output_act_obs_or_fq = obs_or_...
5
22
7
127
2
558
581
558
null
['new_output', 'output_act_obs_or_fq']
None
null
0
0
0
null
0
null
The function (_maybe_insert_output_observer_for_node) defined within the public class called public.The function start at line 558 and ends at 581. It contains 22 lines of code and it has a cyclomatic complexity of 5. It takes 7 parameters, represented as [558.0] and does not return any value..
pytorch_ao
public
public
0
0
_maybe_insert_input_and_output_observers_for_node
def _maybe_insert_input_and_output_observers_for_node(node: Node,model: torch.fx.GraphModule,obs_or_fq_map: dict[EdgeOrNode, ObserverOrFakeQuantize],is_qat: bool,model_device: Optional[torch.device] = None,):this_node_quantization_annotation = (node.meta[Q_ANNOTATION_KEY] if Q_ANNOTATION_KEY in node.meta else None)if t...
8
41
5
176
5
584
644
584
null
['named_modules', 'orig_users', 'this_node_quantization_annotation', 'maybe_output_obs_node', 'output_is_a_tensor']
None
null
0
0
0
null
0
null
The function (_maybe_insert_input_and_output_observers_for_node) defined within the public class called public.The function start at line 584 and ends at 644. It contains 41 lines of code and it has a cyclomatic complexity of 8. It takes 5 parameters, represented as [584.0] and does not return any value..
pytorch_ao
public
public
0
0
prepare
def prepare(model: GraphModule,node_name_to_scope: dict[str, tuple[str, type]],is_qat: bool,obs_or_fq_callback=None,) -> GraphModule:# Since we are mutating the graph as we go, we iterate over the original# nodes before observer insertion, instead of model.graph.nodes.nodes_before_observation = list(model.graph.nodes)#...
3
35
4
136
6
647
692
647
null
['nodes_before_observation', 'model_device', 'edge_or_node_to_group_id', 'edge_or_node_to_qspec', 'model', 'obs_or_fq_map']
None
null
0
0
0
null
0
null
The function (prepare) defined within the public class called public.The function start at line 647 and ends at 692. It contains 35 lines of code and it has a cyclomatic complexity of 3. It takes 4 parameters, represented as [647.0] and does not return any value..
pytorch_ao
public
public
0
0
_get_quantized_conv_bn_example_inputs_kwargs
def _get_quantized_conv_bn_example_inputs_kwargs(is_per_channel: bool,has_bias: bool,bias_is_quantized: bool,is_cuda: bool,) -> dict[str, Any]:"""Optional example inputs for quantized and folded conv-bn patternsused in convert, expressed as kwargs."""kwargs = {}# Per tensor quantization uses literals to represent scale...
8
20
4
166
1
41
66
41
null
['kwargs']
None
null
0
0
0
null
0
null
The function (_get_quantized_conv_bn_example_inputs_kwargs) defined within the public class called public.The function start at line 41 and ends at 66. It contains 20 lines of code and it has a cyclomatic complexity of 8. It takes 4 parameters, represented as [41.0] and does not return any value..
pytorch_ao
public
public
0
0
_get_conv_bn_pattern._conv_bn_pattern
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(x, bn_running_mean, bn_running_var, bn_weight, bn_bias,...
1
14
7
82
0
70
83
70
null
[]
None
null
0
0
0
null
0
null
The function (_get_conv_bn_pattern._conv_bn_pattern) defined within the public class called public.The function start at line 70 and ends at 83. It contains 14 lines of code and it has a cyclomatic complexity of 1. It takes 7 parameters, represented as [70.0] and does not return any value..