Skip to content

Commit

Permalink
fix ipex linear check (#741)
Browse files Browse the repository at this point in the history
Signed-off-by: jiqing-feng <jiqing.feng@intel.com>
  • Loading branch information
jiqing-feng authored Dec 4, 2024
1 parent b11d112 commit 3182177
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions gptqmodel/nn_modules/qlinear/qlinear_ipex.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ def post_init(self):
self.validate_device(self.qweight.device.type)
assert self.qweight.device.type in ("cpu", "xpu")

def init_ipex_linear(self):
if not self.training and IPEX_AVAILABLE:
def init_ipex_linear(self, x):
if not self.training and IPEX_AVAILABLE and not x.requires_grad:
self.ipex_linear = IPEXWeightOnlyQuantizedLinear.from_weight(self.qweight, self.scales, self.qzeros, \
self.infeatures, self.outfeatures, None, self.bias, \
self.group_size, self.g_idx, quant_method=0, dtype=0)
Expand Down Expand Up @@ -199,7 +199,7 @@ def pack(self, linear, scales, zeros, g_idx=None):

def forward(self, x: torch.Tensor):
if not self.init_ipex:
self.init_ipex_linear()
self.init_ipex_linear(x)
self.init_ipex = True

if hasattr(self, "ipex_linear"):
Expand Down

0 comments on commit 3182177

Please sign in to comment.