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 | swizzle_addmm | def swizzle_addmm(aten_op, args, kwargs=None):bias = args[0]a = args[1]b = args[2]a = a.unswizzle() if isinstance(a, SwizzleTensor) else ab = b.unswizzle() if isinstance(b, SwizzleTensor) else breturn aten_op(bias, a, b, args[3:], **kwargs) | 3 | 7 | 3 | 79 | 3 | 66 | 72 | 66 | null | ['b', 'a', 'bias'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (swizzle_addmm) defined within the public class called public.The function start at line 66 and ends at 72. It contains 7 lines of code and it has a cyclomatic complexity of 3. It takes 3 parameters, represented as [66.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | swizzle_scaled_mm | def swizzle_scaled_mm(aten_op, args, kwargs=None):a = args[0]b = args[1]scale_a = args[2]scale_b = args[3]bias = None if len(args) <= 4 else args[4]scale_result = None if len(args) <= 5 else args[5]out_dtype = None if len(args) <= 6 else args[6]a_is_swizzled = Falseb_is_swizzled = Falseif isinstance(a, SwizzleTensor):a... | 6 | 28 | 3 | 151 | 9 | 76 | 104 | 76 | null | ['scale_a', 'b_is_swizzled', 'bias', 'a', 'scale_b', 'b', 'scale_result', 'out_dtype', 'a_is_swizzled'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (swizzle_scaled_mm) defined within the public class called public.The function start at line 76 and ends at 104. It contains 28 lines of code and it has a cyclomatic complexity of 6. It takes 3 parameters, represented as [76.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | swizzle_permute | def swizzle_permute(aten_op, args, kwargs=None):tensor = args[0]dims = args[1]if len(dims) == 2 and dims[0] == 1 and dims[1] == 0:return tensor.shallow_transpose()return aten_op(tensor.unswizzle(), dims) | 4 | 6 | 3 | 62 | 2 | 108 | 113 | 108 | null | ['dims', 'tensor'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (swizzle_permute) defined within the public class called public.The function start at line 108 and ends at 113. It contains 6 lines of code and it has a cyclomatic complexity of 4. It takes 3 parameters, represented as [108.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | swizzle_numpy_T | def swizzle_numpy_T(aten_op, args, kwargs=None):tensor = args[0]return tensor.shallow_transpose() | 1 | 3 | 3 | 23 | 1 | 117 | 119 | 117 | null | ['tensor'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (swizzle_numpy_T) defined within the public class called public.The function start at line 117 and ends at 119. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [117.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _get_min_alignment | def _get_min_alignment(size: int, alignment_value: int) -> int:return (1 + ((size - 1) // alignment_value)) * alignment_value | 1 | 2 | 2 | 24 | 0 | 12 | 13 | 12 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_get_min_alignment) defined within the public class called public.The function start at line 12 and ends at 13. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [12.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __new__ | def __new__(cls,original: torch.Tensor,shallow: bool = False,):wrapper = torch.empty_like(original, device="meta")return torch.Tensor._make_subclass(cls, wrapper) | 1 | 7 | 3 | 41 | 0 | 24 | 30 | 24 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__new__) defined within the public class called public.The function start at line 24 and ends at 30. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [24.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self, original, shallow=False):if shallow:return# assert original.ndim == 2 or original.ndim == 3# (M, K) or (B, M, K)assert original.ndim == 2, "SwizzleTensor only supports ndim 2"assert original.itemsize == 1 or original.itemsize == 2kdiv = 32 if original.itemsize == 2 else 64lastdim = 8 if original.item... | 9 | 33 | 3 | 264 | 0 | 32 | 65 | 32 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 32 and ends at 65. It contains 33 lines of code and it has a cyclomatic complexity of 9. It takes 3 parameters, represented as [32.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __repr__ | def __repr__(self):return f"{self.__class__.__name__}(original={self.unswizzle()})" | 1 | 2 | 1 | 8 | 0 | 67 | 68 | 67 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__repr__) 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 | unswizzle | def unswizzle(self):undone = Noneif self.original_ndim == 2:undone = self.x.permute(0, 3, 1, 2, 4).contiguous()undone = undone.reshape(self.alignedM, self.alignedK)undone = undone[0 : self.M, 0 : self.K]undone = undone.reshape(self.M, self.K)if self.is_transposed:undone = undone.Tif self.original_ndim == 3:undone = sel... | 4 | 15 | 1 | 182 | 0 | 70 | 84 | 70 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (unswizzle) defined within the public class called public.The function start at line 70 and ends at 84. It contains 15 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 | as_tensor | def as_tensor(self):# note the transpose because this causes col major hipblaslt op to be TNif self.original_ndim == 2:tmp = self.x.reshape(self.alignedM, self.alignedK)if self.is_transposed:tmp = tmp.Treturn tmpif self.original_ndim == 3:tmp = self.x.reshape(self.B, self.alignedM, self.alignedK)if self.is_transposed:t... | 5 | 11 | 1 | 79 | 0 | 86 | 97 | 86 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (as_tensor) defined within the public class called public.The function start at line 86 and ends at 97. It contains 11 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 | shallow_transpose | def shallow_transpose(self):shape = ((self.M, self.K) if self.original_ndim == 2 else (self.B, self.M, self.K),)new_obj = SwizzleTensor(torch.empty(*shape, dtype=self.dtype, layout=self.layout, device="meta"),True,)new_obj.x = self.xnew_obj.B = self.Bnew_obj.M = self.Mnew_obj.K = self.Knew_obj.alignedM = self.alignedMn... | 2 | 19 | 1 | 143 | 0 | 99 | 117 | 99 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (shallow_transpose) defined within the public class called public.The function start at line 99 and ends at 117. It contains 19 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 | shape | def shape(self):return torch.Size((self.K, self.M) if self.is_transposed else (self.M, self.K)) | 2 | 2 | 1 | 34 | 0 | 120 | 121 | 120 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (shape) defined within the public class called public.The function start at line 120 and ends at 121. It contains 2 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | stride | def stride(self):return (1, self.K) if self.is_transposed else (self.K, 1) | 2 | 2 | 1 | 25 | 0 | 123 | 124 | 123 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (stride) defined within the public class called public.The function start at line 123 and ends at 124. It contains 2 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 | __torch_dispatch__.unwrap | def unwrap(e):return e.unswizzle() if isinstance(e, SwizzleTensor) else e | 2 | 2 | 1 | 20 | 0 | 134 | 135 | 134 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__torch_dispatch__.unwrap) defined within the public class called public.The function start at line 134 and ends at 135. It contains 2 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 | __torch_dispatch__.wrap | def wrap(e):return SwizzleTensor(e) if isinstance(e, torch.Tensor) else e | 2 | 2 | 1 | 21 | 0 | 137 | 138 | 137 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__torch_dispatch__.wrap) defined within the public class called public.The function start at line 137 and ends at 138. It contains 2 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 | __torch_dispatch__ | def __torch_dispatch__(cls, func, types, args, kwargs=None):# Lazy import to avoid circular dependencyfrom torchao.swizzle.swizzle_ops import SWIZZLE_OPS_TABLEif func in SWIZZLE_OPS_TABLE:return SWIZZLE_OPS_TABLE[func](func, args, kwargs)def unwrap(e):return e.unswizzle() if isinstance(e, SwizzleTensor) else edef wrap(... | 2 | 7 | 5 | 68 | 0 | 127 | 140 | 127 | 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 127 and ends at 140. It contains 7 lines of code and it has a cyclomatic complexity of 2. It takes 5 parameters, represented as [127.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self, k=64, n=32, dtype=torch.bfloat16):super().__init__()self.linear1 = torch.nn.Linear(k, n, bias=False).to(dtype) | 1 | 3 | 4 | 49 | 0 | 16 | 18 | 16 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 16 and ends at 18. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [16.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | forward | def forward(self, x):x = self.linear1(x)return x | 1 | 3 | 2 | 17 | 0 | 20 | 22 | 20 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (forward) defined within the public class called public.The function start at line 20 and ends at 22. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [20.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self, n_chunks, in_channels, out_channels, kernel_size=3, stride=1, padding=1) -> None:super().__init__()self.n_chunks = n_chunksself.conv = nn.Conv2d(in_channels, out_channels, kernel_size, stride, padding)self.bn = nn.BatchNorm2d(out_channels)self.relu = nn.ReLU(inplace=True) | 1 | 8 | 7 | 77 | 0 | 26 | 33 | 26 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 26 and ends at 33. It contains 8 lines of code and it has a cyclomatic complexity of 1. It takes 7 parameters, represented as [26.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | forward | def forward(self, x) -> torch.Tensor:chunks = torch.chunk(x, self.n_chunks, dim=1)outputs = []for chunk in chunks:out = self.conv(chunk)out = self.bn(out)out = self.relu(out)outputs.append(out)return torch.cat(outputs, dim=1) | 2 | 9 | 2 | 77 | 0 | 35 | 43 | 35 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (forward) defined within the public class called public.The function start at line 35 and ends at 43. It contains 9 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [35.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self, fc_dim1, fc_dim2, dtype=torch.bfloat16, activation="sigmoid"):super().__init__()activation = activation.lower()activation_map = {"relu": nn.ReLU(),"sigmoid": nn.Sigmoid(),"leakyrelu": nn.LeakyReLU(),"relu6": nn.ReLU6(),"gelu": nn.GELU(),"silu": nn.SiLU(),"hardswish": nn.Hardswish(),}if activation not... | 2 | 17 | 5 | 150 | 0 | 47 | 66 | 47 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 47 and ends at 66. It contains 17 lines of code and it has a cyclomatic complexity of 2. It takes 5 parameters, represented as [47.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | forward | def forward(self, x):x = self.ln(x)x = self.fc(x)return self.activation(x) | 1 | 4 | 2 | 30 | 0 | 68 | 71 | 68 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (forward) defined within the public class called public.The function start at line 68 and ends at 71. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [68.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self, dim: int, eps: float = 1e-5):super().__init__()self.eps = epsself.weight = nn.Parameter(torch.ones(dim)) | 1 | 4 | 3 | 44 | 0 | 75 | 78 | 75 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 75 and ends at 78. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [75.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _norm | def _norm(self, x):return x * torch.rsqrt(torch.mean(x * x, dim=-1, keepdim=True) + self.eps) | 1 | 2 | 2 | 36 | 0 | 80 | 81 | 80 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_norm) defined within the public class called public.The function start at line 80 and ends at 81. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [80.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | forward | def forward(self, x: torch.Tensor) -> torch.Tensor:output = self._norm(x.float()).type_as(x)return output * self.weight | 1 | 3 | 2 | 38 | 0 | 83 | 85 | 83 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (forward) defined within the public class called public.The function start at line 83 and ends at 85. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [83.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self, hidden_dim, num_heads=8, mlp_ratio=4, dtype=torch.bfloat16):super().__init__()self.hidden_dim = hidden_dimself.num_heads = num_headsself.head_dim = hidden_dim // num_heads# Self-attentionself.qkv = torch.nn.Linear(hidden_dim, 3 * hidden_dim, bias=False).to(dtype)self.proj = torch.nn.Linear(hidden_dim... | 1 | 18 | 5 | 194 | 0 | 89 | 114 | 89 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 89 and ends at 114. It contains 18 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [89.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | forward | def forward(self, x):batch_size, seq_len, _ = x.shape# Self-attentionresidual = xx = self.norm1(x)# Reshape qkv projection for better memory layoutqkv = self.qkv(x)# [batch_size, seq_len, 3 * hidden_dim]qkv = qkv.reshape(batch_size, seq_len, 3, self.num_heads, self.head_dim)qkv = qkv.permute(2, 0, 3, 1, 4)# [3, batch_s... | 1 | 27 | 2 | 276 | 0 | 116 | 160 | 116 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (forward) defined within the public class called public.The function start at line 116 and ends at 160. It contains 27 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [116.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | create_model_and_input_data | def create_model_and_input_data(model_type: str,m: int,k: int,n: int,high_precision_dtype: torch.dtype = torch.bfloat16,device: str = "cuda",activation: str = "relu",):"""Create a model and input data for benchmarking.Args:model_type (str): type of the model to be createdbatch_size (int): batch size of the input datade... | 6 | 27 | 7 | 213 | 4 | 163 | 201 | 163 | null | ['activation', 'match', 'input_data', 'model'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (create_model_and_input_data) defined within the public class called public.The function start at line 163 and ends at 201. It contains 27 lines of code and it has a cyclomatic complexity of 6. It takes 7 parameters, represented as [163.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self,num_local_experts: int,dim: int,hidden_dim: int,dtype: torch.dtype,device: torch.device,) -> None:super().__init__()self.num_local_experts = num_local_expertsself.dim = dimself.w1: nn.Parameter = nn.Parameter(torch.randn(num_local_experts,dim,hidden_dim,dtype=dtype,device=device,))self.w2: nn.Paramete... | 1 | 38 | 6 | 145 | 0 | 206 | 247 | 206 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 206 and ends at 247. It contains 38 lines of code and it has a cyclomatic complexity of 1. It takes 6 parameters, represented as [206.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | forward | def forward(self,routed_in_egD: torch.Tensor,# noqa: N803) -> torch.Tensor:e = self.num_local_expertsD = self.dimx_egD = routed_in_egD.view(e, -1, D)middle_out_egF = F.silu(torch.bmm(x_egD, self.w1)) * torch.bmm(x_egD, self.w3)out_egD = torch.bmm(middle_out_egF, self.w2)out_egD = out_egD.view(-1, D)return out_egD | 1 | 11 | 2 | 92 | 0 | 249 | 262 | 249 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (forward) defined within the public class called public.The function start at line 249 and ends at 262. It contains 11 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [249.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | skip_if_compute_capability_less_than.skip_if_compute_capability_less_than.decorator.wrapper | def wrapper(*args, **kwargs):if get_compute_capability() < min_capability:raise unittest.SkipTest(f"Compute capability is less than {min_capability}")return test_func(*args, **kwargs) | 2 | 6 | 2 | 33 | 0 | 61 | 66 | 61 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (skip_if_compute_capability_less_than.skip_if_compute_capability_less_than.decorator.wrapper) defined within the public class called public.The function start at line 61 and ends at 66. It contains 6 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [61.0] and doe... |
pytorch_ao | public | public | 0 | 0 | skip_if_compute_capability_less_than.decorator | def decorator(test_func):def wrapper(*args, **kwargs):if get_compute_capability() < min_capability:raise unittest.SkipTest(f"Compute capability is less than {min_capability}")return test_func(*args, **kwargs)return wrapper | 1 | 3 | 1 | 9 | 0 | 60 | 68 | 60 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (skip_if_compute_capability_less_than.decorator) defined within the public class called public.The function start at line 60 and ends at 68. 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 | skip_if_compute_capability_less_than | def skip_if_compute_capability_less_than(min_capability):import unittestdef decorator(test_func):def wrapper(*args, **kwargs):if get_compute_capability() < min_capability:raise unittest.SkipTest(f"Compute capability is less than {min_capability}")return test_func(*args, **kwargs)return wrapperreturn decorator | 1 | 4 | 1 | 11 | 0 | 57 | 70 | 57 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (skip_if_compute_capability_less_than) defined within the public class called public.The function start at line 57 and ends at 70. 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 | skip_if_rocm.skip_if_rocm.decorator.wrapper | def wrapper(*args, **kwargs):if torch.version.hip is not None:skip_message = "Skipping the test in ROCm"if message:skip_message += f": {message}"pytest.skip(skip_message)return func(*args, **kwargs) | 3 | 7 | 2 | 44 | 0 | 83 | 89 | 83 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (skip_if_rocm.skip_if_rocm.decorator.wrapper) defined within the public class called public.The function start at line 83 and ends at 89. It contains 7 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [83.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | skip_if_rocm.decorator | def decorator(func):@functools.wraps(func)def wrapper(*args, **kwargs):if torch.version.hip is not None:skip_message = "Skipping the test in ROCm"if message:skip_message += f": {message}"pytest.skip(skip_message)return func(*args, **kwargs)return wrapper | 1 | 4 | 1 | 16 | 0 | 81 | 91 | 81 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (skip_if_rocm.decorator) defined within the public class called public.The function start at line 81 and ends at 91. It contains 4 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | skip_if_rocm | def skip_if_rocm(message=None):"""Decorator to skip tests on ROCm platform with custom message.Args:message (str, optional): Additional information about why the test is skipped."""import pytestdef decorator(func):@functools.wraps(func)def wrapper(*args, **kwargs):if torch.version.hip is not None:skip_message = "Skippi... | 2 | 8 | 1 | 31 | 3 | 73 | 98 | 73 | null | ['message', 'func', 'skip_message'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (skip_if_rocm) defined within the public class called public.The function start at line 73 and ends at 98. It contains 8 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | skip_if_no_cuda.skip_if_no_cuda.decorator.wrapper | def wrapper(*args, **kwargs):if not torch.cuda.is_available():raise unittest.SkipTest("No cuda available")return test_func(*args, **kwargs) | 2 | 4 | 2 | 35 | 0 | 106 | 109 | 106 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (skip_if_no_cuda.skip_if_no_cuda.decorator.wrapper) defined within the public class called public.The function start at line 106 and ends at 109. It contains 4 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [106.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | skip_if_no_cuda.decorator | def decorator(test_func):@functools.wraps(test_func)def wrapper(*args, **kwargs):if not torch.cuda.is_available():raise unittest.SkipTest("No cuda available")return test_func(*args, **kwargs)return wrapper | 1 | 4 | 1 | 16 | 0 | 104 | 111 | 104 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (skip_if_no_cuda.decorator) defined within the public class called public.The function start at line 104 and ends at 111. 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 | skip_if_no_cuda | def skip_if_no_cuda():import unittestdef decorator(test_func):@functools.wraps(test_func)def wrapper(*args, **kwargs):if not torch.cuda.is_available():raise unittest.SkipTest("No cuda available")return test_func(*args, **kwargs)return wrapperreturn decorator | 1 | 4 | 0 | 10 | 0 | 101 | 113 | 101 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (skip_if_no_cuda) defined within the public class called public.The function start at line 101 and ends at 113. 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 | skip_if_no_gemlite.skip_if_no_gemlite.decorator.wrapper | def wrapper(*args, **kwargs):try:import gemlite# noqa: F401except:raise unittest.SkipTest("No gemlite available")return test_func(*args, **kwargs) | 2 | 6 | 2 | 31 | 0 | 121 | 126 | 121 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (skip_if_no_gemlite.skip_if_no_gemlite.decorator.wrapper) defined within the public class called public.The function start at line 121 and ends at 126. It contains 6 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [121.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | skip_if_no_gemlite.decorator | def decorator(test_func):@functools.wraps(test_func)def wrapper(*args, **kwargs):try:import gemlite# noqa: F401except:raise unittest.SkipTest("No gemlite available")return test_func(*args, **kwargs)return wrapper | 1 | 4 | 1 | 16 | 0 | 119 | 128 | 119 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (skip_if_no_gemlite.decorator) defined within the public class called public.The function start at line 119 and ends at 128. 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 | skip_if_no_gemlite | def skip_if_no_gemlite():import unittestdef decorator(test_func):@functools.wraps(test_func)def wrapper(*args, **kwargs):try:import gemlite# noqa: F401except:raise unittest.SkipTest("No gemlite available")return test_func(*args, **kwargs)return wrapperreturn decorator | 1 | 4 | 0 | 10 | 0 | 116 | 130 | 116 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (skip_if_no_gemlite) defined within the public class called public.The function start at line 116 and ends at 130. 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 | copy_tests.new_test | def new_test(self, value=value):return value(self) | 1 | 2 | 2 | 14 | 0 | 144 | 145 | 144 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (copy_tests.new_test) defined within the public class called public.The function start at line 144 and ends at 145. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [144.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | copy_tests | def copy_tests(my_cls, other_cls, suffix, test_failures=None, xfail_prop=None):# noqa: B902for name, value in my_cls.__dict__.items():if name.startswith("test_"):# You cannot copy functions in Python, so we use closures here to# create objects with different ids. Otherwise, unittest.skip# would modify all methods shari... | 9 | 17 | 5 | 135 | 3 | 134 | 162 | 134 | null | ['tf', 'skip_func', 'new_test'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (copy_tests) defined within the public class called public.The function start at line 134 and ends at 162. It contains 17 lines of code and it has a cyclomatic complexity of 9. It takes 5 parameters, represented as [134.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_flatten_unflatten | def test_flatten_unflatten(self):hp_tensor = torch.randn(4, 128)lp_tensor = self.FACTORY_FN(hp_tensor, **self.kwargs)tensor_data_name_dict, tensor_attributes = lp_tensor.__tensor_flatten__()tensor_data_dict = {name: getattr(lp_tensor, name) for name in tensor_data_name_dict}outer_size = lp_tensor.size()outer_stride = l... | 2 | 13 | 1 | 99 | 0 | 180 | 192 | 180 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_flatten_unflatten) defined within the public class called public.The function start at line 180 and ends at 192. It contains 13 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 | test_hp_tensor_device_dtype | def test_hp_tensor_device_dtype(self, device, dtype):hp_tensor = torch.randn(4, 128, device=device, dtype=dtype)self.FACTORY_FN(hp_tensor, **self.kwargs) | 1 | 3 | 3 | 38 | 0 | 196 | 198 | 196 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_hp_tensor_device_dtype) defined within the public class called public.The function start at line 196 and ends at 198. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [196.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_device1_to_device2 | def test_device1_to_device2(self, device1, device2):"""Note: this should be parametrized with device1 and device2e.g. device1 = ["cpu", "cuda"], device2 = ["cpu", "cuda"]"""hp_tensor = torch.randn(4, 128, device=device1, dtype=torch.bfloat16)lp_tensor = self.FACTORY_FN(hp_tensor, **self.kwargs)lp_tensor.to(device=devic... | 1 | 13 | 3 | 166 | 0 | 202 | 220 | 202 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_device1_to_device2) defined within the public class called public.The function start at line 202 and ends at 220. It contains 13 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [202.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_transpose | def test_transpose(self, device, dtype):hp_tensor = torch.randn(4, 128, device=device, dtype=dtype)lp_tensor = self.FACTORY_FN(hp_tensor, **self.kwargs)lp_tensor = lp_tensor.t()self.assertEqual(lp_tensor.shape, (128, 4)) | 1 | 5 | 3 | 61 | 0 | 224 | 228 | 224 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_transpose) defined within the public class called public.The function start at line 224 and ends at 228. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [224.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_linear | def test_linear(self, device, dtype):hp_tensor = torch.randn(4, 128, device=device, dtype=dtype)lp_tensor = self.FACTORY_FN(hp_tensor, **self.kwargs)hp_act_tensor = torch.randn(32, 128, device=device, dtype=dtype)hp_res = torch.nn.functional.linear(hp_act_tensor, hp_tensor)lp_res = torch.nn.functional.linear(hp_act_ten... | 1 | 10 | 3 | 108 | 0 | 232 | 242 | 232 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_linear) defined within the public class called public.The function start at line 232 and ends at 242. It contains 10 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [232.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_input_output_tensor_subclass.f | def f(tensor):return tensor | 1 | 2 | 1 | 7 | 0 | 267 | 268 | 267 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_input_output_tensor_subclass.f) defined within the public class called public.The function start at line 267 and ends at 268. 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 | test_input_output_tensor_subclass | def test_input_output_tensor_subclass(self, device, dtype):hp_tensor = torch.randn(4, 128, device=device, dtype=dtype)lp_tensor = self.FACTORY_FN(hp_tensor, **self.kwargs)def f(tensor):return tensorref = f(lp_tensor)f = torch.compile(f)compiled = f(lp_tensor)self.assertTrue(isinstance(f(lp_tensor), self.TENSOR_SUBCLASS... | 1 | 9 | 3 | 94 | 0 | 263 | 274 | 263 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_input_output_tensor_subclass) defined within the public class called public.The function start at line 263 and ends at 274. It contains 9 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [263.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_input_tensor_subclass.f | def f(tensor):return tensor.dequantize() | 1 | 2 | 1 | 11 | 0 | 282 | 283 | 282 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_input_tensor_subclass.f) defined within the public class called public.The function start at line 282 and ends at 283. 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 | test_input_tensor_subclass | def test_input_tensor_subclass(self, device, dtype):hp_tensor = torch.randn(4, 128, device=device, dtype=dtype)lp_tensor = self.FACTORY_FN(hp_tensor, **self.kwargs)def f(tensor):return tensor.dequantize()ref = f(lp_tensor)f = torch.compile(f)compiled = f(lp_tensor)self.assertFalse(isinstance(f(lp_tensor), self.TENSOR_S... | 1 | 9 | 3 | 86 | 0 | 278 | 289 | 278 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_input_tensor_subclass) defined within the public class called public.The function start at line 278 and ends at 289. It contains 9 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [278.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_output_tensor_subclass.f | def f(hp_tensor):return self.FACTORY_FN(hp_tensor, **self.kwargs) | 1 | 2 | 1 | 17 | 0 | 296 | 297 | 296 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_output_tensor_subclass.f) defined within the public class called public.The function start at line 296 and ends at 297. 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 | test_output_tensor_subclass | def test_output_tensor_subclass(self, device, dtype):hp_tensor = torch.randn(4, 128, device=device, dtype=dtype)def f(hp_tensor):return self.FACTORY_FN(hp_tensor, **self.kwargs)ref = f(hp_tensor)f = torch.compile(f)compiled = f(hp_tensor)self.assertTrue(isinstance(f(hp_tensor), self.TENSOR_SUBCLASS))# bfloat16 seems to... | 2 | 14 | 3 | 102 | 0 | 293 | 310 | 293 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_output_tensor_subclass) defined within the public class called public.The function start at line 293 and ends at 310. It contains 14 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [293.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_linear_compile | def test_linear_compile(self, device, dtype):hp_tensor = torch.randn(4, 128, device=device, dtype=dtype)lp_tensor = self.FACTORY_FN(hp_tensor, **self.kwargs)hp_act_tensor = torch.randn(32, 128, device=device, dtype=dtype)hp_res = torch.nn.functional.linear(hp_act_tensor, hp_tensor)linear = torch.nn.Linear(128, 4, bias=... | 1 | 12 | 3 | 141 | 0 | 314 | 326 | 314 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_linear_compile) defined within the public class called public.The function start at line 314 and ends at 326. It contains 12 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [314.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | colwise_shard | def colwise_shard(m: torch.nn.Module, mesh: DeviceMesh) -> torch.nn.Module:"""Shard linear layer of the model in column-wise fashion"""# Column-wise is wrt to A^T, so for A it is row-wise.# Number of rows per rankorig_weight = m.linear.weightn_local_rows = orig_weight.size(0) // mesh.size()rank = mesh.get_local_rank()l... | 1 | 8 | 2 | 100 | 0 | 339 | 353 | 339 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (colwise_shard) defined within the public class called public.The function start at line 339 and ends at 353. It contains 8 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [339.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | rowwise_shard | def rowwise_shard(m: torch.nn.Module, mesh: DeviceMesh) -> torch.nn.Module:"""Shard linear layer of the model in row-wise fashion"""# Row-wise is wrt to A^T, so for A it is column-wise.# Number of rows per rankorig_weight = m.linear.weightn_local_cols = orig_weight.size(1) // mesh.size()rank = mesh.get_local_rank()loca... | 1 | 8 | 2 | 100 | 0 | 356 | 370 | 356 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (rowwise_shard) defined within the public class called public.The function start at line 356 and ends at 370. It contains 8 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [356.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | quantize | def quantize(self, m: torch.nn.Module) -> torch.nn.Module:"""Quantize the model"""quantize_(m, self.QUANT_METHOD_FN(**self.QUANT_METHOD_KWARGS))return m | 1 | 3 | 2 | 36 | 0 | 372 | 377 | 372 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (quantize) defined within the public class called public.The function start at line 372 and ends at 377. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [372.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_tp.__init__ | def __init__(self, in_features, out_features, **kwargs) -> None:super().__init__(**kwargs)self.linear = torch.nn.Linear(in_features, out_features, bias=False, device="cuda") | 1 | 5 | 4 | 45 | 0 | 388 | 392 | 388 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_tp.__init__) defined within the public class called public.The function start at line 388 and ends at 392. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [388.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_tp.forward | def forward(self, x: torch.Tensor) -> torch.Tensor:return self.linear(x) | 1 | 2 | 2 | 22 | 0 | 394 | 395 | 394 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_tp.forward) defined within the public class called public.The function start at line 394 and ends at 395. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [394.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | test_tp | def test_tp(self, dtype):device = "cuda"# To make sure different ranks create the same moduletorch.manual_seed(5)class M(torch.nn.Module):def __init__(self, in_features, out_features, **kwargs) -> None:super().__init__(**kwargs)self.linear = torch.nn.Linear(in_features, out_features, bias=False, device="cuda")def forwa... | 1 | 24 | 2 | 206 | 0 | 382 | 426 | 382 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (test_tp) defined within the public class called public.The function start at line 382 and ends at 426. It contains 24 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [382.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _test_slice_and_copy_similar_to_vllm | def _test_slice_and_copy_similar_to_vllm(self, config: AOBaseConfig):# making sure https://github.com/vllm-project/vllm/blob/90bd2ab6e3eb7e83d3f40d99fc23e6e43834743a/vllm/model_executor/layers/linear.py#L483-L495 works properly# the test is similar to the linked code, but with some hardcoded arguments# and does not use... | 5 | 32 | 2 | 293 | 0 | 430 | 475 | 430 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_test_slice_and_copy_similar_to_vllm) defined within the public class called public.The function start at line 430 and ends at 475. It contains 32 lines of code and it has a cyclomatic complexity of 5. It takes 2 parameters, represented as [430.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _test_moe_weight_reshape_ops._quantize_experts | def _quantize_experts(model, config):for _, module in model.named_modules():if not isinstance(module, LlamaModelsLlama4Experts):continueexpert_module = modulefor weight_name in ["w1", "w2", "w3"]:weight = getattr(expert_module, weight_name)config_handler = _QUANTIZE_CONFIG_HANDLER[type(config)]dummy_mod = DummyModule(w... | 4 | 11 | 2 | 83 | 0 | 486 | 497 | 486 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_test_moe_weight_reshape_ops._quantize_experts) defined within the public class called public.The function start at line 486 and ends at 497. It contains 11 lines of code and it has a cyclomatic complexity of 4. It takes 2 parameters, represented as [486.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _test_moe_weight_reshape_ops.process_key | def process_key(key: str) -> torch.Tensor:tensors = [s[key] for s in state_dicts]# Note: we have a hacky implementation for cat in user codebase# since it is not implemented correctly beforeif key == "w2":return torch.cat(tensors, dim=-1)else:return torch.cat(tensors, dim=-2) | 3 | 6 | 1 | 54 | 0 | 585 | 592 | 585 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_test_moe_weight_reshape_ops.process_key) defined within the public class called public.The function start at line 585 and ends at 592. It contains 6 lines of code and it has a cyclomatic complexity of 3. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _test_moe_weight_reshape_ops | def _test_moe_weight_reshape_ops(self, config):"""This is testing the op call sequence in saving and loading quantizationcheckpoints in llama-models for llama4(https://github.com/meta-llama/llama-models/tree/main/models/llama4)"""# only per row quantization is supported for bmmdtype = torch.bfloat16device = "cuda"def _... | 7 | 89 | 2 | 777 | 0 | 477 | 609 | 477 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_test_moe_weight_reshape_ops) defined within the public class called public.The function start at line 477 and ends at 609. It contains 89 lines of code and it has a cyclomatic complexity of 7. It takes 2 parameters, represented as [477.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _test_narrow_similar_to_vllm | def _test_narrow_similar_to_vllm(self, config: AOBaseConfig):# this happens various times in vllm when slicing weights arounddtype = torch.bfloat16l = torch.nn.Linear(1024, 1024, device="cuda", dtype=dtype)quantize_(l, config)orig = l.weightnew = orig.narrow(1, 0, 1024)for data_attr_name in new.tensor_data_names:orig_a... | 2 | 12 | 2 | 99 | 0 | 611 | 626 | 611 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_test_narrow_similar_to_vllm) defined within the public class called public.The function start at line 611 and ends at 626. It contains 12 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [611.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _get_dynamo_graph | def _get_dynamo_graph(function: Callable, inputs) -> torch.fx.Graph:gm, _ = torchdynamo.export(function, aten_graph=True)(*inputs)gm.graph.eliminate_dead_code()return gm.graph | 1 | 4 | 2 | 44 | 0 | 56 | 59 | 56 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_get_dynamo_graph) defined within the public class called public.The function start at line 56 and ends at 59. It contains 4 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 | _get_linear_patterns.linear_op | def linear_op(act, weight, bias=None):return F.linear(act, weight, bias) | 1 | 2 | 3 | 22 | 0 | 69 | 70 | 69 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_get_linear_patterns.linear_op) defined within the public class called public.The function start at line 69 and ends at 70. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [69.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _get_linear_patterns | def _get_linear_patterns(input_size: list[int]):in_channels = input_size[-1]out_channels = 8# hard coding but this should not matterweight = torch.ones((out_channels, in_channels))bias = torch.ones((out_channels,))act = torch.ones(input_size)def linear_op(act, weight, bias=None):return F.linear(act, weight, bias)patter... | 1 | 10 | 1 | 85 | 7 | 62 | 74 | 62 | null | ['in_channels', 'pattern_w_bias', 'pattern_wo_bias', 'bias', 'act', 'out_channels', 'weight'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_get_linear_patterns) defined within the public class called public.The function start at line 62 and ends at 74. It contains 10 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 | _supported_symmetric_quantized_operators | def _supported_symmetric_quantized_operators() -> dict[str, list[OperatorPatternType]]:supported_operators: dict[str, list[OperatorPatternType]] = {# Both conv and linear should be able to handle relu + hardtanh fusion since# those are clamp ops"conv2d": [[torch.nn.Conv2d, torch.nn.ReLU],[torch.nn.Conv2d, F.relu],[F.co... | 1 | 16 | 0 | 135 | 0 | 77 | 94 | 77 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_supported_symmetric_quantized_operators) defined within the public class called public.The function start at line 77 and ends at 94. It contains 16 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _get_supported_symmetric_config_and_operators | def _get_supported_symmetric_config_and_operators() -> list[OperatorConfig]:supported_config_and_operators: list[OperatorConfig] = []for quantization_config in [get_symmetric_quantization_config(),get_symmetric_quantization_config(is_qat=True),get_symmetric_quantization_config(is_per_channel=True),get_symmetric_quantiz... | 3 | 14 | 0 | 84 | 1 | 97 | 110 | 97 | null | ['ops'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_get_supported_symmetric_config_and_operators) defined within the public class called public.The function start at line 97 and ends at 110. It contains 14 lines of code and it has a cyclomatic complexity of 3. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_symmetric_quantization_config | def get_symmetric_quantization_config(is_per_channel: bool = False,is_qat: bool = False,is_dynamic: bool = False,act_qmin: int = -128,act_qmax: int = 127,weight_qmin: int = -127,weight_qmax: int = 127,):extra_args: dict[str, Any] = {"eps": 2**-12}if is_qat:if is_dynamic:act_observer_or_fake_quant_ctr = FakeQuantizedyna... | 10 | 79 | 7 | 302 | 8 | 114 | 196 | 114 | null | ['weight_observer_or_fake_quant_ctr', 'act_quantization_spec', 'act_observer_or_fake_quant_ctr', 'quantization_config', 'bias_quantization_spec', 'weight_qscheme', 'dynamic_quant_observer', 'weight_quantization_spec'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_symmetric_quantization_config) defined within the public class called public.The function start at line 114 and ends at 196. It contains 79 lines of code and it has a cyclomatic complexity of 10. It takes 7 parameters, represented as [114.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _get_supported_config_and_operators | def _get_supported_config_and_operators() -> list[OperatorConfig]:return _get_supported_symmetric_config_and_operators() | 1 | 2 | 0 | 13 | 0 | 199 | 200 | 199 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_get_supported_config_and_operators) defined within the public class called public.The function start at line 199 and ends at 200. 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 | _get_module_type_filter.module_type_filter | def module_type_filter(n: Node) -> bool:# example: {# 'L__self___sub': ("L['self'].sub", <class '....Sub'>),# 'L__self___sub_linear': ("L['self'].sub.linear", <class 'torch.nn.modules.linear.Linear'>)# }nn_module_stack = n.meta.get("nn_module_stack", {})types = []for _, t in nn_module_stack.values():# export() returns ... | 3 | 8 | 1 | 66 | 0 | 218 | 231 | 218 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_get_module_type_filter.module_type_filter) defined within the public class called public.The function start at line 218 and ends at 231. It contains 8 lines of code and it has a cyclomatic complexity of 3. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _get_module_type_filter | def _get_module_type_filter(tp: Callable):"""Get the module_type_filter function for a given module type, the filter acceptsa node and checks if the node comes from a module that has certain module typeFor example:node: linear_op = call_function[...](...)# comes from a module with type Block -> Sub -> Linear>> module_t... | 1 | 4 | 1 | 23 | 4 | 203 | 233 | 203 | null | ['nn_module_stack', 't', 'tp_str', 'types'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_get_module_type_filter) defined within the public class called public.The function start at line 203 and ends at 233. 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 | _get_not_module_type_or_name_filter.not_module_type_or_name_filter | def not_module_type_or_name_filter(n: Node) -> bool:return not any(f(n) for f in module_type_filters + module_name_list_filters) | 2 | 2 | 1 | 24 | 0 | 242 | 243 | 242 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_get_not_module_type_or_name_filter.not_module_type_or_name_filter) defined within the public class called public.The function start at line 242 and ends at 243. It contains 2 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _get_not_module_type_or_name_filter | def _get_not_module_type_or_name_filter(tp_list: list[Callable], module_name_list: list[str]) -> Callable[[Node], bool]:module_type_filters = [_get_module_type_filter(tp) for tp in tp_list]module_name_list_filters = [get_module_name_filter(m) for m in module_name_list]def not_module_type_or_name_filter(n: Node) -> bool... | 3 | 7 | 2 | 54 | 2 | 236 | 245 | 236 | null | ['module_type_filters', 'module_name_list_filters'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_get_not_module_type_or_name_filter) defined within the public class called public.The function start at line 236 and ends at 245. It contains 7 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [236.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | __init__ | def __init__(self) -> None:super().__init__()warnings.warn(f"{self.__class__.__name__} is deprecated!")self.global_config: Optional[QuantizationConfig] = Noneself.operator_type_config: dict[torch._ops.OpOverloadPacket, Optional[QuantizationConfig]] = {}self.module_type_config: dict[Callable, Optional[QuantizationConfig... | 1 | 9 | 1 | 83 | 0 | 287 | 295 | 287 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (__init__) defined within the public class called public.The function start at line 287 and ends at 295. 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 | get_supported_quantization_configs | def get_supported_quantization_configs(cls) -> list[QuantizationConfig]:op_configs: set[QuantizationConfig] = {spec for spec, _ in cls.supported_config_and_operators}return list(op_configs) | 2 | 5 | 1 | 33 | 0 | 298 | 302 | 298 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_supported_quantization_configs) defined within the public class called public.The function start at line 298 and ends at 302. It contains 5 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_supported_operator_for_quantization_config | def get_supported_operator_for_quantization_config(cls, quantization_config: Optional[QuantizationConfig]) -> list[OperatorPatternType]:if quantization_config is None:all_ops = []for _, ops in cls.supported_config_and_operators:all_ops.extend(ops)return all_opsfor config, ops in cls.supported_config_and_operators:# not... | 5 | 12 | 2 | 62 | 0 | 305 | 322 | 305 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_supported_operator_for_quantization_config) defined within the public class called public.The function start at line 305 and ends at 322. It contains 12 lines of code and it has a cyclomatic complexity of 5. It takes 2 parameters, represented as [305.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | set_global | def set_global(self, quantization_config: QuantizationConfig) -> XNNPACKQuantizer:self.global_config = quantization_configreturn self | 1 | 3 | 2 | 18 | 0 | 324 | 326 | 324 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (set_global) defined within the public class called public.The function start at line 324 and ends at 326. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [324.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | set_operator_type | def set_operator_type(self,operator_type: torch._ops.OpOverloadPacket,quantization_config: QuantizationConfig,) -> XNNPACKQuantizer:self.operator_type_config[operator_type] = quantization_configreturn self | 1 | 7 | 3 | 30 | 0 | 328 | 334 | 328 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (set_operator_type) defined within the public class called public.The function start at line 328 and ends at 334. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [328.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | set_module_type | def set_module_type(self, module_type: Callable, quantization_config: QuantizationConfig):"""Set quantization_config for a submodule with type: `module_type`, for example:quantizer.set_module_name(Sub) or quantizer.set_module_name(nn.Linear), it will quantize all supported operator/operatorpatterns in the submodule wit... | 1 | 5 | 3 | 24 | 0 | 336 | 344 | 336 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (set_module_type) defined within the public class called public.The function start at line 336 and ends at 344. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [336.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | set_module_name | def set_module_name(self, module_name: str, quantization_config: Optional[QuantizationConfig]):"""Set quantization_config for a submodule with name: `module_name`, for example:quantizer.set_module_name("blocks.sub"), it will quantize all supported operator/operatorpatterns in the submodule with this module name with th... | 1 | 8 | 3 | 36 | 0 | 346 | 357 | 346 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (set_module_name) defined within the public class called public.The function start at line 346 and ends at 357. It contains 8 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [346.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | transform_for_annotation | def transform_for_annotation(self, model: torch.fx.GraphModule) -> torch.fx.GraphModule:"""Transforms scalar values to tensor attributes"""return _convert_scalars_to_attrs(model) | 1 | 4 | 2 | 25 | 0 | 359 | 363 | 359 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (transform_for_annotation) defined within the public class called public.The function start at line 359 and ends at 363. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [359.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | annotate | def annotate(self, model: torch.fx.GraphModule) -> torch.fx.GraphModule:"""just handling global spec for now"""# hacked for handling dynamic linear quant. will fix later.if self.global_config and self.global_config.input_activation.is_dynamic:# type: ignore[union-attr]model = self._annotate_for_dynamic_quantization_con... | 3 | 7 | 2 | 57 | 0 | 365 | 373 | 365 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (annotate) defined within the public class called public.The function start at line 365 and ends at 373. It contains 7 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [365.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _annotate_all_static_patterns | def _annotate_all_static_patterns(self,model: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[Callable[[Node], bool]] = None,) -> torch.fx.GraphModule:# TODO: implement the support for None to be canceling out previous annotationsif quantization_config is None:return modelif q... | 5 | 14 | 5 | 93 | 0 | 375 | 390 | 375 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_annotate_all_static_patterns) defined within the public class called public.The function start at line 375 and ends at 390. It contains 14 lines of code and it has a cyclomatic complexity of 5. It takes 5 parameters, represented as [375.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _annotate_all_dynamic_patterns | def _annotate_all_dynamic_patterns(self,model: torch.fx.GraphModule,quantization_config: Optional[QuantizationConfig],filter_fn: Optional[Callable[[Node], bool]] = None,) -> torch.fx.GraphModule:# TODO: implement the support for None to be canceling out previous annotationsif quantization_config is None:return modelfor... | 3 | 11 | 5 | 70 | 0 | 392 | 404 | 392 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_annotate_all_dynamic_patterns) defined within the public class called public.The function start at line 392 and ends at 404. It contains 11 lines of code and it has a cyclomatic complexity of 3. It takes 5 parameters, represented as [392.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _annotate_for_static_quantization_config | def _annotate_for_static_quantization_config(self, model: torch.fx.GraphModule) -> torch.fx.GraphModule:module_name_list = list(self.module_name_config.keys())for module_name, config in self.module_name_config.items():self._annotate_all_static_patterns(model, config, get_module_name_filter(module_name))tp_list = list(s... | 3 | 19 | 2 | 115 | 0 | 406 | 426 | 406 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_annotate_for_static_quantization_config) defined within the public class called public.The function start at line 406 and ends at 426. It contains 19 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [406.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | _annotate_for_dynamic_quantization_config | def _annotate_for_dynamic_quantization_config(self, model: torch.fx.GraphModule) -> torch.fx.GraphModule:module_name_list = list(self.module_name_config.keys())for module_name, config in self.module_name_config.items():self._annotate_all_dynamic_patterns(model, config, get_module_name_filter(module_name))tp_list = list... | 3 | 19 | 2 | 115 | 0 | 428 | 448 | 428 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_annotate_for_dynamic_quantization_config) defined within the public class called public.The function start at line 428 and ends at 448. It contains 19 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [428.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | validate | def validate(self, model: torch.fx.GraphModule) -> None:pass | 1 | 2 | 2 | 16 | 0 | 450 | 451 | 450 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (validate) 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. It takes 2 parameters, represented as [450.0] and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_supported_operators | def get_supported_operators(cls) -> list[OperatorConfig]:return cls.supported_config_and_operators | 1 | 2 | 1 | 14 | 0 | 454 | 455 | 454 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_supported_operators) defined within the public class called public.The function start at line 454 and ends at 455. 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 | register_annotator.decorator | def decorator(annotator: AnnotatorType) -> None:OP_TO_ANNOTATOR[op] = annotator | 1 | 2 | 1 | 15 | 0 | 81 | 82 | 81 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (register_annotator.decorator) defined within the public class called public.The function start at line 81 and ends at 82. 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 | register_annotator | def register_annotator(op: str) -> Callable[[AnnotatorType], None]:def decorator(annotator: AnnotatorType) -> None:OP_TO_ANNOTATOR[op] = annotatorreturn decorator | 1 | 3 | 1 | 20 | 0 | 80 | 84 | 80 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (register_annotator) defined within the public class called public.The function start at line 80 and ends at 84. 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 | _is_annotated | def _is_annotated(nodes: list[Node]):"""Given a list of nodes (that represents an operator pattern),check if any of the node is annotated, return True if any of the nodeis annotated, otherwise return False"""annotated = Falsefor node in nodes:annotated = annotated or ("quantization_annotation" in node.metaand node.meta... | 4 | 8 | 1 | 41 | 1 | 100 | 112 | 100 | null | ['annotated'] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_is_annotated) defined within the public class called public.The function start at line 100 and ends at 112. 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 | _mark_nodes_as_annotated | def _mark_nodes_as_annotated(nodes: list[Node]):for node in nodes:if node is not None:if "quantization_annotation" not in node.meta:node.meta["quantization_annotation"] = QuantizationAnnotation()node.meta["quantization_annotation"]._annotated = True | 4 | 6 | 1 | 49 | 0 | 115 | 120 | 115 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (_mark_nodes_as_annotated) defined within the public class called public.The function start at line 115 and ends at 120. It contains 6 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 | get_input_act_qspec | def get_input_act_qspec(quantization_config: Optional[QuantizationConfig]):if quantization_config is None:return Noneif quantization_config.input_activation is None:return Nonequantization_spec: QuantizationSpec = quantization_config.input_activationassert quantization_spec.qscheme in [torch.per_tensor_affine,torch.per... | 3 | 11 | 1 | 50 | 0 | 123 | 133 | 123 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_input_act_qspec) defined within the public class called public.The function start at line 123 and ends at 133. It contains 11 lines of code and it has a cyclomatic complexity of 3. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_output_act_qspec | def get_output_act_qspec(quantization_config: Optional[QuantizationConfig]):if quantization_config is None:return Noneif quantization_config.output_activation is None:return Nonequantization_spec: QuantizationSpec = quantization_config.output_activationassert quantization_spec.qscheme in [torch.per_tensor_affine,torch.... | 3 | 11 | 1 | 50 | 0 | 136 | 146 | 136 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_output_act_qspec) defined within the public class called public.The function start at line 136 and ends at 146. It contains 11 lines of code and it has a cyclomatic complexity of 3. The function does not take any parameters and does not return any value.. |
pytorch_ao | public | public | 0 | 0 | get_weight_qspec | def get_weight_qspec(quantization_config: Optional[QuantizationConfig]):if quantization_config is None:return Noneassert quantization_config is not Noneif quantization_config.weight is None:return Nonequantization_spec: QuantizationSpec = quantization_config.weightif quantization_spec.qscheme not in [torch.per_tensor_s... | 4 | 16 | 1 | 65 | 0 | 149 | 164 | 149 | null | [] | None | null | 0 | 0 | 0 | null | 0 | null | The function (get_weight_qspec) defined within the public class called public.The function start at line 149 and ends at 164. It contains 16 lines of code and it has a cyclomatic complexity of 4. The function does not take any parameters and does not return any value.. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.