diff --git a/backends/qualcomm/utils/utils.py b/backends/qualcomm/utils/utils.py index 18de0a85ed5..3cfea965282 100644 --- a/backends/qualcomm/utils/utils.py +++ b/backends/qualcomm/utils/utils.py @@ -168,11 +168,16 @@ def __init__(self, weight, bias=None): def forward(self, x): rank = x.dim() - x = x.reshape(*x.shape, 1) if rank == 3 else x.reshape(1, *x.shape, 1) - x = torch.transpose(x, 1, 2) + if rank == 3: + bsz, dim0, dim1 = x.size() + x = torch.reshape(x, (bsz, dim0, 1, dim1)) + else: + dim0, dim1 = x.size() + x = torch.reshape(x, (1, dim0, 1, dim1)) + x = torch.transpose(x, 1, 3) res = self.conv(x) - res = torch.transpose(res, 1, 2) - res = res.squeeze(-1) if rank == 3 else res.reshape(*res.shape[1:3]) + res = torch.transpose(res, 1, 3) + res = res.squeeze(2) if rank == 3 else res.reshape(dim0, dim1) return res def replace_linear(module: torch.nn.Module):