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
t_default
def t_default(func, *args, **kwargs):a = args[0][0]tensor_meta = SubclassTensorArgs(a.size(),(a.stride(1), a.stride(0)),a.storage_offset(),a.dtype,a.device,a.requires_grad,)b = NF4Tensor(tensor_meta,a.block_size,a.n_blocks,a.scaler_block_size,a.quantized_scalers,a.quantization_factor,a.scaler_mean,a.quantized_data,a.nf...
1
22
3
106
3
404
425
404
null
['b', 'tensor_meta', 'a']
None
null
0
0
0
null
0
null
The function (t_default) defined within the public class called public.The function start at line 404 and ends at 425. It contains 22 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [404.0] and does not return any value..
pytorch_ao
public
public
0
0
mm_default
def mm_default(func, *args, **kwargs):return linear_nf4(args[0][0], args[0][1])
1
2
3
30
0
429
430
429
null
[]
None
null
0
0
0
null
0
null
The function (mm_default) defined within the public class called public.The function start at line 429 and ends at 430. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [429.0] and does not return any value..
pytorch_ao
public
public
0
0
copy_
def copy_(func, *args, **kwargs):original: NF4Tensor = args[0][0]copy_in: torch.Tensor = args[0][1]# Base Caseif same_metadata(original, copy_in):original_tensors = original.__tensor_flatten__()[0]for tensor_name in original_tensors:getattr(original, tensor_name).copy_(getattr(copy_in, tensor_name))return# Convert Non ...
4
18
3
144
4
438
462
438
null
['original_tensors', 'same_meta_nf4', 'copy_in_nf4', 'full_precision']
None
null
0
0
0
null
0
null
The function (copy_) defined within the public class called public.The function start at line 438 and ends at 462. It contains 18 lines of code and it has a cyclomatic complexity of 4. It takes 3 parameters, represented as [438.0] and does not return any value..
pytorch_ao
public
public
0
0
nf4_is_pinned
def nf4_is_pinned(aten_op, args, kwargs=None):nf4tensor = args[0]for attr in _INNER_TENSOR_NAMES_FOR_SHARDING:inner_tensor = getattr(nf4tensor, attr)if not aten_op(inner_tensor, *(args[1:]), **kwargs):return Falsereturn True
3
7
3
53
2
470
476
470
null
['inner_tensor', 'nf4tensor']
None
null
0
0
0
null
0
null
The function (nf4_is_pinned) defined within the public class called public.The function start at line 470 and ends at 476. It contains 7 lines of code and it has a cyclomatic complexity of 3. It takes 3 parameters, represented as [470.0] and does not return any value..
pytorch_ao
public
public
0
0
nf4_pin_memory
def nf4_pin_memory(aten_op, args, kwargs=None):nf4tensor = args[0]updated_attrs = apply_to_inner_tensors(nf4tensor, aten_op, args[1:], kwargs)return NF4Tensor(*construct_nf4_args(nf4tensor, updated_attrs))
1
4
3
44
2
484
487
484
null
['updated_attrs', 'nf4tensor']
None
null
0
0
0
null
0
null
The function (nf4_pin_memory) defined within the public class called public.The function start at line 484 and ends at 487. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [484.0] and does not return any value..
pytorch_ao
public
public
0
0
nf4_cat
def nf4_cat(aten_op: torch._ops.OpOverload, args, kwargs=None):tensors_to_cat = args[0]assert all(isinstance(t, torch.Tensor) for t in tensors_to_cat)remaining_args = args[1:]ts = []for t in tensors_to_cat:assert isinstance(t, torch.Tensor)if isinstance(t, NF4Tensor):ts.append(t.get_original_weight())else:ts.append(t)d...
6
17
3
134
6
495
516
495
null
['tensors', 'remaining_args', 'tensors_to_cat', 'kwargs', 'dtype', 'ts']
None
null
0
0
0
null
0
null
The function (nf4_cat) defined within the public class called public.The function start at line 495 and ends at 516. It contains 17 lines of code and it has a cyclomatic complexity of 6. It takes 3 parameters, represented as [495.0] and does not return any value..
pytorch_ao
public
public
0
0
wait_tensor
def wait_tensor(func, *args, **kwargs):nf4tensor = args[0][0]updated_attrs = {}for attr in _INNER_TENSOR_NAMES_FOR_SHARDING:updated_attrs[attr] = func(getattr(nf4tensor, attr))updatedNF4Tensor = NF4Tensor(*construct_nf4_args(nf4tensor, updated_attrs))return updatedNF4Tensor
2
7
3
57
3
524
530
524
null
['updatedNF4Tensor', 'updated_attrs', 'nf4tensor']
None
null
0
0
0
null
0
null
The function (wait_tensor) defined within the public class called public.The function start at line 524 and ends at 530. It contains 7 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [524.0] and does not return any value..
pytorch_ao
public
public
0
0
get_block_absmax
def get_block_absmax(input_tensor: torch.Tensor, block_size: int) -> torch.Tensor:"""Iterate through a flattened tensor getting the absmax scalers for each blockArgs:input_tensor: Input tensor to get scalers forblock_size: Block size for the scanning windowReturns:torch.Tensor: Tensor of scalers for each block"""assert...
1
9
2
81
3
544
561
544
null
['n_blocks', 'blocks', 'block_scalers']
None
null
0
0
0
null
0
null
The function (get_block_absmax) defined within the public class called public.The function start at line 544 and ends at 561. It contains 9 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [544.0] and does not return any value..
pytorch_ao
public
public
0
0
__new__
def __new__(cls,# Args related for base tensor constructiontensor_meta: SubclassTensorArgs,# Args stored on the instanceblock_size: int,n_blocks: int,scaler_block_size: int,quantized_scalers: torch.Tensor,quantization_factor: torch.Tensor,scaler_mean: torch.Tensor,quantized_data: torch.Tensor,nf4: torch.Tensor,):"""Cre...
1
22
10
96
0
568
606
568
null
[]
None
null
0
0
0
null
0
null
The function (__new__) defined within the public class called public.The function start at line 568 and ends at 606. It contains 22 lines of code and it has a cyclomatic complexity of 1. It takes 10 parameters, represented as [568.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self,tensor_meta: SubclassTensorArgs,block_size: int,n_blocks: int,scaler_block_size: int,quantized_scalers: torch.Tensor,quantization_factor: torch.Tensor,scaler_mean: torch.Tensor,quantized_data: torch.Tensor,nf4: torch.Tensor,):"""Initialize the NF4Tensor class"""self.block_size = block_sizeself.n_block...
1
20
10
93
0
609
629
609
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 609 and ends at 629. It contains 20 lines of code and it has a cyclomatic complexity of 1. It takes 10 parameters, represented as [609.0] and does not return any value..
pytorch_ao
public
public
0
0
from_tensor
def from_tensor(cls,input_tensor: torch.Tensor,block_size: int,scaler_block_size: int,):assert input_tensor.dim() <= 2, (f"expect input tensor dim <= 2 but got dim = {input_tensor.dim()}")assert input_tensor.numel() % block_size == 0, (f"Input tensor must be divisible by block size, got {input_tensor.numel()} and {bloc...
1
66
4
254
0
633
702
633
null
[]
None
null
0
0
0
null
0
null
The function (from_tensor) defined within the public class called public.The function start at line 633 and ends at 702. It contains 66 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [633.0] and does not return any value..
pytorch_ao
public
public
0
0
double_quantize_scalers
def double_quantize_scalers(input_tensor: torch.Tensor,block_size: int,scaler_block_size: int,) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:"""Used to achieve the double quantization of the scalersWe take the input tensor first calculate the absmax quantization factors for each block.We then find the mean of our...
1
31
3
207
0
705
762
705
null
[]
None
null
0
0
0
null
0
null
The function (double_quantize_scalers) defined within the public class called public.The function start at line 705 and ends at 762. It contains 31 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [705.0] and does not return any value..
pytorch_ao
public
public
0
0
dequantize_scalers
def dequantize_scalers(self,input_tensor: torch.Tensor,quantization_factor: torch.Tensor,scaler_block_size: int,) -> torch.Tensor:"""Used to unpack the double quantized scalersArgs:input_tensor: Input tensor to convert to QLoRA format this is the quantized scalers in int8 formatquantization_factor: Tensor of per_scaler...
1
16
4
102
0
764
787
764
null
[]
None
null
0
0
0
null
0
null
The function (dequantize_scalers) defined within the public class called public.The function start at line 764 and ends at 787. It contains 16 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [764.0] and does not return any value..
pytorch_ao
public
public
0
0
convert_to_norm_float_weight
def convert_to_norm_float_weight(input_tensor: torch.Tensor, n_blocks: int, block_size: int, nf4: torch.Tensor) -> torch.Tensor:"""Convert a tensor to the normalized float weight format"""flattened_tensor = input_tensor.flatten()#Since we are using uint8 we will encode 2 entries per bytenumel = input_tensor.numel()asse...
2
24
4
205
0
790
827
790
null
[]
None
null
0
0
0
null
0
null
The function (convert_to_norm_float_weight) defined within the public class called public.The function start at line 790 and ends at 827. It contains 24 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [790.0] and does not return any value..
pytorch_ao
public
public
0
0
get_original_weight
def get_original_weight(self) -> torch.Tensor:"""Get the original weight from the normalized float weight format"""# Since we are using uint8 we will decode 2 entries per byte# Shift elements down 4 and select out the bottom 4 bitsfirst_elements = (self.quantized_data >> 4).to(torch.long)second_elements = (self.quantiz...
1
14
1
181
0
829
855
829
null
[]
None
null
0
0
0
null
0
null
The function (get_original_weight) defined within the public class called public.The function start at line 829 and ends at 855. It contains 14 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
quantize_tensor_nearest
def quantize_tensor_nearest(value: torch.Tensor, nf4: torch.Tensor) -> torch.Tensor:"""Quantize a float16 tensor to nf4 format to nearest and not rounded up"""value = value.unsqueeze(-1)# (numel, 1)# Compare the value tensor with the nf4 tensor element-wisediff = (value - nf4).abs()closest_nf4 = diff.min(dim=-1).indice...
1
5
2
55
0
858
864
858
null
[]
None
null
0
0
0
null
0
null
The function (quantize_tensor_nearest) defined within the public class called public.The function start at line 858 and ends at 864. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [858.0] and does not return any value..
pytorch_ao
public
public
0
0
dequantize
def dequantize(value: torch.Tensor, nf4: torch.Tensor) -> torch.Tensor:"""Dequantize a nf4 value to bfloat16 format"""# return nf4.index_select(0, value)return nf4[value]
1
2
2
25
0
867
870
867
null
[]
None
null
0
0
0
null
0
null
The function (dequantize) defined within the public class called public.The function start at line 867 and ends at 870. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [867.0] and does not return any value..
pytorch_ao
public
public
0
0
__repr__
def __repr__(self) -> str:return f"Quantized Data: {self.quantized_data}\nScalers: {self.quantized_scalers}\n"
1
2
1
10
0
872
873
872
null
[]
None
null
0
0
0
null
0
null
The function (__repr__) defined within the public class called public.The function start at line 872 and ends at 873. 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
__str__
def __str__(self) -> str:return f"NF4Tensor({self.shape}, {self.block_size})"
1
2
1
10
0
875
876
875
null
[]
None
null
0
0
0
null
0
null
The function (__str__) defined within the public class called public.The function start at line 875 and ends at 876. It contains 2 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
__tensor_flatten__
def __tensor_flatten__(self):tensor_meta = SubclassTensorArgs(self.shape,self.stride(),self.storage_offset(),self.dtype,self.device,self.requires_grad,)ctx = {"block_size": self.block_size,"n_blocks": self.n_blocks,"scaler_block_size": self.scaler_block_size,"tensor_meta": tensor_meta,}return ["quantized_data","scaler_...
1
22
1
79
0
878
899
878
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 878 and ends at 899. It contains 22 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__(inner_tensors: Dict, metadata, outer_size, outer_stride):assert len(inner_tensors) == 5, "Expected 5 inner tensors"return NF4Tensor(metadata["tensor_meta"],metadata["block_size"],metadata["n_blocks"],metadata["scaler_block_size"],inner_tensors["quantized_scalers"],inner_tensors["quantization_fa...
1
13
4
71
0
902
914
902
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 902 and ends at 914. It contains 13 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [902.0] and does not return any value..
pytorch_ao
public
public
0
0
__torch_dispatch__.allowed_subclasses
def allowed_subclasses(type):return (issubclass(cls, type)or issubclass(torch._subclasses.fake_tensor.FakeTensor, type)or issubclass(torch._subclasses.functional_tensor.FunctionalTensor, type))
3
8
1
40
0
926
933
926
null
[]
None
null
0
0
0
null
0
null
The function (__torch_dispatch__.allowed_subclasses) defined within the public class called public.The function start at line 926 and ends at 933. 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
__torch_dispatch__
def __torch_dispatch__(cls, func, types, args, kwargs=None):"""TODO we are not supporting torch dispatch at the momentinstead we have created a Autograd.Function to handle the linear"""# All ops in theNF4_OPS_TABLE expect NF4 Tensors as inputs# And don't support mixed tensor subclasses. This will trigger the handler fo...
4
9
5
60
0
918
942
918
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 918 and ends at 942. It contains 9 lines of code and it has a cyclomatic complexity of 4. It takes 5 parameters, represented as [918.0] and does not return any value..
pytorch_ao
public
public
0
0
__torch_function__
def __torch_function__(cls, func, types, args=(), kwargs=None):if kwargs is None:kwargs = {}try:if func in NF4_TORCH_FUNCTIONS:return NF4_TORCH_FUNCTIONS[func](*args, **kwargs)except NotImplementedError:passwith torch._C.DisableTorchFunctionSubclass():return func(*args, **kwargs)
4
10
4
68
0
947
958
947
null
[]
None
null
0
0
0
null
0
null
The function (__torch_function__) defined within the public class called public.The function start at line 947 and ends at 958. It contains 10 lines of code and it has a cyclomatic complexity of 4. It takes 4 parameters, represented as [947.0] and does not return any value..
pytorch_ao
public
public
0
0
fsdp_pre_all_gather
def fsdp_pre_all_gather(self, mesh: DeviceMesh) -> Tuple[Tuple[torch.Tensor, ...], Any]:return (self.quantized_scalers,self.quantization_factor,self.quantized_data,), (SubclassTensorArgs(self.size(),self.stride(),self.storage_offset(),self.dtype,self.device,self.requires_grad,),self.block_size,self.n_blocks,self.scaler...
1
23
2
105
0
960
982
960
null
[]
None
null
0
0
0
null
0
null
The function (fsdp_pre_all_gather) defined within the public class called public.The function start at line 960 and ends at 982. It contains 23 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [960.0] and does not return any value..
pytorch_ao
public
public
0
0
fsdp_post_all_gather
def fsdp_post_all_gather(self,all_gather_outputs: Tuple[torch.Tensor, ...],metadata: Any,param_dtype: torch.dtype,*,out: Optional[torch.Tensor] = None,) -> Union[Tuple[torch.Tensor, Tuple[torch.Tensor, ...]], None]:(quantized_scalers, quantization_factor, quantized_data) = all_gather_outputs(tensor_meta,block_size,n_bl...
5
48
5
255
0
984
1,034
984
null
[]
None
null
0
0
0
null
0
null
The function (fsdp_post_all_gather) defined within the public class called public.The function start at line 984 and ends at 1034. It contains 48 lines of code and it has a cyclomatic complexity of 5. It takes 5 parameters, represented as [984.0] and does not return any value..
pytorch_ao
public
public
0
0
forward
def forward(ctx, input: torch.Tensor, weight: NF4Tensor):"""Save the quantized nf4 weight for backward pass"""ctx.save_for_backward(weight)return F.linear(input, weight.to(input.dtype))
1
3
3
38
0
1,039
1,042
1,039
null
[]
None
null
0
0
0
null
0
null
The function (forward) defined within the public class called public.The function start at line 1039 and ends at 1042. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [1039.0] and does not return any value..
pytorch_ao
public
public
0
0
backward
def backward(ctx, grad_output):"""The nf4 weight will never require grad so we can just return the grad_output @ weight.to(grad_output.dtype)"""weight: NF4Tensor = ctx.saved_tensors[0]return grad_output @ weight.to(grad_output.dtype), None
1
3
2
31
0
1,045
1,048
1,045
null
[]
None
null
0
0
0
null
0
null
The function (backward) defined within the public class called public.The function start at line 1045 and ends at 1048. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [1045.0] and does not return any value..
pytorch_ao
public
public
0
0
linear_nf4
def linear_nf4(input: torch.Tensor, weight: NF4Tensor) -> torch.Tensor:"""Apply a linear operation with the NF4Tensor weightArgs:input: Input tensorweight: NF4Tensor weight"""return LinearNF4.apply(input, weight)
1
2
2
27
0
1,051
1,058
1,051
null
[]
None
null
0
0
0
null
0
null
The function (linear_nf4) defined within the public class called public.The function start at line 1051 and ends at 1058. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [1051.0] and does not return any value..
pytorch_ao
public
public
0
0
to_nf4
def to_nf4(tensor, block_size: int = 64, scaler_block_size: int = 256):"""Convert a given tensor to normalized float 4-bit tensor."""return NF4Tensor.from_tensor(tensor, block_size, scaler_block_size)
1
2
3
29
0
1,061
1,063
1,061
null
[]
None
null
0
0
0
null
0
null
The function (to_nf4) defined within the public class called public.The function start at line 1061 and ends at 1063. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [1061.0] and does not return any value..
pytorch_ao
public
public
0
0
implements_torch_function.decorator
def decorator(func):functools.update_wrapper(func, torch_function)NF4_TORCH_FUNCTIONS[torch_function] = funcreturn func
1
4
1
21
0
1,070
1,073
1,070
null
[]
None
null
0
0
0
null
0
null
The function (implements_torch_function.decorator) defined within the public class called public.The function start at line 1070 and ends at 1073. 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
implements_torch_function
def implements_torch_function(torch_function):def decorator(func):functools.update_wrapper(func, torch_function)NF4_TORCH_FUNCTIONS[torch_function] = funcreturn funcreturn decorator
1
3
1
9
0
1,069
1,075
1,069
null
[]
None
null
0
0
0
null
0
null
The function (implements_torch_function) defined within the public class called public.The function start at line 1069 and ends at 1075. 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
function_to_dtype
def function_to_dtype(*args, **kwargs):tensor = args[0]device, dtype, non_blocking, convert_to_format = torch._C._nn._parse_to(*args[1:], **kwargs)# dtype is specified -> dequantizeif dtype is not None:return tensor.get_original_weight().to(device, dtype, non_blocking, memory_format=convert_to_format)# dtype is not spe...
3
17
2
126
3
1,079
1,099
1,079
null
['inner_tensor', 'updated_attrs', 'tensor']
None
null
0
0
0
null
0
null
The function (function_to_dtype) defined within the public class called public.The function start at line 1079 and ends at 1099. It contains 17 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [1079.0] and does not return any value..
pytorch_ao
public
public
0
0
function_cpu
def function_cpu(*args, **kwargs):# Tensor.cpu(self, memory_format)return args[0].to("cpu", *args[1:], **kwargs)
1
2
2
29
0
1,103
1,105
1,103
null
[]
None
null
0
0
0
null
0
null
The function (function_cpu) defined within the public class called public.The function start at line 1103 and ends at 1105. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [1103.0] and does not return any value..
pytorch_ao
public
public
0
0
function_cuda
def function_cuda(*args, **kwargs):# Tensor.cuda(self, device, non_blocking, memory_format)tensor = args[0]updated_attrs = dict()tensor_attrs, _ = tensor.__tensor_flatten__()for attr in tensor_attrs:inner_tensor = getattr(tensor, attr)updated_attrs[attr] = inner_tensor.cuda(*args[1:], **kwargs)updated_attrs["device"] =...
2
9
2
86
3
1,109
1,118
1,109
null
['inner_tensor', 'updated_attrs', 'tensor']
None
null
0
0
0
null
0
null
The function (function_cuda) defined within the public class called public.The function start at line 1109 and ends at 1118. It contains 9 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [1109.0] and does not return any value..
pytorch_ao
public
public
0
0
_
def _(*args, **kwargs):input = args[0]weight = args[1]bias = args[2] if len(args) > 2 else Noneout = LinearNF4.apply(input, weight)if bias is not None:out = out + biasreturn out
3
8
2
59
4
1,122
1,129
1,122
null
['out', 'input', 'weight', 'bias']
None
null
0
0
0
null
0
null
The function (_) defined within the public class called public.The function start at line 1122 and ends at 1129. It contains 8 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [1122.0] and does not return any value..
pytorch_ao
public
public
0
0
nf4_constructor
def nf4_constructor(tensor_meta: SubclassTensorArgs,block_size: int,n_blocks: int,scaler_block_size: int,quantized_scalers: torch.Tensor,quantization_factor: torch.Tensor,scaler_mean: torch.Tensor,quantized_data: torch.Tensor,nf4: torch.Tensor,):return NF4Tensor(tensor_meta,block_size,n_blocks,scaler_block_size,quantiz...
1
22
9
72
0
1,133
1,154
1,133
null
[]
None
null
0
0
0
null
0
null
The function (nf4_constructor) defined within the public class called public.The function start at line 1133 and ends at 1154. It contains 22 lines of code and it has a cyclomatic complexity of 1. It takes 9 parameters, represented as [1133.0] and does not return any value..
pytorch_ao
public
public
0
0
pre_process
def pre_process(self, input: torch.Tensor) -> torch.Tensor:return input
1
2
2
17
0
44
45
44
null
[]
None
null
0
0
0
null
0
null
The function (pre_process) defined within the public class called public.The function start at line 44 and ends at 45. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [44.0] and does not return any value..
pytorch_ao
public
public
0
0
post_process
def post_process(self,input: torch.Tensor,scale: torch.Tensor,zero_point: torch.Tensor,block_size: Tuple[int, ...],) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:return input, scale, zero_point
1
8
5
54
0
47
54
47
null
[]
None
null
0
0
0
null
0
null
The function (post_process) defined within the public class called public.The function start at line 47 and ends at 54. It contains 8 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [47.0] and does not return any value..
pytorch_ao
public
public
0
0
pre_process_static
def pre_process_static(self,input: torch.Tensor,scale: torch.Tensor,zero_point: torch.Tensor,block_size: Tuple[int, ...],) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:return self.pre_process(input), scale, zero_point
1
8
5
59
0
56
63
56
null
[]
None
null
0
0
0
null
0
null
The function (pre_process_static) defined within the public class called public.The function start at line 56 and ends at 63. It contains 8 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [56.0] and does not return any value..
pytorch_ao
public
public
0
0
__repr__
def __repr__(self):return f"{self.__class__.__name__}({self.extra_repr()})"
1
2
1
8
0
65
66
65
null
[]
None
null
0
0
0
null
0
null
The function (__repr__) defined within the public class called public.The function start at line 65 and ends at 66. 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
extra_repr
def extra_repr(self) -> str:return ""
1
2
1
9
0
68
69
68
null
[]
None
null
0
0
0
null
0
null
The function (extra_repr) defined within the public class called public.The function start at line 68 and ends at 69. It contains 2 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
__post_init__
def __post_init__(self):torch._C._log_api_usage_once(str(type(self)))
1
2
1
19
0
71
72
71
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 71 and ends at 72. It contains 2 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
is_device
def is_device(target_device_str: str, device: Union[str, torch.device]):return torch.device(device).type == target_device_str
1
2
2
29
0
85
86
85
null
[]
None
null
0
0
0
null
0
null
The function (is_device) defined within the public class called public.The function start at line 85 and ends at 86. It contains 2 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [85.0] and does not return any value..
pytorch_ao
public
public
0
0
get_out_shape
def get_out_shape(input_shape: Tuple[int], weight_shape: Tuple[int]) -> Tuple[int, int]:"""Returns the unflattened shape of the input tensor.Args:input_shape: The input tensor shape possibly more than 2 dimensionsweight_shape: The weight tensor shape.Returns:The unflattened shape of the input tensor."""out_dim = weight...
1
4
2
46
2
89
99
89
null
['inpt_dims', 'out_dim']
None
null
0
0
0
null
0
null
The function (get_out_shape) defined within the public class called public.The function start at line 89 and ends at 99. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [89.0] and does not return any value..
pytorch_ao
public
public
0
0
get_plain
def get_plain(self) -> Tuple[torch.Tensor, torch.Tensor, Optional[torch.Tensor]]:"""Get the plain (unpacked) Tensor for the tensor implReturns data, scale and zero_pointCan be overwritten if other types of AQTTensorImpl has different numbers of plain tensors"""pass
1
2
1
25
0
113
119
113
null
[]
None
null
0
0
0
null
0
null
The function (get_plain) defined within the public class called public.The function start at line 113 and ends at 119. 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_layout
def get_layout(self) -> Layout:pass
1
2
1
8
0
121
122
121
null
[]
None
null
0
0
0
null
0
null
The function (get_layout) defined within the public class called public.The function start at line 121 and ends at 122. It contains 2 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
from_plain
def from_plain(cls,data: torch.Tensor,scale: torch.Tensor,zero_point: Optional[torch.Tensor],_layout: Layout,):"""Construct a TensorImpl from data, scale, zero_point and the _layout"""pass
1
8
5
33
0
125
133
125
null
[]
None
null
0
0
0
null
0
null
The function (from_plain) defined within the public class called public.The function start at line 125 and ends at 133. It contains 8 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [125.0] and does not return any value..
pytorch_ao
public
public
0
0
__repr__
def __repr__(self):data, scale, zero_point = self.get_plain()_layout = self.get_layout()return f"{self.__class__.__name__}(data={str(data)}... , scale={str(scale)}... , zero_point={str(zero_point)}... , _layout={_layout})"
1
4
1
26
0
135
138
135
null
[]
None
null
0
0
0
null
0
null
The function (__repr__) defined within the public class called public.The function start at line 135 and ends at 138. 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
_same_metadata
def _same_metadata(self: "CutlassSemiSparseTensorImpl", src: "CutlassSemiSparseTensorImpl") -> bool:return (isinstance(self, CutlassSemiSparseTensorImpl)and isinstance(src, CutlassSemiSparseTensorImpl)and self.shape == src.shapeand self.sparse.shape == src.sparse.shapeand self.meta.shape == src.meta.shapeand self.scale...
7
12
2
87
0
27
38
27
null
[]
None
null
0
0
0
null
0
null
The function (_same_metadata) defined within the public class called public.The function start at line 27 and ends at 38. It contains 12 lines of code and it has a cyclomatic complexity of 7. It takes 2 parameters, represented as [27.0] and does not return any value..
pytorch_ao
public
public
0
0
pre_process
def pre_process(self, dense: torch.Tensor) -> torch.Tensor:# prune to 2:4 if not alreadyfrom torchao.sparsity.utils import mask_creatorreturn dense * mask_creator(dense).bool()
1
3
2
34
0
45
49
45
null
[]
None
null
0
0
0
null
0
null
The function (pre_process) defined within the public class called public.The function start at line 45 and ends at 49. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [45.0] and does not return any value..
pytorch_ao
public
public
0
0
__new__
def __new__(cls,sparse: torch.Tensor,meta: torch.Tensor,scale: torch.Tensor,_layout: Layout,):kwargs = {}kwargs["device"] = sparse.devicekwargs["layout"] = (kwargs.get("layout") if kwargs.get("layout", False) else sparse.layout)kwargs["dtype"] = sparse.dtypekwargs["requires_grad"] = Falseshape = (sparse.shape[0], 2 * s...
2
16
5
114
0
55
70
55
null
[]
None
null
0
0
0
null
0
null
The function (__new__) defined within the public class called public.The function start at line 55 and ends at 70. It contains 16 lines of code and it has a cyclomatic complexity of 2. It takes 5 parameters, represented as [55.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self,sparse: torch.Tensor,meta: torch.Tensor,scale: torch.Tensor,_layout: Layout,):self.sparse = sparseself.meta = metaself.scale = scaleself._layout = _layout
1
11
5
48
0
72
82
72
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 72 and ends at 82. It contains 11 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
__torch_dispatch__
def __torch_dispatch__(cls, func, types, args, kwargs):kwargs = {} if kwargs is None else kwargsif func is aten.detach.default:return return_and_correct_aliasing(func, args, kwargs, args[0]._apply_fn_to_data(torch.detach))elif func is aten.copy_.default:self = args[0]src = args[1]if _same_metadata(self, src):self_tenso...
8
32
5
230
0
85
118
85
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 85 and ends at 118. It contains 32 lines of code and it has a cyclomatic complexity of 8. It takes 5 parameters, represented as [85.0] and does not return any value..
pytorch_ao
public
public
0
0
__tensor_flatten__
def __tensor_flatten__(self):return ["sparse", "meta", "scale"], [self._layout]
1
2
1
19
0
120
121
120
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 120 and ends at 121. It contains 2 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
__tensor_unflatten__
def __tensor_unflatten__(cls, tensor_data_dict, tensor_attributes, outer_size, outer_stride):sparse = tensor_data_dict["sparse"]meta = tensor_data_dict["meta"]scale = tensor_data_dict["scale"](_layout,) = tensor_attributesreturn cls(sparse, meta, scale, _layout)
1
8
5
48
0
124
131
124
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 124 and ends at 131. It contains 8 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [124.0] and does not return any value..
pytorch_ao
public
public
0
0
get_plain
def get_plain(self):# No support in CUTLASS to convert back to dense from sparse# semi-structured format, so multiplying with identity matrix,# and using identity scale factors, for the conversion.cols = self.shape[1]plain_input = torch.eye(cols, device=self.sparse.device)input = plain_input.to(dtype=self.sparse.dtype)...
1
22
1
139
0
133
159
133
null
[]
None
null
0
0
0
null
0
null
The function (get_plain) defined within the public class called public.The function start at line 133 and ends at 159. It contains 22 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
from_plain
def from_plain(cls,dense: torch.Tensor,scale: torch.Tensor,zero_point: Optional[torch.Tensor],_layout: Layout,):assert zero_point is None or torch.all(zero_point == 0)sparse, meta = to_sparse_semi_structured_cutlass_sm9x_f8(dense)return cls(sparse,meta,scale,_layout,)
2
15
5
64
0
162
178
162
null
[]
None
null
0
0
0
null
0
null
The function (from_plain) defined within the public class called public.The function start at line 162 and ends at 178. It contains 15 lines of code and it has a cyclomatic complexity of 2. It takes 5 parameters, represented as [162.0] and does not return any value..
pytorch_ao
public
public
0
0
get_layout
def get_layout(self) -> Layout:return self._layout
1
2
1
11
0
180
181
180
null
[]
None
null
0
0
0
null
0
null
The function (get_layout) defined within the public class called public.The function start at line 180 and ends at 181. 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
_apply_fn_to_data
def _apply_fn_to_data(self, fn):self.sparse = fn(self.sparse)self.meta = fn(self.meta)self.scale = fn(self.scale)return self
1
5
2
39
0
183
187
183
null
[]
None
null
0
0
0
null
0
null
The function (_apply_fn_to_data) defined within the public class called public.The function start at line 183 and ends at 187. It contains 5 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [183.0] and does not return any value..
pytorch_ao
public
public
0
0
_linear_fp8_act_fp8_weight_sparse_cutlass_check
def _linear_fp8_act_fp8_weight_sparse_cutlass_check(input_tensor, weight_tensor, bias):from torchao.dtypes.floatx import Float8Layoutbase_check = (isinstance(input_tensor, AffineQuantizedTensor)and isinstance(input_tensor._layout, Float8Layout)and input_tensor.dtype in (torch.float16, torch.bfloat16)and len(input_tenso...
24
52
3
374
4
190
249
190
null
['base_check', 'extra_check', 'weight_tensor_squeezed', 'input_tensor_squeezed']
None
null
0
0
0
null
0
null
The function (_linear_fp8_act_fp8_weight_sparse_cutlass_check) defined within the public class called public.The function start at line 190 and ends at 249. It contains 52 lines of code and it has a cyclomatic complexity of 24. It takes 3 parameters, represented as [190.0] and does not return any value..
pytorch_ao
public
public
0
0
_linear_fp8_act_fp8_weight_sparse_cutlass_impl
def _linear_fp8_act_fp8_weight_sparse_cutlass_impl(input_tensor, weight_tensor, bias):from torchao.ops import rowwise_scaled_linear_sparse_cutlass_f8f8input = input_tensor.tensor_impl.float8_datainput_scale = input_tensor.tensor_impl.scaleweight = weight_tensor.tensor_impl.sparseweight_meta = weight_tensor.tensor_impl....
1
12
3
75
7
252
266
252
null
['out', 'input', 'weight_meta', 'input_scale', 'weight_scale', 'out_dtype', 'weight']
None
null
0
0
0
null
0
null
The function (_linear_fp8_act_fp8_weight_sparse_cutlass_impl) defined within the public class called public.The function start at line 252 and ends at 266. It contains 12 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [252.0] and does not return any value..
pytorch_ao
public
public
0
0
implements.decorator
def decorator(func):for op in aten_ops:FLOAT8_IMPL_OPS_TABLE[op] = funcreturn func
2
4
1
18
0
38
41
38
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 38 and ends at 41. 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: List[Any]):"""Register aten ops to the float8 op table"""def decorator(func):for op in aten_ops:FLOAT8_IMPL_OPS_TABLE[op] = funcreturn funcreturn decorator
1
3
1
15
0
35
43
35
null
[]
None
null
0
0
0
null
0
null
The function (implements) defined within the public class called public.The function start at line 35 and ends at 43. 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
_same_metadata
def _same_metadata(self: "Float8AQTTensorImpl", src: "Float8AQTTensorImpl") -> bool:# Special handling for transposed attributetransposed_match = (self.transposed == src.transposed) or (self.transposed is False and src.transposed is None)return (isinstance(self, Float8AQTTensorImpl)and isinstance(src, Float8AQTTensorIm...
9
13
2
102
1
46
59
46
null
['transposed_match']
None
null
0
0
0
null
0
null
The function (_same_metadata) defined within the public class called public.The function start at line 46 and ends at 59. It contains 13 lines of code and it has a cyclomatic complexity of 9. It takes 2 parameters, represented as [46.0] and does not return any value..
pytorch_ao
public
public
0
0
__new__
def __new__(cls,float8_data: torch.Tensor,scale: torch.Tensor,transposed: bool,_layout: Layout,):kwargs = {}kwargs["device"] = float8_data.devicekwargs["layout"] = (kwargs.get("layout") if kwargs.get("layout", False) else float8_data.layout)kwargs["dtype"] = float8_data.dtypekwargs["requires_grad"] = Falseshape = float...
2
16
5
97
0
89
104
89
null
[]
None
null
0
0
0
null
0
null
The function (__new__) defined within the public class called public.The function start at line 89 and ends at 104. It contains 16 lines of code and it has a cyclomatic complexity of 2. It takes 5 parameters, represented as [89.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self,float8_data: torch.Tensor,scale: torch.Tensor,transposed: bool,_layout: Layout,):warnings.warn("Models quantized with version 1 of Float8DynamicActivationFloat8WeightConfig is deprecated and will no longer be supported in a future release, please upgrade torchao and quantize again, or download a newer...
1
14
5
52
0
106
119
106
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 106 and ends at 119. It contains 14 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [106.0] and does not return any value..
pytorch_ao
public
public
0
0
_apply_fn_to_data
def _apply_fn_to_data(self, fn):"""Applys a fn to all tensor components stored on this class"""global _fallback_warning_showntry:return self.__class__(fn(self.float8_data),fn(self.scale),self.transposed,self._layout,)except RuntimeError as e:if '"index_cuda" not implemented for ' in str(e):if not _fallback_warning_show...
4
27
2
122
0
121
151
121
null
[]
None
null
0
0
0
null
0
null
The function (_apply_fn_to_data) defined within the public class called public.The function start at line 121 and ends at 151. It contains 27 lines of code and it has a cyclomatic complexity of 4. It takes 2 parameters, represented as [121.0] and does not return any value..
pytorch_ao
public
public
0
0
to
def to(self, *args, **kwargs):kwargs = self._get_to_kwargs(*args, **kwargs)return self.__class__(self.float8_data.to(kwargs["device"]),self.scale.to(kwargs["device"]),self.transposed,self._layout,)
1
8
3
61
0
153
160
153
null
[]
None
null
0
0
0
null
0
null
The function (to) defined within the public class called public.The function start at line 153 and ends at 160. It contains 8 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [153.0] and does not return any value..
pytorch_ao
public
public
0
0
__tensor_flatten__
def __tensor_flatten__(self):return ["float8_data", "scale"], [self.transposed, self._layout]
1
2
1
21
0
162
163
162
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 162 and ends at 163. It contains 2 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
__tensor_unflatten__
def __tensor_unflatten__(cls, tensor_data_dict, tensor_attributes, outer_size, outer_stride):float8_data, scale = tensor_data_dict["float8_data"], tensor_data_dict["scale"](transposed,_layout,) = tensor_attributesreturn cls(float8_data, scale, transposed, _layout)
1
9
5
45
0
166
174
166
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 166 and ends at 174. It contains 9 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [166.0] and does not return any value..
pytorch_ao
public
public
0
0
__torch_dispatch__.allowed_subclasses
def allowed_subclasses(type):return (issubclass(cls, type)or issubclass(torch._subclasses.fake_tensor.FakeTensor, type)or issubclass(torch._subclasses.functional_tensor.FunctionalTensor, type))
3
8
1
40
0
180
187
180
null
[]
None
null
0
0
0
null
0
null
The function (__torch_dispatch__.allowed_subclasses) defined within the public class called public.The function start at line 180 and ends at 187. 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
__torch_dispatch__
def __torch_dispatch__(cls, func, types, args, kwargs):kwargs = {} if kwargs is None else kwargsdef allowed_subclasses(type):return (issubclass(cls, type)or issubclass(torch._subclasses.fake_tensor.FakeTensor, type)or issubclass(torch._subclasses.functional_tensor.FunctionalTensor, type))if not all(allowed_subclasses(t...
5
8
5
66
0
177
195
177
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 177 and ends at 195. It contains 8 lines of code and it has a cyclomatic complexity of 5. It takes 5 parameters, represented as [177.0] and does not return any value..
pytorch_ao
public
public
0
0
get_plain
def get_plain(self) -> Tuple[torch.Tensor, torch.Tensor, Optional[torch.Tensor]]:return self.float8_data, self.scale, None
1
2
1
33
0
199
200
199
null
[]
None
null
0
0
0
null
0
null
The function (get_plain) defined within the public class called public.The function start at line 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_layout
def get_layout(self) -> Layout:return self._layout
1
2
1
11
0
202
203
202
null
[]
None
null
0
0
0
null
0
null
The function (get_layout) defined within the public class called public.The function start at line 202 and ends at 203. It contains 2 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
from_plain
def from_plain(cls,data: torch.Tensor,scale: torch.Tensor,zero_point: Optional[torch.Tensor],_layout: Layout,):"""Main entrypoint for constructing Float8TensorImpl"""assert _is_float8_type(data.dtype), (f"Float8 TensorImpl must be constructed from float8 dtype but got {data.dtype}")assert isinstance(_layout, Float8Layo...
1
14
5
67
0
206
220
206
null
[]
None
null
0
0
0
null
0
null
The function (from_plain) defined within the public class called public.The function start at line 206 and ends at 220. It contains 14 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [206.0] and does not return any value..
pytorch_ao
public
public
0
0
__repr__
def __repr__(self):float8_data, scale, _ = self.get_plain()_layout = self.get_layout()return (f"{self.__class__.__name__}(\n"f"float8_data={float8_data},\n"f"scale={scale},\n"f"transposed={self.transposed}, "f"_layout={_layout})")
1
10
1
36
0
222
231
222
null
[]
None
null
0
0
0
null
0
null
The function (__repr__) defined within the public class called public.The function start at line 222 and ends at 231. 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
_
def _(func, types, args, kwargs):return return_and_correct_aliasing(func, args, kwargs, args[0]._apply_fn_to_data(func))
1
4
4
30
0
240
243
240
null
[]
None
null
0
0
0
null
0
null
The function (_) defined within the public class called public.The function start at line 240 and ends at 243. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [240.0] and does not return any value..
pytorch_ao
public
public
0
0
_
def _(func, types, args, kwargs):"""we don't need to repack the weight and just rely on externalshape being changed and record the status of transpose/no-transpose"""args[0].transposed = not args[0].transposedreturn return_and_correct_aliasing(func, args, kwargs, args[0])
1
3
4
40
0
247
252
247
null
[]
None
null
0
0
0
null
0
null
The function (_) defined within the public class called public.The function start at line 247 and ends at 252. It contains 3 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [247.0] and does not return any value..
pytorch_ao
public
public
0
0
_
def _(func, types, args, kwargs):self = args[0]src = args[1]if _same_metadata(self, src):self_tensors = self.__tensor_flatten__()[0]for tensor_name in self_tensors:getattr(self, tensor_name).copy_(getattr(src, tensor_name))returnraise ValueError(f"Not supported args for copy_ due to metadata mismatch: {args[0], args[1]...
3
11
4
69
3
256
266
256
null
['self_tensors', 'src', 'self']
None
null
0
0
0
null
0
null
The function (_) defined within the public class called public.The function start at line 256 and ends at 266. It contains 11 lines of code and it has a cyclomatic complexity of 3. It takes 4 parameters, represented as [256.0] and does not return any value..
pytorch_ao
public
public
0
0
_
def _(func, types, args, kwargs):return return_and_correct_aliasing(func,args,kwargs,args[0]._apply_fn_to_data(lambda x: func(x, *args[1:], **kwargs)),)
1
7
4
47
0
270
276
270
null
[]
None
null
0
0
0
null
0
null
The function (_) defined within the public class called public.The function start at line 270 and ends at 276. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [270.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])# Always slice the float8_datasliced_data = aten.slice.Tensor(self.float8_data, dim, start, end, step)if self.scale.numel() == 1:# Per-tensor quantization - scale doesn't changesliced_scale = self.scaleelse:# Block-...
2
20
4
123
2
280
305
280
null
['sliced_data', 'sliced_scale']
None
null
0
0
0
null
0
null
The function (_) defined within the public class called public.The function start at line 280 and ends at 305. It contains 20 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [280.0] and does not return any value..
pytorch_ao
public
public
0
0
_linear_fp8_act_fp8_weight_check.check_aqt
def check_aqt(aqt: Union[torch.Tensor, AffineQuantizedTensor]) -> bool:return (isinstance(aqt, AffineQuantizedTensor)and isinstance(aqt._layout, Float8Layout)and _is_float8_type(aqt.tensor_impl.dtype)and (aqt.shape == aqt.block_size or _is_rowwise_scaled(aqt)))
5
7
1
58
0
318
324
318
null
[]
None
null
0
0
0
null
0
null
The function (_linear_fp8_act_fp8_weight_check.check_aqt) defined within the public class called public.The function start at line 318 and ends at 324. It contains 7 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
_linear_fp8_act_fp8_weight_check
def _linear_fp8_act_fp8_weight_check(input_tensor: Union[torch.Tensor, "AffineQuantizedTensor"],weight_tensor: Union[torch.Tensor, "AffineQuantizedTensor"],bias: Optional[torch.Tensor],) -> bool:def check_aqt(aqt: Union[torch.Tensor, AffineQuantizedTensor]) -> bool:return (isinstance(aqt, AffineQuantizedTensor)and isin...
2
7
3
49
0
313
326
313
null
[]
None
null
0
0
0
null
0
null
The function (_linear_fp8_act_fp8_weight_check) defined within the public class called public.The function start at line 313 and ends at 326. It contains 7 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [313.0] and does not return any value..
pytorch_ao
public
public
0
0
_linear_fp8_act_fp8_weight_impl
def _linear_fp8_act_fp8_weight_impl(input_tensor: "AffineQuantizedTensor",weight_tensor: "AffineQuantizedTensor",bias: Optional[torch.Tensor],):"""Implements matmul between FP8 input and FP8 weight with compute using _scaled_mm"""scaled_mm_config = weight_tensor._layout.mm_configassert scaled_mm_config is not Noneasser...
2
31
3
185
6
329
367
329
null
['w_data', 'scaled_mm_config', 'out_shape', 'inpt_data', 'w_scale', 'input_scale']
None
null
0
0
0
null
0
null
The function (_linear_fp8_act_fp8_weight_impl) defined within the public class called public.The function start at line 329 and ends at 367. It contains 31 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [329.0] and does not return any value..
pytorch_ao
public
public
0
0
_linear_fp_act_fp8_weight_check
def _linear_fp_act_fp8_weight_check(input_tensor: Union[torch.Tensor, "AffineQuantizedTensor"],weight_tensor: Union[torch.Tensor, "AffineQuantizedTensor"],bias: Optional[torch.Tensor],) -> bool:return (# input is native float tensornot is_traceable_wrapper_subclass(input_tensor)and input_tensor.is_floating_point()and# ...
7
17
3
91
0
370
388
370
null
[]
None
null
0
0
0
null
0
null
The function (_linear_fp_act_fp8_weight_check) defined within the public class called public.The function start at line 370 and ends at 388. It contains 17 lines of code and it has a cyclomatic complexity of 7. It takes 3 parameters, represented as [370.0] and does not return any value..
pytorch_ao
public
public
0
0
_linear_fp_act_fp8_weight_impl
def _linear_fp_act_fp8_weight_impl(input_tensor: torch.Tensor,weight_tensor: "AffineQuantizedTensor",bias: Optional[torch.Tensor],):return torch.nn.functional.linear(input_tensor, weight_tensor.dequantize(), bias)
1
6
3
42
0
391
396
391
null
[]
None
null
0
0
0
null
0
null
The function (_linear_fp_act_fp8_weight_impl) defined within the public class called public.The function start at line 391 and ends at 396. It contains 6 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [391.0] and does not return any value..
pytorch_ao
public
public
0
0
_pack
def _pack(x: Tensor, n_bits: int) -> Tensor:return reduce(torch.bitwise_or,[x[..., i :: (8 // n_bits)] << (8 - (i + 1) * n_bits)for i in range(8 // n_bits)],)
2
8
2
40
0
35
42
35
null
[]
None
null
0
0
0
null
0
null
The function (_pack) defined within the public class called public.The function start at line 35 and ends at 42. It contains 8 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
_unpack
def _unpack(x: Tensor, n_bits: int) -> Tensor:return torch.stack([(x >> (8 - (i + 1) * n_bits)) & ((1 << n_bits) - 1)for i in range(8 // n_bits)],dim=-1,).flatten(-2)
2
8
2
67
0
45
52
45
null
[]
None
null
0
0
0
null
0
null
The function (_unpack) defined within the public class called public.The function start at line 45 and ends at 52. It contains 8 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [45.0] and does not return any value..
pytorch_ao
public
public
0
0
_bit_interleave
def _bit_interleave(x: Tensor, n_bits: int, undo: bool = False) -> Tensor:# the original code unpacks/packs the values from/to uint32 while we unpack/pack the values from/to uint8# thus, we need to reverse byte order within a uint32 word.x = x.reshape(-1, 4).flip(1)x = _unpack(x, n_bits)x = x.view(-1, 4 * (8 // n_bits)...
2
86
3
365
2
56
151
56
null
['x', 'bit_order']
None
null
0
0
0
null
0
null
The function (_bit_interleave) defined within the public class called public.The function start at line 56 and ends at 151. It contains 86 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [56.0] and does not return any value..
pytorch_ao
public
public
0
0
_pack_tc_floatx
def _pack_tc_floatx(tensor: Tensor, nbits: int) -> Tensor:assert tensor.ndim == 2, tensor.dtype == torch.uint8M, N = tensor.shapeassert (M % 64 == 0) and (N % 64 == 0)# Pass 1 from original codetensor = tensor.view(M // 64, 4, 2, 8, N // 16, 2, 8)tensor = tensor.permute(0, 4, 1, 5, 2, 3, 6)tensor = tensor.reshape(-1, 3...
4
25
2
236
5
156
186
156
null
['fragments', 'tensor', 'tensor_ybit', 'mask', 'used_bits']
None
null
0
0
0
null
0
null
The function (_pack_tc_floatx) defined within the public class called public.The function start at line 156 and ends at 186. It contains 25 lines of code and it has a cyclomatic complexity of 4. It takes 2 parameters, represented as [156.0] and does not return any value..
pytorch_ao
public
public
0
0
_pack_tc_fp6
def _pack_tc_fp6(tensor: Tensor) -> Tensor:assert tensor.ndim == 2, tensor.dtype == torch.uint8M, N = tensor.shapeassert (M % 64 == 0) and (N % 64 == 0)tensor = tensor.view(M // 64, 2, 2, 2, 8, N // 16, 2, 8)tensor = tensor.flip(3)tensor_2bit = (tensor >> 4) & 0b11tensor_2bit = tensor_2bit.permute(0, 5, 1, 4, 7, 3, 2, ...
2
13
1
168
3
190
206
190
null
['tensor_2bit', 'tensor', 'tensor_4bit']
None
null
0
0
0
null
0
null
The function (_pack_tc_fp6) defined within the public class called public.The function start at line 190 and ends at 206. 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
pack_tc_floatx
def pack_tc_floatx(tensor: Tensor, nbits: int) -> Tensor:if nbits == 6:return _pack_tc_fp6(tensor)return _pack_tc_floatx(tensor, nbits)
2
4
2
30
0
210
213
210
null
[]
None
null
0
0
0
null
0
null
The function (pack_tc_floatx) defined within the public class called public.The function start at line 210 and ends at 213. It contains 4 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [210.0] and does not return any value..
pytorch_ao
public
public
0
0
to_scaled_tc_floatx
def to_scaled_tc_floatx(tensor: Tensor, ebits: int, mbits: int) -> Tuple[Tensor, Tensor]:# _n_ones() is not compatible with torch.compile() due to << operator# https://github.com/pytorch/pytorch/issues/119152# exp_bias = _n_ones(ebits - 1)# max_normal = 2 ** (_n_ones(ebits) - exp_bias) * (_n_ones(mbits + 1) / (2 ** mbi...
1
13
3
133
7
216
235
216
null
['tensor', 'tensor_tc_floatx', 'tensor_floatx', 'exp_bias', 'scale', 'dtype', 'max_normal']
None
null
0
0
0
null
0
null
The function (to_scaled_tc_floatx) defined within the public class called public.The function start at line 216 and ends at 235. It contains 13 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [216.0] and does not return any value..
pytorch_ao
public
public
0
0
_unpack_tc_floatx
def _unpack_tc_floatx(tensor: Tensor, nbits: int) -> Tensor:assert tensor.ndim == 2 and tensor.dtype == torch.uint8M = tensor.shape[0]size = tensor.numel()tensor = tensor.flatten()offset = 0used_bits = 0tensor_floatx = Nonefor y in [1, 2, 4]:if nbits & y:size_ybit = size // nbits * ytensor_ybit = tensor[offset : offset...
5
29
2
235
8
239
274
239
null
['offset', 'tensor', 'tensor_floatx', 'size_ybit', 'tensor_ybit', 'used_bits', 'M', 'size']
None
null
0
0
0
null
0
null
The function (_unpack_tc_floatx) defined within the public class called public.The function start at line 239 and ends at 274. It contains 29 lines of code and it has a cyclomatic complexity of 5. It takes 2 parameters, represented as [239.0] and does not return any value..
pytorch_ao
public
public
0
0
_unpack_tc_fp6
def _unpack_tc_fp6(tensor: Tensor) -> Tensor:assert tensor.ndim == 2 and tensor.dtype == torch.uint8M = tensor.shape[0]N = tensor.shape[1] // 3 * 4assert (M % 64 == 0) and (N % 64 == 0)size_2bit = M * N // 4size_4bit = M * N // 2tensor = tensor.view(-1)assert tensor.numel() == size_2bit + size_4bittensor_2bit, tensor_4...
3
19
1
204
8
279
301
279
null
['size_2bit', 'tensor', 'tensor_fp6', 'N', 'size_4bit', 'tensor_2bit', 'M', 'tensor_4bit']
None
null
0
0
0
null
0
null
The function (_unpack_tc_fp6) defined within the public class called public.The function start at line 279 and ends at 301. It contains 19 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
unpack_tc_floatx
def unpack_tc_floatx(tensor: Tensor, nbits: int) -> Tensor:if nbits == 6:return _unpack_tc_fp6(tensor)return _unpack_tc_floatx(tensor, nbits)
2
4
2
30
0
304
307
304
null
[]
None
null
0
0
0
null
0
null
The function (unpack_tc_floatx) defined within the public class called public.The function start at line 304 and ends at 307. It contains 4 lines of code and it has a cyclomatic complexity of 2. It takes 2 parameters, represented as [304.0] and does not return any value..
pytorch_ao
public
public
0
0
from_scaled_tc_floatx
def from_scaled_tc_floatx(tensor: Tensor, ebits: int, mbits: int, scale=None) -> Tensor:floatx_unpacked = unpack_tc_floatx(tensor, 1 + ebits + mbits)tensor = _floatx_unpacked_to_f32(floatx_unpacked, ebits, mbits)if scale is not None:tensor = tensor * scale.float().view(-1, 1)return tensor
2
6
4
68
2
310
315
310
null
['tensor', 'floatx_unpacked']
None
null
0
0
0
null
0
null
The function (from_scaled_tc_floatx) defined within the public class called public.The function start at line 310 and ends at 315. It contains 6 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [310.0] and does not return any value..
pytorch_ao
public
public
0
0
__new__
def __new__(cls,packed_floatx_data: torch.Tensor,scale: torch.Tensor,_layout: Layout,):assert packed_floatx_data.ndim == 2assert packed_floatx_data.dtype == torch.uint8shape = (packed_floatx_data.shape[0],packed_floatx_data.shape[1] // (1 + _layout.ebits + _layout.mbits) * 8,)kwargs = {}kwargs["device"] = packed_floatx...
2
22
4
120
0
490
511
490
null
[]
None
null
0
0
0
null
0
null
The function (__new__) defined within the public class called public.The function start at line 490 and ends at 511. It contains 22 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [490.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self,packed_floatx_data: torch.Tensor,scale: torch.Tensor,_layout: Layout,):self.packed_floatx_data = packed_floatx_dataself.scale = scaleself._layout = _layout
1
9
4
37
0
513
521
513
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 513 and ends at 521. It contains 9 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [513.0] and does not return any value..