MCPcopy Create free account
hub / github.com/pytorch/executorch / dequantize_value

Method dequantize_value

backends/arm/_passes/quant_args.py:51–73  ·  view source on GitHub ↗

Dequantizes the input tensor or value to a dequantized tensor If the input is not a tensor, it is converted to a tensor first. If self.per_channel is True, the dequantization is done per channel, otherwise it is done per tensor.

(self, qx: torch.Tensor)

Source from the content-addressed store, hash-verified

49 return q_op(*args)
50
51 def dequantize_value(self, qx: torch.Tensor) -> torch.Tensor:
52 """Dequantizes the input tensor or value to a dequantized tensor If the
53 input is not a tensor, it is converted to a tensor first.
54
55 If self.per_channel is True, the dequantization is done per channel,
56 otherwise it is done per tensor.
57
58 """
59 if self.per_channel:
60 dq_op = exir_ops.edge.quantized_decomposed.dequantize_per_channel.default
61 args = (
62 qx,
63 torch.tensor(self.scale),
64 torch.tensor(self.zp),
65 self.axis,
66 self.qmin,
67 self.qmax,
68 self.dtype,
69 )
70 else:
71 dq_op = exir_ops.edge.quantized_decomposed.dequantize_per_tensor.default
72 args = (qx, self.scale, self.zp, self.qmin, self.qmax, self.dtype) # type: ignore[assignment]
73 return dq_op(*args)
74
75 @classmethod
76 def from_operator(cls, op, args):

Calls

no outgoing calls