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

Method from_operator

backends/arm/_passes/quant_args.py:76–99  ·  view source on GitHub ↗
(cls, op, args)

Source from the content-addressed store, hash-verified

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):

Callers 5

_extract_input_paramsMethod · 0.80
callMethod · 0.80
fold_dq_q_to_rescaleMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected