4 writes to weight
Microsoft.ML.GenAI.Core (4)
Module\GenAILinear.cs (1)
24this.weight = torch.zeros(outFeatures, inFeatures, dtype: dtype, device: device);
Module\QuantizedLinear.cs (3)
57this.weight = null; 71this.weight = null; 203this.weight = null;
21 references to weight
Microsoft.ML.GenAI.Core (21)
Module\GenAILinear.cs (1)
42var weight2 = this.weight!.to_type(ScalarType.Float32);
Module\QuantizedLinear.cs (20)
19if (this.weight is null) 24if (this.weight.device_type != DeviceType.META) 33var scale = 255 / (torch.max(this.weight, 1).values - torch.min(this.weight, 1).values); 36var zeroPoint = -scale * torch.min(this.weight, 1).values - 128; 47var eightBitWeight = torch.round(this.weight * scale.view(-1, 1) + zeroPoint.view(-1, 1)).to(torch.int8); 56this.weight.Dispose(); 66var eightBitWeight = torch.zeros(this.weight.shape, dtype: torch.int8); 67var zeroPoint = torch.zeros(this.weight.shape[0], dtype: torch.int8); 68var scale = torch.zeros(this.weight.shape[0], dtype: torch.float32); 140if (this.weight is null) 145var fourBitWeightDim = this.weight.size(0) * this.weight.size(1); 147if (this.weight.device_type != DeviceType.META) 154var scale = 15 / (torch.max(this.weight, 1).values - torch.min(this.weight, 1).values); 157var zeroPoint = -scale * torch.min(this.weight, 1).values - 8; 160var fourBitWeight = torch.round(this.weight * scale.view(-1, 1) + zeroPoint.view(-1, 1)).to(torch.int8); 187this.weight.Dispose(); 200var scale = torch.zeros(this.weight.shape[0], dtype: torch.float32);