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
_tensor_shape_equals
def _tensor_shape_equals(x: object, y: object) -> bool:if isinstance(x, torch.Tensor) and isinstance(y, torch.Tensor):return x.shape == y.shapeelif isinstance(x, (list, tuple)) and isinstance(y, (list, tuple)):return all(_tensor_shape_equals(e1, e2) for e1, e2 in zip(x, y))elif isinstance(x, dict) and isinstance(y, dic...
12
13
2
157
1
156
168
156
null
['all_equal']
None
null
0
0
0
null
0
null
The function (_tensor_shape_equals) defined within the public class called public.The function start at line 156 and ends at 168. It contains 13 lines of code and it has a cyclomatic complexity of 12. It takes 2 parameters, represented as [156.0] and does not return any value..
pytorch_ao
public
public
0
0
_loss_fn
def _loss_fn(loss: Callable[[torch.Tensor, torch.Tensor], torch.Tensor], x: object, y: object) -> object:"""The returned loss will have the same structure as `x` and `y`, e.g.if both are Tensor, we'll return a Tensorif both are list, we'll return a list of Tensorsif both are dict, we'll return a dict with the same key,...
9
11
3
169
0
171
187
171
null
[]
None
null
0
0
0
null
0
null
The function (_loss_fn) defined within the public class called public.The function start at line 171 and ends at 187. It contains 11 lines of code and it has a cyclomatic complexity of 9. It takes 3 parameters, represented as [171.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self,debug_info: NodeSourceDebugInfo,node_name: Optional[str] = None,nn_module_stack: Optional[object] = None,) -> None:super().__init__()self.node_name = node_nameself.nn_module_stack = nn_module_stackself.debug_info = debug_infoself.stats: list[object] = []
1
11
4
63
0
199
209
199
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 199 and ends at 209. It contains 11 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [199.0] and does not return any value..
pytorch_ao
public
public
0
0
forward
def forward(self, x: object) -> object:self.stats.append(_detach(x))return x
1
3
2
24
0
211
213
211
null
[]
None
null
0
0
0
null
0
null
The function (forward) defined within the public class called public.The function start at line 211 and ends at 213. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [211.0] and does not return any value..
pytorch_ao
public
public
0
0
__extra_repr__
def __extra_repr__(self) -> str:return (f"debug_info={self.debug_info}, node_name={self.node_name}, ""nn_module_stack={self.nn_module_stack}, num_stats={len(self.stats)})")
1
5
1
13
0
215
219
215
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 215 and ends at 219. 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
_insert_logger
def _insert_logger(model: GraphModule, node: Node, debug_info: NodeSourceDebugInfo) -> Node:"""For a given node, adds an OutputLogger that observes the output of that node,and all its users use the OutputLogger output instead.The OutputLogger will contain the debug_info which can be used to comparegraphs after transfor...
3
19
3
127
4
222
250
222
null
['logger_node', 'get_new_attr_name', 'logger_name', 'orig_users']
None
null
0
0
0
null
0
null
The function (_insert_logger) defined within the public class called public.The function start at line 222 and ends at 250. It contains 19 lines of code and it has a cyclomatic complexity of 3. It takes 3 parameters, represented as [222.0] and does not return any value..
pytorch_ao
public
public
0
0
prepare_for_propagation_comparison
def prepare_for_propagation_comparison(model: GraphModule) -> GraphModule:"""Add output loggers to unlifted nodeArgs:model (GraphModule): original modelReturns:a model with output loggers for all unlifted nodes"""# don't change the original modelmodel = copy.deepcopy(model)for n in model.graph.nodes:if (debug_info := _...
3
7
1
55
1
253
268
253
null
['model']
None
null
0
0
0
null
0
null
The function (prepare_for_propagation_comparison) defined within the public class called public.The function start at line 253 and ends at 268. 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
mse_loss
def mse_loss(self) -> object:return self.loss(F.mse_loss)
1
2
1
16
0
277
278
277
null
[]
None
null
0
0
0
null
0
null
The function (mse_loss) defined within the public class called public.The function start at line 277 and ends at 278. 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
sqnr
def sqnr(self) -> object:return self.loss(compute_sqnr)
1
2
1
14
0
281
282
281
null
[]
None
null
0
0
0
null
0
null
The function (sqnr) defined within the public class called public.The function start at line 281 and ends at 282. 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
loss
def loss(self, loss_function: Callable[[torch.Tensor, torch.Tensor], torch.Tensor]) -> object:return _loss_fn(loss_function, self.actual, self.ref)
1
4
2
39
0
284
287
284
null
[]
None
null
0
0
0
null
0
null
The function (loss) defined within the public class called public.The function start at line 284 and ends at 287. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [284.0] and does not return any value..
pytorch_ao
public
public
0
0
__repr__
def __repr__(self) -> str:# Don't include the tensors themselves as they are quite large to print# out.return (f"QuantizationComparisonResult(mse_loss={self.mse_loss}, sqnr={self.sqnr})")
1
4
1
12
0
289
294
289
null
[]
None
null
0
0
0
null
0
null
The function (__repr__) defined within the public class called public.The function start at line 289 and ends at 294. 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
__post_init__
def __post_init__(self) -> None:if not isinstance(self.actual, (torch.Tensor, list, tuple, dict)):raise ValueError(f"`self.actual` value must be a Tensor, list, tuple or dict, got: {self.actual}")if not isinstance(self.ref, (torch.Tensor, list, tuple, dict)):raise ValueError(f"`self.ref` value must be a Tensor, list, t...
4
13
1
80
0
296
310
296
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 296 and ends at 310. It contains 13 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
_module_stack_to_str
def _module_stack_to_str(module_stack: object) -> str:"""Simplifies the stack from ("mod", "mod.foo", "mod.foo.0", "mod.foo.0.linear")to "mod.foo.0.linear""""if not isinstance(module_stack, dict):return str(module_stack)module_values_list = list(module_stack.values())if len(module_values_list) > 0:owning_module = modul...
3
9
1
64
2
323
334
323
null
['owning_module', 'module_values_list']
None
null
0
0
0
null
0
null
The function (_module_stack_to_str) defined within the public class called public.The function start at line 323 and ends at 334. 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
extract_results_from_loggers
def extract_results_from_loggers(model: GraphModule,) -> dict[NodeSourceDebugInfo, tuple[Optional[str], object, list[object]]]:"""For a given model, extract the tensors stats and related information for each debug info.The reason we have a list of object, instead of Tensor is because the output of node may not bea Tens...
4
12
1
104
0
337
359
337
null
[]
None
null
0
0
0
null
0
null
The function (extract_results_from_loggers) defined within the public class called public.The function start at line 337 and ends at 359. It contains 12 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
compare_results
def compare_results(ref_results: dict[NodeSourceDebugInfo, tuple[Optional[str], object, list[torch.Tensor]]],actual_results: dict[NodeSourceDebugInfo, tuple[Optional[str], object, list[torch.Tensor]]],) -> dict[NodeSourceDebugInfo, NodeAccuracySummary]:"""Given two dict mapping from `NodeSourceDebugInfo` to list of ten...
7
35
4
191
2
362
411
362
null
['results', 'comparisons']
None
null
0
0
0
null
0
null
The function (compare_results) defined within the public class called public.The function start at line 362 and ends at 411. It contains 35 lines of code and it has a cyclomatic complexity of 7. It takes 4 parameters, represented as [362.0] and does not return any value..
pytorch_ao
public
public
0
0
replace_node_with_constant
def replace_node_with_constant(gm: torch.fx.GraphModule,node: torch.fx.Node,constant: Optional[torch.Tensor] = None,name: Optional[str] = None,) -> None:g = gm.graphif name:qualname = nameelse:if not hasattr(gm, "_frozen_param_count"):gm._frozen_param_count = 0# type: ignore[assignment]i = gm._frozen_param_countwhile T...
7
32
4
204
4
25
64
25
null
['g', 'qualname', 'i', 'new_input_node']
None
null
0
0
0
null
0
null
The function (replace_node_with_constant) defined within the public class called public.The function start at line 25 and ends at 64. It contains 32 lines of code and it has a cyclomatic complexity of 7. It takes 4 parameters, represented as [25.0] and does not return any value..
pytorch_ao
public
public
0
0
is_const_source
def is_const_source(node: torch.fx.Node, lifted_constant_names: Optional[list[str]]) -> bool:return node.op == "get_attr" or node.name in (lifted_constant_names or ())
3
4
2
40
0
67
70
67
null
[]
None
null
0
0
0
null
0
null
The function (is_const_source) defined within the public class called public.The function start at line 67 and ends at 70. It contains 4 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [67.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self,gm: torch.fx.GraphModule,skip_constructors: bool = False,lifted_constant_names: Optional[list[str]] = None,skip_folding_node_fn: Optional[Callable[[torch.fx.Node], bool]] = None,) -> None:super().__init__(gm)self.node_replacements: dict[torch.fx.Node, Any] = {}self.replaced_uses: dict[torch.fx.Node, i...
1
17
6
148
0
74
95
74
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 74 and ends at 95. It contains 17 lines of code and it has a cyclomatic complexity of 1. It takes 6 parameters, represented as [74.0] and does not return any value..
pytorch_ao
public
public
0
0
_find_mutable_buffers
def _find_mutable_buffers(self) -> set[torch.fx.Node]:"""Find mutable buffers by identifying copy_ operations.The first argument of copy_ op is the mutable buffer."""mutable_buffers = set()for node in self.module.graph.nodes:if (node.op == "call_function"and hasattr(node.target, "_schema")and "copy_" in str(node.target...
7
11
1
97
0
97
110
97
null
[]
None
null
0
0
0
null
0
null
The function (_find_mutable_buffers) defined within the public class called public.The function start at line 97 and ends at 110. It contains 11 lines of code and it has a cyclomatic complexity of 7. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
_support_dynamic_shape
def _support_dynamic_shape(self) -> bool:# ConstantFolder not support dynamic shape nowreturn False
1
2
1
9
0
112
114
112
null
[]
None
null
0
0
0
null
0
null
The function (_support_dynamic_shape) defined within the public class called public.The function start at line 112 and ends at 114. 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
_deduce_value
def _deduce_value(self, node: torch.fx.Node) -> Any:if self.lifted_constant_names is None:return super().run_node(node)# if lifted_constant_names is passed in, no concrete value is available# so we just check if all inputs have valuesif self.skip_folding_node_fn is not None and self.skip_folding_node_fn(node):return se...
9
14
2
118
0
116
131
116
null
[]
None
null
0
0
0
null
0
null
The function (_deduce_value) defined within the public class called public.The function start at line 116 and ends at 131. It contains 14 lines of code and it has a cyclomatic complexity of 9. It takes 2 parameters, represented as [116.0] and does not return any value..
pytorch_ao
public
public
0
0
is_impure.is_woq_int8_pattern
def is_woq_int8_pattern(node: torch.fx.node.Node) -> bool:return (node.target == torch.ops.prims.convert_element_type.default# type: ignore[return-value]and isinstance(node.args[0], torch.fx.Node)and "val" in node.args[0].metaand node.args[0].meta["val"].dtype == torch.int8# type: ignore[union-attr]and node.args[1] == ...
5
8
1
87
0
134
141
134
null
[]
None
null
0
0
0
null
0
null
The function (is_impure.is_woq_int8_pattern) defined within the public class called public.The function start at line 134 and ends at 141. It contains 8 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
is_impure
def is_impure(self, node: torch.fx.node.Node) -> bool:def is_woq_int8_pattern(node: torch.fx.node.Node) -> bool:return (node.target == torch.ops.prims.convert_element_type.default# type: ignore[return-value]and isinstance(node.args[0], torch.fx.Node)and "val" in node.args[0].metaand node.args[0].meta["val"].dtype == to...
10
27
2
172
0
133
178
133
null
[]
None
null
0
0
0
null
0
null
The function (is_impure) defined within the public class called public.The function start at line 133 and ends at 178. It contains 27 lines of code and it has a cyclomatic complexity of 10. It takes 2 parameters, represented as [133.0] and does not return any value..
pytorch_ao
public
public
0
0
node_to_last_non_output_use.add_use
def add_use(inp: torch.fx.Node) -> None:if inp in seen_uses:returnseen_uses.add(inp)last_non_output_use[node].append(inp)
2
5
1
34
0
189
194
189
null
[]
None
null
0
0
0
null
0
null
The function (node_to_last_non_output_use.add_use) defined within the public class called public.The function start at line 189 and ends at 194. 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
node_to_last_non_output_use
def node_to_last_non_output_use(self) -> dict[torch.fx.Node, list[torch.fx.Node]]:last_non_output_use = collections.defaultdict(list)seen_uses = OrderedSet[torch.fx.Node]()output_node = next(iter(reversed(self.module.graph.nodes)))# type: ignore[arg-type, union-attr]for node in reversed(self.module.graph.nodes):# type:...
5
12
1
134
0
180
203
180
null
[]
None
null
0
0
0
null
0
null
The function (node_to_last_non_output_use) defined within the public class called public.The function start at line 180 and ends at 203. It contains 12 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
run_node.set_env
def set_env(arg: torch.fx.Node) -> None:self.env[arg] = self.unknown_value
1
2
1
23
0
209
210
209
null
[]
None
null
0
0
0
null
0
null
The function (run_node.set_env) defined within the public class called public.The function start at line 209 and ends at 210. 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
run_node
def run_node(self, node: torch.fx.Node) -> Any:if node.target == "output":# because we remove nodes from env on last non output use,# re-define them now or we'll get error in interpreterdef set_env(arg: torch.fx.Node) -> None:self.env[arg] = self.unknown_value# In-place is fine since we don't mutatepytree.tree_map_only...
30
61
2
431
0
205
298
205
null
[]
None
null
0
0
0
null
0
null
The function (run_node) defined within the public class called public.The function start at line 205 and ends at 298. It contains 61 lines of code and it has a cyclomatic complexity of 30. It takes 2 parameters, represented as [205.0] and does not return any value..
pytorch_ao
public
public
0
0
insertable_tensor_check
def insertable_tensor_check(self, tensor: torch.Tensor) -> bool:return True
1
2
2
15
0
300
301
300
null
[]
None
null
0
0
0
null
0
null
The function (insertable_tensor_check) defined within the public class called public.The function start at line 300 and ends at 301. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [300.0] and does not return any value..
pytorch_ao
public
public
0
0
add_node_replacement
def add_node_replacement(self, node: torch.fx.Node, tensor: torch.Tensor) -> None:self.node_replacements[node] = tensor
1
2
3
29
0
303
304
303
null
[]
None
null
0
0
0
null
0
null
The function (add_node_replacement) defined within the public class called public.The function start at line 303 and ends at 304. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [303.0] and does not return any value..
pytorch_ao
public
public
0
0
run
def run(self) -> Any:# type: ignore[override]env: dict[torch.fx.Node, Any] = {}self.insert_placerholder_values(env)return super().run(initial_env=env)
1
4
1
39
0
306
309
306
null
[]
None
null
0
0
0
null
0
null
The function (run) defined within the public class called public.The function start at line 306 and ends at 309. 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
insert_placerholder_values
def insert_placerholder_values(self, env: dict[torch.fx.Node, Any]) -> None:for n in self.module.graph.find_nodes(op="placeholder"):# type: ignore[operator, union-attr]env[n] = self.unknown_value# type: ignore[assignment]if self.lifted_constant_names is None:returnfor n in self.module.graph.nodes:# type: ignore[union-a...
6
8
2
85
0
311
318
311
null
[]
None
null
0
0
0
null
0
null
The function (insert_placerholder_values) defined within the public class called public.The function start at line 311 and ends at 318. It contains 8 lines of code and it has a cyclomatic complexity of 6. It takes 2 parameters, represented as [311.0] and does not return any value..
pytorch_ao
public
public
0
0
constant_fold
def constant_fold(gm: torch.fx.GraphModule,constraint_fn: Optional[Callable[[torch.fx.Node], bool]] = None,) -> None:with torch.utils._python_dispatch._disable_current_modes():cf = ConstantFolder(gm, skip_constructors=True)cf.run()for node, constant in cf.node_replacements.items():if constraint_fn is not None and not c...
8
22
3
178
2
321
346
321
null
['erased_params', 'cf']
None
null
0
0
0
null
0
null
The function (constant_fold) defined within the public class called public.The function start at line 321 and ends at 346. It contains 22 lines of code and it has a cyclomatic complexity of 8. It takes 3 parameters, represented as [321.0] and does not return any value..
pytorch_ao
public
public
0
0
constant_graph_tag
def constant_graph_tag(gm: torch.fx.GraphModule,skip_constructors: bool = True,lifted_constant_names: Optional[list[str]] = None,skip_folding_node_fn: Optional[Callable[[torch.fx.Node], bool]] = None,) -> None:with torch.utils._python_dispatch._disable_current_modes():cf = ConstantFolder(gm,skip_constructors=skip_const...
7
26
5
156
1
349
375
349
null
['cf']
None
null
0
0
0
null
0
null
The function (constant_graph_tag) defined within the public class called public.The function start at line 349 and ends at 375. It contains 26 lines of code and it has a cyclomatic complexity of 7. It takes 5 parameters, represented as [349.0] and does not return any value..
pytorch_ao
public
public
0
0
run_and_get_constant_graph.untag
def untag(node: torch.fx.Node) -> bool:used_to_fold = Falsefor u in node.users:if u.meta[META_TAG] == CONST_MODULE_TAG:used_to_fold = Truebreakif not used_to_fold:node.meta[META_TAG] = MODULE_TAGreturn used_to_fold
4
9
1
51
0
393
401
393
null
[]
None
null
0
0
0
null
0
null
The function (run_and_get_constant_graph.untag) defined within the public class called public.The function start at line 393 and ends at 401. 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
run_and_get_constant_graph
def run_and_get_constant_graph(gm: torch.fx.GraphModule,skip_constructors: bool = True,lifted_constant_names: Optional[list[str]] = None,skip_folding_node_fn: Optional[Callable[[torch.fx.Node], bool]] = None,) -> torch.fx.GraphModule:"""Construct a GraphModule which corresponds to the part which could beconstant folded...
9
29
5
228
5
378
429
378
null
['new_graph', 'new_node', 'new_gm', 'output_nodes', 'used_to_fold']
None
null
0
0
0
null
0
null
The function (run_and_get_constant_graph) defined within the public class called public.The function start at line 378 and ends at 429. It contains 29 lines of code and it has a cyclomatic complexity of 9. It takes 5 parameters, represented as [378.0] and does not return any value..
pytorch_ao
public
public
0
0
attach_preserved_attrs_to_model
def attach_preserved_attrs_to_model(model: Union[GraphModule, torch.nn.Module],preserved_attrs: dict[str, Any],) -> None:"""Store preserved attributes to the model.meta so that it can be preserved during deepcopy"""model.meta[_USER_PRESERVED_ATTRIBUTES_KEY] = copy.copy(preserved_attrs)# type: ignore[operator, index, as...
2
7
2
66
0
103
112
103
null
[]
None
null
0
0
0
null
0
null
The function (attach_preserved_attrs_to_model) defined within the public class called public.The function start at line 103 and ends at 112. It contains 7 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [103.0] and does not return any value..
pytorch_ao
public
public
0
0
_check_is_graph_module
def _check_is_graph_module(model: torch.nn.Module) -> None:if not isinstance(model, GraphModule):raise ValueError("input model must be a GraphModule, "+ "Got type:"+ str(type(model))+ " Please make "+ "sure to follow the tutorials.")
2
9
1
41
0
115
123
115
null
[]
None
null
0
0
0
null
0
null
The function (_check_is_graph_module) defined within the public class called public.The function start at line 115 and ends at 123. 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
_replace_observer_with_quantize_dequantize_node_decomposed.add_dequantize_op_kwargs
def add_dequantize_op_kwargs(dequantize_op, input_node):dequantize_op_kwargs = {}if "val" in input_node.meta:dq_out_dtype = input_node.meta["val"].dtypeif dq_out_dtype != torch.float32:dequantize_op_kwargs = {"out_dtype": dq_out_dtype}return dequantize_op_kwargs
3
7
2
44
0
179
185
179
null
[]
None
null
0
0
0
null
0
null
The function (_replace_observer_with_quantize_dequantize_node_decomposed.add_dequantize_op_kwargs) defined within the public class called public.The function start at line 179 and ends at 185. It contains 7 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [179.0] and does not...
pytorch_ao
public
public
0
0
_replace_observer_with_quantize_dequantize_node_decomposed.add_quantize_dequantize_node_info
def add_quantize_dequantize_node_info(qdq_node, original_node):# propagate from_node info from observer/fake_quant node to quantize/dequantize nodeqdq_node.meta[FROM_NODE_KEY] = [NodeSource(original_node,"replace_observer_with_quantize_dequantize_node",[NodeSourceAction.CREATE],)]
1
8
2
29
0
187
195
187
null
[]
None
null
0
0
0
null
0
null
The function (_replace_observer_with_quantize_dequantize_node_decomposed.add_quantize_dequantize_node_info) defined within the public class called public.The function start at line 187 and ends at 195. It contains 8 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [187.0] and...
pytorch_ao
public
public
0
0
_replace_observer_with_quantize_dequantize_node_decomposed
def _replace_observer_with_quantize_dequantize_node_decomposed(model: torch.fx.GraphModule,node: Node,modules: dict[str, torch.nn.Module],node_name_to_scope: dict[str, tuple[str, type]],node_name_to_qconfig: dict[str, QConfigAny],model_device: Optional[torch.device] = None,) -> None:"""Replace activation_post_process m...
17
177
6
1,048
33
126
398
126
null
['skip_replacement', 'dq_inputs', 'quant_max', 'dequantized_node', 'choose_qparams_op', 'zero_point', 'dq_out_dtype', 'eps', 'scale', 'dtype_', 'qscheme', 'scale_node', 'choose_qparams_node', 'dequantize_op_kwargs', 'graph', 'dtype_convert_op', 'quantize_op', 'is_dynamic', 'dtype', 'quantized_node', 'dequantize_op', 'n...
None
null
0
0
0
null
0
null
The function (_replace_observer_with_quantize_dequantize_node_decomposed) defined within the public class called public.The function start at line 126 and ends at 398. It contains 177 lines of code and it has a cyclomatic complexity of 17. It takes 6 parameters, represented as [126.0] and does not return any value..
pytorch_ao
public
public
0
0
_replace_observer_with_quantize_dequantize_node
def _replace_observer_with_quantize_dequantize_node(model: torch.fx.GraphModule,node: Node,modules: dict[str, torch.nn.Module],node_name_to_scope: dict[str, tuple[str, type]],node_name_to_qconfig: dict[str, QConfigAny],model_device: Optional[torch.device] = None,) -> None:"""Replace activation_post_process module call ...
14
104
6
660
17
404
547
404
null
['graph', 'skip_replacement', 'quantize_op', 'zero_point', 'qparam_node', 'reduce_range', 'is_dynamic', 'qparams', 'activation_post_process', 'scale', 'dtype', 'quantized_node', 'dequantized_node', 'input_node', 'node_type', 'ch_axis', 'quantize_op_inputs']
None
null
0
0
0
null
0
null
The function (_replace_observer_with_quantize_dequantize_node) defined within the public class called public.The function start at line 404 and ends at 547. It contains 104 lines of code and it has a cyclomatic complexity of 14. It takes 6 parameters, represented as [404.0] and does not return any value..
pytorch_ao
public
public
0
0
_replace_observer_or_dequant_stub_with_dequantize_node
def _replace_observer_or_dequant_stub_with_dequantize_node(node: Node, graph: Graph) -> None:call_custom_module_node = node.args[0]assert isinstance(call_custom_module_node, Node), (f"Expecting the for call custom module node to be a Node, but got {call_custom_module_node}")node.replace_all_uses_with(call_custom_module...
1
10
2
51
1
558
567
558
null
['call_custom_module_node']
None
null
0
0
0
null
0
null
The function (_replace_observer_or_dequant_stub_with_dequantize_node) defined within the public class called public.The function start at line 558 and ends at 567. It contains 10 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [558.0] and does not return any value..
pytorch_ao
public
public
0
0
_is_conversion_supported
def _is_conversion_supported(activation_post_process: torch.nn.Module) -> bool:dtype = activation_post_process.dtype# type: ignore[attr-defined]is_dynamic = Falseif hasattr(activation_post_process, "is_dynamic"):is_dynamic = activation_post_process.is_dynamic# type: ignore[attr-defined, assignment]return ((dtype in SUP...
5
10
1
55
2
570
581
570
null
['dtype', 'is_dynamic']
None
null
0
0
0
null
0
null
The function (_is_conversion_supported) defined within the public class called public.The function start at line 570 and ends at 581. It contains 10 lines of code and it has a cyclomatic complexity of 5. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
_has_none_qconfig
def _has_none_qconfig(node: Argument, node_name_to_qconfig: dict[str, QConfigAny]) -> bool:"""Check if a node has a qconfig of None, i.e. user requested to not quantizethe node"""return (isinstance(node, Node)and node.name in node_name_to_qconfigand node_name_to_qconfig[node.name] is None)
3
8
2
43
0
584
594
584
null
[]
None
null
0
0
0
null
0
null
The function (_has_none_qconfig) defined within the public class called public.The function start at line 584 and ends at 594. It contains 8 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [584.0] and does not return any value..
pytorch_ao
public
public
0
0
_run_weight_observers
def _run_weight_observers(observed: GraphModule, backend_config: BackendConfig) -> None:"""Extract the subgraph that produces the weight for dynamic quantor weight only quant node and run the subgraph to observe the weight.Note that the observers of dynamic quant or weight only quant ops arerun during the convert step....
7
13
2
71
2
597
616
597
null
['weight_observer_nodes', 'weight_observer_module']
None
null
0
0
0
null
0
null
The function (_run_weight_observers) defined within the public class called public.The function start at line 597 and ends at 616. It contains 13 lines of code and it has a cyclomatic complexity of 7. It takes 2 parameters, represented as [597.0] and does not return any value..
pytorch_ao
public
public
0
0
_maybe_recursive_remove_dequantize
def _maybe_recursive_remove_dequantize(arg: Any, node: Node, graph: Graph) -> None:"""If the arg is a dequantize Node, or a list/tuple/dict of dequantize Node,we'll recursively remove the dequantize Node"""if isinstance(arg, Node) and arg.op == "call_method" and arg.target == "dequantize":quantize_node = arg.args[0]# w...
8
14
3
113
1
619
637
619
null
['quantize_node']
None
null
0
0
0
null
0
null
The function (_maybe_recursive_remove_dequantize) defined within the public class called public.The function start at line 619 and ends at 637. It contains 14 lines of code and it has a cyclomatic complexity of 8. It takes 3 parameters, represented as [619.0] and does not return any value..
pytorch_ao
public
public
0
0
_get_module_path_and_prefix
def _get_module_path_and_prefix(obs_node: Node,node_name_to_scope: dict[str, tuple[str, type]],node_name_to_qconfig: dict[str, QConfigAny],) -> tuple[str, str]:"""Given and observer node, get the `Scope` or the fully qualified name forthe submodule containing the observed node, also return a prefix of "_input"when the ...
10
36
3
178
7
640
694
640
null
['prefix', 'module_path', 'is_input_observer_only', 'users', 'observed_node', 'linear_node', 'first_linear_use_or_first_use']
None
null
0
0
0
null
0
null
The function (_get_module_path_and_prefix) defined within the public class called public.The function start at line 640 and ends at 694. It contains 36 lines of code and it has a cyclomatic complexity of 10. It takes 3 parameters, represented as [640.0] and does not return any value..
pytorch_ao
public
public
0
0
_insert_dequantize_node
def _insert_dequantize_node(node: Node, graph: Graph) -> None:"""Inserts dequantize node for `node` in `graph`"""with graph.inserting_after(node):dequantize_node = graph.call_method("dequantize", (node,))for user_node in dict(node.users):if user_node is not dequantize_node:user_node.replace_input_with(node, dequantize_...
3
6
2
59
1
697
703
697
null
['dequantize_node']
None
null
0
0
0
null
0
null
The function (_insert_dequantize_node) defined within the public class called public.The function start at line 697 and ends at 703. It contains 6 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [697.0] and does not return any value..
pytorch_ao
public
public
0
0
_maybe_get_observer_for_node
def _maybe_get_observer_for_node(node: Node, modules: dict[str, torch.nn.Module]) -> Optional[torch.nn.Module]:"""If the node is observed, return the observerinstance. Otherwise, return None."""for maybe_obs_node in node.users.keys():if maybe_obs_node.op == "call_module":maybe_obs = modules[str(maybe_obs_node.target)]i...
4
9
2
69
1
706
718
706
null
['maybe_obs']
None
null
0
0
0
null
0
null
The function (_maybe_get_observer_for_node) defined within the public class called public.The function start at line 706 and ends at 718. It contains 9 lines of code and it has a cyclomatic complexity of 4. It takes 2 parameters, represented as [706.0] and does not return any value..
pytorch_ao
public
public
0
0
convert_standalone_module
def convert_standalone_module(node: Node,modules: dict[str, torch.nn.Module],model: torch.fx.GraphModule,is_reference: bool,backend_config: Optional[BackendConfig],) -> None:"""Converts a observed standalone module to a quantized standalone module by callingthe fx convert api, currently using the same `is_reference` fl...
8
37
5
248
7
721
782
721
null
['arg', 'quantize_node', 'args', 'convert_fn', 'sm_input_quantized_idxs', 'sm_output_quantized_idxs', 'quantized_standalone_module']
None
null
0
0
0
null
0
null
The function (convert_standalone_module) defined within the public class called public.The function start at line 721 and ends at 782. It contains 37 lines of code and it has a cyclomatic complexity of 8. It takes 5 parameters, represented as [721.0] and does not return any value..
pytorch_ao
public
public
0
0
convert_weighted_module
def convert_weighted_module(node: Node,modules: dict[str, torch.nn.Module],observed_node_names: set[str],node_name_to_qconfig: dict[str, QConfigAny],backend_config: BackendConfig,is_decomposed: bool = False,is_reference: bool = False,model_device: Optional[torch.device] = None,) -> None:"""Convert a weighted module to ...
21
89
8
531
21
785
930
785
null
['ref_qmodule_cls', 'is_qat', 'weight_post_process', 'original_module', 'float_module', 'is_observed', 'device', 'root_module_to_quantized_reference_module', 'is_ptq', 'weight_post_process_ih', 'weight_qparams_hh', 'weight_post_process_hh', 'pattern_to_dtype_configs', 'dtype_configs', 'is_weight_quantized', 'fused_modu...
None
null
0
0
0
null
0
null
The function (convert_weighted_module) defined within the public class called public.The function start at line 785 and ends at 930. It contains 89 lines of code and it has a cyclomatic complexity of 21. It takes 8 parameters, represented as [785.0] and does not return any value..
pytorch_ao
public
public
0
0
convert
def convert(model: GraphModule,is_reference: bool = False,convert_custom_config: Union[ConvertCustomConfig, dict[str, Any], None] = None,is_standalone_module: bool = False,_remove_qconfig_flag: bool = True,qconfig_mapping: Union[QConfigMapping, dict[str, Any], None] = None,backend_config: Union[BackendConfig, dict[str,...
32
176
12
852
20
933
1,195
933
null
['observed_graph_module_attrs', 'mod', 'return_node', 'cur_placeholder_node_idx', 'modules_copy', 'weight_eq_obs_dict', 'model_device', 'root_module_to_quantized_reference_module', 'placeholder_node_seen_cnt', 'backend_config', 'convert_custom_config', 'modules', 'convert_node_name_to_qconfig', 'output', 'node_name_to_...
None
null
0
0
0
null
0
null
The function (convert) defined within the public class called public.The function start at line 933 and ends at 1195. It contains 176 lines of code and it has a cyclomatic complexity of 32. It takes 12 parameters, represented as [933.0] and does not return any value..
pytorch_ao
public
public
0
0
_convert_fx
def _convert_fx(graph_module: GraphModule,is_reference: bool,convert_custom_config: Union[ConvertCustomConfig, dict[str, Any], None] = None,is_standalone_module: bool = False,_remove_qconfig: bool = True,qconfig_mapping: Union[QConfigMapping, dict[str, Any], None] = None,backend_config: Union[BackendConfig, dict[str, A...
5
41
12
206
4
1,198
1,243
1,198
null
['convert_custom_config', 'preserved_attr_names', 'preserved_attrs', 'quantized']
None
null
0
0
0
null
0
null
The function (_convert_fx) defined within the public class called public.The function start at line 1198 and ends at 1243. It contains 41 lines of code and it has a cyclomatic complexity of 5. It takes 12 parameters, represented as [1198.0] and does not return any value..
pytorch_ao
public
public
0
0
_convert_to_reference_decomposed_fx
def _convert_to_reference_decomposed_fx(graph_module: GraphModule,convert_custom_config: Union[ConvertCustomConfig, dict[str, Any], None] = None,qconfig_mapping: Union[QConfigMapping, dict[str, Any], None] = None,backend_config: Union[BackendConfig, dict[str, Any], None] = None,) -> GraphModule:r"""Convert a calibrated...
1
15
7
96
0
1,246
1,295
1,246
null
[]
None
null
0
0
0
null
0
null
The function (_convert_to_reference_decomposed_fx) defined within the public class called public.The function start at line 1246 and ends at 1295. It contains 15 lines of code and it has a cyclomatic complexity of 1. It takes 7 parameters, represented as [1246.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self, fn):super().__init__()self.fn = fn
1
3
2
19
0
27
29
27
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 27 and ends at 29. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [27.0] and does not return any value..
pytorch_ao
public
public
0
0
forward
def forward(self, *args, **kwargs):"""Simple forward that just calls the ``fn`` provided to :meth:`WrapperModule.__init__`."""return self.fn(*args, **kwargs)
1
2
3
23
0
31
33
31
null
[]
None
null
0
0
0
null
0
null
The function (forward) defined within the public class called public.The function start at line 31 and ends at 33. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [31.0] and does not return any value..
pytorch_ao
public
public
0
0
model_is_exported
def model_is_exported(m: torch.nn.Module) -> bool:"""Return True if the `torch.nn.Module` was exported, False otherwise(e.g. if the model was FX symbolically traced or not traced at all)."""return isinstance(m, torch.fx.GraphModule) and any("val" in n.meta for n in m.graph.nodes)
3
4
1
42
0
36
43
36
null
[]
None
null
0
0
0
null
0
null
The function (model_is_exported) defined within the public class called public.The function start at line 36 and ends at 43. It contains 4 lines of code and it has a cyclomatic complexity of 3. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
_replace_dropout.dropout_train
def dropout_train(x):return F.dropout(x, p=0.5, training=True, inplace=inplace)
1
2
1
26
0
66
67
66
null
[]
None
null
0
0
0
null
0
null
The function (_replace_dropout.dropout_train) defined within the public class called public.The function start at line 66 and ends at 67. 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
_replace_dropout.dropout_eval
def dropout_eval(x):return F.dropout(x, p=0.5, training=False, inplace=inplace)
1
2
1
26
0
69
70
69
null
[]
None
null
0
0
0
null
0
null
The function (_replace_dropout.dropout_eval) defined within the public class called public.The function start at line 69 and ends at 70. 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
_replace_dropout
def _replace_dropout(m: torch.fx.GraphModule, train_to_eval: bool):"""Switch dropout patterns in the model between train and eval modes.Dropout has different behavior in train vs eval mode. For exported models,however, calling `model.train()` or `model.eval()` does not automatically switchthe dropout behavior between t...
3
35
2
141
3
46
101
46
null
['match_pattern', 'replacement_pattern', 'example_inputs']
None
null
0
0
0
null
0
null
The function (_replace_dropout) defined within the public class called public.The function start at line 46 and ends at 101. It contains 35 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [46.0] and does not return any value..
pytorch_ao
public
public
0
0
_replace_batchnorm.bn_train
def bn_train(x: torch.Tensor,bn_weight: torch.Tensor,bn_bias: torch.Tensor,bn_running_mean: torch.Tensor,bn_running_var: torch.Tensor,):return F.batch_norm(x, bn_running_mean, bn_running_var, bn_weight, bn_bias, training=True)
1
10
5
53
0
123
132
123
null
[]
None
null
0
0
0
null
0
null
The function (_replace_batchnorm.bn_train) defined within the public class called public.The function start at line 123 and ends at 132. It contains 10 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [123.0] and does not return any value..
pytorch_ao
public
public
0
0
_replace_batchnorm.bn_eval
def bn_eval(x: torch.Tensor,bn_weight: torch.Tensor,bn_bias: torch.Tensor,bn_running_mean: torch.Tensor,bn_running_var: torch.Tensor,):return F.batch_norm(x, bn_running_mean, bn_running_var, bn_weight, bn_bias, training=False)
1
10
5
53
0
134
143
134
null
[]
None
null
0
0
0
null
0
null
The function (_replace_batchnorm.bn_eval) defined within the public class called public.The function start at line 134 and ends at 143. It contains 10 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [134.0] and does not return any value..
pytorch_ao
public
public
0
0
_replace_batchnorm
def _replace_batchnorm(m: torch.fx.GraphModule, train_to_eval: bool):"""Switch batchnorm patterns in the model between train and eval modes.Batchnorm has different behavior in train vs eval mode. For exported models,however, calling `model.train()` or `model.eval()` does not automatically switchthe batchnorm behavior b...
3
40
2
176
7
104
182
104
null
['bn_train_aten', 'is_cuda', 'device', 'example_inputs', 'bn_eval_aten', 'match_pattern', 'replacement_pattern']
None
null
0
0
0
null
0
null
The function (_replace_batchnorm) defined within the public class called public.The function start at line 104 and ends at 182. It contains 40 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [104.0] and does not return any value..
pytorch_ao
public
public
0
0
_move_exported_model_to_eval
def _move_exported_model_to_eval(model: torch.fx.GraphModule):"""Move an exported GraphModule to eval mode.This is equivalent to model.eval() but only for certain special ops like dropout, batchnorm.QAT users should call this before performing inference on the model.This call is idempotent; if the model is already in e...
2
8
1
54
1
186
201
186
null
['is_training']
None
null
0
0
0
null
0
null
The function (_move_exported_model_to_eval) defined within the public class called public.The function start at line 186 and ends at 201. It contains 8 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
_move_exported_model_to_train
def _move_exported_model_to_train(model: torch.fx.GraphModule):"""Move an exported GraphModule to train mode.This is equivalent to model.train() but only for certain special ops like dropout, batchnorm.QAT users should call this before performing training on the model.This call is idempotent; if the model is already in...
2
8
1
53
1
204
219
204
null
['is_training']
None
null
0
0
0
null
0
null
The function (_move_exported_model_to_train) defined within the public class called public.The function start at line 204 and ends at 219. It contains 8 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
_allow_exported_model_train_eval._train
def _train(self, mode: bool = True):if mode:_move_exported_model_to_train(self)else:_move_exported_model_to_eval(self)
2
5
2
24
0
235
239
235
null
[]
None
null
0
0
0
null
0
null
The function (_allow_exported_model_train_eval._train) defined within the public class called public.The function start at line 235 and ends at 239. It contains 5 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [235.0] and does not return any value..
pytorch_ao
public
public
0
0
_allow_exported_model_train_eval._eval
def _eval(self):_move_exported_model_to_eval(self)
1
2
1
9
0
241
242
241
null
[]
None
null
0
0
0
null
0
null
The function (_allow_exported_model_train_eval._eval) defined within the public class called public.The function start at line 241 and ends at 242. 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
_allow_exported_model_train_eval
def _allow_exported_model_train_eval(model: torch.fx.GraphModule):"""Allow users to call `model.train()` and `model.eval()` on an exported model,but with the effect of changing behavior between the two modes limited to specialops only, which are currently dropout and batchnorm.Note: This does not achieve the same effec...
1
6
1
42
0
222
246
222
null
[]
None
null
0
0
0
null
0
null
The function (_allow_exported_model_train_eval) defined within the public class called public.The function start at line 222 and ends at 246. It contains 6 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
_is_per_channel
def _is_per_channel(qscheme: "torch.qscheme") -> bool:return qscheme in [torch.per_channel_symmetric,torch.per_channel_affine,torch.per_channel_affine_float_qparams,]
1
6
1
26
0
56
61
56
null
[]
None
null
0
0
0
null
0
null
The function (_is_per_channel) defined within the public class called public.The function start at line 56 and ends at 61. It contains 6 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
_is_per_tensor
def _is_per_tensor(qscheme: "torch.qscheme") -> bool:return qscheme in [torch.per_tensor_symmetric, torch.per_tensor_affine]
1
2
1
21
0
64
65
64
null
[]
None
null
0
0
0
null
0
null
The function (_is_per_tensor) defined within the public class called public.The function start at line 64 and ends at 65. It contains 2 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
_is_symmetric_quant
def _is_symmetric_quant(qscheme: "torch.qscheme") -> bool:return qscheme in [torch.per_tensor_symmetric, torch.per_channel_symmetric]
1
2
1
21
0
68
69
68
null
[]
None
null
0
0
0
null
0
null
The function (_is_symmetric_quant) defined within the public class called public.The function start at line 68 and ends at 69. It contains 2 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
_is_float_qparams
def _is_float_qparams(qscheme: "torch.qscheme") -> bool:return qscheme in [torch.per_channel_affine_float_qparams,]
1
4
1
18
0
72
75
72
null
[]
None
null
0
0
0
null
0
null
The function (_is_float_qparams) defined within the public class called public.The function start at line 72 and ends at 75. 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:"""Set fake_quant_enabled and observer_enabled."""super().__init__()# fake_quant_enabled and observer_enabled are buffers to support their# replication in DDP. Data type is uint8 because NCCL does not support# bool tensors.self.register_buffer("fake_quant_enabled", torch.tensor([1], dtype=tor...
1
4
1
57
0
94
101
94
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 94 and ends at 101. 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
forward
def forward(self, x):pass
1
2
2
8
0
104
105
104
null
[]
None
null
0
0
0
null
0
null
The function (forward) defined within the public class called public.The function start at line 104 and ends at 105. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [104.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
108
109
108
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 108 and ends at 109. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [108.0] and does not return any value..
pytorch_ao
public
public
0
0
enable_fake_quant
def enable_fake_quant(self, enabled: bool = True) -> None:self.fake_quant_enabled[0] = 1 if enabled else 0
2
2
2
25
0
112
113
112
null
[]
None
null
0
0
0
null
0
null
The function (enable_fake_quant) defined within the public class called public.The function start at line 112 and ends at 113. It contains 2 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [112.0] and does not return any value..
pytorch_ao
public
public
0
0
disable_fake_quant
def disable_fake_quant(self):self.enable_fake_quant(False)
1
2
1
11
0
116
117
116
null
[]
None
null
0
0
0
null
0
null
The function (disable_fake_quant) defined within the public class called public.The function start at line 116 and ends at 117. 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
enable_observer
def enable_observer(self, enabled: bool = True) -> None:self.observer_enabled[0] = 1 if enabled else 0
2
2
2
25
0
120
121
120
null
[]
None
null
0
0
0
null
0
null
The function (enable_observer) defined within the public class called public.The function start at line 120 and ends at 121. It contains 2 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [120.0] and does not return any value..
pytorch_ao
public
public
0
0
disable_observer
def disable_observer(self):self.enable_observer(False)
1
2
1
11
0
124
125
124
null
[]
None
null
0
0
0
null
0
null
The function (disable_observer) defined within the public class called public.The function start at line 124 and ends at 125. 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(cls, **kwargs):fake_quant_constructor = _with_args(cls, **kwargs)# need to assign the correct module to fake_quantize# constructors to satisfy public v private requirementsfake_quant_constructor.__module__ = "torchao.quantization.pt2e.fake_quantize"return fake_quant_constructor
1
4
2
24
0
128
133
128
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 128 and ends at 133. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [128.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self,observer=MovingAverageMinMaxObserver,quant_min=None,quant_max=None,is_dynamic=False,**observer_kwargs,):super().__init__()# Populate quant_min/quant_max to observer_kwargs if validif quant_min is not None and quant_max is not None:assert quant_min <= quant_max, ("quant_min must be less than or equal t...
7
45
6
321
0
175
224
175
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 175 and ends at 224. It contains 45 lines of code and it has a cyclomatic complexity of 7. It takes 6 parameters, represented as [175.0] and does not return any value..
pytorch_ao
public
public
0
0
calculate_qparams
def calculate_qparams(self):return self.activation_post_process.calculate_qparams()
1
2
1
13
0
227
228
227
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 227 and ends at 228. 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):if self.observer_enabled[0] == 1:self.activation_post_process(X.detach())_scale, _zero_point = self.calculate_qparams()_scale, _zero_point = (_scale.to(self.scale.device),_zero_point.to(self.zero_point.device),)if self.scale.shape != _scale.shape:self.scale.resize_(_scale.shape)self.zero_point.resi...
5
32
2
192
0
230
262
230
null
[]
None
null
0
0
0
null
0
null
The function (forward) defined within the public class called public.The function start at line 230 and ends at 262. It contains 32 lines of code and it has a cyclomatic complexity of 5. It takes 2 parameters, represented as [230.0] and does not return any value..
pytorch_ao
public
public
0
0
extra_repr
def extra_repr(self):return (f"fake_quant_enabled={self.fake_quant_enabled}, observer_enabled={self.observer_enabled}, "f"quant_min={self.activation_post_process.quant_min}, quant_max={self.activation_post_process.quant_max}, "f"dtype={self.dtype}, qscheme={self.qscheme}, ch_axis={self.ch_axis}, "f"scale={self.scale}, ...
1
7
1
16
0
265
271
265
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 265 and ends at 271. 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
_save_to_state_dict
def _save_to_state_dict(self, destination, prefix, keep_vars):# We cannot currently register scalar values as buffers, so need to manually# specify serialization here.super()._save_to_state_dict(destination, prefix, keep_vars)destination[prefix + "scale"] = self.scaledestination[prefix + "zero_point"] = self.zero_point
1
4
4
43
0
273
278
273
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 273 and ends at 278. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [273.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,):# Removing this function throws an error that the size of the loaded tensor does not match the original size# i.e., These buffers start out with numel 0 and become numel 1 once they have their first forward ...
7
37
8
145
0
280
324
280
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 280 and ends at 324. It contains 37 lines of code and it has a cyclomatic complexity of 7. It takes 8 parameters, represented as [280.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self, observer):super().__init__(observer=observer)assert type(self.activation_post_process) == FixedQParamsObserver, (f"{self.__class__.__name__}'s observer must be a {FixedQParamsObserver.__name__}")self._observer_ctr = observerself.scale = self.activation_post_process.scaleself.zero_point = self.activat...
1
13
2
74
0
336
348
336
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 336 and ends at 348. It contains 13 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [336.0] and does not return any value..
pytorch_ao
public
public
0
0
calculate_qparams
def calculate_qparams(self):return self.activation_post_process.calculate_qparams()
1
2
1
13
0
351
352
227
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 351 and ends at 352. 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):"""Define a string representation of the object's attributes."""return (f"fake_quant_enabled={self.fake_quant_enabled}, observer_enabled={self.observer_enabled}, "f"scale={self.scale}, zero_point={self.zero_point}, "f"dtype={self.dtype}, quant_min={self.activation_post_process.quant_min}, "f"quant_...
1
7
1
17
0
355
362
355
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 355 and ends at 362. 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,observer: Any = MovingAverageMinMaxObserver,quant_min: int = 0,quant_max: int = 255,**observer_kwargs: Any,) -> None:super().__init__(observer, quant_min, quant_max, **observer_kwargs)assert isinstance(self.activation_post_process,(MovingAverageMinMaxObserver, MovingAveragePerChannelMinMaxObserver),),...
1
19
5
118
0
383
401
383
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 383 and ends at 401. It contains 19 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [383.0] and does not return any value..
pytorch_ao
public
public
0
0
calculate_qparams
def calculate_qparams(self) -> tuple[torch.Tensor, torch.Tensor]:return self.activation_post_process.calculate_qparams()
1
2
1
24
0
404
405
404
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 404 and ends at 405. 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) -> str:return (f"fake_quant_enabled={self.fake_quant_enabled}, observer_enabled={self.observer_enabled}, "f"scale={self.scale}, zero_point={self.zero_point}, dtype={self.dtype}, "f"quant_min={self.activation_post_process.quant_min}, quant_max={self.activation_post_process.quant_max}, "f"qscheme={se...
1
7
1
18
0
408
414
408
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 408 and ends at 414. 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
forward
def forward(self, X: torch.Tensor) -> torch.Tensor:return torch.fused_moving_avg_obs_fake_quant(X,self.observer_enabled,self.fake_quant_enabled,self.activation_post_process.min_val,self.activation_post_process.max_val,self.scale,self.zero_point,self.activation_post_process.averaging_constant,self.activation_post_proces...
1
16
2
81
0
416
431
416
null
[]
None
null
0
0
0
null
0
null
The function (forward) defined within the public class called public.The function start at line 416 and ends at 431. It contains 16 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [416.0] and does not return any value..
pytorch_ao
public
public
0
0
_is_fake_quant_script_module
def _is_fake_quant_script_module(mod):"""Return true if given mod is an instance of FakeQuantize script module."""if isinstance(mod, torch.jit.RecursiveScriptModule):# qualified name looks like '__torch__.torchao.quantization.pt2e.fake_quantize.___torch_mangle_2.FakeQuantize'suffix = mod._c.qualified_name.split(".", 1)...
3
10
1
60
2
593
604
593
null
['suffix', 'name']
None
null
0
0
0
null
0
null
The function (_is_fake_quant_script_module) defined within the public class called public.The function start at line 593 and ends at 604. It contains 10 lines of code and it has a cyclomatic complexity of 3. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
disable_fake_quant
def disable_fake_quant(mod):"""Disable fake quantization for the module.Disable fake quantization for this module, if applicable. Example usage::# model is any PyTorch modelmodel.apply(torchao.quantization.pt2e.disable_fake_quant)"""if isinstance(mod, FakeQuantizeBase) or _is_fake_quant_script_module(mod):mod.disable_f...
3
3
1
24
0
607
617
607
null
[]
None
null
0
0
0
null
0
null
The function (disable_fake_quant) defined within the public class called public.The function start at line 607 and ends at 617. It contains 3 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
enable_fake_quant
def enable_fake_quant(mod):"""Enable fake quantization for the module.Enable fake quantization for this module, if applicable. Example usage::# model is any PyTorch modelmodel.apply(torchao.quantization.pt2e.enable_fake_quant)"""if isinstance(mod, FakeQuantizeBase) or _is_fake_quant_script_module(mod):mod.enable_fake_q...
3
3
1
24
0
620
630
620
null
[]
None
null
0
0
0
null
0
null
The function (enable_fake_quant) defined within the public class called public.The function start at line 620 and ends at 630. It contains 3 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
disable_observer
def disable_observer(mod):"""Disable observation for this module.Disable observation for this module, if applicable. Example usage::# model is any PyTorch modelmodel.apply(torchao.quantization.pt2e.disable_observer)"""if isinstance(mod, FakeQuantizeBase) or _is_fake_quant_script_module(mod):mod.disable_observer()
3
3
1
24
0
633
643
633
null
[]
None
null
0
0
0
null
0
null
The function (disable_observer) defined within the public class called public.The function start at line 633 and ends at 643. It contains 3 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
enable_observer
def enable_observer(mod):"""Enable observation for this module.Enable observation for this module, if applicable. Example usage::# model is any PyTorch modelmodel.apply(torchao.quantization.pt2e.enable_observer)"""if isinstance(mod, FakeQuantizeBase) or _is_fake_quant_script_module(mod):mod.enable_observer()
3
3
1
24
0
646
656
646
null
[]
None
null
0
0
0
null
0
null
The function (enable_observer) defined within the public class called public.The function start at line 646 and ends at 656. It contains 3 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_equivalent_types_dict
def _create_equivalent_types_dict():_DICT = {}for values in _EQUIVALENT_TYPES:for v in values:_DICT[v] = list(values)return _DICT
3
6
0
29
1
42
47
42
null
['_DICT']
None
null
0
0
0
null
0
null
The function (_create_equivalent_types_dict) defined within the public class called public.The function start at line 42 and ends at 47. 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
get_equivalent_types
def get_equivalent_types() -> list[set]:return _EQUIVALENT_TYPES
1
2
0
11
0
53
54
53
null
[]
None
null
0
0
0
null
0
null
The function (get_equivalent_types) defined within the public class called public.The function start at line 53 and ends at 54. 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..