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
__tensor_flatten__
def __tensor_flatten__(self):return ["packed_floatx_data", "scale"], [self._layout]
1
2
1
17
0
523
524
523
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 523 and ends at 524. 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):packed_floatx_data, scale = (tensor_data_dict["packed_floatx_data"],tensor_data_dict["scale"],)(_layout,) = tensor_attributesreturn cls(packed_floatx_data, scale, _layout)
1
9
5
44
0
527
535
527
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 527 and ends at 535. It contains 9 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [527.0] and does not return any value..
pytorch_ao
public
public
0
0
get_plain
def get_plain(self) -> Tuple[torch.Tensor, torch.Tensor]:unpacked_floatx_data = unpack_tc_floatx(self.packed_floatx_data, 1 + self._layout.ebits + self._layout.mbits)return unpacked_floatx_data, self.scale
1
5
1
44
0
537
541
537
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 537 and ends at 541. It contains 5 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
from_plain
def from_plain(cls,unpacked_floatx_data: torch.Tensor,scale: torch.Tensor,zero_point: Optional[torch.Tensor],_layout: Layout,):"""Format for `unpacked_floatx_data` will be:zero padding bits | sign bit | exponent bits | mantissa bitsFor example for fp6_e3_m2, the format will be: `00SEEEMM`, where S is sign bit, E is exp...
1
12
5
64
0
544
562
544
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 544 and ends at 562. It contains 12 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [544.0] and does not return any value..
pytorch_ao
public
public
0
0
__repr__
def __repr__(self):unpacked_floatx_data, scale = self.get_plain()_layout = self.get_layout()return f"{self.__class__.__name__}(unpacked_floatx_data={unpacked_floatx_data}, scale={scale}, _layout={_layout})"
1
4
1
24
0
564
567
564
null
[]
None
null
0
0
0
null
0
null
The function (__repr__) defined within the public class called public.The function start at line 564 and ends at 567. 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
_apply_fn_to_data
def _apply_fn_to_data(self, fn):return self.__class__(fn(self.packed_floatx_data),fn(self.scale),self._layout,)
1
6
2
31
0
569
574
569
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 569 and ends at 574. It contains 6 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [569.0] and does not return any value..
pytorch_ao
public
public
0
0
to
def to(self, *args, **kwargs):kwargs = self._get_to_kwargs(*args, **kwargs)device = kwargs.pop("device")return self.__class__(self.packed_floatx_data.to(device),self.scale.to(device),self._layout,)
1
8
3
59
0
576
583
576
null
[]
None
null
0
0
0
null
0
null
The function (to) defined within the public class called public.The function start at line 576 and ends at 583. It contains 8 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [576.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.clone.default:return return_and_correct_aliasing(func, args, kwargs, args[0]._ap...
5
22
5
135
0
586
609
586
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 586 and ends at 609. It contains 22 lines of code and it has a cyclomatic complexity of 5. It takes 5 parameters, represented as [586.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
613
614
613
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 613 and ends at 614. 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
_linear_f16_bf16_act_floatx_weight_check
def _linear_f16_bf16_act_floatx_weight_check(input_tensor, weight_tensor, bias):from torchao.dtypes.floatx import FloatxTensorCoreLayoutreturn (# input is native float32 tensornot is_traceable_wrapper_subclass(input_tensor)and input_tensor.is_floating_point()and input_tensor.dtype in (torch.float16, torch.bfloat16)and#...
13
17
3
135
0
617
638
617
null
[]
None
null
0
0
0
null
0
null
The function (_linear_f16_bf16_act_floatx_weight_check) defined within the public class called public.The function start at line 617 and ends at 638. It contains 17 lines of code and it has a cyclomatic complexity of 13. It takes 3 parameters, represented as [617.0] and does not return any value..
pytorch_ao
public
public
0
0
_linear_f16_bf16_act_floatx_weight_impl
def _linear_f16_bf16_act_floatx_weight_impl(input_tensor, weight_tensor, bias):from torchao.ops import quant_llm_linearact = input_tensorweight = weight_tensorout_dim, in_dim = weight.shapeact_reshaped = act.view(-1, in_dim)# https://github.com/microsoft/DeepSpeed/blob/3a3a6db3332e339cc9fd94efd4982f6d60635a3d/deepspeed...
2
19
3
125
6
641
666
641
null
['out', 'splitK', 'bsize', 'act_reshaped', 'act', 'weight']
None
null
0
0
0
null
0
null
The function (_linear_f16_bf16_act_floatx_weight_impl) defined within the public class called public.The function start at line 641 and ends at 666. It contains 19 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [641.0] and does not return any value..
pytorch_ao
public
public
0
0
abs_lsh
def abs_lsh(data, shift):if shift == 0:return dataelif shift < 0:return data >> -shiftelse:return data << shift
3
7
2
32
0
52
58
52
null
[]
None
null
0
0
0
null
0
null
The function (abs_lsh) defined within the public class called public.The function start at line 52 and ends at 58. It contains 7 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [52.0] and does not return any value..
pytorch_ao
public
public
0
0
abs_rsh
def abs_rsh(data, shift):if shift == 0:return dataelif shift < 0:return data << -shiftelse:return data >> shift
3
7
2
32
0
62
68
62
null
[]
None
null
0
0
0
null
0
null
The function (abs_rsh) defined within the public class called public.The function start at line 62 and ends at 68. It contains 7 lines of code and it has a cyclomatic complexity of 3. It takes 2 parameters, represented as [62.0] and does not return any value..
pytorch_ao
public
public
0
0
pack_cpu
def pack_cpu(data: torch.Tensor, elem_size: int, dim: Optional[int] = -1) -> List[torch.Tensor]:"""Inputs:data: a tensor of sub byte elements in uint8elem_size: the size in bits of the elements to packdim: the dimension to pack alongReturns: a list of packed shards=======================================================...
3
23
3
221
9
71
141
71
null
['shard', 'output', 'slice_len', 'bit_slice', 'rel_pos', 'scale', 'output_shape', 'bits', 'bit_size']
None
null
0
0
0
null
0
null
The function (pack_cpu) defined within the public class called public.The function start at line 71 and ends at 141. It contains 23 lines of code and it has a cyclomatic complexity of 3. It takes 3 parameters, represented as [71.0] and does not return any value..
pytorch_ao
public
public
0
0
unpack_cpu
def unpack_cpu(data: List[torch.Tensor], elem_size: int, dim: Optional[int] = -1) -> torch.Tensor:"""Unpacks small dtype elements from a larger dtype.Inputs:data: - a list of packed shardselem_size: the size in bits of the elements to unpackdim: the dimension to unpack alongReturns: torch.Tensor - a tensor of the unpac...
3
18
3
187
8
144
175
144
null
['group', 'output', 'group_size', 'rel_pos', 'scale', 'output_shape', 'output_narrow', 'bit_size']
None
null
0
0
0
null
0
null
The function (unpack_cpu) defined within the public class called public.The function start at line 144 and ends at 175. It contains 18 lines of code and it has a cyclomatic complexity of 3. It takes 3 parameters, represented as [144.0] and does not return any value..
pytorch_ao
public
public
0
0
_pack
def _pack(data, elem_size, scale, dim):"""Inner for loop from above pack function"""packed_shape = list(data.shape)packed_shape[dim] = packed_shape[dim] // scalepacked = torch.zeros(packed_shape, dtype=data.dtype, device=data.device)for i in range(scale):narrow_slice = data.narrow(dim, data.shape[dim] * i // scale, dat...
2
10
4
88
3
181
196
181
null
['narrow_slice', 'packed', 'packed_shape']
None
null
0
0
0
null
0
null
The function (_pack) defined within the public class called public.The function start at line 181 and ends at 196. It contains 10 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [181.0] and does not return any value..
pytorch_ao
public
public
0
0
_unpack
def _unpack(data, element_size, scale, dim):"""Inner for loop from above unpack function"""unpacked_shape = list(data.shape)unpacked_shape[dim] *= scalenbits = (1 << element_size) - 1# mask for the last element_size bitsunpacked_data = torch.zeros(unpacked_shape, dtype=data.dtype, device=data.device)for i in range(scal...
2
13
4
107
4
199
218
199
null
['unpacked_data', 'shift_amt', 'unpacked_shape', 'nbits']
None
null
0
0
0
null
0
null
The function (_unpack) defined within the public class called public.The function start at line 199 and ends at 218. It contains 13 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [199.0] and does not return any value..
pytorch_ao
public
public
0
0
pack
def pack(data: torch.Tensor, elem_size: int, dim: Optional[int] = -1) -> List[torch.Tensor]:"""a less branching but more compute version so better for gpu"""torch._assert(data.shape[dim] % 8 == 0,f"pack dimension size ({data.shape[dim]}) is not divisble by scale",)torch._assert(data.dtype == torch.uint8, "data must be ...
3
24
3
143
2
221
247
221
null
['shards', 'container_size']
None
null
0
0
0
null
0
null
The function (pack) defined within the public class called public.The function start at line 221 and ends at 247. It contains 24 lines of code and it has a cyclomatic complexity of 3. It takes 3 parameters, represented as [221.0] and does not return any value..
pytorch_ao
public
public
0
0
unpack
def unpack(data: List[torch.Tensor], elem_size: int, dim: Optional[int] = 0) -> torch.Tensor:"""a less branching but more compute version so better for gpu"""container_size = 8# unpack each 4,2,1 bit shard and unshift them back to the correct positiondata = [_unpack(data[i], numbits[elem_size][i], container_size // num...
2
12
3
83
2
250
265
250
null
['data', 'container_size']
None
null
0
0
0
null
0
null
The function (unpack) defined within the public class called public.The function start at line 250 and ends at 265. It contains 12 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [250.0] and does not return any value..
pytorch_ao
public
public
0
0
__new__
def __new__(# noqa: PYI034cls,shape: torch.Size,bsr_crow_indices: Optional[torch.Tensor],bsr_col_indices: Optional[torch.Tensor],bsr_values: Optional[torch.Tensor],scale: Optional[torch.Tensor],zero_point: Optional[torch.Tensor],_layout: Layout,requires_grad: bool = False,):if bsr_values is None:raise ValueError("bsr v...
2
22
9
122
0
61
83
61
null
[]
None
null
0
0
0
null
0
null
The function (__new__) defined within the public class called public.The function start at line 61 and ends at 83. It contains 22 lines of code and it has a cyclomatic complexity of 2. It takes 9 parameters, represented as [61.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(# noqa: PYI034self,shape: torch.Size,bsr_crow_indices: Optional[torch.Tensor],bsr_col_indices: Optional[torch.Tensor],bsr_values: Optional[torch.Tensor],scale: Optional[torch.Tensor],zero_point: Optional[torch.Tensor],_layout: Layout,requires_grad: bool = False,):self.bsr_crow_indices = bsr_crow_indicessel...
1
17
9
97
0
85
101
85
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 85 and ends at 101. It contains 17 lines of code and it has a cyclomatic complexity of 1. It takes 9 parameters, represented as [85.0] and does not return any value..
pytorch_ao
public
public
0
0
__tensor_flatten__
def __tensor_flatten__(self):inner_tensors = list(filter(lambda x: getattr(self, x) is not None, self.__slots__))tensor_meta = (self.shape, self._layout, self.requires_grad)return inner_tensors, tensor_meta
1
6
1
48
0
103
108
103
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 103 and ends at 108. It contains 6 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
__tensor_unflatten__
def __tensor_unflatten__(cls,inner_tensors,tensor_meta: Tuple[torch.Size, bool],outer_size,outer_stride,) -> torch.Tensor:shape, _layout, requires_grad = tensor_metareturn cls(shape=shape,bsr_crow_indices=inner_tensors.get("bsr_crow_indices", None),bsr_col_indices=inner_tensors.get("bsr_col_indices", None),bsr_values=i...
1
18
5
105
0
111
128
111
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 111 and ends at 128. It contains 18 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [111.0] and does not return any value..
pytorch_ao
public
public
0
0
from_plain
def from_plain(cls, int_data, scale, zero_point, _layout):bsr_tensor = int_data.to_sparse_bsr(_layout.blocksize)return cls(shape=int_data.shape,bsr_crow_indices=bsr_tensor.crow_indices(),bsr_col_indices=bsr_tensor.col_indices(),bsr_values=bsr_tensor.values(),scale=scale,zero_point=zero_point,_layout=_layout,requires_gr...
1
12
5
73
0
131
142
131
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 131 and ends at 142. It contains 12 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [131.0] and does not return any value..
pytorch_ao
public
public
0
0
get_plain
def get_plain(self):int_data_expanded = torch.ops.blocksparse.bsr_to_dense(self.crow_indices(),self.col_indices(),self.values(),self.shape[0],self.shape[1],)return int_data_expanded, self.scale, self.zero_point
1
9
1
58
0
144
152
144
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 144 and ends at 152. 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
_apply_fn_to_data
def _apply_fn_to_data(self, func):return self.__class__(shape=self.shape,bsr_crow_indices=func(self.bsr_crow_indices),bsr_col_indices=func(self.bsr_col_indices),bsr_values=func(self.bsr_values),scale=self.scale,zero_point=self.zero_point,_layout=self._layout,requires_grad=self.requires_grad,)
1
11
2
70
0
154
164
154
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 154 and ends at 164. It contains 11 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [154.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))if func is aten.clone.default:return return_and_correct_aliasing(func, args, kwargs, args[0]._appl...
8
21
5
170
0
167
194
167
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 167 and ends at 194. It contains 21 lines of code and it has a cyclomatic complexity of 8. It takes 5 parameters, represented as [167.0] and does not return any value..
pytorch_ao
public
public
0
0
_linear_int8_act_int8_weight_block_sparse_check
def _linear_int8_act_int8_weight_block_sparse_check(input_tensor, weight_tensor, bias):return (isinstance(input_tensor, AffineQuantizedTensor)and _aqt_is_int8_reduced_range(input_tensor)and isinstance(weight_tensor, AffineQuantizedTensor)and weight_tensor.is_cudaand input_tensor.dtype == weight_tensor.dtypeand isinstan...
7
10
3
60
0
197
206
197
null
[]
None
null
0
0
0
null
0
null
The function (_linear_int8_act_int8_weight_block_sparse_check) defined within the public class called public.The function start at line 197 and ends at 206. It contains 10 lines of code and it has a cyclomatic complexity of 7. It takes 3 parameters, represented as [197.0] and does not return any value..
pytorch_ao
public
public
0
0
_linear_int8_act_int8_weight_block_sparse_impl
def _linear_int8_act_int8_weight_block_sparse_impl(input_tensor, weight_tensor, bias):x_vals_int8 = input_tensor.tensor_impl.int_datax_scales = input_tensor.tensor_impl.scalew_vals = weight_tensor.tensor_implw_scales = weight_tensor.tensor_impl.scaletmp = x_vals_int8.reshape(-1, x_vals_int8.shape[-1])tmp_t = tmp.t()y =...
2
22
3
154
9
209
233
209
null
['tmp', 'w_vals', 'x_scales', 'tmp_t', 'output_dtype', 'x_vals_int8', 'y', 'w_scales', 'y_shape']
None
null
0
0
0
null
0
null
The function (_linear_int8_act_int8_weight_block_sparse_impl) defined within the public class called public.The function start at line 209 and ends at 233. It contains 22 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [209.0] and does not return any value..
pytorch_ao
public
public
0
0
_aqt_is_int4
def _aqt_is_int4(aqt):"""Check if an AffineQuantizedTensor is int4 quantized Tensor"""# TODO: use torch.int4return (aqt.tensor_impl.dtype == torch.int8and aqt.quant_min == -8and aqt.quant_max == 7)
3
6
1
31
0
26
33
26
null
[]
None
null
0
0
0
null
0
null
The function (_aqt_is_int4) defined within the public class called public.The function start at line 26 and ends at 33. 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
_same_metadata
def _same_metadata(self: "Int4PackedTensorImpl", src: "Int4PackedTensorImpl") -> bool:return (isinstance(self, Int4PackedTensorImpl)and isinstance(src, Int4PackedTensorImpl)and self.shape == src.shapeand self.int_data.shape == src.int_data.shapeand self.scale.shape == src.scale.shapeand type(self._layout) == type(src._...
6
9
2
75
0
36
44
36
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 36 and ends at 44. It contains 9 lines of code and it has a cyclomatic complexity of 6. It takes 2 parameters, represented as [36.0] and does not return any value..
pytorch_ao
public
public
0
0
__new__
def __new__(cls,int_data: torch.Tensor,scale: torch.Tensor,_layout: Layout,):kwargs = {}kwargs["device"] = int_data.devicekwargs["layout"] = (kwargs.get("layout") if kwargs.get("layout", False) else int_data.layout)kwargs["dtype"] = int_data.dtypekwargs["requires_grad"] = Falseshape = int_data.shapereturn torch.Tensor....
2
15
4
93
0
61
75
61
null
[]
None
null
0
0
0
null
0
null
The function (__new__) defined within the public class called public.The function start at line 61 and ends at 75. It contains 15 lines of code and it has a cyclomatic complexity of 2. It takes 4 parameters, represented as [61.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self,int_data: torch.Tensor,scale: torch.Tensor,_layout: Layout,):self.int_data = int_dataself.scale = scaleself._layout = _layout
1
9
4
37
0
77
85
77
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 77 and ends at 85. It contains 9 lines of code and it has a cyclomatic complexity of 1. It takes 4 parameters, represented as [77.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...
6
20
5
126
0
88
110
88
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 88 and ends at 110. It contains 20 lines of code and it has a cyclomatic complexity of 6. It takes 5 parameters, represented as [88.0] and does not return any value..
pytorch_ao
public
public
0
0
__tensor_flatten__
def __tensor_flatten__(self):return ["int_data", "scale"], [self._layout]
1
2
1
17
0
112
113
112
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 112 and ends at 113. 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):int_data = tensor_data_dict["int_data"]scale = tensor_data_dict["scale"](_layout,) = tensor_attributesreturn cls(int_data, scale, _layout)
1
7
5
40
0
116
122
116
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 116 and ends at 122. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [116.0] and does not return any value..
pytorch_ao
public
public
0
0
get_plain
def get_plain(self):int_data = torch.stack(((self.int_data << 4) >> 4, self.int_data >> 4), dim=-1).view(self.int_data.shape[:-1] + (2 * self.int_data.shape[-1],))return int_data, self.scale, None
1
5
1
74
0
124
128
124
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 124 and ends at 128. It contains 5 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
from_plain
def from_plain(cls,int_data: torch.Tensor,scale: torch.Tensor,zero_point: Optional[torch.Tensor],_layout: Layout,):assert zero_point is None or torch.all(zero_point == 0)int_data_s4 = ((int_data[..., 1::2] & 0xF) << 4) | (int_data[..., 0::2] & 0xF)return cls(int_data_s4,scale,_layout,)
2
14
5
86
0
131
144
131
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 131 and ends at 144. It contains 14 lines of code and it has a cyclomatic complexity of 2. It takes 5 parameters, represented as [131.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
146
147
146
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 146 and ends at 147. 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.int_data = fn(self.int_data)self.scale = fn(self.scale)return self
1
4
2
29
0
149
152
149
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 149 and ends at 152. It contains 4 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [149.0] and does not return any value..
pytorch_ao
public
public
0
0
_linear_int8_act_int4_weight_cutlass_check
def _linear_int8_act_int4_weight_cutlass_check(input_tensor, weight_tensor, bias):return (isinstance(input_tensor, AffineQuantizedTensor)and isinstance(input_tensor._layout, PlainLayout)and _aqt_is_int8(input_tensor)and input_tensor.dtype in (torch.float16, torch.bfloat16)and len(input_tensor.shape) >= 2and input_tenso...
18
19
3
179
0
155
173
155
null
[]
None
null
0
0
0
null
0
null
The function (_linear_int8_act_int4_weight_cutlass_check) defined within the public class called public.The function start at line 155 and ends at 173. It contains 19 lines of code and it has a cyclomatic complexity of 18. It takes 3 parameters, represented as [155.0] and does not return any value..
pytorch_ao
public
public
0
0
_linear_int8_act_int4_weight_cutlass_impl
def _linear_int8_act_int4_weight_cutlass_impl(input_tensor, weight_tensor, bias):from torchao.ops import rowwise_scaled_linear_cutlass_s8s4weight = weight_tensor.tensor_impl.int_dataweight_scale = weight_tensor.tensor_impl.scaleinput = input_tensor.tensor_impl.int_datainput_scale = input_tensor.tensor_impl.scaleout_dty...
1
11
3
66
6
176
189
176
null
['out', 'input', 'input_scale', 'weight_scale', 'out_dtype', 'weight']
None
null
0
0
0
null
0
null
The function (_linear_int8_act_int4_weight_cutlass_impl) defined within the public class called public.The function start at line 176 and ends at 189. It contains 11 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [176.0] and does not return any value..
pytorch_ao
public
public
0
0
_linear_int4_act_int4_weight_cutlass_check
def _linear_int4_act_int4_weight_cutlass_check(input_tensor, weight_tensor, bias):return (isinstance(input_tensor, AffineQuantizedTensor)and isinstance(input_tensor._layout, CutlassInt4PackedLayout)and _aqt_is_int4(input_tensor)and input_tensor.dtype in (torch.float16, torch.bfloat16)and len(input_tensor.shape) >= 2and...
14
17
3
150
0
192
208
192
null
[]
None
null
0
0
0
null
0
null
The function (_linear_int4_act_int4_weight_cutlass_check) defined within the public class called public.The function start at line 192 and ends at 208. It contains 17 lines of code and it has a cyclomatic complexity of 14. It takes 3 parameters, represented as [192.0] and does not return any value..
pytorch_ao
public
public
0
0
_linear_int4_act_int4_weight_cutlass_impl
def _linear_int4_act_int4_weight_cutlass_impl(input_tensor, weight_tensor, bias):from torchao.ops import rowwise_scaled_linear_cutlass_s4s4weight = weight_tensor.tensor_impl.int_dataweight_scale = weight_tensor.tensor_impl.scaleinput = input_tensor.tensor_impl.int_datainput_scale = input_tensor.tensor_impl.scaleout_dty...
1
11
3
66
6
211
224
211
null
['out', 'input', 'input_scale', 'weight_scale', 'out_dtype', 'weight']
None
null
0
0
0
null
0
null
The function (_linear_int4_act_int4_weight_cutlass_impl) defined within the public class called public.The function start at line 211 and ends at 224. It contains 11 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [211.0] and does not return any value..
pytorch_ao
public
public
0
0
__new__
def __new__(cls,packed_weight: torch.Tensor,scales: torch.Tensor,qzeros: torch.Tensor,compensation: torch.Tensor,transposed: bool,_layout: Layout,):kwargs = {}kwargs["device"] = packed_weight.devicekwargs["layout"] = (kwargs.get("layout")if kwargs.get("layout", False)else packed_weight.layout)kwargs["dtype"] = packed_w...
2
20
7
109
0
48
67
48
null
[]
None
null
0
0
0
null
0
null
The function (__new__) defined within the public class called public.The function start at line 48 and ends at 67. It contains 20 lines of code and it has a cyclomatic complexity of 2. It takes 7 parameters, represented as [48.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self,packed_weight: torch.Tensor,scales: torch.Tensor,qzeros: torch.Tensor,compensation: torch.Tensor,transposed: bool,_layout: Layout,):self.packed_weight = packed_weightself.scales = scalesself.qzeros = qzerosself.compensation = compensationself.transposed = transposedself._layout = _layout
1
15
7
68
0
69
83
69
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 69 and ends at 83. It contains 15 lines of code and it has a cyclomatic complexity of 1. It takes 7 parameters, represented as [69.0] and does not return any value..
pytorch_ao
public
public
0
0
__tensor_flatten__
def __tensor_flatten__(self):return ["packed_weight", "scales", "qzeros", "compensation"], [self.transposed,self._layout,]
1
5
1
26
0
85
89
85
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 85 and ends at 89. It contains 5 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
__tensor_unflatten__
def __tensor_unflatten__(cls, tensor_data_dict, tensor_attributes, outer_size, outer_stride):packed_weight, scales, qzeros, compensation = (tensor_data_dict["packed_weight"],tensor_data_dict["scales"],tensor_data_dict["qzeros"],tensor_data_dict["compensation"],)(transposed,_layout,) = tensor_attributesreturn cls(packed...
1
14
5
66
0
92
105
92
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 92 and ends at 105. It contains 14 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [92.0] and does not return any value..
pytorch_ao
public
public
0
0
from_plain
def from_plain(cls,int_data: torch.Tensor,scale: torch.Tensor,zero_point: torch.Tensor,_layout: Layout,):assert isinstance(_layout, Int8DynamicActInt4WeightCPULayout)assert int_data.dtype == torch.uint8, "DA8W4 CPU: expects uint8 weight"assert int_data.shape[1] % 2 == 0, "DA8W4 CPU: expects even number of columns"if sc...
3
19
5
139
0
108
131
108
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 108 and ends at 131. It contains 19 lines of code and it has a cyclomatic complexity of 3. It takes 5 parameters, represented as [108.0] and does not return any value..
pytorch_ao
public
public
0
0
_apply_fn_to_data
def _apply_fn_to_data(self, fn):return self.__class__(fn(self.packed_weight),fn(self.scales),fn(self.qzeros),fn(self.compensation),self.transposed,self._layout,)
1
9
2
49
0
133
141
133
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 133 and ends at 141. It contains 9 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [133.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.t.default:"""we don't need to repack the weight and just rely on externalshape being changed and record the status of transpose/no-transpose"""transposed = DA8W4CPUAQTTensorImpl(args[0].packed_weight,args[0]....
3
14
5
109
0
144
160
144
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 144 and ends at 160. It contains 14 lines of code and it has a cyclomatic complexity of 3. It takes 5 parameters, represented as [144.0] and does not return any value..
pytorch_ao
public
public
0
0
block_size
def block_size(self):assert len(self.packed_weight.shape) == 2weight_shape = self.packed_weight.shapeN = weight_shape[0]K = weight_shape[1] * 2groups = self.scales.numel() // Ngroup_size = K // groupsreturn (1, group_size)
1
8
1
57
0
165
172
165
null
[]
None
null
0
0
0
null
0
null
The function (block_size) defined within the public class called public.The function start at line 165 and ends at 172. It contains 8 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
get_plain
def get_plain(self) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:# Unpack weight by linear(eye(K), packed_weight).t()packed_w_shape = self.packed_weight.shapeif len(packed_w_shape) == 4:K = packed_w_shape[1] * packed_w_shape[2]else:K = packed_w_shape[1]x = torch.eye(K).to(torch.uint8)x_scale = torch.ones(K).float...
4
38
1
321
0
174
214
174
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 174 and ends at 214. It contains 38 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
_aqt_is_uint8
def _aqt_is_uint8(aqt):"""Check if an AffineQuantizedTensor is uint8 quantized Tensor"""return (aqt.tensor_impl.dtype == torch.uint8and aqt.quant_min == 0and aqt.quant_max == 255)
3
6
1
30
0
217
223
217
null
[]
None
null
0
0
0
null
0
null
The function (_aqt_is_uint8) defined within the public class called public.The function start at line 217 and ends at 223. 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
_aqt_is_int8
def _aqt_is_int8(aqt):"""Check if an AffineQuantizedTensor is uint8 quantized Tensor"""return (aqt.tensor_impl.dtype == torch.int8and aqt.quant_min == -127and aqt.quant_max == 127)
3
6
1
31
0
226
232
226
null
[]
None
null
0
0
0
null
0
null
The function (_aqt_is_int8) defined within the public class called public.The function start at line 226 and ends at 232. 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
_aqt_is_uint4
def _aqt_is_uint4(aqt):"""Check if an AffineQuantizedTensor is uint4 quantized Tensor"""return (aqt.tensor_impl.dtype == torch.uint8and aqt.quant_min == 0and aqt.quant_max == 15)
3
6
1
30
0
235
241
235
null
[]
None
null
0
0
0
null
0
null
The function (_aqt_is_uint4) defined within the public class called public.The function start at line 235 and ends at 241. 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
_linear_int8_act_int4_weight_cpu_check
def _linear_int8_act_int4_weight_cpu_check(input_tensor, weight_tensor, bias):return (torch_version_at_least("2.7.0")and is_device(input_tensor.device.type, "cpu")and is_device(weight_tensor.device.type, "cpu")and (bias is None or is_device(bias.device.type, "cpu"))and isinstance(input_tensor, AffineQuantizedTensor)and...
14
15
3
118
0
244
258
244
null
[]
None
null
0
0
0
null
0
null
The function (_linear_int8_act_int4_weight_cpu_check) defined within the public class called public.The function start at line 244 and ends at 258. It contains 15 lines of code and it has a cyclomatic complexity of 14. It takes 3 parameters, represented as [244.0] and does not return any value..
pytorch_ao
public
public
0
0
_linear_int8_act_int4_weight_cpu_impl
def _linear_int8_act_int4_weight_cpu_impl(input_tensor, weight_tensor, bias):assert torch_version_at_least("2.7.0"), (f"Requires PyTorch version at least 2.7, but got: {torch.__version__}")if _aqt_is_int8(input_tensor):assert torch_version_at_least("2.8.0"), (f"Requires PyTorch version at least 2.8, but got: {torch.__v...
3
44
3
255
12
261
313
261
null
['packed_weight', 'wei_scales', 'compensation', 'act', 'orig_act_size', 'act_mat', 'y', 'act_scales', 'orig_out_features', 'wei_qzeros', 'orig_dtype', 'act_qzeros']
None
null
0
0
0
null
0
null
The function (_linear_int8_act_int4_weight_cpu_impl) defined within the public class called public.The function start at line 261 and ends at 313. It contains 44 lines of code and it has a cyclomatic complexity of 3. It takes 3 parameters, represented as [261.0] and does not return any value..
pytorch_ao
public
public
0
0
_same_metadata
def _same_metadata(self: "GemliteAQTTensorImpl",src: "GemliteAQTTensorImpl",) -> bool:kwargs_match = len(self.gemlite_kwargs) == len(src.gemlite_kwargs)for k, v in self.gemlite_kwargs.items():if k in ["in_features","out_features","packing_bitwidth","elements_per_sample",]:kwargs_match = kwargs_match and (v == src.gemli...
11
23
2
146
1
31
54
31
null
['kwargs_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 31 and ends at 54. It contains 23 lines of code and it has a cyclomatic complexity of 11. It takes 2 parameters, represented as [31.0] and does not return any value..
pytorch_ao
public
public
0
0
get_gemlite_quant_kwargs
def get_gemlite_quant_kwargs(bit_width, group_size, dtype):from torchao.quantization.quant_primitives import MappingType, ZeroPointDomainkwargs = {}if bit_width != 8:kwargs["mapping_type"] = MappingType.ASYMMETRICkwargs["block_size"] = (1, group_size)kwargs["target_dtype"] = torch.uint8kwargs["eps"] = 1e-6kwargs["quant...
3
23
3
170
1
57
80
57
null
['kwargs']
None
null
0
0
0
null
0
null
The function (get_gemlite_quant_kwargs) defined within the public class called public.The function start at line 57 and ends at 80. It contains 23 lines of code and it has a cyclomatic complexity of 3. It takes 3 parameters, represented as [57.0] and does not return any value..
pytorch_ao
public
public
0
0
get_gemlite_aqt_kwargs
def get_gemlite_aqt_kwargs(weight,group_size=64,bit_width=4,packing_bitwidth=None,mode="weight_only",use_hqq=True,):if gemlite is None:raise ImportError("Unable to import 'gemlite'. Please ensure it is installed correctly. You can install it with: pip install gemlite")assert bit_width in [4,8,], f"gemlite only works wi...
4
40
6
187
2
83
127
83
null
['group_size', 'aqt_kwargs']
None
null
0
0
0
null
0
null
The function (get_gemlite_aqt_kwargs) defined within the public class called public.The function start at line 83 and ends at 127. It contains 40 lines of code and it has a cyclomatic complexity of 4. It takes 6 parameters, represented as [83.0] and does not return any value..
pytorch_ao
public
public
0
0
__new__
def __new__(cls,packed_weight: torch.Tensor,scale: torch.Tensor,zero_point: torch.Tensor,gemlite_kwargs: Dict,_layout: Layout,):kwargs = {}kwargs["device"] = packed_weight.devicekwargs["layout"] = (kwargs.get("layout")if kwargs.get("layout", False)else packed_weight.layout)kwargs["dtype"] = packed_weight.dtypekwargs["r...
2
19
6
103
0
140
158
140
null
[]
None
null
0
0
0
null
0
null
The function (__new__) defined within the public class called public.The function start at line 140 and ends at 158. It contains 19 lines of code and it has a cyclomatic complexity of 2. It takes 6 parameters, represented as [140.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self,packed_weight: torch.Tensor,scale: torch.Tensor,zero_point: torch.Tensor,gemlite_kwargs: Dict,_layout: Layout,):self.packed_weight = packed_weightself.scale = scaleself.zero_point = zero_pointself.gemlite_kwargs = gemlite_kwargsself._layout = _layout
1
13
6
57
0
160
172
160
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 160 and ends at 172. It contains 13 lines of code and it has a cyclomatic complexity of 1. It takes 6 parameters, represented as [160.0] and does not return any value..
pytorch_ao
public
public
0
0
__tensor_flatten__
def __tensor_flatten__(self):return ["packed_weight", "scale", "zero_point"], [self._layout,self.gemlite_kwargs,]
1
5
1
24
0
174
178
174
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 174 and ends at 178. It contains 5 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
__tensor_unflatten__
def __tensor_unflatten__(cls, tensor_data_dict, tensor_attributes, outer_size, outer_stride):packed_weight, scale, zero_point = (tensor_data_dict["packed_weight"],tensor_data_dict["scale"],tensor_data_dict["zero_point"],)_layout, gemlite_kwargs = tensor_attributesreturn cls(packed_weight, scale, zero_point, gemlite_kwa...
1
10
5
54
0
181
190
181
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 181 and ends at 190. It contains 10 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [181.0] and does not return any value..
pytorch_ao
public
public
0
0
from_plain
def from_plain(cls,int_data: torch.Tensor,scale: torch.Tensor,zero_point: Optional[torch.Tensor],_layout: Layout,):assert isinstance(_layout, GemlitePackedLayout), (f"GemliteAQTTensorImpl only works with GemliteLinearTriton but got {_layout}")device = int_data.deviceif device.type != "cuda":int_data = (int_data.cuda())...
7
56
5
300
0
193
253
193
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 193 and ends at 253. It contains 56 lines of code and it has a cyclomatic complexity of 7. It takes 5 parameters, represented as [193.0] and does not return any value..
pytorch_ao
public
public
0
0
to
def to(self, *args, **kwargs):kwargs = self._get_to_kwargs(*args, **kwargs)device = kwargs["device"]return self.__class__(self.packed_weight.to(device),self.scale.to(device),self.zero_point.to(device),self.gemlite_kwargs,self._layout,)
1
10
3
70
0
255
264
255
null
[]
None
null
0
0
0
null
0
null
The function (to) defined within the public class called public.The function start at line 255 and ends at 264. It contains 10 lines of code and it has a cyclomatic complexity of 1. It takes 3 parameters, represented as [255.0] and does not return any value..
pytorch_ao
public
public
0
0
_apply_fn_to_data
def _apply_fn_to_data(self, fn):return self.__class__(fn(self.packed_weight),fn(self.scale),fn(self.zero_point),self.gemlite_kwargs,self._layout,)
1
8
2
42
0
266
273
266
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 266 and ends at 273. It contains 8 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [266.0] and does not return any value..
pytorch_ao
public
public
0
0
get_plain
def get_plain(self) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:device = self.packed_weight.deviceint_data = ((gemlite.bitpack.unpack_over_rows(self.packed_weight.cuda(),W_nbits=self._layout.bit_width,num_output_rows=self.gemlite_kwargs["in_features"],dtype=torch.uint8,)).to(device).t())# Preserve col-row major ...
3
32
1
239
0
275
312
275
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 275 and ends at 312. It contains 32 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 kwargs# we don't handle transpose operations and just ignore them. In practice the only# reason a transpsoe should occur is because the functional linear# op can decompose into e.g. transpose + addmm so since we want# to use the g...
16
76
5
526
0
315
414
315
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 315 and ends at 414. It contains 76 lines of code and it has a cyclomatic complexity of 16. It takes 5 parameters, represented as [315.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
418
419
418
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 418 and ends at 419. It contains 2 lines of code and it has a cyclomatic complexity of 1. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
block_size
def block_size(self):return (1, self._layout.group_size)
1
2
1
15
0
422
423
422
null
[]
None
null
0
0
0
null
0
null
The function (block_size) defined within the public class called public.The function start at line 422 and ends at 423. 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
_linear_fp_act_int4_weight_gemlite_impl
def _linear_fp_act_int4_weight_gemlite_impl(input_tensor, weight_tensor, bias=None):if hasattr(weight_tensor, "tensor_impl"):weight_impl = weight_tensor.tensor_implelse:weight_impl = weight_tensorreturn gemlite.core.forward_functional(x=input_tensor,bias=bias,tensor_args=(weight_impl.packed_weight,weight_impl.scale,wei...
2
15
3
71
1
426
441
426
null
['weight_impl']
None
null
0
0
0
null
0
null
The function (_linear_fp_act_int4_weight_gemlite_impl) defined within the public class called public.The function start at line 426 and ends at 441. It contains 15 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [426.0] and does not return any value..
pytorch_ao
public
public
0
0
_linear_fp_act_int4_weight_gemlite_check
def _linear_fp_act_int4_weight_gemlite_check(input_tensor, weight_tensor, bias):return (# input is native fp16 tensornot is_traceable_wrapper_subclass(input_tensor)# and input_tensor.dtype in [torch.float16, torch.bfloat16]# weight is gemlite layoutand isinstance(weight_tensor, AffineQuantizedTensor)and isinstance(weig...
3
6
3
33
0
444
452
444
null
[]
None
null
0
0
0
null
0
null
The function (_linear_fp_act_int4_weight_gemlite_check) defined within the public class called public.The function start at line 444 and ends at 452. It contains 6 lines of code and it has a cyclomatic complexity of 3. It takes 3 parameters, represented as [444.0] and does not return any value..
pytorch_ao
public
public
0
0
__new__
def __new__(cls,packed_weight: torch.Tensor,scale_and_zero: torch.Tensor,transposed: bool,_layout: Layout,):kwargs = {}kwargs["device"] = packed_weight.devicekwargs["layout"] = (kwargs.get("layout")if kwargs.get("layout", False)else packed_weight.layout)kwargs["dtype"] = packed_weight.dtypekwargs["requires_grad"] = Fal...
2
18
5
97
0
56
73
56
null
[]
None
null
0
0
0
null
0
null
The function (__new__) defined within the public class called public.The function start at line 56 and ends at 73. It contains 18 lines of code and it has a cyclomatic complexity of 2. It takes 5 parameters, represented as [56.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self,packed_weight: torch.Tensor,scale_and_zero: torch.Tensor,transposed: bool,_layout: Layout,):warnings.warn("Models quantized with version 1 of Int4WeightOnlyConfig is deprecated and will no longer be supported in a future release, please upgrade torchao and quantize again, or download a newer torchao c...
1
14
5
52
0
75
88
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 88. It contains 14 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [75.0] and does not return any value..
pytorch_ao
public
public
0
0
__tensor_flatten__
def __tensor_flatten__(self):return ["packed_weight", "scale_and_zero"], [self.transposed, self._layout]
1
2
1
21
0
90
91
90
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 90 and ends at 91. 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):packed_weight, scale_and_zero = (tensor_data_dict["packed_weight"],tensor_data_dict["scale_and_zero"],)(transposed,_layout,) = tensor_attributesreturn cls(packed_weight, scale_and_zero, transposed, _layout)
1
12
5
48
0
94
105
94
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 94 and ends at 105. It contains 12 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [94.0] and does not return any value..
pytorch_ao
public
public
0
0
from_plain
def from_plain(cls,int_data: torch.Tensor,scale: torch.Tensor,zero_point: Optional[torch.Tensor],_layout: Layout,):assert isinstance(_layout, Int4CPULayout)assert int_data.dtype == torch.int32, ("torch.ops.aten._convert_weight_to_int4pack_for_cpu expects `int32` dtype")packed_weight = torch.ops.aten._convert_weight_to_...
1
20
5
128
0
108
130
108
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 108 and ends at 130. It contains 20 lines of code and it has a cyclomatic complexity of 1. It takes 5 parameters, represented as [108.0] and does not return any value..
pytorch_ao
public
public
0
0
to
def to(self, *args, **kwargs):kwargs = self._get_to_kwargs(*args, **kwargs)device = kwargs["device"]if not is_device(torch.device(self.device).type, device):raise ValueError(f"{self.__class__.__name__} does not support conversion from {self.device} to {device}")return self.__class__(self.packed_weight.to(device),self.s...
2
13
3
85
0
132
144
132
null
[]
None
null
0
0
0
null
0
null
The function (to) defined within the public class called public.The function start at line 132 and ends at 144. It contains 13 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [132.0] and does not return any value..
pytorch_ao
public
public
0
0
_apply_fn_to_data
def _apply_fn_to_data(self, fn):return self.__class__(fn(self.packed_weight),fn(self.scale_and_zero),self.transposed,self._layout,)
1
7
2
35
0
146
152
146
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 146 and ends at 152. It contains 7 lines of code and it has a cyclomatic complexity of 1. It takes 2 parameters, represented as [146.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))if func is aten.clone.default:return return_and_correct_aliasing(func, args, kwargs, args[0]._appl...
6
37
5
298
0
155
197
155
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 155 and ends at 197. It contains 37 lines of code and it has a cyclomatic complexity of 6. It takes 5 parameters, represented as [155.0] and does not return any value..
pytorch_ao
public
public
0
0
block_size
def block_size(self):from torchao.quantization.utils import unpack_tinygemm_scales_and_zerosscale, zero = unpack_tinygemm_scales_and_zeros(self.scale_and_zero)cur_shape = self.shapeassert len(cur_shape) == 4inner_k_tiles = cur_shape[-1] * 2original_shape = (cur_shape[0] * 8, cur_shape[1] * (inner_k_tiles * 16))groupsiz...
1
9
1
88
0
202
211
202
null
[]
None
null
0
0
0
null
0
null
The function (block_size) defined within the public class called public.The function start at line 202 and ends at 211. 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_plain
def get_plain(self) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:from torchao.quantization.utils import unpack_tinygemm_scales_and_zerosscale, zero = unpack_tinygemm_scales_and_zeros(self.scale_and_zero)cur_shape = self.shapeassert len(cur_shape) == 2original_shape = (cur_shape[0], cur_shape[1] * 2)eye_shape = or...
2
34
1
242
0
213
250
213
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 213 and ends at 250. It contains 34 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_layout
def get_layout(self) -> Layout:return self._layout
1
2
1
11
0
252
253
252
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 252 and ends at 253. 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
_aqt_is_uint4
def _aqt_is_uint4(aqt):"""Check if an AffineQuantizedTensor is uint4 quantized Tensor"""return (aqt.tensor_impl.dtype == torch.uint8and aqt.quant_min == 0and aqt.quant_max == 15)
3
6
1
30
0
256
262
256
null
[]
None
null
0
0
0
null
0
null
The function (_aqt_is_uint4) defined within the public class called public.The function start at line 256 and ends at 262. 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
_is_float
def _is_float(dtype):return dtype in (torch.float, torch.half, torch.bfloat16)
1
2
1
21
0
265
266
265
null
[]
None
null
0
0
0
null
0
null
The function (_is_float) defined within the public class called public.The function start at line 265 and ends at 266. 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
_linear_fp_act_uint4_weight_cpu_check
def _linear_fp_act_uint4_weight_cpu_check(input_tensor, weight_tensor, bias):return (is_device(input_tensor.device.type, "cpu")and is_device(weight_tensor.device.type, "cpu")and (bias is None or is_device(bias.device.type, "cpu"))and not is_traceable_wrapper_subclass(input_tensor)and _is_float(input_tensor.dtype)and is...
12
14
3
108
0
269
282
269
null
[]
None
null
0
0
0
null
0
null
The function (_linear_fp_act_uint4_weight_cpu_check) defined within the public class called public.The function start at line 269 and ends at 282. It contains 14 lines of code and it has a cyclomatic complexity of 12. It takes 3 parameters, represented as [269.0] and does not return any value..
pytorch_ao
public
public
0
0
_linear_fp_act_uint4_weight_cpu_impl
def _linear_fp_act_uint4_weight_cpu_impl(input_tensor, weight_tensor, bias):assert is_device(input_tensor.device.type, "cpu"), (f"For CPU device only but got: {input_tensor.device}")assert weight_tensor.block_size[0] == 1, (f"Requires groupwise quantization, got block_size: {weight_tensor.block_size}")assert input_tens...
2
27
3
187
8
285
320
285
null
['packed_weight', 'groupsize', 'scale_and_zero', 'orig_act_size', 'orig_out_features', 'act_mat', 'y', 'orig_dtype']
None
null
0
0
0
null
0
null
The function (_linear_fp_act_uint4_weight_cpu_impl) defined within the public class called public.The function start at line 285 and ends at 320. It contains 27 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [285.0] and does not return any value..
pytorch_ao
public
public
0
0
_aqt_is_xpu_layout_uint4
def _aqt_is_xpu_layout_uint4(aqt):"""Check if an AffineQuantizedTensor is uint4 quantized Tensor"""# TODO: use torch.uint4return (aqt.tensor_impl.dtype == torch.int32and aqt.quant_min == 0and aqt.quant_max == 15)
3
6
1
30
0
31
38
31
null
[]
None
null
0
0
0
null
0
null
The function (_aqt_is_xpu_layout_uint4) defined within the public class called public.The function start at line 31 and ends at 38. 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
_linear_bf16_act_uint4_weight_float_zero_check
def _linear_bf16_act_uint4_weight_float_zero_check(input_tensor, weight_tensor, bias):return (# input is native bfloat16 tensornot is_traceable_wrapper_subclass(input_tensor)and input_tensor.dtype == torch.bfloat16and# weight is uint4, group quantized tensor_core_tiled tensor impl affine quantized tensorisinstance(weig...
10
14
3
92
0
41
56
41
null
[]
None
null
0
0
0
null
0
null
The function (_linear_bf16_act_uint4_weight_float_zero_check) defined within the public class called public.The function start at line 41 and ends at 56. It contains 14 lines of code and it has a cyclomatic complexity of 10. It takes 3 parameters, represented as [41.0] and does not return any value..
pytorch_ao
public
public
0
0
_linear_bf16_act_uint4_weight_float_zero_impl
def _linear_bf16_act_uint4_weight_float_zero_impl(input_tensor, weight_tensor, bias):assert weight_tensor.block_size[0] == 1, (f"Requires groupwise quantization, got block_size: {weight_tensor.block_size}")assert input_tensor.shape[-1] == weight_tensor.shape[1], (f"need input_tensor shape: {input_tensor.shape} final"f"...
3
26
3
190
8
59
96
59
null
['packed_weight', 'groupsize', 'orig_act_size', 'orig_out_features', 'act_mat', 'y', 'orig_dtype', 'scales_and_zeros']
None
null
0
0
0
null
0
null
The function (_linear_bf16_act_uint4_weight_float_zero_impl) defined within the public class called public.The function start at line 59 and ends at 96. It contains 26 lines of code and it has a cyclomatic complexity of 3. It takes 3 parameters, represented as [59.0] and does not return any value..
pytorch_ao
public
public
0
0
_linear_fp_act_uint4_weight_int8_zero_check
def _linear_fp_act_uint4_weight_int8_zero_check(input_tensor, weight_tensor, bias):return (not is_traceable_wrapper_subclass(input_tensor)and# weight is uint4, group quantized tensor_core_tiled tensor impl affine quantized tensorisinstance(weight_tensor, AffineQuantizedTensor)and _aqt_is_xpu_layout_uint4(weight_tensor)...
8
12
3
75
0
99
111
99
null
[]
None
null
0
0
0
null
0
null
The function (_linear_fp_act_uint4_weight_int8_zero_check) defined within the public class called public.The function start at line 99 and ends at 111. It contains 12 lines of code and it has a cyclomatic complexity of 8. It takes 3 parameters, represented as [99.0] and does not return any value..
pytorch_ao
public
public
0
0
_linear_fp_act_uint4_weight_int8_zero_impl
def _linear_fp_act_uint4_weight_int8_zero_impl(input_tensor, weight_tensor, bias):assert weight_tensor.block_size[0] == 1, (f"Requires groupwise quantization, got block_size: {weight_tensor.block_size}")assert input_tensor.shape[-1] == weight_tensor.shape[1], (f"need input_tensor shape: {input_tensor.shape} final"f"dim...
2
25
3
176
9
114
151
114
null
['packed_weight', 'zero', 'groupsize', 'scale', 'orig_act_size', 'orig_out_features', 'act_mat', 'y', 'orig_dtype']
None
null
0
0
0
null
0
null
The function (_linear_fp_act_uint4_weight_int8_zero_impl) defined within the public class called public.The function start at line 114 and ends at 151. It contains 25 lines of code and it has a cyclomatic complexity of 2. It takes 3 parameters, represented as [114.0] and does not return any value..
pytorch_ao
public
public
0
0
__new__
def __new__(cls,packed_weight: torch.Tensor,scale_and_zero: torch.Tensor,transposed: bool,_layout: Layout,scale: torch.Tensor = None,zero: torch.Tensor = None,):kwargs = {}kwargs["device"] = packed_weight.devicekwargs["layout"] = (kwargs.get("layout")if kwargs.get("layout", False)else packed_weight.layout)kwargs["dtype...
2
20
7
113
0
181
200
181
null
[]
None
null
0
0
0
null
0
null
The function (__new__) defined within the public class called public.The function start at line 181 and ends at 200. It contains 20 lines of code and it has a cyclomatic complexity of 2. It takes 7 parameters, represented as [181.0] and does not return any value..
pytorch_ao
public
public
0
0
__init__
def __init__(self,packed_weight: torch.Tensor,scale_and_zero: torch.Tensor,transposed: bool,_layout: Layout,scale: torch.Tensor = None,zero: torch.Tensor = None,):warnings.warn("Models quantized with version 1 of Int4WeightOnlyConfig is deprecated and will no longer be supported in a future release, please upgrade torc...
1
18
7
78
0
202
219
202
null
[]
None
null
0
0
0
null
0
null
The function (__init__) defined within the public class called public.The function start at line 202 and ends at 219. It contains 18 lines of code and it has a cyclomatic complexity of 1. It takes 7 parameters, represented as [202.0] and does not return any value..
pytorch_ao
public
public
0
0
__tensor_flatten__
def __tensor_flatten__(self):if self.scale_and_zero is not None:return ["packed_weight", "scale_and_zero"], [self.transposed, self._layout]else:return ["packed_weight", "scale", "zero"], [self.transposed, self._layout]
2
5
1
49
0
221
225
221
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 221 and ends at 225. It contains 5 lines of code and it has a cyclomatic complexity of 2. The function does not take any parameters and does not return any value..
pytorch_ao
public
public
0
0
__tensor_unflatten__
def __tensor_unflatten__(cls, tensor_data_dict, tensor_attributes, outer_size, outer_stride):packed_weight = tensor_data_dict["packed_weight"]scale_and_zero = (tensor_data_dict.get("scale_and_zero")if "scale_and_zero" in tensor_data_dictelse None)scale = tensor_data_dict.get("scale") if "scale" in tensor_data_dict else...
4
16
5
86
0
228
243
228
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 228 and ends at 243. It contains 16 lines of code and it has a cyclomatic complexity of 4. It takes 5 parameters, represented as [228.0] and does not return any value..
pytorch_ao
public
public
0
0
from_plain
def from_plain(cls,int_data: torch.Tensor,scale: torch.Tensor,zero_point: Optional[torch.Tensor],_layout: Layout,):assert isinstance(_layout, Int4XPULayout)if torch_version_at_least("2.8.0"):assert int_data.dtype == torch.int32, ("torch.ops.aten._convert_weight_to_int4pack_for_cpu expects `int32` dtype")packed_weight =...
3
35
5
229
0
246
283
246
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 246 and ends at 283. It contains 35 lines of code and it has a cyclomatic complexity of 3. It takes 5 parameters, represented as [246.0] and does not return any value..
pytorch_ao
public
public
0
0
to
def to(self, *args, **kwargs):kwargs = self._get_to_kwargs(*args, **kwargs)device = kwargs["device"]if not is_device(torch.device(self.device).type, device):raise ValueError(f"Int4XPUAQTTensorImpl does not support conversion from {self.device} to {device}")return self.__class__(self.packed_weight.to(device),self.scale_...
5
15
3
130
0
285
299
285
null
[]
None
null
0
0
0
null
0
null
The function (to) defined within the public class called public.The function start at line 285 and ends at 299. It contains 15 lines of code and it has a cyclomatic complexity of 5. It takes 3 parameters, represented as [285.0] and does not return any value..