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 | __init__ | def __init__(self,original_weight_tensor: torch.Tensor,input_quant_func_static: Callable[[torch.Tensor, torch.Tensor, Optional[torch.Tensor], Dict[str, Any]],torch.Tensor,],scale: torch.Tensor,zero_point: Optional[torch.Tensor],quant_kwargs: Dict[str, Any],):self.original_weight_tensor = original_weight_tensorself.inpu... | 1 | 16 | 7 | 95 | 0 | 57 | 72 | 57 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 57 and ends at 72. It contains 16 lines of code and it has a cyclomatic complexity of 1. It takes 7 parameters, represented as [57.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __repr__ | def __repr__(self):return f"{self.__class__.__name__}({self.original_weight_tensor}, {self.input_quant_func_static}, scale={self.scale}, zero_point={self.zero_point}, quant_kwargs={self.quant_kwargs})" | 1 | 2 | 1 | 8 | 0 | 74 | 75 | 74 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__repr__) defined within the public class called public.The function start at line 74 and ends at 75. 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_flatten__ | def __tensor_flatten__(self):tensor_data = ["original_weight_tensor", "scale"]if self.zero_point is not None:tensor_data.append("zero_point")return tensor_data, [self.input_quant_func_static, self.quant_kwargs] | 2 | 5 | 1 | 38 | 0 | 77 | 81 | 77 | 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 77 and ends at 81. 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 | __tensor_unflatten__ | def __tensor_unflatten__(cls, tensor_data_dict, tensor_attributes, outer_size, outer_stride):original_weight_tensor = tensor_data_dict["original_weight_tensor"]input_quant_func_static, quant_kwargs = tensor_attributeszero_point = tensor_data_dict.get("zero_point", None)return cls(original_weight_tensor,input_quant_func... | 1 | 13 | 5 | 51 | 0 | 84 | 96 | 84 | 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 84 and ends at 96. It contains 13 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [84.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _quantized_linear_op | def _quantized_linear_op(input_tensor: torch.Tensor, weight_tensor: torch.Tensor, bias: torch.Tensor):input_quant_func_static = weight_tensor.input_quant_func_staticoriginal_weight_tensor = weight_tensor.original_weight_tensorscale = weight_tensor.scalezero_point = weight_tensor.zero_pointquant_kwargs = weight_tensor.q... | 1 | 14 | 3 | 78 | 0 | 99 | 112 | 99 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_quantized_linear_op) defined within the public class called public.The function start at line 99 and ends at 112. It contains 14 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [99.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | from_float | def from_float(cls,input_float: torch.Tensor,input_quant_func: Callable,scale: torch.Tensor,zero_point: Optional[torch.Tensor] = None,quant_kwargs: Optional[Dict[str, Any]] = None,):if quant_kwargs is None:quant_kwargs = {}return cls(input_float, input_quant_func, scale, zero_point, quant_kwargs) | 2 | 11 | 6 | 69 | 0 | 115 | 125 | 115 | 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 115 and ends at 125. It contains 11 lines of code and it has a cyclomatic complexity of 2. It takes 6 parameters, represented as [115.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _apply_fn_to_data | def _apply_fn_to_data(self, fn):return self.__class__(fn(self.original_weight_tensor),self.input_quant_func_static,fn(self.scale),fn(self.zero_point) if self.zero_point is not None else None,self.quant_kwargs,) | 2 | 8 | 2 | 51 | 0 | 127 | 134 | 127 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_apply_fn_to_data) defined within the public class called public.The function start at line 127 and ends at 134. It contains 8 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [127.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | to | def to(self, *args, **kwargs):kwargs = self._get_to_kwargs(*args, **kwargs)device = kwargs.pop("device")return self.__class__(self.original_weight_tensor.to(device),self.input_quant_func_static,self.scale.to(device),self.zero_point.to(device) if self.zero_point is not None else None,self.quant_kwargs,) | 2 | 10 | 3 | 81 | 0 | 136 | 145 | 136 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (to) defined within the public class called public.The function start at line 136 and ends at 145. It contains 10 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [136.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _ | def _(func, types, args, kwargs):input_tensor, weight_tensor, bias = (args[0],args[1],args[2] if len(args) > 2 else None,)if isinstance(weight_tensor, WeightTensorWithLinearActivationQuantizationMetadata):return weight_tensor._quantized_linear_op(input_tensor, weight_tensor, bias)raise NotImplementedError("LinearActiva... | 3 | 11 | 4 | 67 | 0 | 152 | 163 | 152 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_) defined within the public class called public.The function start at line 152 and ends at 163. It contains 11 lines of code and it has a cyclomatic complexity of 3. It takes 4 parameters, represented as [152.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _ | def _(func, types, args, kwargs):return return_and_correct_aliasing(func, args, kwargs, args[0]._apply_fn_to_data(torch.detach)) | 1 | 4 | 4 | 32 | 0 | 167 | 170 | 167 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_) defined within the public class called public.The function start at line 167 and ends at 170. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [167.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _ | def _(func, types, args, kwargs):return return_and_correct_aliasing(func, args, kwargs, args[0]._apply_fn_to_data(torch.detach)) | 1 | 4 | 4 | 32 | 0 | 174 | 177 | 167 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_) defined within the public class called public.The function start at line 174 and ends at 177. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [167.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _ | def _(func, types, args, kwargs):return return_and_correct_aliasing(func,args,kwargs,args[0].to(*args[1:], **kwargs)._apply_fn_to_data(torch.clone),) | 1 | 7 | 4 | 46 | 0 | 181 | 187 | 181 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_) defined within the public class called public.The function start at line 181 and ends at 187. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [181.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _ | def _(func, types, args, kwargs):return return_and_correct_aliasing(func, args, kwargs, args[0]._apply_fn_to_data(torch.detach)) | 1 | 4 | 4 | 32 | 0 | 191 | 194 | 167 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_) defined within the public class called public.The function start at line 191 and ends at 194. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [167.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __new__ | def __new__(cls, input: Union[torch.Tensor, Sequence[torch.Tensor]], **kwargs: Any) -> "MultiTensor":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 | 8 | 3 | 87 | 0 | 62 | 69 | 62 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__new__) defined within the public class called public.The function start at line 62 and ends at 69. It contains 8 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [62.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self, input: Union[torch.Tensor, Sequence[torch.Tensor]], **kwargs: Any) -> None:self.values: List[torch.Tensor] = []self.state_dict_manager = StateDictManager.get_instance()self.count: int = 0self.add_tensors(input)self.debug: bool = Falseself.gptq_done = False | 1 | 9 | 3 | 75 | 0 | 71 | 79 | 71 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 71 and ends at 79. It contains 9 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [71.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __repr__ | def __repr__(self) -> str:return (f"{self.__class__.__name__}(shape={self.shape}, example={self.values[0]})") | 1 | 4 | 1 | 12 | 0 | 81 | 84 | 81 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__repr__) defined within the public class called public.The function start at line 81 and ends at 84. 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 | append | def append(self, input: torch.Tensor):return self.add_tensors(input) | 1 | 2 | 2 | 18 | 0 | 86 | 87 | 86 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (append) defined within the public class called public.The function start at line 86 and ends at 87. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [86.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | add_tensors | def add_tensors(self, input: Union[torch.Tensor, Sequence[torch.Tensor]]) -> "MultiTensor":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 += 1... | 3 | 13 | 2 | 77 | 0 | 89 | 101 | 89 | 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 89 and ends at 101. It contains 13 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [89.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | pad_to_length | def pad_to_length(self, length, pad_in_place=True):if self.count < length:if pad_in_place:for _ in range(length - self.count):# we need to handle in place ops where we do want the model's value to stay changed.# e.g. if someone does z[1,:]=x, if z were a size 1 multiTensor and x were size 3,# we want z to become a mult... | 4 | 10 | 3 | 83 | 0 | 103 | 118 | 103 | 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 103 and ends at 118. It contains 10 lines of code and it has a cyclomatic complexity of 4. It takes 3 parameters, represented as [103.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | unpad | def unpad(self, count=1):count = min(count, self.count)self.values = self.values[:count]self.count = count | 1 | 4 | 2 | 35 | 0 | 120 | 123 | 120 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (unpad) defined within the public class called public.The function start at line 120 and ends at 123. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [120.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | configure_quantization_mode | def configure_quantization_mode(cls,get_qparams_func,quantize_func,dequantize_func,combine_qparams_list_func,make_qtensor,skip_layer_func,act_fake_quant_func=None,group_size=-1,percdamp=0.01,blocksize=128,device: torch.device = torch.device("cuda"),):cls.get_qparams_func = get_qparams_funccls.quantize_func = quantize_f... | 2 | 27 | 12 | 117 | 0 | 126 | 152 | 126 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (configure_quantization_mode) defined within the public class called public.The function start at line 126 and ends at 152. It contains 27 lines of code and it has a cyclomatic complexity of 2. It takes 12 parameters, represented as [126.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __torch_function__ | def __torch_function__(cls,func: Callable,types: Tuple[type, ...],args: Tuple[Any, ...] = (),kwargs: Optional[Dict[str, Any]] = None,skip_gptq: bool = False,) -> Any:# The way MultiTensor handles various functions is as follows. Normally when you apply a function on a MultiTensor that has n Tensors inside, we want# the... | 16 | 104 | 4 | 728 | 0 | 155 | 314 | 155 | 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 155 and ends at 314. It contains 104 lines of code and it has a cyclomatic complexity of 16. It takes 4 parameters, represented as [155.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | grouped_to_flat | def grouped_to_flat(cls, grouped: List[Tuple[Any, ...]]) -> Tuple[List[Any], bool]:# 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 ... | 6 | 12 | 2 | 109 | 0 | 317 | 330 | 317 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (grouped_to_flat) defined within the public class called public.The function start at line 317 and ends at 330. It contains 12 lines of code and it has a cyclomatic complexity of 6. It takes 2 parameters, represented as [317.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _evaluate_function | def _evaluate_function(cls, func, grouped_args, spec, is_in_place, device):outputs = []for inp in grouped_args:# we move all remaining cpu tensors to cudadevice_inp = _tensors_to_device(inp, device)# return input to original structurecur_args, cur_kwargs = tree_unflatten(device_inp, spec)out = func(*cur_args, **cur_kwa... | 9 | 32 | 6 | 215 | 0 | 333 | 377 | 333 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_evaluate_function) defined within the public class called public.The function start at line 333 and ends at 377. It contains 32 lines of code and it has a cyclomatic complexity of 9. It takes 6 parameters, represented as [333.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | faster_quant | def faster_quant(cls, H, W, device):"""GPTQ quantization implementation.Args:H: Hessian matrix approximationW: Weight matrix to quantizedevice: accelerator deviceReturns:Tuple containing:- Q: Quantized weights- DQ: Dequantized weights- all_qparams: Quantization parameters"""msg = ("tried to do faster quant but configur... | 9 | 78 | 4 | 600 | 0 | 380 | 487 | 380 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (faster_quant) defined within the public class called public.The function start at line 380 and ends at 487. It contains 78 lines of code and it has a cyclomatic complexity of 9. It takes 4 parameters, represented as [380.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __torch_dispatch__ | def __torch_dispatch__(cls,func: Callable,types: Tuple[type, ...],args: Tuple[Any, ...] = (),kwargs: Dict[str, Any] = {},skip_gptq: bool = False,) -> Any:pass | 1 | 9 | 4 | 52 | 0 | 490 | 498 | 490 | 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 490 and ends at 498. It contains 9 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [490.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __tensor_flatten__ | def __tensor_flatten__(self) -> Tuple[List[str], Optional[Any]]:return ["values"], None | 1 | 2 | 1 | 24 | 0 | 500 | 501 | 500 | 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 500 and ends at 501. 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: Dict[str, Any],tensor_attributes: Optional[Any],outer_size: torch.Size,outer_stride: Tuple[int, ...],) -> "MultiTensor":return cls(tensor_data_dict["values"]) | 1 | 8 | 5 | 47 | 0 | 504 | 511 | 504 | 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 504 and ends at 511. It contains 8 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [504.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | is_linear_layer | def is_linear_layer(cls, func: Callable) -> bool:return func == torch.nn.functional.linear | 1 | 2 | 2 | 21 | 0 | 514 | 515 | 514 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (is_linear_layer) defined within the public class called public.The function start at line 514 and ends at 515. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [514.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self, disable_input_validation=False, target_class=MultiTensor):super().__init__()self.flat_args = []self.spec = Noneself.validate = not disable_input_validationself.target_class = target_classself.count = 0 | 1 | 7 | 3 | 47 | 0 | 519 | 525 | 519 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 519 and ends at 525. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [519.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | forward.validate_input | def validate_input(flat_args, spec):if self.spec is None:assert spec == self.spec, (f"got two different input structures when recording inputs, {self.spec} is not the same as {spec}")for count, x in enumerate(flat_args):y = self.flat_args[count]if not isinstance(x, torch.Tensor):assert x == y, (f"got different values f... | 4 | 21 | 2 | 105 | 0 | 528 | 549 | 528 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (forward.validate_input) defined within the public class called public.The function start at line 528 and ends at 549. It contains 21 lines of code and it has a cyclomatic complexity of 4. It takes 2 parameters, represented as [528.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | forward | def forward(self, *args: Any, **kwargs: Any) -> "MultiTensorInputRecorder":def validate_input(flat_args, spec):if self.spec is None:assert spec == self.spec, (f"got two different input structures when recording inputs, {self.spec} is not the same as {spec}")for count, x in enumerate(flat_args):y = self.flat_args[count]... | 8 | 18 | 3 | 131 | 0 | 527 | 568 | 527 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (forward) defined within the public class called public.The function start at line 527 and ends at 568. It contains 18 lines of code and it has a cyclomatic complexity of 8. It takes 3 parameters, represented as [527.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_recorded_inputs | def get_recorded_inputs(self) -> Tuple[Any, ...]:args, kwargs = self.get_recorded_args_and_kwargs()assert len(kwargs) == 0, ("kwargs is not empty but get_recorded_inputs called on MultiTensorInputRecorder, use get_recorded_args_and_kwargs instead")return args | 1 | 6 | 1 | 34 | 0 | 570 | 575 | 570 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_recorded_inputs) defined within the public class called public.The function start at line 570 and ends at 575. It contains 6 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_recorded_args_and_kwargs | def get_recorded_args_and_kwargs(self) -> Tuple[Tuple[Any, ...], Dict[str, Any]]:assert self.spec is not None, "no inputs have been recorded yet"args, kwargs = tree_unflatten(self.flat_args, self.spec)return args, kwargs | 1 | 4 | 1 | 49 | 0 | 577 | 580 | 577 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_recorded_args_and_kwargs) defined within the public class called public.The function start at line 577 and ends at 580. 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):super().__init__()self.state_dict_manager = StateDictManager.get_instance()self.get_qparams_func = Noneself.quantize_func = Noneself.dequantize_func = Noneself.combine_qparams_list_func = Noneself.make_qtensor = Noneself.skip_layer_func = Noneself.act_fake_quant_func = Noneself.device = None | 1 | 11 | 1 | 61 | 0 | 584 | 594 | 584 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 584 and ends at 594. It contains 11 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 | _check_functions | def _check_functions(self):assert self.get_qparams_func is not None, "get_qparams_func must be set"assert self.quantize_func is not None, "quantize_func must be set"assert self.dequantize_func is not None, "dequantize_func must be set"assert self.combine_qparams_list_func is not None, ("combine_qparams_list_func must b... | 1 | 9 | 1 | 61 | 0 | 596 | 604 | 596 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_check_functions) defined within the public class called public.The function start at line 596 and ends at 604. It contains 9 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 | covert_multi_tensors_to_tensors | def covert_multi_tensors_to_tensors(self, state_dict):for key, value in state_dict.items():if isinstance(value, MultiTensor):state_dict[key] = value.values[0]return state_dict | 3 | 5 | 2 | 39 | 0 | 606 | 610 | 606 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (covert_multi_tensors_to_tensors) defined within the public class called public.The function start at line 606 and ends at 610. It contains 5 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [606.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _create_quantized_state_dict | def _create_quantized_state_dict(self,model,args,kwargs,group_size=64,blocksize=128,percdamp=0.01,#`typing.Dict[<key type>, <value type>]` to avoid runtime subscripting errors.) -> Dict:if kwargs is None:kwargs = {}MultiTensor.configure_quantization_mode(get_qparams_func=self.get_qparams_func,quantize_func=self.quantiz... | 2 | 35 | 7 | 165 | 0 | 613 | 652 | 613 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_create_quantized_state_dict) defined within the public class called public.The function start at line 613 and ends at 652. It contains 35 lines of code and it has a cyclomatic complexity of 2. It takes 7 parameters, represented as [613.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__.make_qtensor | def make_qtensor(q, qparams):# this should be setup to just use the quantized tensor and qparams directly to make# the aqt int4 tensor but i don't think we have that functionality atm so just dequant# then requantweight = self.dequantize_func(q, qparams)scale = qparams[0]zero_point = qparams[1]if self.zero_point_domain... | 2 | 22 | 2 | 111 | 0 | 719 | 748 | 719 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__.make_qtensor) defined within the public class called public.The function start at line 719 and ends at 748. It contains 22 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [719.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self,group_size=64,blocksize=128,percdamp=0.01,inner_k_tiles=8,padding_allowed=True,device: torch.device = torch.device("cuda"),layout: Optional[Layout] = TensorCoreTiledLayout(inner_k_tiles=8),):super().__init__()self.group_size = group_sizeself.blocksize = blocksizeself.percdamp = percdampself.inner_k_ti... | 4 | 62 | 7 | 307 | 0 | 656 | 752 | 656 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 656 and ends at 752. It contains 62 lines of code and it has a cyclomatic complexity of 4. It takes 7 parameters, represented as [656.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | quantize | def quantize(self, model: torch.nn.Module, *args: Tuple[Any, ...], **kwargs: Dict[str, Any]) -> torch.nn.Module:state_dict = self._create_quantized_state_dict(model,args,kwargs,self.group_size,self.blocksize,self.percdamp,)# this is hacky and potentially wrong, better to just make the flow return a state dict and let u... | 4 | 21 | 4 | 125 | 0 | 754 | 780 | 754 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (quantize) defined within the public class called public.The function start at line 754 and ends at 780. It contains 21 lines of code and it has a cyclomatic complexity of 4. It takes 4 parameters, represented as [754.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_instance | def get_instance():if StateDictManager._instance is None:StateDictManager._instance = StateDictManager()return StateDictManager._instance | 2 | 4 | 0 | 22 | 0 | 787 | 790 | 787 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_instance) defined within the public class called public.The function start at line 787 and ends at 790. 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 | __init__ | def __init__(self):self.state_dict = {}self.id_to_name = {} | 1 | 3 | 1 | 17 | 0 | 792 | 794 | 792 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 792 and ends at 794. 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 | set_state_dict | def set_state_dict(self, model):self.state_dict = model.state_dict()self.id_to_name = {id(v): k for k, v in model.named_parameters()} | 2 | 3 | 2 | 38 | 0 | 796 | 798 | 796 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (set_state_dict) defined within the public class called public.The function start at line 796 and ends at 798. It contains 3 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [796.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | update_id_to_name | def update_id_to_name(self, model):self.id_to_name = {id(v): k for k, v in model.named_parameters()} | 2 | 2 | 2 | 29 | 0 | 800 | 801 | 800 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (update_id_to_name) defined within the public class called public.The function start at line 800 and ends at 801. It contains 2 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [800.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_name_for_param | def get_name_for_param(self, param):return self.id_to_name.get(id(param), None) | 1 | 2 | 2 | 21 | 0 | 803 | 804 | 803 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_name_for_param) defined within the public class called public.The function start at line 803 and ends at 804. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [803.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | update_param | def update_param(self, name, new_value):if name in self.state_dict:if isinstance(new_value, MultiTensor):self.state_dict[name] = new_value.values[0]# Convert MultiTensor to regular tensorelse:self.state_dict[name] = new_valueelse:raise KeyError(f"Parameter {name} not found in state_dict") | 3 | 10 | 3 | 55 | 0 | 806 | 815 | 806 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (update_param) defined within the public class called public.The function start at line 806 and ends at 815. It contains 10 lines of code and it has a cyclomatic complexity of 3. It takes 3 parameters, represented as [806.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_state_dict | def get_state_dict(self):return self.state_dict | 1 | 2 | 1 | 9 | 0 | 817 | 818 | 817 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_state_dict) defined within the public class called public.The function start at line 817 and ends at 818. 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 | _check_linear_int4_k | def _check_linear_int4_k(k, group_size=1, inner_k_tiles=None):"""Check if the dimensions are compatible with int4 quantization.Args:k: The dimension size to checkgroup_size: The group size for quantizationinner_k_tiles: The inner k tiles sizeReturns:bool: Whether the dimensions are compatible"""k_divisible_by_group_siz... | 3 | 6 | 3 | 44 | 2 | 826 | 842 | 826 | null | ['k_divisible_by_16_times_inner_k_tiles', 'k_divisible_by_group_size'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_check_linear_int4_k) defined within the public class called public.The function start at line 826 and ends at 842. It contains 6 lines of code and it has a cyclomatic complexity of 3. It takes 3 parameters, represented as [826.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _flat_to_grouped_and_pad | def _flat_to_grouped_and_pad(flat: List[Any], pad_in_place=True) -> Tuple[List[Tuple[Any, ...]], List[int]]:"""Convert flattened arguments to grouped arguments with padding.Args:flat: Flattened argumentspad_in_place: Whether to pad in placeReturns:Tuple containing grouped arguments and original counts"""# Convert [A, M... | 5 | 16 | 2 | 103 | 3 | 845 | 871 | 845 | null | ['orig_counts', 'grouped', 'multi_tensor_size'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_flat_to_grouped_and_pad) defined within the public class called public.The function start at line 845 and ends at 871. It contains 16 lines of code and it has a cyclomatic complexity of 5. It takes 2 parameters, represented as [845.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _tensors_to_device | def _tensors_to_device(args, device=torch.device("cuda"), move_all=False):"""Move tensors to accelerator for faster processing.Args:args: Arguments that may contain tensorsdevice: accelerator devicemove_all: Whether to move all tensors or just single count tensorsReturns:List with tensors moved to CUDA"""new_args = []f... | 7 | 12 | 2 | 101 | 1 | 874 | 896 | 874 | null | ['new_args'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_tensors_to_device) defined within the public class called public.The function start at line 874 and ends at 896. It contains 12 lines of code and it has a cyclomatic complexity of 7. It takes 2 parameters, represented as [874.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _maybe_copy_new_values | def _maybe_copy_new_values(orig_inp, new_inp, force=False):"""Copy values from new inputs to original inputs if they've changed.Used for handling in-place operations.Args:orig_inp: Original inputsnew_inp: New inputs (potentially modified)force: Whether to force copying regardless of differencesReturns:bool: Whether any... | 5 | 8 | 3 | 68 | 1 | 899 | 918 | 899 | null | ['detected_difference'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_maybe_copy_new_values) defined within the public class called public.The function start at line 899 and ends at 918. It contains 8 lines of code and it has a cyclomatic complexity of 5. It takes 3 parameters, represented as [899.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _do_unpad | def _do_unpad(args, orig_counts):"""Unpad MultiTensors to their original counts.Args:args: Arguments that may contain MultiTensorsorig_counts: Original counts of MultiTensors"""for arg, count in zip(args, orig_counts):if isinstance(arg, MultiTensor) and arg.count > count:arg.unpad(count) | 4 | 4 | 2 | 40 | 0 | 921 | 931 | 921 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_do_unpad) defined within the public class called public.The function start at line 921 and ends at 931. It contains 4 lines of code and it has a cyclomatic complexity of 4. It takes 2 parameters, represented as [921.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _calculate_hessian | def _calculate_hessian(grouped_args, spec, device=torch.device("cuda")):"""Calculate the Hessian matrix for GPTQ.Args:grouped_args: Grouped argumentsspec: Original structure specificationdevice: accelerator deviceReturns:torch.Tensor: Hessian matrix"""H = 0total_batches = 0for inp in grouped_args:# Move all remaining C... | 5 | 15 | 3 | 156 | 6 | 934 | 968 | 934 | null | ['total_batches', 'n', 'shape', 'device_inp', 'x', 'H'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_calculate_hessian) defined within the public class called public.The function start at line 934 and ends at 968. It contains 15 lines of code and it has a cyclomatic complexity of 5. It takes 3 parameters, represented as [934.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _replace_with_custom_fn_if_matches_filter | def _replace_with_custom_fn_if_matches_filter(model: nn.Module,replacement_fn: Callable[[nn.Module], nn.Module],filter_fn: Callable[[nn.Module, str], bool],cur_fqn: str = "",) -> nn.Module:"""Replace modules in the model if they match a filter.Args:model: The model to modifyreplacement_fn: Function to apply to matching... | 4 | 15 | 4 | 110 | 2 | 971 | 999 | 971 | null | ['new_child', 'model'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_replace_with_custom_fn_if_matches_filter) defined within the public class called public.The function start at line 971 and ends at 999. It contains 15 lines of code and it has a cyclomatic complexity of 4. It takes 4 parameters, represented as [971.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _replace_buffers_and_params_with_multitensors | def _replace_buffers_and_params_with_multitensors(model: nn.Module) -> nn.Module:"""Replace model buffers and parameters with MultiTensors.Args:model: The model to modifyReturns:nn.Module: Modified model"""for name, buf in model.named_buffers(recurse=False):setattr(model, name, MultiTensor([buf]))for name, param in mod... | 3 | 6 | 1 | 79 | 0 | 1,002 | 1,018 | 1,002 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_replace_buffers_and_params_with_multitensors) defined within the public class called public.The function start at line 1002 and ends at 1018. 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 | _remove_multitensors_from_buffers_and_params | def _remove_multitensors_from_buffers_and_params(model: nn.Module) -> nn.Module:"""Convert MultiTensors in model buffers and parameters back to regular tensors.Args:model: The model to modifyReturns:nn.Module: Modified model"""for name, buf in model.named_buffers(recurse=False):if isinstance(buf, MultiTensor):setattr(m... | 5 | 12 | 1 | 101 | 0 | 1,021 | 1,043 | 1,021 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_remove_multitensors_from_buffers_and_params) defined within the public class called public.The function start at line 1021 and ends at 1043. 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 | marlin_qqq_workspace | def marlin_qqq_workspace(out_features: int,min_thread_n: int = const.MIN_THREAD_N,max_parallel: int = const.MAX_PARALLEL,) -> torch.Tensor:"""Creates a workspace for marlin qqq. The workspace is used to coordinate the locksduring the execution of the kernel.Args:out_features (int): The number of output features.min_thr... | 1 | 10 | 3 | 62 | 1 | 27 | 46 | 27 | null | ['max_workspace_size'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (marlin_qqq_workspace) defined within the public class called public.The function start at line 27 and ends at 46. It contains 10 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [27.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | pack_to_marlin_qqq | def pack_to_marlin_qqq(q_w: torch.Tensor,s_group: torch.Tensor,s_channel: torch.Tensor,num_bits: int,group_size: int,) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:"""Pack the quantized weights and scales to the marlin format.Args:q_w (torch.Tensor): The quantized weight.s_group (torch.Tensor): The per-group quan... | 1 | 16 | 5 | 97 | 1 | 49 | 79 | 49 | null | ['marlin_qqq_q_w'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (pack_to_marlin_qqq) defined within the public class called public.The function start at line 49 and ends at 79. It contains 16 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [49.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _to_marlin_weights | def _to_marlin_weights(q_w: torch.Tensor,size_k: int,size_n: int,num_bits: int,group_size: int,) -> torch.Tensor:"""Converts a quantized weight tensor to the marlin format.Args:q_w (torch.Tensor): The quantized weight.size_k (int): The number of input features.size_n (int): The number of output features.num_bits (int):... | 6 | 28 | 5 | 208 | 7 | 82 | 128 | 82 | null | ['granularity', 'group_size', 'pack_factor', 'orig_device', 'q_w', 'q_packed', 'perm'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_to_marlin_weights) defined within the public class called public.The function start at line 82 and ends at 128. It contains 28 lines of code and it has a cyclomatic complexity of 6. It takes 5 parameters, represented as [82.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _to_marlin_scales | def _to_marlin_scales(s_group: torch.Tensor,s_channel: torch.Tensor,size_k: int,size_n: int,num_bits: int,group_size: int,) -> Tuple[torch.Tensor, torch.Tensor]:"""Converts the per-group scale and the per-channel scale to the format necessary for marlin.Args:s_group (torch.Tensor): The per-group quantization scale.s_ch... | 3 | 23 | 6 | 169 | 3 | 131 | 166 | 131 | null | ['s_group', 's_channel', 'group_size'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_to_marlin_scales) defined within the public class called public.The function start at line 131 and ends at 166. It contains 23 lines of code and it has a cyclomatic complexity of 3. It takes 6 parameters, represented as [131.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | unpack_from_marlin_qqq | def unpack_from_marlin_qqq(q_w: torch.Tensor,s_group: torch.Tensor,s_channel: torch.Tensor,original_shape: torch.Size,num_bits: int,group_size: int,) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:"""Unpacks the quantized weights and scales from the marlin format.Args:q_w (torch.Tensor): The packed quantized weight... | 1 | 17 | 6 | 101 | 1 | 169 | 202 | 169 | null | ['unpacked_q_w'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (unpack_from_marlin_qqq) defined within the public class called public.The function start at line 169 and ends at 202. It contains 17 lines of code and it has a cyclomatic complexity of 1. It takes 6 parameters, represented as [169.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _from_marlin_weights | def _from_marlin_weights(q_w: torch.Tensor,size_k: int,size_n: int,num_bits: int,group_size: int,) -> torch.Tensor:"""Converts a weight tensor in the marlin format to a regular format.Args:q_w (torch.Tensor): The packed quantized weights.size_k (int): The number of input features.size_n (int): The number of output feat... | 3 | 25 | 5 | 194 | 7 | 205 | 244 | 205 | null | ['granularity', 'group_size', 'orig_device', 'q_w_comp', 'wf', 'perm', 'weight'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_from_marlin_weights) defined within the public class called public.The function start at line 205 and ends at 244. It contains 25 lines of code and it has a cyclomatic complexity of 3. It takes 5 parameters, represented as [205.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _from_marlin_scales | def _from_marlin_scales(s_group: torch.Tensor,s_channel: torch.Tensor,size_k: int,size_n: int,num_bits: int,group_size: int,) -> Tuple[torch.Tensor, torch.Tensor]:"""Converts the quantization scales from the marlin format to their original format.Args:s_group (torch.Tensor): The per-group quantization scale in marlin f... | 3 | 23 | 6 | 169 | 3 | 247 | 282 | 247 | null | ['s_group', 's_channel', 'group_size'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_from_marlin_scales) defined within the public class called public.The function start at line 247 and ends at 282. It contains 23 lines of code and it has a cyclomatic complexity of 3. It takes 6 parameters, represented as [247.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_pack_factor | def get_pack_factor(num_bits: int) -> int:"""Compute the packing factor for a given number of bits.Args:num_bits (int): Number of bits to pack.Returns:int: The packing factor."""assert 32 % num_bits == 0, f"Unsupported num_bits = {num_bits}"return 32 // num_bits | 1 | 3 | 1 | 22 | 0 | 31 | 40 | 31 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_pack_factor) defined within the public class called public.The function start at line 31 and ends at 40. 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 | marlin_permute_weights | def marlin_permute_weights(q_w: torch.Tensor,size_k: int,size_n: int,perm: torch.Tensor,tile: int = const.TILE,) -> torch.Tensor:"""Permute weights to 16x64 Marlin tiles.Args:q_w (torch.Tensor): Quantized weights.size_k (int): Number of input features.size_n (int): Number of output features.perm (torch.Tensor): The com... | 1 | 15 | 5 | 130 | 1 | 43 | 72 | 43 | null | ['q_w'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (marlin_permute_weights) defined within the public class called public.The function start at line 43 and ends at 72. It contains 15 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [43.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | reverse_marlin_permute_weights | def reverse_marlin_permute_weights(q_w_unpacked: torch.Tensor,size_k: int,size_n: int,reverse_perm: torch.Tensor,tile: int = const.TILE,) -> torch.Tensor:"""Reverse permute weights from 16x64 Marlin tiles.Args:q_w_unpacked (torch.Tensor): Unpacked quantized weights.size_k (int): Number of input features.size_n (int): N... | 1 | 20 | 5 | 146 | 1 | 75 | 108 | 75 | null | ['q_w_comp'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (reverse_marlin_permute_weights) defined within the public class called public.The function start at line 75 and ends at 108. It contains 20 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [75.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_qqq_weight_perm | def get_qqq_weight_perm(num_bits: int, granularity: Granularity) -> torch.Tensor:"""Precompute permutations for the marlin weight shuffling.Args:num_bits (int): Number of bits to pack.granularity (Granularity): The weight quantization granularity.Returns:torch.Tensor: The weight permutation tensor."""perm_list: List[in... | 8 | 26 | 2 | 255 | 3 | 112 | 148 | 112 | null | ['interleave', 'col', 'perm'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_qqq_weight_perm) defined within the public class called public.The function start at line 112 and ends at 148. It contains 26 lines of code and it has a cyclomatic complexity of 8. It takes 2 parameters, represented as [112.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_qqq_scale_perms | def get_qqq_scale_perms(num_bits: int) -> Tuple[List[int], List[int]]:"""Precompute permutations for the marlin scale shuffling.Args:num_bits (int): Number of bits to pack.Returns:Tuple[List[int], List[int]]: Scale permutation list andscale permutation list for a single group."""if num_bits != 4:raise Exception("num_bi... | 6 | 10 | 1 | 125 | 0 | 151 | 167 | 151 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_qqq_scale_perms) defined within the public class called public.The function start at line 151 and ends at 167. It contains 10 lines of code and it has a cyclomatic complexity of 6. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_qqq_weight_reverse_perm | def get_qqq_weight_reverse_perm(num_bits: int, granularity: Granularity) -> torch.Tensor:"""Reverse permutation for Marlin weight shuffling from `get_qqq_weight_perm`.Args:num_bits (int): Number of bits to pack.granularity (Granularity): The weight quantization granularity.Returns:torch.Tensor: The reversed weight perm... | 1 | 6 | 2 | 33 | 1 | 170 | 183 | 170 | null | ['perm'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_qqq_weight_reverse_perm) defined within the public class called public.The function start at line 170 and ends at 183. It contains 6 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [170.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_qqq_scale_reverse_perms | def get_qqq_scale_reverse_perms(num_bits: int) -> Tuple[torch.Tensor, torch.Tensor]:"""Reverse permutation for Marlin scale shuffling from `get_qqq_scale_perms`.Args:num_bits (int): Number of bits to pack.Returns:Tuple[List[int], List[int]]: The reversed scale permutation list andthe reversed scale permutation list for... | 1 | 5 | 1 | 55 | 2 | 186 | 198 | 186 | null | ['scale_perm_single', 'scale_perm'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_qqq_scale_reverse_perms) defined within the public class called public.The function start at line 186 and ends at 198. 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 | __init__ | def __init__(self,dtype: torch.dtype,obs_or_fqs: list[ObserverOrFakeQuantize],derive_qparams_fn: Callable[[list[ObserverOrFakeQuantize]], tuple[Tensor, Tensor]],quant_min: Optional[int] = None,quant_max: Optional[int] = None,qscheme: Optional[torch.qscheme] = None,ch_axis: Optional[int] = None,):super().__init__(dtype)... | 2 | 24 | 8 | 138 | 0 | 165 | 190 | 165 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 165 and ends at 190. It contains 24 lines of code and it has a cyclomatic complexity of 2. It takes 8 parameters, represented as [165.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | forward | def forward(self, x: Tensor) -> Tensor:return x | 1 | 2 | 2 | 13 | 0 | 192 | 193 | 192 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (forward) defined within the public class called public.The function start at line 192 and ends at 193. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [192.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | calculate_qparams | def calculate_qparams(self):# type:ignore[override]return self.derive_qparams_fn(self.obs_or_fqs) | 1 | 2 | 1 | 14 | 0 | 195 | 196 | 195 | 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 195 and ends at 196. 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_float8_type | def _is_float8_type(dtype: torch.dtype) -> bool:fp8_types = {torch.float8_e4m3fn,torch.float8_e4m3fnuz,torch.float8_e5m2,torch.float8_e5m2fnuz,}return dtype in fp8_types | 1 | 8 | 1 | 35 | 1 | 58 | 65 | 58 | null | ['fp8_types'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_is_float8_type) defined within the public class called public.The function start at line 58 and ends at 65. It contains 8 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _get_and_check_qmin_qmax | def _get_and_check_qmin_qmax(dtype, quant_min, quant_max):"""Get quant_min and quant_max args based on dtype and alsoverify that they are within the range of possible quant_min/quant_maxfor dtype"""if dtype in FP8_TYPES:quant_min_lower_bound, quant_max_upper_bound = (torch.finfo(dtype).min,torch.finfo(dtype).max,)elif ... | 5 | 23 | 3 | 101 | 2 | 69 | 97 | 69 | null | ['quant_max', 'quant_min'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_get_and_check_qmin_qmax) defined within the public class called public.The function start at line 69 and ends at 97. It contains 23 lines of code and it has a cyclomatic complexity of 5. It takes 3 parameters, represented as [69.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _get_reduction_params | def _get_reduction_params(block_size, input_size):"""Given block_size and input size find the parameters for reduction:Output:shape_for_reduction: the shape we use to `view` input to prepare it for reductionreduction_dims: the dims we'll do reduction overExample::Input:block_size: (3, 3, 2, 10)input_size: (3, 3, 10, 10... | 5 | 21 | 2 | 138 | 3 | 100 | 139 | 100 | null | ['reduction_dims', 'cur_dim', 'shape_for_reduction'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_get_reduction_params) defined within the public class called public.The function start at line 100 and ends at 139. It contains 21 lines of code and it has a cyclomatic complexity of 5. It takes 2 parameters, represented as [100.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | choose_qparams_affine_with_min_max | def choose_qparams_affine_with_min_max(min_val: torch.Tensor,max_val: torch.Tensor,mapping_type: MappingType,block_size: tuple[int, ...],target_dtype: torch.dtype,quant_min: Optional[int] = None,quant_max: Optional[int] = None,eps: Optional[float] = None,scale_dtype: Optional[torch.dtype] = None,zero_point_dtype: Optio... | 2 | 29 | 12 | 154 | 0 | 142 | 180 | 142 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (choose_qparams_affine_with_min_max) defined within the public class called public.The function start at line 142 and ends at 180. It contains 29 lines of code and it has a cyclomatic complexity of 2. It takes 12 parameters, represented as [142.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _choose_qparams_affine | def _choose_qparams_affine(input: Optional[torch.Tensor],mapping_type: str,block_size: List[int],target_dtype: torch.dtype,quant_min: Optional[Union[int, float, bool]] = None,quant_max: Optional[Union[int, float, bool]] = None,eps: Optional[float] = None,scale_dtype: Optional[torch.dtype] = None,zero_point_dtype: Optio... | 20 | 105 | 13 | 712 | 14 | 183 | 311 | 183 | null | ['scale_dtype', 'input', 'smax', 'max_val', 'max_val_pos', 'zero_point', 'eps', 'min_val', 'min_val_neg', 'scale', 'mask', 'mid_point', 'zero_point_dtype', 'smin'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_choose_qparams_affine) defined within the public class called public.The function start at line 183 and ends at 311. It contains 105 lines of code and it has a cyclomatic complexity of 20. It takes 13 parameters, represented as [183.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | quantize_affine | def quantize_affine(input: torch.Tensor,block_size: tuple[int, ...],scale: torch.Tensor,zero_point: Optional[torch.Tensor],output_dtype: torch.dtype,quant_min: Optional[Union[int, float]] = None,quant_max: Optional[Union[int, float]] = None,zero_point_domain: Optional[ZeroPointDomain] = ZeroPointDomain.INT,) -> torch.T... | 2 | 20 | 8 | 113 | 0 | 315 | 368 | 315 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (quantize_affine) defined within the public class called public.The function start at line 315 and ends at 368. It contains 20 lines of code and it has a cyclomatic complexity of 2. It takes 8 parameters, represented as [315.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _quantize_affine | def _quantize_affine(input: torch.Tensor,block_size: list[int],scale: torch.Tensor,zero_point: Optional[torch.Tensor],output_dtype: torch.dtype,quant_min: Optional[Union[int, float, bool]] = None,quant_max: Optional[Union[int, float, bool]] = None,zero_point_domain: Optional[str] = ZeroPointDomain.INT.name,) -> torch.T... | 2 | 22 | 8 | 133 | 1 | 371 | 403 | 371 | null | ['output_dtype'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_quantize_affine) defined within the public class called public.The function start at line 371 and ends at 403. It contains 22 lines of code and it has a cyclomatic complexity of 2. It takes 8 parameters, represented as [371.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _quantize_affine_no_dtype_cast | def _quantize_affine_no_dtype_cast(input: torch.Tensor,block_size: list[int],scale: torch.Tensor,zero_point: Optional[torch.Tensor],quant_min: Union[int, float],quant_max: Union[int, float],zero_point_domain: Optional[str] = ZeroPointDomain.INT.name,) -> torch.Tensor:"""The op does the following:1. figure out the dimen... | 6 | 51 | 7 | 339 | 8 | 406 | 468 | 406 | null | ['shape_after_reduction', 'input', 'zero_point', 'mid_point', 'scale', 'min_val', 'quant', 'original_shape'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_quantize_affine_no_dtype_cast) defined within the public class called public.The function start at line 406 and ends at 468. It contains 51 lines of code and it has a cyclomatic complexity of 6. It takes 7 parameters, represented as [406.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | dequantize_affine | def dequantize_affine(input: torch.Tensor,block_size: tuple[int, ...],scale: torch.Tensor,zero_point: Optional[torch.Tensor],input_dtype: torch.dtype,quant_min: Optional[Union[int, float]] = None,quant_max: Optional[Union[int, float]] = None,zero_point_domain: ZeroPointDomain = ZeroPointDomain.INT,*,output_dtype: torch... | 2 | 23 | 9 | 126 | 0 | 471 | 515 | 471 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (dequantize_affine) defined within the public class called public.The function start at line 471 and ends at 515. It contains 23 lines of code and it has a cyclomatic complexity of 2. It takes 9 parameters, represented as [471.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _dequantize_affine | def _dequantize_affine(input: torch.Tensor,block_size: list[int],scale: torch.Tensor,zero_point: Optional[torch.Tensor],input_dtype: torch.dtype,quant_min: Optional[Union[int, float, bool]] = None,quant_max: Optional[Union[int, float, bool]] = None,zero_point_domain: Optional[str] = ZeroPointDomain.INT.name,output_dtyp... | 2 | 31 | 9 | 167 | 0 | 518 | 550 | 518 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_dequantize_affine) defined within the public class called public.The function start at line 518 and ends at 550. It contains 31 lines of code and it has a cyclomatic complexity of 2. It takes 9 parameters, represented as [518.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _dequantize_affine_no_dtype_check | def _dequantize_affine_no_dtype_check(input: torch.Tensor,block_size: list[int],scale: torch.Tensor,zero_point: Optional[torch.Tensor],quant_min: Union[int, float],quant_max: Union[int, float],zero_point_domain: Optional[str] = ZeroPointDomain.INT.name,output_dtype: torch.dtype = torch.float32,) -> torch.Tensor:"""This... | 8 | 56 | 8 | 343 | 7 | 553 | 624 | 553 | null | ['shape_after_reduction', 'input', 'zero_point', 'mid_point', 'scale', 'original_shape', 'dequant'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_dequantize_affine_no_dtype_check) defined within the public class called public.The function start at line 553 and ends at 624. It contains 56 lines of code and it has a cyclomatic complexity of 8. It takes 8 parameters, represented as [553.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | forward | def forward(self, input: torch.Tensor):if input.numel() == 0:return inputinput_detached = input.detach()self.original_dtype = input_detached.dtypeassert self.granularity is not None, "granularity is None"self.block_size = get_block_size(input_detached.shape, self.granularity)shape_for_reduction, reduction_dims = _get_r... | 4 | 28 | 2 | 216 | 0 | 628 | 658 | 628 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (forward) defined within the public class called public.The function start at line 628 and ends at 658. It contains 28 lines of code and it has a cyclomatic complexity of 4. It takes 2 parameters, represented as [628.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | calculate_qparams | def calculate_qparams(self) -> tuple[torch.Tensor, torch.Tensor]:assert hasattr(self, "min_val") and hasattr(self, "max_val"), ("Expecting the observer has min_val and max_val, please run the observer before calling calculate_qparams")return choose_qparams_affine_with_min_max(self.min_val,self.max_val,self.mapping_type... | 2 | 18 | 1 | 85 | 0 | 660 | 677 | 660 | 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 660 and ends at 677. 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 | __init__ | def __init__(self,mapping_type: MappingType,target_dtype: torch.dtype,granularity: Granularity,averaging_constant=0.01,quant_min: Optional[int] = None,quant_max: Optional[int] = None,eps: Optional[float] = None,is_dynamic=False,scale_dtype: Optional[torch.dtype] = None,zero_point_dtype: Optional[torch.dtype] = None,pre... | 3 | 35 | 14 | 172 | 0 | 681 | 717 | 681 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 681 and ends at 717. It contains 35 lines of code and it has a cyclomatic complexity of 3. It takes 14 parameters, represented as [681.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | forward | def forward(self, input: torch.Tensor):if input.numel() == 0:return inputinput_detached = input.detach()self.original_dtype = input_detached.dtypeassert self.granularity is not None, "granularity is None"self.block_size = get_block_size(input_detached.shape, self.granularity)shape_for_reduction, reduction_dims = _get_r... | 4 | 28 | 2 | 226 | 0 | 719 | 750 | 719 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (forward) defined within the public class called public.The function start at line 719 and ends at 750. It contains 28 lines of code and it has a cyclomatic complexity of 4. It takes 2 parameters, represented as [719.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | calculate_qparams | def calculate_qparams(self) -> tuple[torch.Tensor, torch.Tensor]:assert hasattr(self, "min_val") and hasattr(self, "max_val"), ("Expecting the observer has min_val and max_val, please run the observer before calling calculate_qparams")return choose_qparams_affine_with_min_max(self.min_val,self.max_val,self.mapping_type... | 2 | 18 | 1 | 85 | 0 | 752 | 770 | 660 | 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 752 and ends at 770. 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 | __init__ | def __init__(self,mapping_type: MappingType,target_dtype: torch.dtype,granularity: Granularity,quant_min: Optional[int] = None,quant_max: Optional[int] = None,eps: Optional[float] = None,is_dynamic=False,scale_dtype: Optional[torch.dtype] = None,zero_point_dtype: Optional[torch.dtype] = None,preserve_zero: bool = True,... | 1 | 28 | 13 | 145 | 0 | 774 | 803 | 774 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 774 and ends at 803. It contains 28 lines of code and it has a cyclomatic complexity of 1. It takes 13 parameters, represented as [774.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | forward | def forward(self, input):self.block_size = get_block_size(input.shape, self.granularity)self.original_dtype = input.dtypereturn input | 1 | 4 | 2 | 30 | 0 | 805 | 808 | 805 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (forward) defined within the public class called public.The function start at line 805 and ends at 808. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [805.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | calculate_qparams | def calculate_qparams(self):raise Exception(# noqa: TRY002"calculate_qparams should not be called for PlaceholderObserver") | 1 | 4 | 1 | 10 | 0 | 810 | 813 | 810 | 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 810 and ends at 813. 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 | generate_numeric_debug_handle._find_max_id | def _find_max_id(node: torch.fx.Node) -> None:nonlocal unique_idunique_id = max(unique_id, node.meta.get(CUSTOM_KEY, {}).get(NUMERIC_DEBUG_HANDLE_KEY, 0)) | 1 | 5 | 1 | 40 | 0 | 71 | 75 | 71 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (generate_numeric_debug_handle._find_max_id) defined within the public class called public.The function start at line 71 and ends at 75. 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 | generate_numeric_debug_handle._assign_debug_handle | def _assign_debug_handle(node: torch.fx.Node) -> None:nonlocal unique_idif CUSTOM_KEY not in node.meta:node.meta[CUSTOM_KEY] = {}if NUMERIC_DEBUG_HANDLE_KEY not in node.meta[CUSTOM_KEY]:node.meta[CUSTOM_KEY][NUMERIC_DEBUG_HANDLE_KEY] = unique_idunique_id += 1 | 3 | 7 | 1 | 57 | 0 | 77 | 84 | 77 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (generate_numeric_debug_handle._assign_debug_handle) defined within the public class called public.The function start at line 77 and ends at 84. 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 | generate_numeric_debug_handle | def generate_numeric_debug_handle(ep: ExportedProgram) -> None:"""Attach numeric_debug_handle_id for all nodes in the graph module of the givenExportedProgram, like conv2d, squeeze, conv1d, etc, except for placeholder.Notice that nodes like getattr are out of scope since they are not in the graph.The graph nodes of inp... | 2 | 11 | 1 | 47 | 1 | 44 | 95 | 44 | null | ['unique_id'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (generate_numeric_debug_handle) defined within the public class called public.The function start at line 44 and ends at 95. It contains 11 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_node_source_debug_info._get_greatest_ancestor_node_source | def _get_greatest_ancestor_node_source(node: Node) -> "NodeSource":node_source = node.meta.get(FROM_NODE_KEY)[-1]while len(node_source.from_node) > 0:node_source = node_source.from_node[-1]return node_source | 2 | 5 | 1 | 44 | 0 | 108 | 114 | 108 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_extract_node_source_debug_info._get_greatest_ancestor_node_source) defined within the public class called public.The function start at line 108 and ends at 114. 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 | _extract_node_source_debug_info._is_node_in_original_graph | def _is_node_in_original_graph(node: Node) -> bool:if (FROM_NODE_KEY not in node.metaor node.meta[FROM_NODE_KEY] is Noneor node.meta[FROM_NODE_KEY][-1].pass_name== "ExportedProgram.module().unlift()"):# This node is not part of the ExportedProgram.module().graph, so it doesn't have a debug handlereturn Falsereturn True | 4 | 9 | 1 | 47 | 0 | 116 | 126 | 116 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_extract_node_source_debug_info._is_node_in_original_graph) defined within the public class called public.The function start at line 116 and ends at 126. 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 | _extract_node_source_debug_info | def _extract_node_source_debug_info(node: Node) -> Optional[NodeSourceDebugInfo]:"""Extract node source debug info from a node, or return None if the nodedoes not need to be traced.Returns NodeSourceDebugInfo containing the name and graph_id from thenode's greatest ancestor node source, or None if the node is not inthe... | 4 | 12 | 1 | 63 | 2 | 98 | 140 | 98 | null | ['greatest_ancestor_node_source', 'node_source'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_extract_node_source_debug_info) defined within the public class called public.The function start at line 98 and ends at 140. 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 | _detach | def _detach(x: object) -> object:detached: object = Noneif isinstance(x, torch.Tensor):detached = x.detach()elif isinstance(x, (list, tuple)):detached = type(x)([_detach(e) for e in x])elif isinstance(x, dict):detached = {k: _detach(e) for k, e in x.items()}else:detached = xreturn detached | 6 | 11 | 1 | 96 | 1 | 143 | 153 | 143 | null | ['detached'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_detach) defined within the public class called public.The function start at line 143 and ends at 153. It contains 11 lines of code and it has a cyclomatic complexity of 6. The function does not take any parameters and does not return any value.. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.