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 | apply_spinquant_r1 | def apply_spinquant_r1(model, device, pretrained_rotation_path=None, qkv_split=False):"""Apply the SpinQuant R1 rotation matrix to the model.qkv_split should be set to True if attention modules have separate tensors wq, wk, wv instead of wqkv"""if pretrained_rotation_path is not None:R1 = torch.load(pretrained_rotation... | 2 | 10 | 4 | 91 | 1 | 89 | 104 | 89 | null | ['R1'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (apply_spinquant_r1) defined within the public class called public.The function start at line 89 and ends at 104. It contains 10 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [89.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | apply_spinquant_r2 | def apply_spinquant_r2(model, device, pretrained_rotation_path=None, qkv_split=False):"""Apply the SpinQuant R2 rotation matrices to the model.qkv_split should be set to True if attention modules have separate tensors wq, wk, wv instead of wqkv"""R2s = []# note that unlike R1, there are multiple R2 matrices (one per la... | 3 | 16 | 4 | 115 | 5 | 107 | 128 | 107 | null | ['R2s_', 'R2s', 'R2', 'key', 'head_dim'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (apply_spinquant_r2) defined within the public class called public.The function start at line 107 and ends at 128. It contains 16 lines of code and it has a cyclomatic complexity of 3. It takes 4 parameters, represented as [107.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | apply_spinquant_r4 | def apply_spinquant_r4(model, device):"""Apply the SpinQuant R4 rotation matrix to the model."""_rotate_model_r4(model)_add_activation_wrappers_r4(model) | 1 | 3 | 2 | 16 | 0 | 131 | 134 | 131 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (apply_spinquant_r4) defined within the public class called public.The function start at line 131 and ends at 134. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [131.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _fuse_layernorm_into_linear | def _fuse_layernorm_into_linear(layernorm: RMSNorm, linear_layers: typing.Iterable[torch.nn.Linear]):"""Fuse the linear operations in Layernorm into the adjacent linear blocks."""for linear in linear_layers:linear_dtype = linear.weight.dtype# Calculate new weight and bias valuesW = linear.weight.data.double()linear.wei... | 4 | 17 | 2 | 168 | 2 | 138 | 160 | 138 | null | ['W', 'linear_dtype'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_fuse_layernorm_into_linear) defined within the public class called public.The function start at line 138 and ends at 160. It contains 17 lines of code and it has a cyclomatic complexity of 4. It takes 2 parameters, represented as [138.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _rotate_model_r1 | def _rotate_model_r1(model, R1, qkv_split=False):_rotate_embeddings(model, R1)_rotate_head(model, R1)for layer in model.layers:_rotate_attention_inputs(layer, R1, qkv_split=qkv_split)_rotate_attention_output(layer, R1)_rotate_mlp_input(layer, R1)_rotate_mlp_output(layer, R1) | 2 | 8 | 3 | 58 | 0 | 164 | 172 | 164 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_rotate_model_r1) defined within the public class called public.The function start at line 164 and ends at 172. It contains 8 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [164.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _rotate_model_r2 | def _rotate_model_r2(model, R2s, qkv_split=False):"""Rotate the W_v and W_o weights of the multi-head self-attention modules."""head_dim = model.config.head_dim# Apply R2 rotation to all multi-head self-attention modulesfor idx, layer in enumerate(model.layers):attn = layer.attentionR2 = R2s[idx]# Rotate W_oapply_exact... | 3 | 24 | 3 | 216 | 5 | 176 | 211 | 176 | null | ['wv_mod', 'R2', 'kv_size', 'head_dim', 'attn'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_rotate_model_r2) defined within the public class called public.The function start at line 176 and ends at 211. It contains 24 lines of code and it has a cyclomatic complexity of 3. It takes 3 parameters, represented as [176.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _rotate_model_r4 | def _rotate_model_r4(model):"""Rotate the MLP output weights."""for layer in model.layers:W = layer.feed_forward.w2# print(f"Min/max before R4 rotation: {W.weight.data.min().item():.2f}/{W.weight.data.max().item():.2f}")apply_exact_had_to_linear(W, had_dim=-1, output=False)# apply exact (inverse) hadamard | 2 | 6 | 1 | 33 | 1 | 215 | 223 | 215 | null | ['W'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_rotate_model_r4) defined within the public class called public.The function start at line 215 and ends at 223. It contains 6 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _add_activation_wrappers_r4 | def _add_activation_wrappers_r4(model):"""Modify the forward pass to rotate the activations at specific points."""# eval_utils/main.py:36had_K, K = get_hadK(model.config.intermediate_size)# print(f"K: {K}")for layer in model.layers:layer.feed_forward.w2 = nn.Sequential(HadamardMultiplier(had_K, K, use_fp32=False), laye... | 2 | 6 | 1 | 52 | 0 | 227 | 235 | 227 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_add_activation_wrappers_r4) defined within the public class called public.The function start at line 227 and ends at 235. It contains 6 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | fuse_layernorm_into_linear | def fuse_layernorm_into_linear(model, qkv_split=False):"""Fuse RMSNorm weights into the subsequent linear layers.This is done in the paper specifically to make pre-norm LLMs like LLaMarotation-invariant when quantization is not present.qkv_split should be set to True if attention modules have separate tensors wq, wk, w... | 3 | 16 | 2 | 145 | 2 | 239 | 267 | 239 | null | ['W', 'W_'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (fuse_layernorm_into_linear) defined within the public class called public.The function start at line 239 and ends at 267. It contains 16 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [239.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _rotate_mlp_output | def _rotate_mlp_output(layer, R1):mod = layer.feed_forward.w2_rotate_mod_weight_left(mod, R1)if mod.bias is not None:b = mod.bias.data.to(dtype=torch.float64)mod.bias.data = torch.matmul(R1.T, b).to(dtype=mod.weight.dtype) | 2 | 6 | 2 | 71 | 2 | 270 | 275 | 270 | null | ['b', 'mod'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_rotate_mlp_output) defined within the public class called public.The function start at line 270 and ends at 275. It contains 6 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [270.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _rotate_mlp_input | def _rotate_mlp_input(layer, R1):_rotate_mod_weight_right(layer.feed_forward.w1, R1)_rotate_mod_weight_right(layer.feed_forward.w3, R1) | 1 | 3 | 2 | 27 | 0 | 278 | 280 | 278 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_rotate_mlp_input) defined within the public class called public.The function start at line 278 and ends at 280. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [278.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _rotate_attention_output | def _rotate_attention_output(layer, R1):mod = layer.attention.wo_rotate_mod_weight_left(mod, R1)if mod.bias is not None:b = mod.bias.data.to(dtype=torch.float64)mod.bias.data = torch.matmul(R1.T, b).to(dtype=mod.weight.dtype) | 2 | 6 | 2 | 71 | 2 | 283 | 288 | 283 | null | ['b', 'mod'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_rotate_attention_output) defined within the public class called public.The function start at line 283 and ends at 288. It contains 6 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [283.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _rotate_attention_inputs | def _rotate_attention_inputs(layer, R1, qkv_split=False):if qkv_split:_rotate_mod_weight_right(layer.attention.wq, R1)_rotate_mod_weight_right(layer.attention.wk, R1)_rotate_mod_weight_right(layer.attention.wv, R1)else:_rotate_mod_weight_right(layer.attention.wqkv, R1) | 2 | 7 | 3 | 56 | 0 | 291 | 297 | 291 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_rotate_attention_inputs) defined within the public class called public.The function start at line 291 and ends at 297. It contains 7 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [291.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _rotate_head | def _rotate_head(model, R1):_rotate_mod_weight_right(model.output, R1) | 1 | 2 | 2 | 15 | 0 | 300 | 301 | 300 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_rotate_head) defined within the public class called public.The function start at line 300 and ends at 301. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [300.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _rotate_embeddings | def _rotate_embeddings(model, R1):_rotate_mod_weight_right(model.tok_embeddings, R1) | 1 | 2 | 2 | 15 | 0 | 304 | 305 | 304 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_rotate_embeddings) defined within the public class called public.The function start at line 304 and ends at 305. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [304.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _rotate_mod_weight_right | def _rotate_mod_weight_right(mod, R):dtype = mod.weight.dtypeW = mod.weight.data.to(dtype=torch.float64)mod.weight.data = torch.matmul(W, R).to(dtype=dtype) | 1 | 4 | 2 | 51 | 2 | 308 | 311 | 308 | null | ['W', 'dtype'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_rotate_mod_weight_right) defined within the public class called public.The function start at line 308 and ends at 311. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [308.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _rotate_mod_weight_left | def _rotate_mod_weight_left(mod, R):dtype = mod.weight.dtypeW = mod.weight.data.to(dtype=torch.float64)mod.weight.data = torch.matmul(R.T, W).to(dtype=dtype) | 1 | 4 | 2 | 53 | 2 | 314 | 317 | 314 | null | ['W', 'dtype'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_rotate_mod_weight_left) defined within the public class called public.The function start at line 314 and ends at 317. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [314.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _convert_linear_weight_to_int8_lut_tensor | def _convert_linear_weight_to_int8_lut_tensor(module):from torchao.prototype.quantization.int8_lut_tensor import Int8LutTensorassert isinstance(module, nn.Linear)weight = module.weightnew_weight = Int8LutTensor.from_intx_unpacked_to_int8_tensor(weight, bias=module.bias)module.weight = torch.nn.Parameter(new_weight, req... | 1 | 9 | 1 | 64 | 2 | 20 | 29 | 20 | null | ['new_weight', 'weight'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_convert_linear_weight_to_int8_lut_tensor) defined within the public class called public.The function start at line 20 and ends at 29. 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 | _convert_module_weight_to_intx_opaque_tensor | def _convert_module_weight_to_intx_opaque_tensor(module, intx_packing_format):from torchao.quantization.quantize_.workflows.intx.intx_opaque_tensor import (IntxOpaqueTensor,)assert isinstance(module, nn.Linear) or isinstance(module, nn.Embedding)weight = module.weightnew_weight = IntxOpaqueTensor.from_intx_unpacked_to_... | 4 | 14 | 2 | 104 | 2 | 32 | 46 | 32 | null | ['new_weight', 'weight'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_convert_module_weight_to_intx_opaque_tensor) defined within the public class called public.The function start at line 32 and ends at 46. It contains 14 lines of code and it has a cyclomatic complexity of 4. It takes 2 parameters, represented as [32.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _find_tied_module_names_for_embedding | def _find_tied_module_names_for_embedding(embedding_weight, model):assert isinstance(embedding_weight, IntxUnpackedToInt8Tensor)tied_names = []for name, module in model.named_modules():is_linear = isinstance(module, nn.Linear)is_embedding = isinstance(module, nn.Embedding)if not (is_linear or is_embedding):continueweig... | 15 | 26 | 2 | 180 | 5 | 49 | 82 | 49 | null | ['is_embedding', 'are_tied', 'tied_names', 'is_linear', 'weight'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_find_tied_module_names_for_embedding) defined within the public class called public.The function start at line 49 and ends at 82. It contains 26 lines of code and it has a cyclomatic complexity of 15. It takes 2 parameters, represented as [49.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _find_tied_params | def _find_tied_params(model):from torchao.quantization.quantize_.workflows.intx.intx_opaque_tensor import (IntxOpaqueTensor,)module_name_to_tied_param = {}for name, module in model.named_modules():if not isinstance(module, nn.Embedding):continueweight = module.weightif not isinstance(weight, IntxUnpackedToInt8Tensor):c... | 8 | 31 | 1 | 159 | 5 | 85 | 123 | 85 | null | ['weight', 'tied_param', 'tied_module_names', 'module_name_to_tied_param', 'prev'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_find_tied_params) defined within the public class called public.The function start at line 85 and ends at 123. It contains 31 lines of code and it has a cyclomatic complexity of 8. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _convert_model_for_aarch64 | def _convert_model_for_aarch64(model,*,tensor_type="auto",intx_packing_format="opaque_torchao_auto",convert_tied_embedding=True,convert_linear=True,):module_name_to_tied_param = (_find_tied_params(model) if convert_tied_embedding else {})# Iterate through modules in model and convert IntxUnpackedToInt8Tensor tensors to... | 13 | 40 | 5 | 176 | 2 | 126 | 172 | 126 | null | ['module_name_to_tied_param', 'weight'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_convert_model_for_aarch64) defined within the public class called public.The function start at line 126 and ends at 172. It contains 40 lines of code and it has a cyclomatic complexity of 13. It takes 5 parameters, represented as [126.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | convert_to_packed_tensor_based_on_current_hardware | def convert_to_packed_tensor_based_on_current_hardware(tensor: TorchAOBaseTensor):"""Convert a plain / unpacked torchao tensor to a packed one based on hardwareGoal is to have an optimized performance on current hardware, while also allowus to(1). distribute a single unpacked / plain format that can be used in multiple... | 4 | 8 | 1 | 40 | 0 | 175 | 192 | 175 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (convert_to_packed_tensor_based_on_current_hardware) defined within the public class called public.The function start at line 175 and ends at 192. It contains 8 lines of code and it has a cyclomatic complexity of 4. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_rotate_in_and_out | def test_rotate_in_and_out(self):"""Perform rotation to output of linear layer and inverse rotation to input of next layer; test that the output is the same."""with torch.no_grad():layer1 = nn.Linear(256, 256, bias=True)layer2 = nn.Linear(256, 256, bias=True)model = nn.Sequential(layer1, layer2)input = torch.rand(256)o... | 1 | 11 | 1 | 97 | 0 | 16 | 27 | 16 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_rotate_in_and_out) defined within the public class called public.The function start at line 16 and ends at 27. 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_cache | def _check_cache(cls, shapes_and_dtype):return _AUTOQUANT_CACHE.get((cls,) + shapes_and_dtype, None) | 1 | 2 | 2 | 21 | 0 | 68 | 69 | 68 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_check_cache) defined within the public class called public.The function start at line 68 and ends at 69. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [68.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _update_cache | def _update_cache(cls, shapes_and_dtype, res):_AUTOQUANT_CACHE[(cls,) + shapes_and_dtype] = res | 1 | 2 | 3 | 20 | 0 | 72 | 73 | 72 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_update_cache) defined within the public class called public.The function start at line 72 and ends at 73. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [72.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __new__ | def __new__(cls,weight,qtensor_class_list,*args,mode=["relu", None],min_sqnr=None,**kwargs,):kwargs["device"] = weight.devicekwargs["layout"] = (kwargs.get("layout") if kwargs.get("layout", False) else weight.layout)kwargs["dtype"] = (kwargs.get("dtype") if kwargs.get("dtype", False) else weight.dtype)kwargs["requires_... | 3 | 19 | 7 | 120 | 0 | 92 | 110 | 92 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__new__) defined within the public class called public.The function start at line 92 and ends at 110. It contains 19 lines of code and it has a cyclomatic complexity of 3. It takes 7 parameters, represented as [92.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self,weight,qtensor_class_list,*args,mode=["relu", None],min_sqnr=None,**kwargs,):self.weight = weightself.qtensor_class_list = qtensor_class_listself.logged_data = {}self.mode = modeself.min_sqnr = min_sqnr | 1 | 14 | 7 | 54 | 0 | 112 | 125 | 112 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 112 and ends at 125. It contains 14 lines of code and it has a cyclomatic complexity of 1. It takes 7 parameters, represented as [112.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __repr__ | def __repr__(self):return (f"{self.__class__.__name__}(data={self.weight}, shape={self.shape}, "f"device={self.device}, dtype={self.dtype}, qtensor_class_list={self.qtensor_class_list})") | 1 | 5 | 1 | 12 | 0 | 127 | 131 | 127 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__repr__) defined within the public class called public.The function start at line 127 and ends at 131. 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 | log_shape | def log_shape(act_mat, w_autoquant, bias):act_mat = act_mat.reshape(-1, act_mat.shape[-1])logged_dtype = act_mat.dtypelogged_shapes = (act_mat.shape,w_autoquant.shape,None if bias is None else bias.shape,)shapes_and_dtype = logged_shapes + (logged_dtype,)w_autoquant.logged_data[shapes_and_dtype] = 1 + w_autoquant.logge... | 4 | 15 | 3 | 105 | 0 | 134 | 148 | 134 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (log_shape) defined within the public class called public.The function start at line 134 and ends at 148. It contains 15 lines of code and it has a cyclomatic complexity of 4. It takes 3 parameters, represented as [134.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | tune_autoquant | def tune_autoquant(self, q_cls, shapes_and_dtype, best_time):act_shape, w_shape, bias_shape, act_dtype = shapes_and_dtypeif _check_cache(q_cls, shapes_and_dtype) is None:with torch.no_grad():act_mat = torch.randn(act_shape, dtype=act_dtype, device=self.device)bias = (Noneif bias_shape is Noneelse torch.randn(bias_shape... | 6 | 36 | 4 | 196 | 0 | 150 | 185 | 150 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (tune_autoquant) defined within the public class called public.The function start at line 150 and ends at 185. It contains 36 lines of code and it has a cyclomatic complexity of 6. It takes 4 parameters, represented as [150.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | to_quantized.count_shapes | def count_shapes(self, do_print=True):differe_shape_count = 0for shapes_and_dtype, times_seen in self.logged_data.items():differe_shape_count += 1if do_print:act_shape, weight_shape, bias_shape, dtype = shapes_and_dtypeprint(f"activation_shapes: {act_shape}, times_seen: {times_seen}")if do_print:print(f"weight_shape: {... | 4 | 12 | 2 | 55 | 0 | 203 | 214 | 203 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (to_quantized.count_shapes) defined within the public class called public.The function start at line 203 and ends at 214. It contains 12 lines of code and it has a cyclomatic complexity of 4. It takes 2 parameters, represented as [203.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | to_quantized | def to_quantized(self, error_on_unseen, **kwargs):if error_on_unseen and self.logged_data == {}:raise RuntimeError("must run module normally to get shape, dtype info for autoquant")elif (self.logged_data == {}) and not error_on_unseen:# default back to non-quantized weight if not seenself = AQDefaultLinearWeight.from_f... | 17 | 47 | 3 | 247 | 0 | 188 | 260 | 188 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (to_quantized) defined within the public class called public.The function start at line 188 and ends at 260. It contains 47 lines of code and it has a cyclomatic complexity of 17. It takes 3 parameters, represented as [188.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.weight),self.qtensor_class_list,dtype=self.dtype,mode=self.mode,min_sqnr=self.min_sqnr,) | 1 | 8 | 2 | 42 | 0 | 262 | 269 | 262 | 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 262 and ends at 269. It contains 8 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [262.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __tensor_flatten__ | def __tensor_flatten__(self):return ["weight"], [self.qtensor_class_list,self.mode,self.min_sqnr,self.dtype,self.shape,] | 1 | 8 | 1 | 32 | 0 | 271 | 278 | 271 | 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 271 and ends at 278. 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 | __tensor_unflatten__ | def __tensor_unflatten__(cls, tensor_data_dict, tensor_attributes, outer_size=None, outer_stride=None):weight = tensor_data_dict["weight"]qtensor_class_list, mode, min_sqnr, dtype, shape = tensor_attributesreturn cls(weight,qtensor_class_list,mode=mode,min_sqnr=min_sqnr,shape=shape if outer_size is None else outer_size... | 2 | 14 | 5 | 68 | 0 | 281 | 294 | 281 | 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 281 and ends at 294. It contains 14 lines of code and it has a cyclomatic complexity of 2. It takes 5 parameters, represented as [281.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | from_float | def from_float(cls, weight, qtensor_class_list, **kwargs):return cls(weight, qtensor_class_list, **kwargs) | 1 | 2 | 4 | 22 | 0 | 297 | 298 | 297 | 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 297 and ends at 298. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [297.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __torch_function__ | def __torch_function__(cls, func, types, args=(), kwargs=None):kwargs = {} if kwargs is None else kwargsif func is torch.nn.functional.linear:mat1, w_autoquant, bias = (args[0],args[1],args[2] if len(args) > 2 else None,)cls.log_shape(mat1, w_autoquant, bias)return func(mat1, w_autoquant.weight, bias)try:with torch._C.... | 5 | 15 | 4 | 120 | 0 | 301 | 316 | 301 | 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 301 and ends at 316. It contains 15 lines of code and it has a cyclomatic complexity of 5. It takes 4 parameters, represented as [301.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __torch_dispatch__ | def __torch_dispatch__(cls, func, types, args, kwargs):if func is aten.detach.default:return return_and_correct_aliasing(func, args, kwargs, args[0]._apply_fn_to_data(torch.detach)) | 2 | 5 | 5 | 43 | 0 | 319 | 323 | 319 | 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 319 and ends at 323. It contains 5 lines of code and it has a cyclomatic complexity of 2. It takes 5 parameters, represented as [319.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | do_autoquant_bench | def do_autoquant_bench(op, *args, **kwargs):"""runs benchmark op(*args, **kwargs) avoiding torch.compile overhead"""from torch._inductor.runtime.benchmarking import benchmarkerrep = kwargs.pop("rep", 100)warmup = kwargs.pop("warmup", 25)with torch.no_grad():torch.cuda.synchronize()stream = torch.cuda.Stream()stream.wai... | 2 | 27 | 3 | 222 | 5 | 327 | 358 | 327 | null | ['res', 'graph', 'stream', 'warmup', 'rep'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (do_autoquant_bench) defined within the public class called public.The function start at line 327 and ends at 358. It contains 27 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [327.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _is_interpolate_mode | def _is_interpolate_mode(mode):if (isinstance(mode, list)and mode[0] == "interpolate"and len(mode) == 2and isinstance(mode[1], float)):return Truereturn False | 5 | 9 | 1 | 43 | 0 | 361 | 369 | 361 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_is_interpolate_mode) defined within the public class called public.The function start at line 361 and ends at 369. It contains 9 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 | _to_float16 | def _to_float16(x: torch.Tensor) -> torch.Tensor:return x.to(torch.float16) | 1 | 2 | 1 | 22 | 0 | 372 | 373 | 372 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_to_float16) defined within the public class called public.The function start at line 372 and ends at 373. 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 | _to_bfloat16 | def _to_bfloat16(x: torch.Tensor) -> torch.Tensor:return x.to(torch.bfloat16) | 1 | 2 | 1 | 22 | 0 | 376 | 377 | 376 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_to_bfloat16) defined within the public class called public.The function start at line 376 and ends at 377. 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 | _identity | def _identity(x: torch.Tensor) -> torch.Tensor:return x | 1 | 2 | 1 | 15 | 0 | 380 | 381 | 380 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_identity) defined within the public class called public.The function start at line 380 and ends at 381. 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 | _autoquant_test | def _autoquant_test(cls, act_mat, weight, bias, best_time, mode=["relu", None]):w_qtensor = cls.from_float(weight)if _is_interpolate_mode(mode):q_c_op = torch.compile(cls._quantized_linear_op, mode="max-autotune-no-cudagraphs")else:func = lambda a, b, c: F.relu(cls._quantized_linear_op(F.relu(a), b, c))q_c_op = torch.c... | 3 | 17 | 6 | 161 | 0 | 401 | 417 | 401 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_autoquant_test) defined within the public class called public.The function start at line 401 and ends at 417. It contains 17 lines of code and it has a cyclomatic complexity of 3. It takes 6 parameters, represented as [401.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | from_float.get_weight_block_size | def get_weight_block_size(x):return (1, x.shape[1]) | 1 | 2 | 1 | 16 | 0 | 450 | 451 | 450 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (from_float.get_weight_block_size) defined within the public class called public.The function start at line 450 and ends at 451. 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 | from_float | def from_float(cls, weight):if weight.dim() != 2:return weight# TODO test if this is valid# in_features = weight.shape[1]# int8 dynamic quantization only has benefit when in_feature > 16# if in_features <= 16:# return weight# avoid circular depfrom torchao.dtypes import to_affine_quantized_intxfrom torchao.quantization... | 2 | 28 | 2 | 120 | 0 | 428 | 471 | 428 | 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 428 and ends at 471. It contains 28 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [428.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _autoquant_test | def _autoquant_test(cls, act_mat, weight, bias, best_time, mode=["relu", None]):"""Tests and benchmarks the autoquantization process with special handling for interpolate mode.Args:act_mat (torch.Tensor): The activation matrix.weight (torch.Tensor): The weight tensor.bias (torch.Tensor or None): The bias tensor.best_ti... | 3 | 37 | 6 | 237 | 0 | 474 | 530 | 474 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_autoquant_test) defined within the public class called public.The function start at line 474 and ends at 530. It contains 37 lines of code and it has a cyclomatic complexity of 3. It takes 6 parameters, represented as [474.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _autoquant_test | def _autoquant_test(cls, act_mat, weight, bias, best_time, mode=["relu", None]):return super()._autoquant_test(act_mat, weight, bias, best_time, None) | 1 | 2 | 6 | 38 | 0 | 539 | 540 | 539 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_autoquant_test) defined within the public class called public.The function start at line 539 and ends at 540. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 6 parameters, represented as [539.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | from_float | def from_float(cls, weight):mapping_type = MappingType.SYMMETRICtarget_dtype = torch.int8eps = torch.finfo(torch.float32).epszero_point_dtype = torch.int64block_size = (1, weight.shape[1])return super(AQInt8WeightOnlyQuantizedLinearWeight, cls).from_hp_to_intx(weight,mapping_type,block_size,target_dtype,eps=eps,zero_po... | 1 | 14 | 2 | 73 | 0 | 549 | 562 | 549 | 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 549 and ends at 562. It contains 14 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [549.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _quantized_linear_op | def _quantized_linear_op(act_mat, w_qtensor, bias):"""Performs the quantized linear operationsArgs:act_mat (torch.Tensor): The activation matrix.w_qtensor (torch.Tensor): The quantized weight tensor.bias (torch.Tensor or None): The bias tensor.Returns:torch.Tensor: The result of the quantized operation."""orig_dtype = ... | 2 | 9 | 3 | 111 | 0 | 574 | 593 | 574 | 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 574 and ends at 593. It contains 9 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [574.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _autoquant_test | def _autoquant_test(cls, act_mat, *args):# if act_mat has batchsize>2 don't use this kernelif act_mat.reshape(-1, act_mat.shape[-1]).shape[0] > 32:return torch.infreturn super()._autoquant_test(act_mat, *args) | 2 | 4 | 3 | 50 | 0 | 596 | 600 | 596 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_autoquant_test) defined within the public class called public.The function start at line 596 and ends at 600. It contains 4 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [596.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _quantized_linear_op | def _quantized_linear_op(act_mat, w_qtensor, bias):orig_shape = act_mat.shapey = torch.mm(act_mat.reshape(-1, orig_shape[-1]),w_qtensor.tensor_impl.int_data.t() * w_qtensor.tensor_impl.scale,)y = y.reshape(*orig_shape[:-1], y.shape[-1])if bias is not None:y += biasreturn y | 2 | 10 | 3 | 84 | 0 | 612 | 621 | 612 | 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 612 and ends at 621. It contains 10 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [612.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | from_float | def from_float(cls, weight):from torchao.dtypes import to_affine_quantized_intxgroup_size = cls.group_size_layout = cls.aq_layoutif weight.shape[-1] % group_size != 0:return weightinput_quant_func = None# NOTE: we only convert activation dtype and weight dtype here# because the kernel implementation for both TensorCore... | 7 | 50 | 2 | 227 | 0 | 636 | 696 | 636 | 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 636 and ends at 696. It contains 50 lines of code and it has a cyclomatic complexity of 7. It takes 2 parameters, represented as [636.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | from_float | def from_float(cls, weight):from torchao.dtypes import to_affine_quantized_intxfrom torchao.dtypes.uintx.gemlite_layout import get_gemlite_aqt_kwargsif weight.dtype != torch.float16:weight = weight.to(torch.float16)bit_width = 4packing_bitwidth = Nonemode = "weight_only"use_hqq = Trueaqt_kwargs = get_gemlite_aqt_kwargs... | 2 | 22 | 2 | 109 | 0 | 730 | 755 | 730 | 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 730 and ends at 755. It contains 22 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [730.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self):super().__init__() | 1 | 2 | 1 | 12 | 0 | 785 | 786 | 785 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 785 and ends at 786. 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 | _quantized_linear_op | def _quantized_linear_op(act_mat, w_qtensor, bias):return torch.nn.functional.linear(act_mat, w_qtensor, bias) | 1 | 2 | 3 | 24 | 0 | 789 | 790 | 789 | 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 789 and ends at 790. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [789.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | from_float | def from_float(cls, weight):return weight | 1 | 2 | 2 | 9 | 0 | 793 | 794 | 793 | 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 793 and ends at 794. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [793.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __new__ | def __new__(cls, weight, skip_weight_conversion=False):kwargs = {}kwargs["device"] = weight.devicekwargs["layout"] = (kwargs.get("layout") if kwargs.get("layout", False) else weight.layout)kwargs["dtype"] = weight.dtypekwargs["requires_grad"] = Falseshape = weight.shapereturn torch.Tensor._make_wrapper_subclass(cls, sh... | 2 | 10 | 3 | 82 | 0 | 802 | 811 | 802 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__new__) defined within the public class called public.The function start at line 802 and ends at 811. It contains 10 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [802.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self, weight, skip_weight_conversion=False):self.weight = weight if skip_weight_conversion else weight.to(torch.float32) | 2 | 2 | 3 | 27 | 0 | 813 | 814 | 813 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 813 and ends at 814. It contains 2 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [813.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _quantized_linear_op | def _quantized_linear_op(act_mat, w_qtensor, bias):_DTYPE = torch.float32orig_dtype = act_mat.dtypereturn torch.nn.functional.linear(act_mat.to(_DTYPE),w_qtensor.weight,bias.to(_DTYPE) if bias is not None else bias,).to(dtype=orig_dtype) | 2 | 8 | 3 | 61 | 0 | 817 | 824 | 817 | 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 817 and ends at 824. It contains 8 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [817.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.weight),) | 1 | 4 | 2 | 20 | 0 | 826 | 829 | 826 | 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 826 and ends at 829. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [826.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | from_float | def from_float(cls, weight):return cls(weight) | 1 | 2 | 2 | 12 | 0 | 832 | 833 | 832 | 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 832 and ends at 833. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [832.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,)return weight_tensor._quantized_linear_op(input_tensor, weight_tensor, bias) | 2 | 7 | 4 | 54 | 0 | 837 | 843 | 837 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_) defined within the public class called public.The function start at line 837 and ends at 843. It contains 7 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [837.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 | 847 | 850 | 847 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_) defined within the public class called public.The function start at line 847 and ends at 850. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [847.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 | 854 | 857 | 847 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_) defined within the public class called public.The function start at line 854 and ends at 857. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [847.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 | 861 | 867 | 861 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_) defined within the public class called public.The function start at line 861 and ends at 867. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [861.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self, weight, skip_weight_conversion=False):self.weight = weight if skip_weight_conversion else weight.to(torch.float32) | 2 | 2 | 3 | 27 | 0 | 871 | 872 | 813 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 871 and ends at 872. It contains 2 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [813.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _quantized_linear_op | def _quantized_linear_op(act_mat, w_qtensor, bias):_DTYPE = torch.float32orig_dtype = act_mat.dtypereturn torch.nn.functional.linear(act_mat.to(_DTYPE),w_qtensor.weight,bias.to(_DTYPE) if bias is not None else bias,).to(dtype=orig_dtype) | 2 | 8 | 3 | 61 | 0 | 875 | 882 | 817 | 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 875 and ends at 882. It contains 8 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [817.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | from_float | def from_float(cls, weight, skip_weight_conversion=False):return cls(weight, skip_weight_conversion) | 1 | 2 | 3 | 18 | 0 | 885 | 886 | 885 | 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 885 and ends at 886. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [885.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self, weight, skip_weight_conversion=False):self.weight = weight if skip_weight_conversion else weight.to(torch.float32) | 2 | 2 | 3 | 27 | 0 | 890 | 891 | 813 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 890 and ends at 891. It contains 2 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [813.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _quantized_linear_op | def _quantized_linear_op(act_mat, w_qtensor, bias):_DTYPE = torch.float32orig_dtype = act_mat.dtypereturn torch.nn.functional.linear(act_mat.to(_DTYPE),w_qtensor.weight,bias.to(_DTYPE) if bias is not None else bias,).to(dtype=orig_dtype) | 2 | 8 | 3 | 61 | 0 | 894 | 901 | 817 | 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 894 and ends at 901. It contains 8 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [817.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | from_float | def from_float(cls, weight, skip_weight_conversion=False):return cls(weight, skip_weight_conversion) | 1 | 2 | 3 | 18 | 0 | 904 | 905 | 885 | 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 904 and ends at 905. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [885.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | from_float | def from_float(cls, weight):return super(AQFloat32LinearWeight, cls).from_float(weight) | 1 | 2 | 2 | 19 | 0 | 917 | 918 | 917 | 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 917 and ends at 918. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [917.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | from_float | def from_float(cls, weight):return super(AQFloat32LinearWeight, cls).from_float(weight) | 1 | 2 | 2 | 19 | 0 | 930 | 931 | 917 | 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 930 and ends at 931. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [917.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | from_float | def from_float(cls, weight):return super(AQFloat32LinearWeight, cls).from_float(weight) | 1 | 2 | 2 | 19 | 0 | 943 | 944 | 917 | 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 943 and ends at 944. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [917.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _quantized_linear_op | def _quantized_linear_op(act_mat, w_qtensor, bias):return torch.nn.functional.linear(act_mat, w_qtensor.dequantize(), bias) | 1 | 2 | 3 | 28 | 0 | 955 | 956 | 955 | 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 955 and ends at 956. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [955.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | from_float | def from_float(cls, weight):block_size = (1, weight.shape[1])return super(AQFloat8WeightOnlyQuantizedLinearWeight, cls).from_hp_to_floatx(weight, block_size, target_dtype=cls.target_dtype, _layout=Float8Layout()) | 1 | 5 | 2 | 45 | 0 | 959 | 963 | 959 | 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 959 and ends at 963. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [959.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | from_float.get_weight_block_size | def get_weight_block_size(x):return (1, x.shape[1]) | 1 | 2 | 1 | 16 | 0 | 982 | 983 | 450 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (from_float.get_weight_block_size) defined within the public class called public.The function start at line 982 and ends at 983. 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 | from_float | def from_float(cls, weight):# avoid circular depfrom torchao.dtypes import to_affine_quantized_floatxfrom torchao.quantization.quant_api import _input_activation_quant_func_fp8# weight settingsdef get_weight_block_size(x):return (1, x.shape[1])target_dtype = torch.float8_e4m3fninput_target_dtype = torch.float8_e4m3fn_l... | 1 | 24 | 2 | 115 | 0 | 976 | 1,005 | 976 | 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 976 and ends at 1005. It contains 24 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [976.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | from_float.get_weight_block_size | def get_weight_block_size(x):assert x.ndim == 2, "Only works for 2D tensors"return x.shape | 1 | 3 | 1 | 17 | 0 | 1,024 | 1,026 | 1,024 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (from_float.get_weight_block_size) defined within the public class called public.The function start at line 1024 and ends at 1026. 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 | from_float | def from_float(cls, weight):# avoid circular depfrom torchao.dtypes import to_affine_quantized_floatxfrom torchao.quantization.quant_api import _input_activation_quant_func_fp8# weight settingsdef get_weight_block_size(x):return (1, x.shape[1])target_dtype = torch.float8_e4m3fninput_target_dtype = torch.float8_e4m3fn_l... | 1 | 24 | 2 | 115 | 0 | 1,018 | 1,048 | 976 | 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 1018 and ends at 1048. It contains 24 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [976.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _change_linears_to_autoquantizable | def _change_linears_to_autoquantizable(model, **kwargs):"""Converts all linear weight tensors to theAutoQuantizableLinearWeight tensor subclass. Expectation is that this is followedby running the model and then calling _change_autoquantizable_to_quantized"""from torchao.quantization.quant_api import _is_linearfilter_fn... | 2 | 20 | 2 | 115 | 2 | 1,121 | 1,147 | 1,121 | null | ['filter_fn', '_'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_change_linears_to_autoquantizable) defined within the public class called public.The function start at line 1121 and ends at 1147. It contains 20 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [1121.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _change_autoquantizable_to_quantized | def _change_autoquantizable_to_quantized(model, supress_autoquant_errors=True, **kwargs):"""Converts AutoQuantizableLinearWeight tensor subclassesto various quantized/non-quantized tensor subclasses dependingon benchmark results. Expectation is that these modules aretorch.compiled afterwards."""hold_automatic_dynamic_s... | 4 | 35 | 3 | 185 | 4 | 1,150 | 1,196 | 1,150 | null | ['error_on_unseen', 'hold_supress_errors', 'hold_automatic_dynamic_shapes', 'filter_fn'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_change_autoquantizable_to_quantized) defined within the public class called public.The function start at line 1150 and ends at 1196. It contains 35 lines of code and it has a cyclomatic complexity of 4. It takes 3 parameters, represented as [1150.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | autoquant.autoquant_prehook | def autoquant_prehook(module, args, kwargs):real_model.forward(*args, **kwargs)module.finalize_autoquant()return args, kwargs | 1 | 4 | 3 | 28 | 0 | 1,307 | 1,310 | 1,307 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (autoquant.autoquant_prehook) defined within the public class called public.The function start at line 1307 and ends at 1310. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [1307.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | autoquant.finalize_autoquant | def finalize_autoquant():_change_autoquantizable_to_quantized(real_model,supress_autoquant_errors,**aq_kwargs,)if hasattr(real_model, "old_forward"):model.forward = real_model.old_forwarddelattr(real_model, "old_forward")if hasattr(real_model, "finalize_autoquant"):delattr(real_model, "finalize_autoquant")if not manual... | 4 | 13 | 0 | 58 | 0 | 1,320 | 1,332 | 1,320 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (autoquant.finalize_autoquant) defined within the public class called public.The function start at line 1320 and ends at 1332. It contains 13 lines of code and it has a cyclomatic complexity of 4. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | autoquant | def autoquant(model,example_input=None,qtensor_class_list=DEFAULT_AUTOQUANT_CLASS_LIST,filter_fn=None,mode=["interpolate", 0.85],manual=False,set_inductor_config=True,supress_autoquant_errors=True,min_sqnr=None,**aq_kwargs,):"""Autoquantization is a process which identifies the fastest way to quantize each layer of a m... | 9 | 47 | 10 | 226 | 4 | 1,203 | 1,342 | 1,203 | null | ['is_compiled', 'real_model', 'example_input', 'handle'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (autoquant) defined within the public class called public.The function start at line 1203 and ends at 1342. It contains 47 lines of code and it has a cyclomatic complexity of 9. It takes 10 parameters, represented as [1203.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self,in_features: int,out_features: int,bias: bool = True,) -> None:super().__init__(in_features, out_features, bias) | 1 | 7 | 4 | 34 | 0 | 25 | 31 | 25 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 25 and ends at 31. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [25.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | forward | def forward(self, X: torch.Tensor, *args, **kwargs) -> torch.Tensor:"""Performs the forward pass of the quantized linear layer which consistsof int8 dynamic symmetric per-token activation and int8 symmetric per-channel weightquantizationArgs:X (torch.Tensor): The input floating point tensor to the quantized linear laye... | 1 | 5 | 4 | 46 | 0 | 33 | 50 | 33 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (forward) defined within the public class called public.The function start at line 33 and ends at 50. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [33.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | from_float | def from_float(cls, mod: torch.nn.Linear) -> "DynamicallyPerAxisQuantizedLinear":"""Converts a `mod` of class `torch.nn.Linear` to the`DynamicallyPerAxisQuantizedLinear` classArgs:mod (torch.nn.Linear): The original `torch.nn.Linear` module to convert.Returns:DynamicallyPerAxisQuantizedLinear: The converted quantized l... | 1 | 19 | 2 | 133 | 0 | 53 | 85 | 53 | 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 53 and ends at 85. It contains 19 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [53.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __new__ | def __new__(cls,original_weight_tensor: torch.Tensor,input_quant_func: Callable,quant_kwargs: Dict[str, Any],):kwargs = {}dtype = original_weight_tensor.dtypekwargs["dtype"] = dtypekwargs["requires_grad"] = Falsekwargs["device"] = original_weight_tensor.deviceshape = original_weight_tensor.shapereturn torch.Tensor._mak... | 1 | 13 | 4 | 73 | 0 | 40 | 52 | 40 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__new__) defined within the public class called public.The function start at line 40 and ends at 52. It contains 13 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [40.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self,original_weight_tensor: torch.Tensor,input_quant_func: Callable[[torch.Tensor], torch.Tensor],quant_kwargs: Dict[str, Any],):self.original_weight_tensor = original_weight_tensorself.input_quant_func = input_quant_funcself.quant_kwargs = quant_kwargs | 1 | 9 | 4 | 51 | 0 | 54 | 62 | 54 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 54 and ends at 62. It contains 9 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [54.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}, quant_kwargs={self.quant_kwargs}))" | 1 | 2 | 1 | 8 | 0 | 64 | 65 | 64 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__repr__) defined within the public class called public.The function start at line 64 and ends at 65. It contains 2 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __tensor_flatten__ | def __tensor_flatten__(self):return ["original_weight_tensor"], [self.input_quant_func, self.quant_kwargs] | 1 | 2 | 1 | 19 | 0 | 67 | 68 | 67 | 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 67 and ends at 68. 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):original_weight_tensor = tensor_data_dict["original_weight_tensor"]input_quant_func, quant_kwargs = tensor_attributesreturn cls(original_weight_tensor, input_quant_func, quant_kwargs) | 1 | 6 | 5 | 33 | 0 | 71 | 76 | 71 | 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 71 and ends at 76. It contains 6 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [71.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):if input_tensor.numel() == 0:return input_tensorinput_quant_func = weight_tensor.input_quant_funcoriginal_weight_tensor = weight_tensor.original_weight_tensorquant_kwargs = weight_tensor.quant_kwargsquantized_tensor = ... | 2 | 12 | 3 | 71 | 0 | 79 | 90 | 79 | 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 79 and ends at 90. It contains 12 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [79.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,quant_kwargs: Optional[Dict[str, Any]] = None,):if quant_kwargs is None:quant_kwargs = {}return cls(input_float, input_quant_func, quant_kwargs) | 2 | 9 | 4 | 48 | 0 | 93 | 101 | 93 | 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 93 and ends at 101. It contains 9 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [93.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,self.quant_kwargs,) | 1 | 6 | 2 | 28 | 0 | 103 | 108 | 103 | 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 103 and ends at 108. It contains 6 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [103.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)return self.__class__(self.original_weight_tensor.to(**kwargs),self.input_quant_func,self.quant_kwargs,) | 1 | 7 | 3 | 47 | 0 | 110 | 116 | 110 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (to) defined within the public class called public.The function start at line 110 and ends at 116. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [110.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _same_metadata | def _same_metadata(self: LinearActivationQuantizedTensor, src: LinearActivationQuantizedTensor):return (isinstance(self, LinearActivationQuantizedTensor)and isinstance(src, LinearActivationQuantizedTensor)and self.shape == src.shapeand self.input_quant_func == src.input_quant_funcand self.quant_kwargs == src.quant_kwar... | 5 | 10 | 2 | 51 | 0 | 119 | 128 | 119 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_same_metadata) defined within the public class called public.The function start at line 119 and ends at 128. It contains 10 lines of code and it has a cyclomatic complexity of 5. It takes 2 parameters, represented as [119.0] 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.