Skip to content

Commit

Permalink
Fix (gptq): fix for depthwise act_order (#688)
Browse files Browse the repository at this point in the history
  • Loading branch information
Giuseppe5 authored Jul 28, 2023
1 parent 0933408 commit 0dc9268
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/brevitas/graph/gptq.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,16 +396,18 @@ def single_layer_update(self, percdamp=.01):
if self.groups > 1:
# In case of depthwise convs, each weight matrix interacts with only
# part of the input values, thus with only one of the hessian matrix
for ii in range(self.groups):
for ii, perm in enumerate(permutation_list):
weight_block[ii, i:] -= error[ii] * h_inv_block[ii, i, i:]
# We need to update the original weights
weight[ii, perm[i1:i2][i:]] = weight_block[ii, i:].to(dtype)
else:
perm = permutation_list[0]
weight_block[:, i:] -= error.unsqueeze(1).matmul(
h_inv_block[0, i, i:].unsqueeze(0))
# We need to update the original weights
weight[:, perm[i1:i2][i:]] = weight_block[:, i:].to(dtype)
error_block[:, i] = error

# We need to update the original weights
weight[:, perm[i1:i2][i:]] = weight_block[:, i:].to(dtype)

if self.groups > 1:
# In case of depthwise convs, each weight matrix interacts with only
# part of the input values, thus with only one of the hessian matrix
Expand Down

0 comments on commit 0dc9268

Please sign in to comment.