project_name string | class_name string | class_modifiers string | class_implements int64 | class_extends int64 | function_name string | function_body string | cyclomatic_complexity int64 | NLOC int64 | num_parameter int64 | num_token int64 | num_variable int64 | start_line int64 | end_line int64 | function_index int64 | function_params string | function_variable string | function_return_type string | function_body_line_type string | function_num_functions int64 | function_num_lines int64 | outgoing_function_count int64 | outgoing_function_names string | incoming_function_count int64 | incoming_function_names string | lexical_representation string |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
pytorch_ao | public | public | 0 | 0 | get_bias_qspec | def get_bias_qspec(quantization_config: Optional[QuantizationConfig]):if quantization_config is None:return Noneassert quantization_config is not Noneif quantization_config.bias is None:return Nonequantization_spec: QuantizationSpec = quantization_config.biasassert quantization_spec.dtype == torch.float, ("Only float d... | 3 | 11 | 1 | 52 | 0 | 167 | 177 | 167 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_bias_qspec) defined within the public class called public.The function start at line 167 and ends at 177. It contains 11 lines of code and it has a cyclomatic complexity of 3. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _annotate_linear | def _annotate_linear(gm: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[Callable[[Node], bool]] = None,) -> Optional[list[list[Node]]]:annotated_partitions = []input_act_qspec = get_input_act_qspec(quantization_config)output_act_qspec = get_output_act_qspec(quantization_confi... | 9 | 43 | 4 | 223 | 9 | 181 | 225 | 181 | null | ['act_node', 'bias_node', 'input_act_qspec', 'weight_node', 'nodes_to_mark_annotated', 'annotated_partitions', 'output_act_qspec', 'bias_qspec', 'weight_qspec'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_annotate_linear) defined within the public class called public.The function start at line 181 and ends at 225. It contains 43 lines of code and it has a cyclomatic complexity of 9. It takes 4 parameters, represented as [181.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _annotate_linear_relu | def _annotate_linear_relu(gm: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[Callable[[Node], bool]] = None,) -> Optional[list[list[Node]]]:annotated_partitions = []input_act_qspec = get_input_act_qspec(quantization_config)output_act_qspec = get_output_act_qspec(quantization_... | 14 | 54 | 4 | 342 | 13 | 229 | 291 | 229 | null | ['relu_node', 'input_qspec_map', 'partition', 'input_act_qspec', 'bias', 'annotated_partitions', 'output_act_qspec', 'maybe_linear_node', 'input_act', 'bias_qspec', 'linear_node', 'weight', 'weight_qspec'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_annotate_linear_relu) defined within the public class called public.The function start at line 229 and ends at 291. It contains 54 lines of code and it has a cyclomatic complexity of 14. It takes 4 parameters, represented as [229.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _annotate_conv | def _annotate_conv(gm: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[Callable[[Node], bool]] = None,) -> Optional[list[list[Node]]]:annotated_partitions = []for n in gm.graph.nodes:if n.op != "call_function" or n.target not in [torch.ops.aten.conv1d.default,torch.ops.aten.co... | 10 | 37 | 4 | 265 | 7 | 295 | 339 | 295 | null | ['input_qspec_map', 'partition', 'conv_node', 'bias', 'annotated_partitions', 'input_act', 'weight'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_annotate_conv) defined within the public class called public.The function start at line 295 and ends at 339. It contains 37 lines of code and it has a cyclomatic complexity of 10. It takes 4 parameters, represented as [295.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _do_annotate_conv_relu | def _do_annotate_conv_relu(gm: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[Callable[[Node], bool]] = None,is_conv_transpose: bool = False,):annotated_partitions = []for n in gm.graph.nodes:if n.op != "call_function" or n.target not in [torch.ops.aten.relu.default,torch.ops... | 14 | 47 | 5 | 320 | 10 | 342 | 399 | 342 | null | ['relu_node', 'input_qspec_map', 'partition', 'is_conv_node', 'conv_node', 'maybe_conv_node', 'bias', 'annotated_partitions', 'input_act', 'weight'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_do_annotate_conv_relu) defined within the public class called public.The function start at line 342 and ends at 399. It contains 47 lines of code and it has a cyclomatic complexity of 14. It takes 5 parameters, represented as [342.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _annotate_conv_relu | def _annotate_conv_relu(gm: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[Callable[[Node], bool]] = None,) -> Optional[list[list[Node]]]:return _do_annotate_conv_relu(gm, quantization_config, filter_fn, is_conv_transpose=False) | 1 | 8 | 4 | 59 | 0 | 403 | 410 | 403 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_annotate_conv_relu) defined within the public class called public.The function start at line 403 and ends at 410. It contains 8 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [403.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _annotate_conv_transpose_relu | def _annotate_conv_transpose_relu(gm: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[Callable[[Node], bool]] = None,) -> Optional[list[list[Node]]]:return _do_annotate_conv_relu(gm, quantization_config, filter_fn, is_conv_transpose=True) | 1 | 8 | 4 | 59 | 0 | 414 | 421 | 414 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_annotate_conv_transpose_relu) defined within the public class called public.The function start at line 414 and ends at 421. It contains 8 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [414.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _annotate_conv_bn | def _annotate_conv_bn(gm: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[Callable[[Node], bool]] = None,) -> Optional[list[list[Node]]]:"""Find conv + batchnorm parititionsNote: This is only used for QAT. In PTQ, batchnorm should already be fused into the conv."""return _do_a... | 1 | 6 | 4 | 60 | 0 | 425 | 434 | 425 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_annotate_conv_bn) defined within the public class called public.The function start at line 425 and ends at 434. It contains 6 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [425.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _annotate_conv_bn_relu | def _annotate_conv_bn_relu(gm: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[Callable[[Node], bool]] = None,) -> Optional[list[list[Node]]]:"""Find conv + batchnorm + relu parititionsNote: This is only used for QAT. In PTQ, batchnorm should already be fused into the conv."""... | 1 | 6 | 4 | 60 | 0 | 438 | 447 | 438 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_annotate_conv_bn_relu) defined within the public class called public.The function start at line 438 and ends at 447. It contains 6 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [438.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _annotate_conv_transpose_bn | def _annotate_conv_transpose_bn(gm: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[Callable[[Node], bool]] = None,) -> Optional[list[list[Node]]]:"""Find conv_transpose + batchnorm parititionsNote: This is only used for QAT. In PTQ, batchnorm should already be fused into the ... | 1 | 8 | 4 | 64 | 0 | 451 | 462 | 451 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_annotate_conv_transpose_bn) defined within the public class called public.The function start at line 451 and ends at 462. It contains 8 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [451.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _annotate_conv_transpose_bn_relu | def _annotate_conv_transpose_bn_relu(gm: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[Callable[[Node], bool]] = None,) -> Optional[list[list[Node]]]:"""Find conv_transpose + batchnorm + relu parititionsNote: This is only used for QAT. In PTQ, batchnorm should already be fus... | 1 | 8 | 4 | 64 | 0 | 466 | 477 | 466 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_annotate_conv_transpose_bn_relu) defined within the public class called public.The function start at line 466 and ends at 477. It contains 8 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [466.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _do_annotate_conv_bn._do_annotate_conv_bn.get_pattern._conv_bn | def _conv_bn(x, conv_weight, conv_bias, bn_weight, bn_bias, bn_rm, bn_rv):conv = conv_fn(x, conv_weight, conv_bias)bn = F.batch_norm(conv, bn_rm, bn_rv, bn_weight, bn_bias, training=True)if has_relu:output = F.relu_(bn) if relu_is_inplace else F.relu(bn)else:output = bnreturn output, {"input": x,"conv": conv,"weight": ... | 3 | 14 | 7 | 97 | 0 | 518 | 531 | 518 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_do_annotate_conv_bn._do_annotate_conv_bn.get_pattern._conv_bn) defined within the public class called public.The function start at line 518 and ends at 531. It contains 14 lines of code and it has a cyclomatic complexity of 3. It takes 7 parameters, represented as [518.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _do_annotate_conv_bn.get_pattern | def get_pattern(conv_fn: Callable, relu_is_inplace: bool):def _conv_bn(x, conv_weight, conv_bias, bn_weight, bn_bias, bn_rm, bn_rv):conv = conv_fn(x, conv_weight, conv_bias)bn = F.batch_norm(conv, bn_rm, bn_rv, bn_weight, bn_bias, training=True)if has_relu:output = F.relu_(bn) if relu_is_inplace else F.relu(bn)else:out... | 1 | 3 | 2 | 18 | 0 | 517 | 533 | 517 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_do_annotate_conv_bn.get_pattern) defined within the public class called public.The function start at line 517 and ends at 533. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [517.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _do_annotate_conv_bn | def _do_annotate_conv_bn(gm: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[Callable[[Node], bool]],has_relu: bool,is_conv_transpose: bool = False,) -> list[list[Node]]:"""Given a function that takes in a `conv_fn` and returns a conv-bn[-relu] pattern,return a list of annotat... | 16 | 88 | 5 | 584 | 18 | 480 | 617 | 480 | null | ['input_qspec_map', 'matches', 'output', 'bias_node', 'pattern', 'partition', 'name_node_map', 'conv', 'matcher', 'conv_node', 'weight_node', 'output_node', 'annotated_partitions', 'combinations', 'input_node', '_conv1d_bn_example_inputs', '_conv2d_bn_example_inputs', 'bn'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_do_annotate_conv_bn) defined within the public class called public.The function start at line 480 and ends at 617. It contains 88 lines of code and it has a cyclomatic complexity of 16. It takes 5 parameters, represented as [480.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _annotate_gru_io_only | def _annotate_gru_io_only(gm: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[Callable[[Node], bool]] = None,) -> Optional[list[list[Node]]]:gru_partitions = get_source_partitions(gm.graph, [torch.nn.GRU], filter_fn)gru_partitions = list(itertools.chain.from_iterable(gru_parti... | 4 | 43 | 4 | 288 | 9 | 621 | 668 | 621 | null | ['input_nodes', 'hidden_state', 'nodes_to_mark_annotated', 'annotated_partitions', 'input_act_user', 'output_nodes', 'input_act', 'gru_partitions', 'hidden_state_user'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_annotate_gru_io_only) defined within the public class called public.The function start at line 621 and ends at 668. It contains 43 lines of code and it has a cyclomatic complexity of 4. It takes 4 parameters, represented as [621.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _annotate_adaptive_avg_pool2d | def _annotate_adaptive_avg_pool2d(gm: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[Callable[[Node], bool]] = None,) -> Optional[list[list[Node]]]:"""Always annotate adaptive_avg_pool2d op"""module_partitions = get_source_partitions(gm.graph, [torch.nn.AdaptiveAvgPool2d, F.a... | 8 | 39 | 4 | 248 | 7 | 672 | 718 | 672 | null | ['pool_node', 'input_act_qspec', 'annotated_partitions', 'output_act_qspec', 'module_partitions', 'partitions', 'input_act'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_annotate_adaptive_avg_pool2d) defined within the public class called public.The function start at line 672 and ends at 718. It contains 39 lines of code and it has a cyclomatic complexity of 8. It takes 4 parameters, represented as [672.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _is_input_large_scalar | def _is_input_large_scalar(node: Node, gm: torch.fx.GraphModule):"""Check if input is a large scalar value. So that we can skip quantization for the nodesince histc op (in HistogramObserver) only works for values up to certain upper bound"""if node.op == "get_attr":qualified_name = str(node.target)module_path, _, name ... | 3 | 9 | 2 | 85 | 4 | 721 | 733 | 721 | null | ['qualified_name', 'tensor', 'submod', 'HISTC_UPPER_BOUND'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_is_input_large_scalar) defined within the public class called public.The function start at line 721 and ends at 733. It contains 9 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [721.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _is_input_non_float_tensor | def _is_input_non_float_tensor(node: Node):"""Check if the input is not a float tensor, so that we can skip quantization for the nodesince observers only works with float Tensors"""if "val" not in node.meta or not isinstance(node.meta["val"], FakeTensor):return Truereturn node.meta["val"].dtype != torch.float32 | 3 | 4 | 1 | 44 | 0 | 736 | 742 | 736 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_is_input_non_float_tensor) defined within the public class called public.The function start at line 736 and ends at 742. 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 | _annotate_add_relu | def _annotate_add_relu(gm: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[Callable[[Node], bool]] = None,) -> Optional[list[list[Node]]]:annotated_partitions = []for node in gm.graph.nodes:if node.op != "call_function" or node.target not in [torch.ops.aten.relu.default,torch.... | 18 | 61 | 4 | 345 | 10 | 746 | 817 | 746 | null | ['relu_node', 'input_qspec_map', 'partition', 'input_act_qspec', 'add_node', 'annotated_partitions', 'output_act_qspec', 'input_act1', 'maybe_add', 'input_act0'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_annotate_add_relu) defined within the public class called public.The function start at line 746 and ends at 817. It contains 61 lines of code and it has a cyclomatic complexity of 18. It takes 4 parameters, represented as [746.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _annotate_add | def _annotate_add(gm: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[Callable[[Node], bool]] = None,) -> Optional[list[list[Node]]]:annotated_partitions = []for node in gm.graph.nodes:if node.op != "call_function" or node.target not in [torch.ops.aten.add.Tensor,torch.ops.ate... | 14 | 44 | 4 | 261 | 8 | 821 | 870 | 821 | null | ['input_qspec_map', 'partition', 'input_act_qspec', 'add_node', 'output_act_qspec', 'annotated_partitions', 'input_act1', 'input_act0'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_annotate_add) defined within the public class called public.The function start at line 821 and ends at 870. It contains 44 lines of code and it has a cyclomatic complexity of 14. It takes 4 parameters, represented as [821.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _annotate_mul_relu | def _annotate_mul_relu(gm: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[Callable[[Node], bool]] = None,) -> Optional[list[list[Node]]]:annotated_partitions = []for node in gm.graph.nodes:if node.op != "call_function" or node.target not in [torch.ops.aten.relu.default,torch.... | 18 | 61 | 4 | 345 | 10 | 874 | 944 | 874 | null | ['relu_node', 'input_qspec_map', 'partition', 'input_act_qspec', 'maybe_mul', 'mul_node', 'annotated_partitions', 'output_act_qspec', 'input_act1', 'input_act0'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_annotate_mul_relu) defined within the public class called public.The function start at line 874 and ends at 944. It contains 61 lines of code and it has a cyclomatic complexity of 18. It takes 4 parameters, represented as [874.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _annotate_mul | def _annotate_mul(gm: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[Callable[[Node], bool]] = None,) -> Optional[list[list[Node]]]:annotated_partitions = []for node in gm.graph.nodes:if node.op != "call_function" or node.target not in [torch.ops.aten.mul.Tensor,torch.ops.ate... | 14 | 44 | 4 | 261 | 8 | 948 | 997 | 948 | null | ['input_qspec_map', 'partition', 'input_act_qspec', 'mul_node', 'output_act_qspec', 'annotated_partitions', 'input_act1', 'input_act0'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_annotate_mul) defined within the public class called public.The function start at line 948 and ends at 997. It contains 44 lines of code and it has a cyclomatic complexity of 14. It takes 4 parameters, represented as [948.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _annotate_cat | def _annotate_cat(gm: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[Callable[[Node], bool]] = None,) -> Optional[list[list[Node]]]:cat_partitions = get_source_partitions(gm.graph, [torch.cat], filter_fn)cat_partitions = list(itertools.chain.from_iterable(cat_partitions.value... | 7 | 35 | 4 | 231 | 9 | 1,002 | 1,044 | 1,002 | null | ['input_qspec_map', 'input_act_qspec', 'cat_partitions', 'annotated_partitions', 'cat_node', 'output_act_qspec', 'shared_with_input0_qspec', 'inputs', 'input_act0'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_annotate_cat) defined within the public class called public.The function start at line 1002 and ends at 1044. It contains 35 lines of code and it has a cyclomatic complexity of 7. It takes 4 parameters, represented as [1002.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _is_share_obs_or_fq_op | def _is_share_obs_or_fq_op(op: Callable) -> bool:return op in [torch.ops.aten.relu.default,torch.ops.aten.hardtanh.default,torch.ops.aten.hardtanh_.default,torch.ops.aten.max_pool2d.default,torch.ops.aten.mean.default,torch.ops.aten.mean.dim,torch.ops.aten.permute.default,torch.ops.aten.permute_copy.default,torch.ops.a... | 1 | 18 | 1 | 164 | 0 | 1,047 | 1,065 | 1,047 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_is_share_obs_or_fq_op) defined within the public class called public.The function start at line 1047 and ends at 1065. It contains 18 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 | propagate_annotation | def propagate_annotation(model: torch.fx.GraphModule) -> None:for n in model.graph.nodes:if n.op != "call_function" or not _is_share_obs_or_fq_op(n.target):continueprev_node = n.args[0]if not isinstance(prev_node, Node):continuequantization_annotation = prev_node.meta.get("quantization_annotation", None)if not quantiza... | 9 | 26 | 1 | 135 | 4 | 1,068 | 1,100 | 1,068 | null | ['quantization_annotation', 'prev_node', 'shared_qspec', 'output_qspec'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (propagate_annotation) defined within the public class called public.The function start at line 1068 and ends at 1100. It contains 26 lines of code and it has a cyclomatic complexity of 9. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _convert_scalars_to_attrs | def _convert_scalars_to_attrs(model: torch.fx.GraphModule) -> torch.fx.GraphModule:for n in model.graph.nodes:if n.op != "call_function" or n.target not in [torch.ops.aten.add.Tensor,torch.ops.aten.mul.Tensor,]:continueargs = list(n.args)new_args = []for i in range(len(args)):if isinstance(args[i], torch.fx.Node):new_a... | 6 | 30 | 1 | 223 | 8 | 1,104 | 1,133 | 1,104 | null | ['args', 'prefix', 'float_tensor', 'fake_mode', 'tensor_constant_name', 'get_new_attr_name', 'get_attr_node', 'new_args'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_convert_scalars_to_attrs) defined within the public class called public.The function start at line 1104 and ends at 1133. It contains 30 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 | _test_quantizer | def _test_quantizer(self,model,example_inputs,quantizer,expected_node_occurrence,expected_node_list=None,check_against_fx_quant=False,# TODO: remove the test if fx quant is removed from pytorchfx_qconfig_mapping=None,export_with_dynamic_shape=False,is_qat=False,is_debug_mode=False,training_ir_node_occurrence=None,):# r... | 16 | 77 | 12 | 409 | 0 | 49 | 132 | 49 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_test_quantizer) defined within the public class called public.The function start at line 49 and ends at 132. It contains 77 lines of code and it has a cyclomatic complexity of 16. It takes 12 parameters, represented as [49.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _assert_each_node_has_from_node_source._assert_node_has_from_node_source | def _assert_node_has_from_node_source(node):if node.op == "placeholder" or node.op == "output":returnself.assertIn(FROM_NODE_KEY,node.meta,f"Node {node} doesn't have from_node info",) | 3 | 8 | 1 | 33 | 0 | 143 | 150 | 143 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_assert_each_node_has_from_node_source._assert_node_has_from_node_source) defined within the public class called public.The function start at line 143 and ends at 150. 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 val... |
pytorch_ao | public | public | 0 | 0 | _assert_each_node_has_from_node_source | def _assert_each_node_has_from_node_source(self, model) -> None:def _assert_node_has_from_node_source(node):if node.op == "placeholder" or node.op == "output":returnself.assertIn(FROM_NODE_KEY,node.meta,f"Node {node} doesn't have from_node info",)bfs_trace_with_node_process(model, _assert_node_has_from_node_source) | 1 | 3 | 2 | 17 | 0 | 142 | 152 | 142 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_assert_each_node_has_from_node_source) defined within the public class called public.The function start at line 142 and ends at 152. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [142.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _extract_from_node_source._extract_from_node_source_from_node | def _extract_from_node_source_from_node(node):nonlocal from_node_source_mapif (root_node_source := _extract_node_source_debug_info(node)) is not None:from_node_source_map[str(node)] = (root_node_source.name,root_node_source.graph_id,) | 2 | 7 | 1 | 38 | 0 | 157 | 163 | 157 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_extract_from_node_source._extract_from_node_source_from_node) defined within the public class called public.The function start at line 157 and ends at 163. 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 | _extract_from_node_source | def _extract_from_node_source(self, model) -> dict[str, any]:from_node_source_map: dict[str, any] = {}def _extract_from_node_source_from_node(node):nonlocal from_node_source_mapif (root_node_source := _extract_node_source_debug_info(node)) is not None:from_node_source_map[str(node)] = (root_node_source.name,root_node_s... | 1 | 5 | 2 | 35 | 0 | 154 | 167 | 154 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_extract_from_node_source) defined within the public class called public.The function start at line 154 and ends at 167. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [154.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _extract_from_node_source_with_prev_decomp_op._extract_from_node_source_with_prev_decomp_op_from_node | def _extract_from_node_source_with_prev_decomp_op_from_node(node):nonlocal prev_decomp_op_to_from_node_source_mapif FROM_NODE_KEY in node.meta and node.meta[FROM_NODE_KEY] is not None:prev_decomp_op = str(node.meta.get("nn_module_stack"))from_node_source = _extract_node_source_debug_info(node)if prev_decomp_op not in p... | 4 | 17 | 1 | 75 | 0 | 172 | 188 | 172 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_extract_from_node_source_with_prev_decomp_op._extract_from_node_source_with_prev_decomp_op_from_node) defined within the public class called public.The function start at line 172 and ends at 188. It contains 17 lines of code and it has a cyclomatic complexity of 4. The function does not take any paramete... |
pytorch_ao | public | public | 0 | 0 | _extract_from_node_source_with_prev_decomp_op | def _extract_from_node_source_with_prev_decomp_op(self, model) -> dict[str, any]:prev_decomp_op_to_from_node_source_map: dict[str, any] = {}def _extract_from_node_source_with_prev_decomp_op_from_node(node):nonlocal prev_decomp_op_to_from_node_source_mapif FROM_NODE_KEY in node.meta and node.meta[FROM_NODE_KEY] is not N... | 1 | 7 | 2 | 35 | 0 | 169 | 193 | 169 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_extract_from_node_source_with_prev_decomp_op) defined within the public class called public.The function start at line 169 and ends at 193. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [169.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | assertNodeSourcesEqual | def assertNodeSourcesEqual(self, node_source_1, node_source_2):self.assertTrue(node_source_1.name == node_source_2.nameand node_source_1.graph_id == node_source_2.graph_id) | 2 | 5 | 3 | 29 | 0 | 195 | 199 | 195 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (assertNodeSourcesEqual) defined within the public class called public.The function start at line 195 and ends at 199. It contains 5 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [195.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self, size):super(FeedForward, self).__init__()self.w1 = nn.Linear(size, size * 2, bias=False)self.w2 = nn.Linear(size, size * 2, bias=False)self.out_proj = nn.Linear(size * 2, size, bias=False) | 1 | 5 | 2 | 71 | 0 | 35 | 39 | 35 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 35 and ends at 39. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [35.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | forward | def forward(self, x):x = F.silu(self.w1(x)) * self.w2(x)x = self.out_proj(x)return x | 1 | 4 | 2 | 37 | 0 | 41 | 44 | 41 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (forward) defined within the public class called public.The function start at line 41 and ends at 44. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [41.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self, size):super(ToyModel, self).__init__()self.ffn = FeedForward(size) | 1 | 3 | 2 | 25 | 0 | 48 | 50 | 48 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 48 and ends at 50. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [48.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | forward | def forward(self, x):return self.ffn(x) | 1 | 2 | 2 | 14 | 0 | 52 | 53 | 52 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (forward) defined within the public class called public.The function start at line 52 and ends at 53. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [52.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _test_lowp_mlp_tensor_parallelism_base | def _test_lowp_mlp_tensor_parallelism_base(mesh: DeviceMesh,config: Union[Float8LinearConfig, MXLinearConfig],size=32,compile: bool = False,allgather_in_lowp: bool = False,):device = mesh.device_type# TODO(future): remove this once float8 training works with `quantize_` APIconvert_model_func = convert_to_float8_trainin... | 5 | 105 | 5 | 642 | 21 | 56 | 182 | 56 | null | ['convert_model_func', 'sp_model2', 'sp_out2', 'go_fp32_sp', 'go_fp32', 'toy_model', 'rowwise_parallel_cls', 'device', 'global_out', 'toy_model_fp8', 'sp_out', 'go_fp32_tp', 'tp_out', 'x_fp32', 'prepare_input', 'x_fp32_sp_input', 'sp_model', 'prepare_input_cls', 'tp_model', 'x_fp32_tp_input', 'colwise_parallel_cls'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_test_lowp_mlp_tensor_parallelism_base) defined within the public class called public.The function start at line 56 and ends at 182. It contains 105 lines of code and it has a cyclomatic complexity of 5. It takes 5 parameters, represented as [56.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | check_parity_no_mp | def check_parity_no_mp(test_cls,ref_model: nn.Module,ref_optim: torch.optim.Optimizer,fsdp_model: nn.Module,fsdp_optim: torch.optim.Optimizer,local_inp: torch.Tensor,config: Float8LinearConfig,precompute: bool = False,compile_transformer_block: bool = False,):# check that requires_grad matches ref modulefor ref_param, ... | 10 | 40 | 9 | 255 | 0 | 19 | 63 | 19 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (check_parity_no_mp) defined within the public class called public.The function start at line 19 and ends at 63. It contains 40 lines of code and it has a cyclomatic complexity of 10. It takes 9 parameters, represented as [19.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | check_parity_bf16_mp | def check_parity_bf16_mp(test_cls,ref_model: nn.Module,ref_model_bf16: nn.Module,ref_optim: torch.optim.Optimizer,fsdp_model: nn.Module,fsdp_optim: torch.optim.Optimizer,local_inp: torch.Tensor,):for iter_idx in range(10):losses: List[torch.Tensor] = []for model, optim in ((ref_model_bf16, ref_optim),(fsdp_model, fsdp_... | 6 | 36 | 7 | 237 | 0 | 66 | 101 | 66 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (check_parity_bf16_mp) defined within the public class called public.The function start at line 66 and ends at 101. It contains 36 lines of code and it has a cyclomatic complexity of 6. It takes 7 parameters, represented as [66.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_specs | def get_specs(gpu_name: Optional[str] = None):if gpu_name is None:gpu_name = torch.cuda.get_device_name(0)return gpu_name_to_specs[gpu_name] | 2 | 4 | 1 | 32 | 1 | 68 | 71 | 68 | null | ['gpu_name'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_specs) defined within the public class called public.The function start at line 68 and ends at 71. It contains 4 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_tensor_memory_traffic_ovhd_s | def get_tensor_memory_traffic_ovhd_s(specs,dim0,dim1,tensor_role: str,float8_recipe_name: Optional[str],mx_recipe_name: Optional[str],fuse_with_prev=False,) -> List[Union[sympy.Symbol, float]]:"""Calculates the roofline estimate of casting one of the gemm inputs(input, weight or grad_output) to float8 in fwd+bwd.Inputs... | 16 | 81 | 7 | 411 | 7 | 80 | 214 | 80 | null | ['kernel_4_rw', 'kernel_2_rw', 'kernel_3_rw', 'kernel_1_rw', 'numel', 'res_bytes', 'res_s'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_tensor_memory_traffic_ovhd_s) defined within the public class called public.The function start at line 80 and ends at 214. It contains 81 lines of code and it has a cyclomatic complexity of 16. It takes 7 parameters, represented as [80.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_individual_gemm_time_sympy | def get_individual_gemm_time_sympy(M: sympy.Symbol,K: sympy.Symbol,N: sympy.Symbol,dtype,mx_recipe_name,gpu_name: Optional[str] = None,) -> sympy.Symbol:# compute boundspecs = get_specs(gpu_name)gemm_ops = 2 * M * K * Nif dtype is torch.bfloat16:peak_tops = specs["bf16_peak_tops"]elif dtype in (torch.float8_e4m3fn, tor... | 6 | 39 | 6 | 231 | 10 | 217 | 264 | 217 | null | ['specs', 'compute_gemm_time_s', 'bytes_rw', 'block_size', 'num_reads', 'peak_tops', 'gemm_ops', 'num_writes', 'mem_gemm_time_s', 'num_scale_reads'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_individual_gemm_time_sympy) defined within the public class called public.The function start at line 217 and ends at 264. It contains 39 lines of code and it has a cyclomatic complexity of 6. It takes 6 parameters, represented as [217.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_gemm_time_sympy | def get_gemm_time_sympy(M: sympy.Symbol,K: sympy.Symbol,N: sympy.Symbol,dtype,float8_recipe_name: Optional[str],mx_recipe_name: Optional[str],gpu_name: Optional[str],):# next: add rowwise_with_gw_hp here# note: this function is currently not super accurate for small shapes:# when M,K,N <= 1k,1k,1k it undercounts by aro... | 2 | 27 | 7 | 126 | 5 | 267 | 298 | 267 | null | ['total', 'gemm_dtype_grad_weight', 'gemm_grad_input_time_s', 'gemm_output_time_s', 'gemm_grad_weight_time_s'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_gemm_time_sympy) defined within the public class called public.The function start at line 267 and ends at 298. It contains 27 lines of code and it has a cyclomatic complexity of 2. It takes 7 parameters, represented as [267.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_float8_mem_sympy | def get_float8_mem_sympy(M,K,N,float8_recipe_name: Optional[str],mx_recipe_name: Optional[str],enable_fusion_modeling: bool,gpu_name: Optional[str] = None,):specs = get_specs(gpu_name)# there are three gemms in the fwd/bwd of a linear:## input @ weight_t = output# MxK @ KxN => MxN## grad_output @ weight = grad_input# M... | 1 | 39 | 7 | 141 | 5 | 301 | 352 | 301 | null | ['specs', 'res', 'fwd_fp8_weight_mem', 'fwd_fp8_input_mem', 'gi_fp8_grad_output_mem'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_float8_mem_sympy) defined within the public class called public.The function start at line 301 and ends at 352. It contains 39 lines of code and it has a cyclomatic complexity of 1. It takes 7 parameters, represented as [301.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_inference_tensor_memory_traffic_ovhd_s | def get_inference_tensor_memory_traffic_ovhd_s(specs,dim0,dim1,tensor_role: str,float8_recipe_name: Optional[str],fuse_with_prev=False,) -> List[Union[sympy.Symbol, float]]:"""Inference version of `get_tensor_memory_traffic_ovhd_s`.The only thing happening here is we quantize the activation."""assert float8_recipe_name... | 3 | 23 | 6 | 114 | 4 | 355 | 392 | 355 | null | ['numel', 'res_bytes', 'res_s', 'kernel_1_rw'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_inference_tensor_memory_traffic_ovhd_s) defined within the public class called public.The function start at line 355 and ends at 392. It contains 23 lines of code and it has a cyclomatic complexity of 3. It takes 6 parameters, represented as [355.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_inference_float8_mem_sympy | def get_inference_float8_mem_sympy(M,K,N,float8_recipe_name: Optional[str],gpu_name: Optional[str] = None,):specs = get_specs(gpu_name)# input @ weight_t = output# MxK @ KxN => MxNfwd_fp8_input_mem = get_inference_tensor_memory_traffic_ovhd_s(specs,M,K,tensor_role="input",float8_recipe_name=float8_recipe_name,fuse_with... | 1 | 18 | 5 | 66 | 3 | 395 | 414 | 395 | null | ['specs', 'res', 'fwd_fp8_input_mem'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_inference_float8_mem_sympy) defined within the public class called public.The function start at line 395 and ends at 414. It contains 18 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [395.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_inference_gemm_time_sympy | def get_inference_gemm_time_sympy(M: sympy.Symbol,K: sympy.Symbol,N: sympy.Symbol,dtype,float8_recipe_name: Optional[str],gpu_name: Optional[str],):assert float8_recipe_name == "rowwise" or float8_recipe_name is None, "unsupported"# note: this function is currently not super accurate for small shapes:# when M,K,N <= 1k... | 2 | 11 | 6 | 66 | 1 | 417 | 429 | 417 | null | ['gemm_output_time_s'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_inference_gemm_time_sympy) defined within the public class called public.The function start at line 417 and ends at 429. It contains 11 lines of code and it has a cyclomatic complexity of 2. It takes 6 parameters, represented as [417.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_test_float8_linear_config | def get_test_float8_linear_config(scaling_type_input,scaling_type_weight,scaling_type_grad_output,emulate: bool,):cast_config_input = CastConfig(scaling_type=scaling_type_input,)cast_config_weight = CastConfig(scaling_type=scaling_type_weight,)cast_config_grad_output = CastConfig(scaling_type=scaling_type_grad_output,)... | 1 | 22 | 4 | 64 | 4 | 12 | 34 | 12 | null | ['config', 'cast_config_weight', 'cast_config_grad_output', 'cast_config_input'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_test_float8_linear_config) defined within the public class called public.The function start at line 12 and ends at 34. It contains 22 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [12.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | gelu | def gelu(func, *args, **kwargs):# The torch dispatch convention is to pass all args and kwargs via the# args input.# args[0] here corresponds to the original *args# args[1] here corresponds to the original *kwargs# We're getting the first argument of the original argsinp = args[0][0]# There's a way very inefficient way... | 1 | 7 | 3 | 50 | 1 | 32 | 44 | 32 | null | ['inp'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (gelu) defined within the public class called public.The function start at line 32 and ends at 44. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [32.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self,in_features: int,out_features: int,act_obs: torch.nn.Module,weight_obs: torch.nn.Module,bias: bool = True,device=None,dtype=None,):super().__init__(in_features, out_features, bias, device, dtype)self.act_obs = act_obsself.weight_obs = weight_obs | 1 | 13 | 8 | 70 | 0 | 50 | 62 | 50 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 50 and ends at 62. It contains 13 lines of code and it has a cyclomatic complexity of 1. It takes 8 parameters, represented as [50.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | forward | def forward(self, input: Tensor):observed_input = self.act_obs(input)observed_weight = self.weight_obs(self.weight)return F.linear(observed_input, observed_weight, self.bias) | 1 | 4 | 2 | 40 | 0 | 64 | 67 | 64 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (forward) defined within the public class called public.The function start at line 64 and ends at 67. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [64.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | from_float | def from_float(cls, float_linear, act_obs, weight_obs):observed_linear = cls(float_linear.in_features,float_linear.out_features,act_obs,weight_obs,False,device=float_linear.weight.device,dtype=float_linear.weight.dtype,)observed_linear.weight = float_linear.weightobserved_linear.bias = float_linear.biasreturn observed_... | 1 | 13 | 4 | 62 | 0 | 70 | 82 | 70 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (from_float) defined within the public class called public.The function start at line 70 and ends at 82. It contains 13 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [70.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | insert_observers_.replacement_fn | def replacement_fn(m):copied_act_obs = copy.deepcopy(act_obs)copied_weight_obs = copy.deepcopy(weight_obs)return ObservedLinear.from_float(m, copied_act_obs, copied_weight_obs) | 1 | 4 | 1 | 32 | 0 | 88 | 91 | 88 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (insert_observers_.replacement_fn) defined within the public class called public.The function start at line 88 and ends at 91. 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_observers_ | def insert_observers_(model, act_obs, weight_obs):_is_linear = lambda m, fqn: isinstance(m, torch.nn.Linear)def replacement_fn(m):copied_act_obs = copy.deepcopy(act_obs)copied_weight_obs = copy.deepcopy(weight_obs)return ObservedLinear.from_float(m, copied_act_obs, copied_weight_obs)_replace_with_custom_fn_if_matches_f... | 1 | 4 | 3 | 36 | 3 | 85 | 93 | 85 | null | ['copied_weight_obs', 'copied_act_obs', '_is_linear'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (insert_observers_) defined within the public class called public.The function start at line 85 and ends at 93. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [85.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _apply_awq_transform.weight_quant_func | def weight_quant_func(weight):block_size = (1, weight.shape[1])if target_dtype == torch.uint8:return to_affine_quantized_intx_static(weight, weight_scale, weight_zero_point, block_size, target_dtype)elif target_dtype == torch.float8_e4m3fn:scale_2d = (weight_scale.view(1, -1) if weight_scale.dim() == 1 else weight_scal... | 4 | 19 | 1 | 94 | 0 | 117 | 135 | 117 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_apply_awq_transform.weight_quant_func) defined within the public class called public.The function start at line 117 and ends at 135. It contains 19 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 | _apply_awq_transform | def _apply_awq_transform(module: torch.nn.Module,config: ApplyAWQConfig,):target_dtype = config.target_dtypeobserved_linear = module# target_dtype = torch.uint8# weight quantizationweight_scale, weight_zero_point = observed_linear.weight_obs.calculate_qparams()def weight_quant_func(weight):block_size = (1, weight.shape... | 1 | 29 | 2 | 154 | 6 | 106 | 164 | 106 | null | ['equalization_scale', 'observed_linear', 'block_size', 'scale_2d', 'target_dtype', 'linear'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_apply_awq_transform) defined within the public class called public.The function start at line 106 and ends at 164. It contains 29 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [106.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self, m=64, n=32, k=64):super().__init__()self.linear1 = torch.nn.Linear(m, k, bias=False)self.linear2 = torch.nn.Linear(k, n, bias=False) | 1 | 4 | 4 | 60 | 0 | 169 | 172 | 169 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 169 and ends at 172. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [169.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | example_inputs | def example_inputs(self, batch_size=1, dtype=torch.float32, device="cpu"):return (torch.randn(batch_size, self.linear1.in_features, dtype=dtype, device=device),) | 1 | 6 | 4 | 43 | 0 | 174 | 179 | 174 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (example_inputs) defined within the public class called public.The function start at line 174 and ends at 179. It contains 6 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [174.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | forward | def forward(self, x):x = self.linear1(x)x = self.linear2(x)return x | 1 | 4 | 2 | 25 | 0 | 181 | 184 | 181 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (forward) defined within the public class called public.The function start at line 181 and ends at 184. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [181.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_awq | def test_awq(target_dtype: torch.dtype, mapping_type: MappingType):print(f"Testing {target_dtype} static quantization:")torch.manual_seed(0)dtype = torch.bfloat16m = ToyLinearModel().eval().to(dtype).to("cuda")m_bf16 = copy.deepcopy(m)example_inputs = m.example_inputs(dtype=dtype, device="cuda")print("example inputs sh... | 2 | 33 | 2 | 241 | 9 | 187 | 232 | 187 | null | ['m_bf16', 'm', 'example_inputs', 'dtype', 'is_observed_linear', 'before_quant', 'act_obs', 'after_quant', 'weight_obs'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_awq) defined within the public class called public.The function start at line 187 and ends at 232. It contains 33 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [187.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __new__ | def __new__(cls, input, **kwargs):if isinstance(input, (list, tuple)):input = input[0]kwargs["dtype"] = kwargs.get("dtype", input.dtype)shape = kwargs.pop("shape", input.shape)return torch.Tensor._make_wrapper_subclass(cls, shape, **kwargs) | 2 | 6 | 3 | 69 | 0 | 66 | 71 | 66 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__new__) defined within the public class called public.The function start at line 66 and ends at 71. It contains 6 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [66.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self, input, **kwargs):self.values = []self.count = 0self.add_tensors(input)self.debug = True | 1 | 5 | 3 | 32 | 0 | 73 | 77 | 73 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 73 and ends at 77. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [73.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __repr__ | def __repr__(self):return f"{self.__class__.__name__}(data={self.values})" | 1 | 2 | 1 | 8 | 0 | 79 | 80 | 79 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__repr__) defined within the public class called public.The function start at line 79 and ends at 80. 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 | __iter__ | def __iter__(self):for v in self.values:yield v | 2 | 3 | 1 | 14 | 0 | 82 | 84 | 82 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__iter__) defined within the public class called public.The function start at line 82 and ends at 84. It contains 3 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | add_tensors | def add_tensors(self, input):if isinstance(input, (tuple, list)):for inp in input:self.add_tensors(inp)else:assert isinstance(input, torch.Tensor), (f"MultiTensor can only use add_tensors for Tensors or lists of tensors but got {type(input)}")self.count += 1self.values.append(input)return self | 3 | 11 | 2 | 61 | 0 | 86 | 96 | 86 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (add_tensors) defined within the public class called public.The function start at line 86 and ends at 96. It contains 11 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [86.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | pad_to_length | def pad_to_length(self, length):if self.count > length:return selfself.add_tensors([self.values[-1]] * (length - self.count))return self | 2 | 5 | 2 | 40 | 0 | 98 | 102 | 98 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (pad_to_length) defined within the public class called public.The function start at line 98 and ends at 102. It contains 5 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [98.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __torch_function__.flat_to_grouped | def flat_to_grouped(flat):# size of biggest MultiTensormulti_tensor_size = max([x.count if isinstance(x, MultiTensor) else 1 for x in flat])# convert [A, MultiTensor(b1,b2,b3), MultiTensor(c1,c2,c3)] => [[A,b1,c1], [A,b2,c2] [A,b3,c3]]grouped = list(zip(*[x.pad_to_length(multi_tensor_size).valuesif isinstance(x, MultiT... | 5 | 15 | 1 | 66 | 0 | 106 | 122 | 106 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__torch_function__.flat_to_grouped) defined within the public class called public.The function start at line 106 and ends at 122. It contains 15 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 | __torch_function__.grouped_to_flat | def grouped_to_flat(grouped):# convert [[A,b1,c1], [A,b2,c2] [A,b3,c3]] => [(A,A,A), (b1,b2,b3), (c1,c2,c3)]flat_tups = list(zip(*grouped))# convert [(A,A,A), (b1,b2,b3), (c1,c2,c3)] => [A, MultiTensor(b1,b2,b3), MultiTensor(c1,c2,c3)]flattened = [cls(tup).cpu() if isinstance(tup[0], torch.Tensor) else tup[0]for tup in... | 6 | 23 | 1 | 99 | 0 | 126 | 151 | 126 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__torch_function__.grouped_to_flat) defined within the public class called public.The function start at line 126 and ends at 151. It contains 23 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 | __torch_function__ | def __torch_function__(cls, func, types, args=(), kwargs=None, skip_gptq=False):def flat_to_grouped(flat):# size of biggest MultiTensormulti_tensor_size = max([x.count if isinstance(x, MultiTensor) else 1 for x in flat])# convert [A, MultiTensor(b1,b2,b3), MultiTensor(c1,c2,c3)] => [[A,b1,c1], [A,b2,c2] [A,b3,c3]]group... | 4 | 21 | 4 | 151 | 0 | 105 | 176 | 105 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__torch_function__) defined within the public class called public.The function start at line 105 and ends at 176. It contains 21 lines of code and it has a cyclomatic complexity of 4. It takes 4 parameters, represented as [105.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __torch_dispatch__ | def __torch_dispatch__(cls, func, types, args=(), kwargs={}, skip_gptq=False):pass | 1 | 2 | 4 | 24 | 0 | 179 | 180 | 179 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__torch_dispatch__) defined within the public class called public.The function start at line 179 and ends at 180. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [179.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __tensor_flatten__ | def __tensor_flatten__(self):return ["values"], None | 1 | 2 | 1 | 11 | 0 | 182 | 183 | 182 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__tensor_flatten__) defined within the public class called public.The function start at line 182 and ends at 183. 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 | __tensor_unflatten__ | def __tensor_unflatten__(cls, tensor_data_dict, tensor_attributes, outer_size, outer_stride):return cls(tensor_data_dict["values"]) | 1 | 4 | 5 | 21 | 0 | 186 | 189 | 186 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__tensor_unflatten__) defined within the public class called public.The function start at line 186 and ends at 189. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [186.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self):super().__init__()self.linear = torch.nn.Linear(64, 128) | 1 | 3 | 1 | 26 | 0 | 193 | 195 | 193 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 193 and ends at 195. 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 | forward | def forward(self, x):x = self.linear(x)return x | 1 | 3 | 2 | 17 | 0 | 197 | 199 | 197 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (forward) defined within the public class called public.The function start at line 197 and ends at 199. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [197.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _is_linear | def _is_linear(mod, fqn):return isinstance(mod, torch.nn.Linear) | 1 | 2 | 2 | 18 | 0 | 202 | 203 | 202 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_is_linear) defined within the public class called public.The function start at line 202 and ends at 203. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [202.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | prepare_model_for_optimization_.forward_pre_hook | def forward_pre_hook(module,args: Tuple[MultiTensor],kwargs: Dict[str, Any],):# remove the hook to avoid recursive callsmodule._forward_pre_hook_handle.remove()# we'll have a single MultiTensor as argument, that contains a list of activation Tensors# from previous layer# we can use the MultiTensor to calculate the quan... | 3 | 28 | 3 | 153 | 0 | 208 | 248 | 208 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (prepare_model_for_optimization_.forward_pre_hook) defined within the public class called public.The function start at line 208 and ends at 248. It contains 28 lines of code and it has a cyclomatic complexity of 3. It takes 3 parameters, represented as [208.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | prepare_model_for_optimization_._register_forward_pre_hook | def _register_forward_pre_hook(module: torch.nn.Module):"""Adds a forward pre hook for the module, that runs before module.forward is run that canmodify the module and the input of the moduledocs for `module.register_forward_pre_hook` can be found in https://pytorch.org/docs/stable/generated/torch.nn.Module.html#torch.... | 1 | 6 | 1 | 31 | 0 | 250 | 259 | 250 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (prepare_model_for_optimization_._register_forward_pre_hook) defined within the public class called public.The function start at line 250 and ends at 259. 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 | prepare_model_for_optimization_ | def prepare_model_for_optimization_(model):def forward_pre_hook(module,args: Tuple[MultiTensor],kwargs: Dict[str, Any],):# remove the hook to avoid recursive callsmodule._forward_pre_hook_handle.remove()# we'll have a single MultiTensor as argument, that contains a list of activation Tensors# from previous layer# we ca... | 1 | 6 | 1 | 17 | 4 | 207 | 263 | 207 | null | ['act_obs', 'forward_pre_hook_handle', 'new_input', 'mt'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (prepare_model_for_optimization_) defined within the public class called public.The function start at line 207 and ends at 263. 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 | _apply_activation_static_weight_quant_transform | def _apply_activation_static_weight_quant_transform(module: torch.nn.Module,config: ApplyActivationStaticWeightQuantConfig,):observed_linear = moduletarget_dtype = torch.uint8# we can quantize the weight here as well# activation quantizationact_scale, act_zero_point = (observed_linear.input_scale,observed_linear.input_... | 1 | 24 | 2 | 120 | 4 | 272 | 301 | 272 | null | ['observed_linear', 'target_dtype', 'weight', 'input_quant_func'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_apply_activation_static_weight_quant_transform) defined within the public class called public.The function start at line 272 and ends at 301. It contains 24 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [272.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self,in_features: int,out_features: int,act_obs: torch.nn.Module,weight_obs: torch.nn.Module,bias: bool = True,device=None,dtype=None,):super().__init__(in_features, out_features, bias, device, dtype)self.act_obs = act_obsself.weight_obs = weight_obs | 1 | 13 | 8 | 70 | 0 | 44 | 56 | 44 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 44 and ends at 56. It contains 13 lines of code and it has a cyclomatic complexity of 1. It takes 8 parameters, represented as [44.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | forward | def forward(self, input: Tensor):observed_input = self.act_obs(input)observed_weight = self.weight_obs(self.weight)return F.linear(observed_input, observed_weight, self.bias) | 1 | 4 | 2 | 40 | 0 | 58 | 61 | 58 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (forward) defined within the public class called public.The function start at line 58 and ends at 61. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [58.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | from_float | def from_float(cls, float_linear, act_obs, weight_obs):observed_linear = cls(float_linear.in_features,float_linear.out_features,act_obs,weight_obs,False,device=float_linear.weight.device,dtype=float_linear.weight.dtype,)observed_linear.weight = float_linear.weightobserved_linear.bias = float_linear.biasreturn observed_... | 1 | 13 | 4 | 62 | 0 | 64 | 76 | 64 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (from_float) defined within the public class called public.The function start at line 64 and ends at 76. It contains 13 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [64.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | insert_observers_.replacement_fn | def replacement_fn(m):copied_act_obs = copy.deepcopy(act_obs)copied_weight_obs = copy.deepcopy(weight_obs)return ObservedLinear.from_float(m, copied_act_obs, copied_weight_obs) | 1 | 4 | 1 | 32 | 0 | 82 | 85 | 82 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (insert_observers_.replacement_fn) defined within the public class called public.The function start at line 82 and ends at 85. 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_observers_ | def insert_observers_(model, act_obs, weight_obs):_is_linear = lambda m, fqn: isinstance(m, torch.nn.Linear)def replacement_fn(m):copied_act_obs = copy.deepcopy(act_obs)copied_weight_obs = copy.deepcopy(weight_obs)return ObservedLinear.from_float(m, copied_act_obs, copied_weight_obs)_replace_with_custom_fn_if_matches_f... | 1 | 4 | 3 | 36 | 3 | 79 | 87 | 79 | null | ['copied_weight_obs', 'copied_act_obs', '_is_linear'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (insert_observers_) defined within the public class called public.The function start at line 79 and ends at 87. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [79.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _apply_static_quant_transform.weight_quant_func | def weight_quant_func(weight):block_size = (1, weight.shape[1])if target_dtype == torch.uint8:return to_affine_quantized_intx_static(weight, weight_scale, weight_zero_point, block_size, target_dtype)elif target_dtype == torch.float8_e4m3fn:mm_config = Float8MMConfig(use_fast_accum=True)return to_affine_quantized_floatx... | 3 | 17 | 1 | 79 | 0 | 108 | 124 | 108 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_apply_static_quant_transform.weight_quant_func) defined within the public class called public.The function start at line 108 and ends at 124. It contains 17 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 | _apply_static_quant_transform | def _apply_static_quant_transform(module: torch.nn.Module,config: StaticQuantConfig,):target_dtype = config.target_dtypeobserved_linear = module# weight quantizationweight_scale, weight_zero_point = observed_linear.weight_obs.calculate_qparams()def weight_quant_func(weight):block_size = (1, weight.shape[1])if target_dt... | 3 | 36 | 2 | 209 | 6 | 98 | 157 | 98 | null | ['observed_linear', 'block_size', 'target_dtype', 'mm_config', 'linear', 'input_quant_func'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_apply_static_quant_transform) defined within the public class called public.The function start at line 98 and ends at 157. It contains 36 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [98.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self,in_features: int,out_features: int,act_obs: torch.nn.Module,weight_obs: torch.nn.Module,weight: torch.Tensor,bias: torch.Tensor,target_dtype: torch.dtype,):super().__init__()self.act_scale, self.act_zero_point = act_obs.calculate_qparams()weight_scale, weight_zero_point = weight_obs.calculate_qparams(... | 3 | 32 | 8 | 181 | 0 | 162 | 193 | 162 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 162 and ends at 193. It contains 32 lines of code and it has a cyclomatic complexity of 3. It takes 8 parameters, represented as [162.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | forward | def forward(self, input: Tensor):block_size = input.shapeif self.target_dtype == torch.uint8:qinput = to_affine_quantized_intx_static(input,self.act_scale,self.act_zero_point,block_size,self.target_dtype,)elif self.target_dtype == torch.float8_e4m3fn:qinput = to_affine_quantized_floatx_static(input,self.act_scale,block... | 3 | 21 | 2 | 100 | 0 | 195 | 215 | 195 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (forward) defined within the public class called public.The function start at line 195 and ends at 215. It contains 21 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [195.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | from_observed | def from_observed(cls, observed_linear, target_dtype):quantized_linear = cls(observed_linear.in_features,observed_linear.out_features,observed_linear.act_obs,observed_linear.weight_obs,observed_linear.weight,observed_linear.bias,target_dtype,)return quantized_linear | 1 | 11 | 3 | 42 | 0 | 218 | 228 | 218 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (from_observed) defined within the public class called public.The function start at line 218 and ends at 228. It contains 11 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [218.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | apply_static_quant | def apply_static_quant(module: torch.nn.Module,config: StaticQuantConfig2,):return QuantizedLinear.from_observed(module, config.target_dtype) | 1 | 5 | 2 | 27 | 0 | 237 | 241 | 237 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (apply_static_quant) defined within the public class called public.The function start at line 237 and ends at 241. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [237.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self, m=64, n=32, k=64):super().__init__()self.linear1 = torch.nn.Linear(m, k, bias=False)self.linear2 = torch.nn.Linear(k, n, bias=False) | 1 | 4 | 4 | 60 | 0 | 245 | 248 | 245 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 245 and ends at 248. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [245.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | example_inputs | def example_inputs(self, batch_size=1, dtype=torch.float32, device="cpu"):return (torch.randn(batch_size, self.linear1.in_features, dtype=dtype, device=device),) | 1 | 6 | 4 | 43 | 0 | 250 | 255 | 250 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (example_inputs) defined within the public class called public.The function start at line 250 and ends at 255. It contains 6 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [250.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | forward | def forward(self, x):x = self.linear1(x)x = self.linear2(x)return x | 1 | 4 | 2 | 25 | 0 | 257 | 260 | 257 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (forward) defined within the public class called public.The function start at line 257 and ends at 260. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [257.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_static_quant | def test_static_quant(target_dtype: torch.dtype, mapping_type: MappingType):print(f"Testing {target_dtype} static quantization:")torch.manual_seed(0)dtype = torch.bfloat16m = ToyLinearModel().eval().to(dtype).to("cuda")m_bf16 = copy.deepcopy(m)example_inputs = m.example_inputs(dtype=dtype, device="cuda")print("example ... | 2 | 42 | 2 | 304 | 10 | 263 | 319 | 263 | null | ['m_bf16', 'm', 'm2', 'example_inputs', 'dtype', 'is_observed_linear', 'before_quant', 'act_obs', 'after_quant', 'weight_obs'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_static_quant) defined within the public class called public.The function start at line 263 and ends at 319. It contains 42 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [263.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _embedding_byte | def _embedding_byte(int_data: torch.Tensor,block_size: List[int],weight_scales: torch.Tensor,indices: torch.Tensor,) -> torch.Tensor:weight = dequantize_affine(int_data,block_size,weight_scales,None,int_data.dtype,)return torch.ops.aten.embedding.default(weight, indices) | 1 | 14 | 4 | 65 | 1 | 39 | 52 | 39 | null | ['weight'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_embedding_byte) defined within the public class called public.The function start at line 39 and ends at 52. It contains 14 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [39.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _ | def _(func, types, args, kwargs):indices = args[0]weight = args[1]tensor_impl = weight.tensor_implint_data, scale = tensor_impl.get_plain()block_size = (1, int_data.shape[-1])return torch.ops.torchao.embedding_byte(int_data, block_size, scale, indices) | 1 | 7 | 4 | 67 | 4 | 56 | 62 | 56 | null | ['weight', 'block_size', 'tensor_impl', 'indices'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_) defined within the public class called public.The function start at line 56 and ends at 62. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [56.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | main | def main():m = torch.nn.Sequential(torch.nn.Embedding(4096, 128))input = torch.randint(0, 4096, (1, 6))m[0].weight = torch.nn.Parameter(to_my_dtype_extended(m[0].weight), requires_grad=False)y_ref = m[0].weight.dequantize()[input]y_q = m(input)from torchao.quantization.utils import compute_errorsqnr = compute_error(y_r... | 2 | 18 | 0 | 188 | 9 | 65 | 87 | 65 | null | ['ops', 'input', 'y_q_exported', 'm', 'm_unwrapped', 'sqnr', 'y_ref', 'm_exported', 'y_q'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (main) defined within the public class called public.The function start at line 65 and ends at 87. It contains 18 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_plain | def get_plain(self) -> Tuple[torch.Tensor, torch.Tensor]:return self.int_data, self.scale | 1 | 2 | 1 | 24 | 0 | 47 | 48 | 47 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_plain) defined within the public class called public.The function start at line 47 and ends at 48. 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.. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.