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 | _linear_impl_2d_torchao | def _linear_impl_2d_torchao(input_tensor, weight_tensor):assert weight_tensor.intx_packing_format != IntxPackingFormat.OPAQUE_ATEN_KLEIDIAIassert input_tensor.dim() == 2assert weight_tensor.dim() == 2assert weight_tensor.block_size[0] == 1group_size = weight_tensor.block_size[1]m, k = input_tensor.shapen, k_ = weight_t... | 3 | 23 | 2 | 141 | 5 | 269 | 295 | 269 | null | ['res', 'group_size', 'packed_weights', 'bit_width', 'input_tensor'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_linear_impl_2d_torchao) defined within the public class called public.The function start at line 269 and ends at 295. It contains 23 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [269.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 weight_tensor.intx_packing_format == IntxPackingFormat.OPAQUE_ATEN_KLEIDIAI:_impl_2d = _linear_impl_2d_atenelse:_impl_2d = _linear_impl_2d_torchao# TODO: why was this added https://github.com/pyt... | 7 | 31 | 4 | 230 | 5 | 299 | 335 | 299 | null | ['res', 'k', 'input_tensor', 'lead_shape', '_impl_2d'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_) defined within the public class called public.The function start at line 299 and ends at 335. It contains 31 lines of code and it has a cyclomatic complexity of 7. It takes 4 parameters, represented as [299.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _ | def _(func, types, args, kwargs):assert len(args) == 2indices, weight_tensor = (args[0],args[1],)assert isinstance(weight_tensor, IntxOpaqueTensor)assert weight_tensor.intx_packing_format == IntxPackingFormat.OPAQUE_TORCHAO_LOWBITpacked_weights = weight_tensor.packed_weightsassert len(weight_tensor.block_size) == 2asse... | 1 | 23 | 4 | 139 | 5 | 339 | 364 | 339 | null | ['out', 'shape', 'group_size', 'packed_weights', 'bit_width'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_) defined within the public class called public.The function start at line 339 and ends at 364. It contains 23 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [339.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __new__ | def __new__(cls,qdata,scale,zero_point,target_dtype,block_size,dtype,activation_quantization,):kwargs = {}kwargs["device"] = qdata.devicekwargs["dtype"] = dtypekwargs["requires_grad"] = Falseshape = qdata.shapereturn torch.Tensor._make_wrapper_subclass(cls, shape, **kwargs)# type: ignore[attr-defined] | 1 | 16 | 8 | 63 | 0 | 82 | 97 | 82 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__new__) defined within the public class called public.The function start at line 82 and ends at 97. It contains 16 lines of code and it has a cyclomatic complexity of 1. It takes 8 parameters, represented as [82.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self,qdata,scale,zero_point,target_dtype,block_size,dtype,activation_quantization,):super().__init__()assert qdata.dtype == torch.int8, (f"qdata dtype must be int8, but got {qdata.dtype}")assert scale.dtype in _FLOAT_TYPES, (f"scale dtype must be one of {_FLOAT_TYPES}, but got {scale.dtype}")assert zero_po... | 4 | 43 | 8 | 207 | 0 | 99 | 148 | 99 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 99 and ends at 148. It contains 43 lines of code and it has a cyclomatic complexity of 4. It takes 8 parameters, represented as [99.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _quantization_type | def _quantization_type(self):return f"target_dtype={self.target_dtype}, block_size={self.block_size}, shape={self.shape}, dtype={self.dtype}, device={self.device}, activation_quantization={self.activation_quantization}" | 1 | 2 | 1 | 8 | 0 | 150 | 151 | 150 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_quantization_type) defined within the public class called public.The function start at line 150 and ends at 151. 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 | _has_float_zero_point | def _has_float_zero_point(self) -> bool:return self.zero_point.dtype in _FLOAT_TYPES | 1 | 2 | 1 | 15 | 0 | 153 | 154 | 153 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_has_float_zero_point) defined within the public class called public.The function start at line 153 and ends at 154. 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 | def to(self, *args, **kwargs):kwargs = self._get_to_kwargs(*args, **kwargs)device = kwargs.pop("device")dtype = kwargs.pop("dtype")assert dtype in _FLOAT_TYPESreturn IntxUnpackedToInt8Tensor(self.qdata.to(device),self.scale.to(device=device, dtype=dtype),self.zero_point.to(device=device, dtype=dtype)if self._has_float_... | 2 | 16 | 3 | 115 | 0 | 156 | 171 | 156 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (to) defined within the public class called public.The function start at line 156 and ends at 171. It contains 16 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [156.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | from_hp | def from_hp(cls,hp_tensor: torch.Tensor,block_size: Tuple[int],target_dtype: torch.dtype,*,mapping_type: MappingType = MappingType.SYMMETRIC,activation_quantization: Optional[IntxUnpackedToInt8TensorActivationQuantization] = None,intx_choose_qparams_algorithm: Optional[IntxChooseQParamsAlgorithm] = IntxChooseQParamsAlg... | 6 | 82 | 9 | 372 | 0 | 174 | 264 | 174 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (from_hp) defined within the public class called public.The function start at line 174 and ends at 264. It contains 82 lines of code and it has a cyclomatic complexity of 6. It takes 9 parameters, represented as [174.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | dequantize | def dequantize(self):qmin, qmax = _DTYPE_TO_QVALUE_BOUNDS[self.target_dtype]return dequantize_affine(self.qdata,self.block_size,self.scale,self.zero_point,torch.int8,qmin,qmax,output_dtype=self.dtype,) | 1 | 12 | 1 | 49 | 0 | 266 | 277 | 266 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (dequantize) defined within the public class called public.The function start at line 266 and ends at 277. It contains 12 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _apply_int8_act_asym_per_token_quant_dequant | def _apply_int8_act_asym_per_token_quant_dequant(hp_tensor):target_dtype = torch.int8mapping_type = MappingType.ASYMMETRICblock_size = _get_per_token_block_size(hp_tensor)qmin, qmax = _DTYPE_TO_QVALUE_BOUNDS[target_dtype]scale, zero_point = choose_qparams_affine(hp_tensor,mapping_type,block_size,target_dtype=target_dty... | 1 | 34 | 1 | 116 | 5 | 280 | 313 | 280 | null | ['dequantized_affine', 'block_size', 'qdata', 'target_dtype', 'mapping_type'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_apply_int8_act_asym_per_token_quant_dequant) defined within the public class called public.The function start at line 280 and ends at 313. It contains 34 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 | _ | def _(func, types, args, kwargs):input_tensor, weight_tensor, bias = (args[0],args[1],args[2] if len(args) > 2 else None,)assert isinstance(weight_tensor, IntxUnpackedToInt8Tensor)# Apply dynamic activation quantif weight_tensor.activation_quantization is not None:if (weight_tensor.activation_quantization== IntxUnpacke... | 4 | 19 | 4 | 105 | 2 | 320 | 341 | 320 | null | ['weight_tensor', 'input_tensor'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_) defined within the public class called public.The function start at line 320 and ends at 341. It contains 19 lines of code and it has a cyclomatic complexity of 4. It takes 4 parameters, represented as [320.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _ | def _(func, types, args, kwargs):assert len(args) == 2indices, weight_tensor = (args[0],args[1],)weight_tensor = weight_tensor.dequantize()return torch.nn.functional.embedding(indices, weight_tensor, **kwargs) | 1 | 8 | 4 | 57 | 1 | 345 | 352 | 345 | null | ['weight_tensor'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_) defined within the public class called public.The function start at line 345 and ends at 352. It contains 8 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [345.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _ | def _(func, types, args, kwargs):self, dim, start, end, step = fill_defaults(args, 5, [0, None, None, 1])assert step == 1# Slicing must be compatible with the block size to make sense on the quantized tensor# In particular both start and end must be a multiple of block_size[dim]# Otherwise the sliced tensor cannot be r... | 2 | 31 | 4 | 241 | 8 | 356 | 407 | 356 | null | ['new_block_size', 'n_blocks', 'zero_point', 'new', 'qdata', 'scale', 'start_scale', 'end_scale'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_) defined within the public class called public.The function start at line 356 and ends at 407. It contains 31 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [356.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | bsr_to_dense | def bsr_to_dense(crow_indices: torch.Tensor,col_indices: torch.Tensor,values: torch.Tensor,M: int,K: int,) -> torch.Tensor:return torch.sparse_bsr_tensor(crow_indices=crow_indices, col_indices=col_indices, values=values, size=(M, K)).to_dense() | 1 | 10 | 5 | 63 | 0 | 20 | 29 | 20 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (bsr_to_dense) defined within the public class called public.The function start at line 20 and ends at 29. It contains 10 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [20.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | bsr_to_dense_abstract | def bsr_to_dense_abstract(crow_indices: torch.Tensor,col_indices: torch.Tensor,values: torch.Tensor,M: int,K: int,) -> torch.Tensor:return torch.empty((M, K), dtype=values.dtype, device=values.device) | 1 | 8 | 5 | 57 | 0 | 33 | 40 | 33 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (bsr_to_dense_abstract) defined within the public class called public.The function start at line 33 and ends at 40. It contains 8 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [33.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | blocksparse_int_addmm | def blocksparse_int_addmm(crow_indices: torch.Tensor,col_indices: torch.Tensor,values: torch.Tensor,A: torch.Tensor,left_alpha: torch.Tensor,right_alpha: torch.Tensor,) -> torch.Tensor:assert values.dtype == torch.int8M = left_alpha.shape[-1]K = A.shape[-2]N = A.shape[-1]weight_bsr = torch.sparse_bsr_tensor(crow_indice... | 1 | 27 | 6 | 163 | 6 | 44 | 70 | 44 | null | ['out', 'weight_bsr', 'N', 'M', 'original_batch_dims_broadcasted', 'K'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (blocksparse_int_addmm) defined within the public class called public.The function start at line 44 and ends at 70. It contains 27 lines of code and it has a cyclomatic complexity of 1. It takes 6 parameters, represented as [44.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | blocksparse_int_addmm_abstract | def blocksparse_int_addmm_abstract(crow_indices: torch.Tensor,col_indices: torch.Tensor,values: torch.Tensor,A: torch.Tensor,left_alpha: torch.Tensor,right_alpha: torch.Tensor,) -> torch.Tensor:N = A.shape[-1]M = left_alpha.shape[-1]# to have the same strides as the transposed resultreturn torch.empty((M, N), dtype=tor... | 1 | 11 | 6 | 89 | 2 | 74 | 85 | 74 | null | ['M', 'N'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (blocksparse_int_addmm_abstract) defined within the public class called public.The function start at line 74 and ends at 85. It contains 11 lines of code and it has a cyclomatic complexity of 1. It takes 6 parameters, represented as [74.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | blocksparse_addmm | def blocksparse_addmm(x_padded: torch.Tensor,crow_indices: torch.Tensor,col_indices: torch.Tensor,values: torch.Tensor,M: int,K: int,bias: torch.Tensor,) -> torch.Tensor:assert bias is Nonebsr = torch.sparse_bsr_tensor(crow_indices, col_indices, values, size=(M, K))N_padded = x_padded.shape[1]out = x_padded.new_empty((... | 1 | 22 | 7 | 113 | 3 | 89 | 110 | 89 | null | ['bsr', 'out', 'N_padded'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (blocksparse_addmm) defined within the public class called public.The function start at line 89 and ends at 110. It contains 22 lines of code and it has a cyclomatic complexity of 1. It takes 7 parameters, represented as [89.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | blocksparse_addmm_abstract | def blocksparse_addmm_abstract(x_padded: torch.Tensor,crow_indices: torch.Tensor,col_indices: torch.Tensor,values: torch.Tensor,M: int,K: int,bias: torch.Tensor,) -> torch.Tensor:N_padded = x_padded.shape[1]return x_padded.new_empty((M, N_padded)) | 1 | 11 | 7 | 65 | 1 | 114 | 124 | 114 | null | ['N_padded'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (blocksparse_addmm_abstract) defined within the public class called public.The function start at line 114 and ends at 124. It contains 11 lines of code and it has a cyclomatic complexity of 1. It takes 7 parameters, represented as [114.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __new__ | def __new__(# noqa: PYI034cls,shape: torch.Size,blocksize: int,bsr_crow_indices: Optional[torch.Tensor],bsr_col_indices: Optional[torch.Tensor],bsr_values: Optional[torch.Tensor],requires_grad: bool = False,):if bsr_values is None:raise ValueError("No values passed to BlockSparseTensor: bsr_values must be provided!")el... | 2 | 27 | 7 | 127 | 0 | 137 | 164 | 137 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__new__) defined within the public class called public.The function start at line 137 and ends at 164. It contains 27 lines of code and it has a cyclomatic complexity of 2. It takes 7 parameters, represented as [137.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __repr__ | def __repr__(self) -> str:# type: ignore[override]assert hasattr(self, "shape")return f"{self.__class__.__name__}(shape={self.shape})" | 1 | 3 | 1 | 17 | 0 | 166 | 168 | 166 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__repr__) defined within the public class called public.The function start at line 166 and ends at 168. 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 | __tensor_flatten__ | def __tensor_flatten__(self) -> Tuple[List[str], Tuple[torch.Size, bool, int]]:inner_tensors = list(filter(lambda x: getattr(self, x) is not None, self.__slots__))tensor_meta = (self.shape, self.requires_grad, self.blocksize)return inner_tensors, tensor_meta | 1 | 6 | 1 | 67 | 0 | 170 | 175 | 170 | 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 170 and ends at 175. 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 | __tensor_unflatten__ | def __tensor_unflatten__(cls,inner_tensors,tensor_meta: Tuple[torch.Size, bool, int],outer_size,outer_stride,) -> torch.Tensor:shape, requires_grad, blocksize = tensor_meta# print("unflatten", outer_size, outer_stride)return cls(shape=shape,blocksize=blocksize,bsr_crow_indices=inner_tensors.get("bsr_crow_indices", None... | 1 | 16 | 5 | 85 | 0 | 178 | 194 | 178 | 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 178 and ends at 194. It contains 16 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [178.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | from_dense | def from_dense(cls, dense_tensor, blocksize):bsr_tensor = dense_tensor.to_sparse_bsr(blocksize)# bsr_tensor_t = dense_tensor.t().contiguous().to_sparse_bsr(blocksize)return cls(shape=dense_tensor.shape,blocksize=blocksize,bsr_crow_indices=bsr_tensor.crow_indices(),bsr_col_indices=bsr_tensor.col_indices(),bsr_values=bsr... | 1 | 10 | 3 | 59 | 0 | 197 | 207 | 197 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (from_dense) defined within the public class called public.The function start at line 197 and ends at 207. It contains 10 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [197.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | apply_fn_to_shard | def apply_fn_to_shard(self, func):return BlockSparseTensor(shape=self.shape,blocksize=self.blocksize,bsr_crow_indices=func(self.bsr_crow_indices),bsr_col_indices=func(self.bsr_col_indices),bsr_values=func(self.bsr_values),requires_grad=self.requires_grad,) | 1 | 9 | 2 | 56 | 0 | 209 | 217 | 209 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (apply_fn_to_shard) defined within the public class called public.The function start at line 209 and ends at 217. It contains 9 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [209.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | block_sparse_detach | def block_sparse_detach(func, types, args, kwargs):return return_and_correct_aliasing(func, args, kwargs, args[0].apply_fn_to_shard(torch.detach)) | 1 | 4 | 4 | 32 | 0 | 225 | 228 | 225 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (block_sparse_detach) defined within the public class called public.The function start at line 225 and ends at 228. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [225.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | block_sparse_unsqueeze | def block_sparse_unsqueeze(func, types, args, kwargs):assert len(args) == 2assert len(kwargs) == 0assert args[-1] == 2bsr = args[0]assert bsr.dim() == 2assert not bsr.requires_gradreturn BlockSparseTensor(bsr.shape + (1,),bsr.blocksize,bsr.crow_indices(),bsr.col_indices(),bsr.values().unsqueeze(-1),requires_grad=False,... | 1 | 15 | 4 | 97 | 1 | 232 | 246 | 232 | null | ['bsr'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (block_sparse_unsqueeze) defined within the public class called public.The function start at line 232 and ends at 246. It contains 15 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [232.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | block_sparse_mul.my_mul | def my_mul(bsr, t):assert isinstance(bsr, BlockSparseTensor)assert isinstance(t, torch.Tensor)assert bsr.dim() == 3assert t.dim() == 3assert not bsr.requires_gradassert t.size(0) == 1t_blocked = t.view(t.size(0), t.size(1) // bsr.blocksize, bsr.blocksize, 1)masked_t = t_blocked.transpose(0, 1).index_select(0, bsr.col_i... | 1 | 13 | 2 | 128 | 0 | 255 | 267 | 255 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (block_sparse_mul.my_mul) defined within the public class called public.The function start at line 255 and ends at 267. It contains 13 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [255.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | block_sparse_mul | def block_sparse_mul(func, types, args, kwargs):assert len(args) == 2assert len(kwargs) == 0bsr, t = argsdef my_mul(bsr, t):assert isinstance(bsr, BlockSparseTensor)assert isinstance(t, torch.Tensor)assert bsr.dim() == 3assert t.dim() == 3assert not bsr.requires_gradassert t.size(0) == 1t_blocked = t.view(t.size(0), t.... | 3 | 8 | 4 | 63 | 3 | 250 | 271 | 250 | null | ['t_blocked', 'masked_t', 'new_values'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (block_sparse_mul) defined within the public class called public.The function start at line 250 and ends at 271. It contains 8 lines of code and it has a cyclomatic complexity of 3. It takes 4 parameters, represented as [250.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | block_sparse_sum | def block_sparse_sum(func, types, args, kwargs):bsr, dim = argsassert type(dim) == listassert len(dim) == 1dim = dim[0]assert dim == 1return torch.ops.blocksparse.sum(bsr.values(), bsr.crow_indices(), bsr.shape[0]) | 1 | 7 | 4 | 68 | 1 | 275 | 281 | 275 | null | ['dim'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (block_sparse_sum) defined within the public class called public.The function start at line 275 and ends at 281. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [275.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | block_sparse_values | def block_sparse_values(func, types, args, kwargs):return args[0].bsr_values.detach() | 1 | 2 | 4 | 22 | 0 | 285 | 286 | 285 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (block_sparse_values) defined within the public class called public.The function start at line 285 and ends at 286. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [285.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | block_sparse_crow_indices | def block_sparse_crow_indices(func, types, args, kwargs):return args[0].bsr_crow_indices.detach() | 1 | 2 | 4 | 22 | 0 | 290 | 291 | 290 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (block_sparse_crow_indices) defined within the public class called public.The function start at line 290 and ends at 291. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [290.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | block_sparse_col_indices | def block_sparse_col_indices(func, types, args, kwargs):return args[0].bsr_col_indices.detach() | 1 | 2 | 4 | 22 | 0 | 295 | 296 | 295 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (block_sparse_col_indices) defined within the public class called public.The function start at line 295 and ends at 296. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [295.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | block_sparse__nnz | def block_sparse__nnz(func, types, args, kwargs):return args[0].bsr_values.shape[0] | 1 | 2 | 4 | 23 | 0 | 300 | 301 | 300 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (block_sparse__nnz) 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 4 parameters, represented as [300.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | block_sparse_linear | def block_sparse_linear(func, types, args, kwargs):x_orig, w, bias = argsx = x_orig.reshape(-1, x_orig.size(-1)).t()M = w.shape[0]K = w.shape[1]out = torch.ops.blocksparse.addmm(x,w.crow_indices(),w.col_indices(),w.values(),M,K,None,)out_orig = out.t()if bias is None:return out_origreturn out_orig + bias | 2 | 18 | 4 | 110 | 5 | 305 | 324 | 305 | null | ['out', 'out_orig', 'x', 'M', 'K'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (block_sparse_linear) defined within the public class called public.The function start at line 305 and ends at 324. It contains 18 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [305.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | apply_fake_sparsity | def apply_fake_sparsity(model, **kwargs):"""This function simulates 2:4 sparsity on all linear layers in a model."""filter_fn = kwargs.pop("filter_fn", _is_linear)# torch.ao.pruning flowsparse_config = []for name, mod in model.named_modules():if filter_fn(mod, name):sparse_config.append({"tensor_fqn": f"{name}.weight"}... | 3 | 12 | 2 | 93 | 3 | 30 | 46 | 30 | null | ['sparse_config', 'sparsifier', 'filter_fn'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (apply_fake_sparsity) defined within the public class called public.The function start at line 30 and ends at 46. It contains 12 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [30.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __post_init__ | def __post_init__(self):torch._C._log_api_usage_once("torchao.sparsity.BlockSparseWeightConfig") | 1 | 2 | 1 | 13 | 0 | 53 | 54 | 53 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__post_init__) defined within the public class called public.The function start at line 53 and ends at 54. It contains 2 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _block_sparse_weight_transform | def _block_sparse_weight_transform(module: torch.nn.Module,config: BlockSparseWeightConfig,):blocksize = config.blocksizenew_weight = BlockSparseTensor.from_dense(module.weight, blocksize)module.weight = torch.nn.Parameter(new_weight, requires_grad=False)module.extra_repr = types.MethodType(_linear_extra_repr, module)r... | 1 | 9 | 2 | 63 | 2 | 62 | 70 | 62 | null | ['blocksize', 'new_weight'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_block_sparse_weight_transform) defined within the public class called public.The function start at line 62 and ends at 70. It contains 9 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [62.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __post_init__ | def __post_init__(self):torch._C._log_api_usage_once("torchao.sparsity.BlockSparseWeightConfig") | 1 | 2 | 1 | 13 | 0 | 78 | 79 | 53 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__post_init__) defined within the public class called public.The function start at line 78 and ends at 79. 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 | _semi_sparse_weight_transform | def _semi_sparse_weight_transform(module: torch.nn.Module,config: SemiSparseWeightConfig,) -> torch.nn.Module:new_weight = to_sparse_semi_structured(module.weight)module.weight = torch.nn.Parameter(new_weight, requires_grad=False)module.extra_repr = types.MethodType(_linear_extra_repr, module)return module | 1 | 8 | 2 | 60 | 1 | 87 | 94 | 87 | null | ['new_weight'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_semi_sparse_weight_transform) defined within the public class called public.The function start at line 87 and ends at 94. It contains 8 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [87.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | sparsify_ | def sparsify_(model: torch.nn.Module,config: AOBaseConfig,filter_fn: Optional[Callable[[torch.nn.Module, str], bool]] = None,) -> torch.nn.Module:"""Convert the weight of linear modules in the model with `apply_tensor_subclass`.This function is essentially the same as quantize, put for sparsity subclasses.Currently, we... | 2 | 13 | 4 | 84 | 1 | 97 | 141 | 97 | null | ['handler'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (sparsify_) defined within the public class called public.The function start at line 97 and ends at 141. It contains 13 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [97.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | percentile | def percentile(t, q):"""Return the value that is larger than q% of t"""k = 1 + round(0.01 * float(q) * (t.numel() - 1))return t.view(-1).kthvalue(k).values | 1 | 3 | 2 | 48 | 1 | 13 | 16 | 13 | null | ['k'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (percentile) defined within the public class called public.The function start at line 13 and ends at 16. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [13.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | forward | def forward(ctx, scores, zeros, ones, sparsity):clamped_scores = scores.clamp(min=SCORES_MIN, max=SCORES_MAX)k_val = percentile(clamped_scores, sparsity * 100)return torch.where(clamped_scores < k_val, zeros.to(scores.device), ones.to(scores.device)) | 1 | 6 | 5 | 64 | 0 | 23 | 28 | 23 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (forward) defined within the public class called public.The function start at line 23 and ends at 28. It contains 6 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [23.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | backward | def backward(ctx, g):return g, None, None, None | 1 | 2 | 2 | 15 | 0 | 31 | 32 | 31 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (backward) defined within the public class called public.The function start at line 31 and ends at 32. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [31.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | forward | def forward(ctx, weight, scores):return weight * scores | 1 | 2 | 3 | 13 | 0 | 39 | 40 | 39 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (forward) defined within the public class called public.The function start at line 39 and ends at 40. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [39.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | backward | def backward(ctx, grad_output):grad_weight = grad_scores = Noneif ctx.needs_input_grad[0]:grad_weight = grad_outputif ctx.needs_input_grad[1]:grad_scores = grad_outputreturn grad_weight, grad_scores | 3 | 7 | 2 | 38 | 0 | 43 | 49 | 43 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (backward) defined within the public class called public.The function start at line 43 and ends at 49. It contains 7 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [43.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self, sparsity_level, blocksize, fixed_mask, fixed_weight, *args, **kwargs):super(SupermaskLinear, self).__init__(*args, **kwargs)# calculate the maximum sparsity given blocksize for the layermax_sparsity_level = 1 - (1 / math.prod([math.ceil(k / blocksize) for k in self.weight.size()]))self.sparsity_level... | 4 | 24 | 7 | 178 | 0 | 55 | 82 | 55 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 55 and ends at 82. It contains 24 lines of code and it has a cyclomatic complexity of 4. It takes 7 parameters, represented as [55.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_mask | def get_mask(self):subnet = GetSubnet.apply(self.scores,torch.zeros_like(self.scores),torch.ones_like(self.scores),self.sparsity_level,)if self.blocksize != 1:for i, k in enumerate(self.weight.shape):subnet = subnet.repeat_interleave(self.blocksize, dim=i)subnet = torch.narrow(subnet, i, 0, k)return subnet | 3 | 12 | 1 | 89 | 0 | 84 | 97 | 84 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_mask) defined within the public class called public.The function start at line 84 and ends at 97. It contains 12 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 | forward | def forward(self, x):subnet = self.get_mask()w = ApplyMask.apply(self.weight, subnet)return F.linear(x, w, self.bias) | 1 | 4 | 2 | 39 | 0 | 99 | 102 | 99 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (forward) defined within the public class called public.The function start at line 99 and ends at 102. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [99.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | from_linear | def from_linear(cls,linear,sparsity_level=0.0,blocksize=1,):"""Main entrypoint for creating a SupermaskLinear from a Linear layer."""assert isinstance(linear, torch.nn.Linear)supermask_linear = SupermaskLinear(sparsity_level,blocksize,False,False,linear.in_features,linear.out_features,bias=linear.bias is not None,).to(... | 2 | 20 | 4 | 117 | 0 | 105 | 128 | 105 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (from_linear) defined within the public class called public.The function start at line 105 and ends at 128. It contains 20 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [105.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | to_linear | def to_linear(cls, supermask_linear):"""Convert a SupermaskLinear to a Linear layer.Replaces the old sparsify_offline() function."""self = supermask_linearlinear = torch.nn.Linear(self.in_features,self.out_features,bias=self.bias is not None,).to(device=self.weight.device, dtype=self.weight.dtype)mask = self.get_mask()... | 2 | 12 | 2 | 101 | 0 | 131 | 148 | 131 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (to_linear) defined within the public class called public.The function start at line 131 and ends at 148. It contains 12 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [131.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | create_block_sparse_tensor | def create_block_sparse_tensor(M, N, blocksize, sparsity, dtype):assert sparsity <= 1.0 and sparsity >= 0.0, ("sparsity should be a value between 0 and 1")A = torch.bernoulli(torch.full((M // blocksize, N // blocksize), 1 - sparsity, dtype=dtype))A = torch.repeat_interleave(A, blocksize, dim=0)A = torch.repeat_interlea... | 2 | 10 | 5 | 86 | 1 | 17 | 26 | 17 | null | ['A'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (create_block_sparse_tensor) defined within the public class called public.The function start at line 17 and ends at 26. It contains 10 lines of code and it has a cyclomatic complexity of 2. It takes 5 parameters, represented as [17.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | create_semi_structured_tensor | def create_semi_structured_tensor(r, c, dtype):"""This function returns a 1:2 sparse matrix of size (r, c).Note that this means this matrix will also be 2:4 and 4:8 sparse as well."""# Choices are [0, 1] and [1, 0] - this is practically one-hot# encoding for two classes, so for better performance the mask is# built as ... | 1 | 10 | 3 | 88 | 3 | 29 | 47 | 29 | null | ['mask', 'sparse_weight', 'choice_indices'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (create_semi_structured_tensor) defined within the public class called public.The function start at line 29 and ends at 47. It contains 10 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [29.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self, **kwargs) -> None:# init with fixed qparams for quantization flowsuper().__init__(dtype=torch.quint8,qscheme=torch.per_channel_affine,reduce_range=False,quant_min=None,quant_max=None,eps=torch.finfo(torch.float32).eps,**kwargs,)# set averaging constant so quantization flow knows observer is memoryles... | 1 | 12 | 2 | 78 | 0 | 56 | 69 | 56 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 56 and ends at 69. It contains 12 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [56.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | forward | def forward(self, x_orig):if x_orig.numel() == 0:return x_origx = x_orig.detach()# avoid keeping autograd tape# channel_ax is always the last dimensionnew_axis_list = [i for i in range(x.dim())]# noqa: C416new_axis_list[0], new_axis_list[-1] = new_axis_list[-1], new_axis_list[0]y = x.permute(new_axis_list)y = torch.fla... | 4 | 15 | 2 | 136 | 0 | 73 | 91 | 73 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (forward) defined within the public class called public.The function start at line 73 and ends at 91. It contains 15 lines of code and it has a cyclomatic complexity of 4. It takes 2 parameters, represented as [73.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | calculate_qparams | def calculate_qparams(self):raise NotImplementedError("PerChannelNormObserver is designed to store activations only. ") | 1 | 4 | 1 | 10 | 0 | 95 | 98 | 95 | 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 95 and ends at 98. 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 | mask_creator | def mask_creator(tensor: torch.Tensor,N: int = 2,M: int = 4,) -> torch.Tensor:"""Class for creating N:M sparsity masks.Masks will be created using the N:M ratio, where for every block ofM weights, N will be pruned based on ranked weight value. Each maskwill correspond to the given tensor.:param tensor: The input tensor... | 2 | 16 | 3 | 139 | 5 | 101 | 132 | 101 | null | ['w_b', 'index', 'mask', 'tensor_temp', 'num_groups'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (mask_creator) defined within the public class called public.The function start at line 101 and ends at 132. It contains 16 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [101.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self,sparsity_level: float = 0.5,semi_structured_block_size: Optional[int] = None,):defaults = {"sparsity_level": sparsity_level,"semi_structured_block_size": semi_structured_block_size,}if semi_structured_block_size is not None:m = semi_structured_block_sizewarnings.warn(f"WandaSparsifier got semi_structu... | 2 | 15 | 3 | 61 | 0 | 35 | 49 | 35 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 35 and ends at 49. It contains 15 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [35.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | prepare | def prepare(self, model: nn.Module, config: list[dict]) -> None:# activation: use PerChannelNormObserver# use no-op placeholder weight observerif config is None:# If no config is provided, apply the qconfig to the entire modelmodel.qconfig = QConfig(activation=PerChannelNormObserver, weight=default_placeholder_observer... | 5 | 19 | 3 | 125 | 0 | 51 | 78 | 51 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (prepare) defined within the public class called public.The function start at line 51 and ends at 78. It contains 19 lines of code and it has a cyclomatic complexity of 5. It takes 3 parameters, represented as [51.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | update_mask | def update_mask(# type: ignore[override]self, module: nn.Module, tensor_name: str, sparsity_level: float, **kwargs) -> None:r"""Pruning function for WandaSparsifierThe activation statistics is retrieved first in the `act_per_input` variable.Then the Wanda pruning metric is computed. The weight matrix is then prunedby c... | 2 | 18 | 5 | 163 | 0 | 80 | 116 | 80 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (update_mask) defined within the public class called public.The function start at line 80 and ends at 116. It contains 18 lines of code and it has a cyclomatic complexity of 2. It takes 5 parameters, represented as [80.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | squash_mask | def squash_mask(self,params_to_keep: Optional[tuple[str, ...]] = None,params_to_keep_per_layer: Optional[dict[str, tuple[str, ...]]] = None,*args,**kwargs,):# remove quantization configfor config in self.groups:module = config["module"]_remove_qconfig(module)# remove parameterizationssuper().squash_mask(params_to_keep=... | 2 | 14 | 5 | 77 | 0 | 118 | 134 | 118 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (squash_mask) defined within the public class called public.The function start at line 118 and ends at 134. It contains 14 lines of code and it has a cyclomatic complexity of 2. It takes 5 parameters, represented as [118.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | inject_24 | def inject_24(w: torch.Tensor, size_k: int, size_n: int) -> Tuple[torch.Tensor, torch.Tensor]:"""Injects 2:4 sparsity into a weight tensor. The sparsity is applied in a 2:4 ratio, where for everygroup of 4 weights, 2 will be pruned based on their value. The mask will be created based on theranked weight values.Args:w (... | 1 | 6 | 3 | 77 | 1 | 17 | 33 | 17 | null | ['mask'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (inject_24) defined within the public class called public.The function start at line 17 and ends at 33. It contains 6 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [17.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | marlin_24_workspace | def marlin_24_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 2:4 quantization. The workspace is used to coordinate the locksduring the execution of the kernel.Args:out_features (int): The number of output feat... | 1 | 10 | 3 | 62 | 1 | 36 | 55 | 36 | null | ['max_workspace_size'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (marlin_24_workspace) defined within the public class called public.The function start at line 36 and ends at 55. It contains 10 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [36.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | pack_to_marlin_24 | def pack_to_marlin_24(q_w_24: torch.Tensor,scales: torch.Tensor,num_bits: int,group_size: int,) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:"""Packs the quantized weights and scales into the marlin 2:4 format.Args:q_w_24 (torch.Tensor): The quantized weight tensor with 2:4 sparsity applied.scales (torch.Tensor):... | 1 | 18 | 4 | 97 | 3 | 58 | 92 | 58 | null | ['marlin_24_s', 'marlin_24_q_w_comp', 'in_features_comp'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (pack_to_marlin_24) defined within the public class called public.The function start at line 58 and ends at 92. It contains 18 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [58.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | unpack_from_marlin_24 | def unpack_from_marlin_24(q_w_24_comp: torch.Tensor,scales: torch.Tensor,meta: torch.Tensor,original_shape: torch.Size,group_size: int,num_bits: int,) -> Tuple[torch.Tensor, torch.Tensor]:"""Unpacks the quantized weights and scales from the marlin 2:4 format.Args:q_w_24_comp (torch.Tensor): The packed quantized weights... | 1 | 18 | 6 | 100 | 4 | 95 | 131 | 95 | null | ['unpacked_q_w_24', 'unpacked_q_w_24_comp', 'unpacked_scales', 'in_features_comp'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (unpack_from_marlin_24) defined within the public class called public.The function start at line 95 and ends at 131. It contains 18 lines of code and it has a cyclomatic complexity of 1. It takes 6 parameters, represented as [95.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _compress_quantized_24_weight | def _compress_quantized_24_weight(q_24: torch.Tensor, size_k: int, size_n: int, num_bits: int) -> Tuple[torch.Tensor, torch.Tensor]:"""Compresses the quantized weights to a 2:4 sparse format. Normalizes the weights over 0before compressing them.Args:q_24 (torch.Tensor): The quantized weight tensor.size_k (int): The num... | 1 | 13 | 4 | 120 | 6 | 134 | 166 | 134 | null | ['max_q_val', 'zp', 'q_24_no_zp', 'q_24_comp', 'meta', 'q_24_no_zp_comp'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_compress_quantized_24_weight) defined within the public class called public.The function start at line 134 and ends at 166. It contains 13 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [134.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _decompress_quantized_24_weight | def _decompress_quantized_24_weight(q_24_comp: torch.Tensor, meta: torch.Tensor, size_k: int, size_n: int, num_bits: int) -> torch.Tensor:"""Decompresses the quantized weights from a 2:4 sparse format and restores the original shape.Args:q_24_comp (torch.Tensor): The compressed quantized weight tensor in 2:4 sparse for... | 1 | 14 | 5 | 130 | 6 | 169 | 204 | 169 | null | ['max_q_val', 'zp', 'q_24_no_zp', 'q_24', 'meta', 'q_24_no_zp_comp'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_decompress_quantized_24_weight) defined within the public class called public.The function start at line 169 and ends at 204. It contains 14 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [169.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,) -> torch.Tensor:"""Converts a quantized and 2:4 sparse format weight tensor to the marlin 2:4 format.Args:q_w (torch.Tensor): The quantized weight tensor in 2:4 sparse format.size_k (int): The number of input features.size_n (int): The num... | 2 | 19 | 4 | 144 | 3 | 207 | 242 | 207 | null | ['q_w', 'q_packed', 'pack_factor'] | 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 207 and ends at 242. It contains 19 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [207.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _from_marlin_weights | def _from_marlin_weights(q_packed: torch.Tensor, size_k: int, size_n: int, num_bits: int) -> torch.Tensor:"""Converts a weight tensor in the marlin 2:4 format to a regular quantized 2:4 sparse format.Args:q_packed (torch.Tensor): The weight tensor in the marlin 2:4 format.size_k (int): The number of input features.size... | 2 | 20 | 4 | 159 | 4 | 245 | 281 | 245 | null | ['q_w_unpacked', 'q_packed', 'q_w_comp', 'pack_factor'] | 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 245 and ends at 281. It contains 20 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [245.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _to_marlin_scales | def _to_marlin_scales(scales: torch.Tensor, size_k: int, size_n: int, group_size: int, num_bits: int) -> torch.Tensor:"""Converts a scale tensor to the format necessary for marlin.Args:scales (torch.Tensor): The scale tensor.size_k (int): The number of input features.size_n (int): The number of output features.group_si... | 3 | 12 | 5 | 115 | 1 | 284 | 306 | 284 | null | ['scales'] | 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 284 and ends at 306. It contains 12 lines of code and it has a cyclomatic complexity of 3. It takes 5 parameters, represented as [284.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _from_marlin_scale | def _from_marlin_scale(scales: torch.Tensor, size_k: int, size_n: int, group_size: int, num_bits: int) -> torch.Tensor:"""Converts a scale tensor from the marlin format to their original format.Args:scales (torch.Tensor): The scale tensor in the marlin format.size_k (int): The number of input features.size_n (int): The... | 3 | 12 | 5 | 116 | 1 | 309 | 331 | 309 | null | ['scales'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_from_marlin_scale) defined within the public class called public.The function start at line 309 and ends at 331. It contains 12 lines of code and it has a cyclomatic complexity of 3. It takes 5 parameters, represented as [309.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 num_bits in const.SUPPORTED_NUM_BITS, f"Unsupported num_bits = {num_bits}"return 32 // num_bits | 1 | 3 | 1 | 22 | 0 | 26 | 36 | 26 | 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 26 and ends at 36. 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 | 39 | 69 | 39 | 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 39 and ends at 69. It contains 15 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [39.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 | 72 | 105 | 72 | 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 72 and ends at 105. It contains 20 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [72.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_perms_24 | def get_perms_24(num_bits: int) -> Tuple[torch.Tensor, List[int], List[int]]:"""Precompute permutations for Marlin24 weight and scale shufflingMarlin works on [16*2,64] tiles. The goal of the permutations is to reorder the weight data so that it is compatiblewith the tensor-core format that is described here:https://do... | 12 | 31 | 1 | 379 | 4 | 108 | 161 | 108 | null | ['col_o', 'interleave', 'col', 'perm'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_perms_24) defined within the public class called public.The function start at line 108 and ends at 161. It contains 31 lines of code and it has a cyclomatic complexity of 12. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_reverse_perms_24 | def get_reverse_perms_24(num_bits: int,) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:"""Reverse permutation for Marlin24 weight and scale shuffling from `get_perms_24`.Args:num_bits (int): Number of bits to pack.Returns:Tuple[torch.Tensor, torch.Tensor, torch.Tensor]: The reversed weight permutation tensor, scal... | 1 | 8 | 1 | 71 | 3 | 164 | 181 | 164 | null | ['scale_perm_single', 'scale_perm', 'perm'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_reverse_perms_24) defined within the public class called public.The function start at line 164 and ends at 181. 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 | _calculate_meta_reordering_scatter_offsets | def _calculate_meta_reordering_scatter_offsets(m, meta_ncols, meta_dtype, device):dst_rows = torch.arange(0, m, device=device)[:, None].repeat(1, meta_ncols)dst_cols = torch.arange(0, meta_ncols, device=device).repeat(m, 1)# Reorder the rows, then swizzle the 2x2 blocks.group_x = 64group_y = 32 if meta_dtype.itemsize =... | 2 | 20 | 4 | 206 | 9 | 197 | 224 | 197 | null | ['group_y', 'interleave', 'dst_cols', 'cols_min', 'dst_rows', 'group_x', 'topright', 'cols_maj', 'bottomleft'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_calculate_meta_reordering_scatter_offsets) defined within the public class called public.The function start at line 197 and ends at 224. It contains 20 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [197.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | sparse_semi_structured_from_dense_cutlass | def sparse_semi_structured_from_dense_cutlass(dense):if dense.dim() != 2:raise RuntimeError(f"Expected 2-dimensional dense tensor, got {dense.dim()}-dimensional tensor"# noqa: E501)m, k = dense.shapedevice = dense.devicemeta_dtype = torch.int8if dense.dtype == torch.int8:meta_dtype = torch.int32elif dense.dtype in [tor... | 13 | 81 | 1 | 658 | 24 | 230 | 355 | 230 | null | ['expr1', 'bit2', 'meta_n', 'dense_4', 'meta_ncols', 'meta_dtype', 'meta', 'bit3', 'meta_reordered', 'device', 'idxs1', 'quadbits_per_meta_elem', 'bit0', 'expr0', 'sparse', 'meta_offsets', 'ksparse', 'sparse1', 'dense_2', 'sparse0', 'idxs0', 'meta_4', 'expr2', 'bit1'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (sparse_semi_structured_from_dense_cutlass) defined within the public class called public.The function start at line 230 and ends at 355. It contains 81 lines of code and it has a cyclomatic complexity of 13. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | sparse_semi_structured_to_dense_cutlass | def sparse_semi_structured_to_dense_cutlass(sparse, meta_reordered):if sparse.dim() != 2:raise RuntimeError(f"Expected 2-dimensional sparse tensor, got {sparse.dim()}-dimensional tensor"# noqa: E501)m, k = sparse.shapedevice = sparse.deviceif meta_reordered.dim() != 2:raise RuntimeError(f"Expected 2-dimensional meta te... | 11 | 76 | 2 | 752 | 9 | 362 | 456 | 362 | null | ['meta_2', 'meta_offsets', 'device', 'quadbits_per_meta_elem', 'ksparse', 'dense', 'meta_dtype', 'dense_offsets', 'meta'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (sparse_semi_structured_to_dense_cutlass) defined within the public class called public.The function start at line 362 and ends at 456. It contains 76 lines of code and it has a cyclomatic complexity of 11. It takes 2 parameters, represented as [362.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | forward | def forward(self, x):sparse_weight = semi_structured_sparsify(self.weight, backend="cusparselt")return torch.nn.functional.linear(x, sparse_weight, self.bias) | 1 | 3 | 2 | 36 | 0 | 30 | 32 | 30 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (forward) defined within the public class called public.The function start at line 30 and ends at 32. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [30.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | from_dense | def from_dense(cls, linear):mod = cls(linear.in_features, linear.out_features)mod.weight = linear.weightmod.bias = linear.biasreturn mod | 1 | 5 | 2 | 35 | 0 | 35 | 39 | 35 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (from_dense) defined within the public class called public.The function start at line 35 and ends at 39. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [35.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | to_dense | def to_dense(cls, semi_sparse_linear):mod = torch.nn.Linear(semi_sparse_linear.in_features, semi_sparse_linear.out_features)mod.weight = semi_sparse_linear.weightmod.bias = semi_sparse_linear.biasreturn mod | 1 | 7 | 2 | 39 | 0 | 42 | 48 | 42 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (to_dense) defined within the public class called public.The function start at line 42 and ends at 48. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [42.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | forward | def forward(self, x):sparse_weight = semi_structured_sparsify(self.weight, backend="cusparselt")return torch.nn.functional.linear(x, sparse_weight, self.bias) | 1 | 3 | 2 | 36 | 0 | 56 | 58 | 30 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (forward) defined within the public class called public.The function start at line 56 and ends at 58. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [30.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | from_dense | def from_dense(cls, linear):mod = cls(linear.in_features, linear.out_features)mod.weight = linear.weightmod.bias = linear.biasreturn mod | 1 | 5 | 2 | 35 | 0 | 61 | 65 | 35 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (from_dense) defined within the public class called public.The function start at line 61 and ends at 65. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [35.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | to_dense | def to_dense(cls, semi_sparse_linear):mod = torch.nn.Linear(semi_sparse_linear.in_features, semi_sparse_linear.out_features)mod.weight = semi_sparse_linear.weightmod.bias = semi_sparse_linear.biasreturn mod | 1 | 7 | 2 | 39 | 0 | 68 | 74 | 42 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (to_dense) defined within the public class called public.The function start at line 68 and ends at 74. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [42.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | swap_linear_with_semi_sparse_linear | def swap_linear_with_semi_sparse_linear(model, config, current=""):"""Public API for replacing nn.Linear with SemiSparseLinear"""name_to_child = dict(model.named_children())for name, child in name_to_child.items():fqn = f"{current}.{name}" if current else nameif isinstance(child, torch.nn.Linear):if fqn in config:setat... | 5 | 10 | 3 | 88 | 2 | 77 | 89 | 77 | null | ['fqn', 'name_to_child'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (swap_linear_with_semi_sparse_linear) defined within the public class called public.The function start at line 77 and ends at 89. It contains 10 lines of code and it has a cyclomatic complexity of 5. It takes 3 parameters, represented as [77.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | swap_semi_sparse_linear_with_linear | def swap_semi_sparse_linear_with_linear(model, current=""):"""Public API for replacing instances of SemiSparseLinear/SemiSparseActivaitonLinear with nn.Linear"""name_to_child = dict(model.named_children())for name, child in name_to_child.items():fqn = f"{current}.{name}" if current else nameif isinstance(child, (SemiSp... | 4 | 9 | 2 | 76 | 2 | 92 | 103 | 92 | null | ['fqn', 'name_to_child'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (swap_semi_sparse_linear_with_linear) defined within the public class called public.The function start at line 92 and ends at 103. It contains 9 lines of code and it has a cyclomatic complexity of 4. It takes 2 parameters, represented as [92.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | forward | def forward(ctx, x: torch.Tensor, algo: str, backend: GRADIENT_TYPE):# type: ignore[override]use_cutlass = backend == "cutlass"if not isinstance(x, SparseSemiStructuredTensor):(packed, meta, packed_t, meta_t, bitmask) = (torch._sparse_semi_structured_tile(x, algorithm=algo, use_cutlass=use_cutlass))cls = (SparseSemiStr... | 3 | 26 | 4 | 118 | 0 | 24 | 50 | 24 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (forward) defined within the public class called public.The function start at line 24 and ends at 50. It contains 26 lines of code and it has a cyclomatic complexity of 3. It takes 4 parameters, represented as [24.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | backward | def backward(ctx, grad_out: torch.Tensor):# type: ignore[override]# We just return grad_out, since we just use STE - straight through estimationreturn grad_out, None, None | 1 | 2 | 2 | 17 | 0 | 53 | 55 | 53 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (backward) defined within the public class called public.The function start at line 53 and ends at 55. It contains 2 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 | forward | def forward(ctx,x: torch.Tensor,pattern: SparseSemiStructuredTensor,gradient=GRADIENT_TYPE.SPARSE,):# type: ignore[override]assert isinstance(pattern, SparseSemiStructuredTensor)if not isinstance(pattern, SparseSemiStructuredTensorCUTLASS):raise NotImplementedError("`sparsify_like(x, pattern)` is only implemented for C... | 3 | 31 | 4 | 130 | 0 | 60 | 95 | 60 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (forward) defined within the public class called public.The function start at line 60 and ends at 95. It contains 31 lines of code and it has a cyclomatic complexity of 3. It takes 4 parameters, represented as [60.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | backward | def backward(ctx, grad_out: torch.Tensor):# type: ignore[override]if ctx.gradient == GRADIENT_TYPE.STE or isinstance(grad_out, SparseSemiStructuredTensor):return grad_out, None, None, Noneassert not isinstance(grad_out, SparseSemiStructuredTensor)assert grad_out.dtype == ctx.dtypeif ctx.gradient == GRADIENT_TYPE.DENSE:... | 4 | 34 | 2 | 161 | 0 | 98 | 133 | 98 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (backward) defined within the public class called public.The function start at line 98 and ends at 133. It contains 34 lines of code and it has a cyclomatic complexity of 4. It takes 2 parameters, represented as [98.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | semi_structured_sparsify | def semi_structured_sparsify(x: torch.Tensor,algo: str = "",backend: str = "cutlass",) -> SparseSemiStructuredTensor:"""Sparsifies a dense tensor into a semi-structured tensor, according to the algo and backend passed."""return _SparsifyFunc.apply(x, algo, backend) | 1 | 6 | 3 | 36 | 0 | 137 | 145 | 137 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (semi_structured_sparsify) defined within the public class called public.The function start at line 137 and ends at 145. It contains 6 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [137.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | semi_structured_sparsify_like | def semi_structured_sparsify_like(x: torch.Tensor,pattern: SparseSemiStructuredTensor,gradient: GRADIENT_TYPE = GRADIENT_TYPE.SPARSE,) -> SparseSemiStructuredTensor:"""Sparsifies a dense tensor into a semi-structured tensor, using the mask of the provided pattern."""return _SparsifyLikeFunc.apply(x, pattern, gradient) | 1 | 6 | 3 | 36 | 0 | 149 | 157 | 149 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (semi_structured_sparsify_like) defined within the public class called public.The function start at line 149 and ends at 157. It contains 6 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [149.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _semi_sparse_pointwise_op.handle_arg | def handle_arg(i, tensor):if isinstance(tensor, torch.Tensor):# For pointwise ops, dense tensors will be sparsified to match the sparsity pattern of the reference tensor# if they are specified in `sparsify_like_args_list`.if not isinstance(tensor, SparseSemiStructuredTensor):if i in sparsify_like_args_list:tensor = sem... | 8 | 26 | 2 | 108 | 0 | 30 | 61 | 30 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_semi_sparse_pointwise_op.handle_arg) defined within the public class called public.The function start at line 30 and ends at 61. It contains 26 lines of code and it has a cyclomatic complexity of 8. It takes 2 parameters, represented as [30.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _semi_sparse_pointwise_op | def _semi_sparse_pointwise_op(func, types, args=(), kwargs=None, sparsify_like_args_list=()):"""adds pointwise op support for semi-structured tensors.Assumes that at least one of the arguments in arg is a SparseSemiStructuredTensor.The last instance of a SparseSemiStructuredTensor is used as the reference mask to spars... | 8 | 28 | 3 | 135 | 3 | 14 | 82 | 14 | null | ['args_updated', 'reference_sparse_tensor', 'tensor'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_semi_sparse_pointwise_op) defined within the public class called public.The function start at line 14 and ends at 82. It contains 28 lines of code and it has a cyclomatic complexity of 8. It takes 3 parameters, represented as [14.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | implements.decorator | def decorator(func):for op in aten_ops:SWIZZLE_OPS_TABLE[op] = funcreturn func | 2 | 4 | 1 | 18 | 0 | 20 | 23 | 20 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (implements.decorator) defined within the public class called public.The function start at line 20 and ends at 23. 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 | implements | def implements(aten_ops):"""Register aten ops to the swizzle op table"""def decorator(func):for op in aten_ops:SWIZZLE_OPS_TABLE[op] = funcreturn funcreturn decorator | 1 | 3 | 1 | 10 | 0 | 17 | 25 | 17 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (implements) defined within the public class called public.The function start at line 17 and ends at 25. 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 | swizzle_mm | def swizzle_mm(aten_op, args, kwargs=None):a = args[0]b = args[1]if (torch.is_floating_point(a)and torch.is_floating_point(b)and a.ndim == 2and b.ndim == 2):a_is_swizzled = Falseb_is_swizzled = Falseif isinstance(a, SwizzleTensor):a = a.as_tensor()a_is_swizzled = Trueif isinstance(b, SwizzleTensor):b = b.as_tensor()b_i... | 9 | 23 | 3 | 157 | 5 | 29 | 52 | 29 | null | ['b_is_swizzled', 'a', 'b', 'tensor_out', 'a_is_swizzled'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (swizzle_mm) defined within the public class called public.The function start at line 29 and ends at 52. It contains 23 lines of code and it has a cyclomatic complexity of 9. It takes 3 parameters, represented as [29.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | swizzle_bmm | def swizzle_bmm(aten_op, args, kwargs=None):a = args[0]b = args[1]a = a.unswizzle() if isinstance(a, SwizzleTensor) else ab = b.unswizzle() if isinstance(b, SwizzleTensor) else breturn aten_op(a, b, **kwargs) | 3 | 6 | 3 | 65 | 2 | 56 | 62 | 56 | null | ['b', 'a'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (swizzle_bmm) defined within the public class called public.The function start at line 56 and ends at 62. It contains 6 lines of code and it has a cyclomatic complexity of 3. It takes 3 parameters, represented as [56.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.