(cls, op, args)
| 74 | |
| 75 | @classmethod |
| 76 | def from_operator(cls, op, args): |
| 77 | if op in PER_TENSOR_QDQ_OPS: |
| 78 | return cls( |
| 79 | scale=cast(float, args[1]), |
| 80 | zp=cast(int, args[2]), |
| 81 | qmin=cast(int, args[3]), |
| 82 | qmax=cast(int, args[4]), |
| 83 | dtype=cast(torch.dtype, args[5]), |
| 84 | axis=0, |
| 85 | per_channel=False, |
| 86 | ) |
| 87 | elif op in PER_CHANNEL_QDQ_OPS: |
| 88 | return cls( |
| 89 | scale=cast(list[float], args[1].tolist()), |
| 90 | zp=cast(list[int], args[2].tolist()), |
| 91 | axis=cast(int, args[3]), |
| 92 | qmin=cast(int, args[4]), |
| 93 | qmax=cast(int, args[5]), |
| 94 | dtype=cast(torch.dtype, args[6]), |
| 95 | per_channel=True, |
| 96 | ) |
| 97 | else: |
| 98 | # We're only handling per tensor and per channel quantization |
| 99 | raise NotImplementedError(f"Unsupported quantization operation: {op}") |
| 100 | |
| 101 | def get_scale_per_tensor(self) -> float: |
| 102 | if not isinstance(self.scale, float): |
no outgoing calls
no test coverage detected