marka17:

m = nn.quantized.dynamic.Linear(20, 30, dtype=torch.qint8)
m = torch.jit.script(m)



Use the _weight_bias() method to get the weights back:
(wt,bias) = m._packed_params._weight_bias()
  
      github.com
  
  
    pytorch/pytorch/blob/master/torch/nn/quantized/modules/linear.py#L32 6

def set_weight_bias(self, weight: torch.Tensor, bias: Optional[torch.Tensor]) -> None:    if self.dtype == torch.qint8:        self._packed_params = torch.ops.quantized.linear_prepack(weight, bias)    elif self.dtype == torch.float16:        self._packed_params = torch.ops.quantized.linear_prepack_fp16(weight, bias)    else:        raise RuntimeError('Unsupported dtype on dynamic quantized linear!')@torch.jit.exportdef _weight_bias(self):    if self.dtype == torch.qint8:        return torch.ops.quantized.linear_unpack(self._packed_params)    elif self.dtype == torch.float16:        return torch.ops.quantized.linear_unpack_fp16(self._packed_params)    else:        raise RuntimeError('Unsupported dtype on dynamic quantized linear!')def forward(self, x):    return x