Walk transparent ops when extracting input quant params#20139
Conversation
Summary: `extract_input_quant_params_from_graph` (used by `QuantizedInputWrapper` to dequantize pre-quantized inputs) only matched a `quantize_per_tensor` placed directly on the input placeholder. Inputs that pass through a shape-only op first -- an nhwc `permute`, or a patchify `reshape` -- defeated it, so callers had to pre-compute the quant params themselves. Walk from each input placeholder through a chain of transparent ops (`view`/`reshape`/`permute`/`transpose`/`slice`/`to`/...) to the first `quantize_per_tensor`, so `QuantizedInputWrapper(module, input_names)` resolves those inputs automatically. Backward compatible (a quantize directly on the placeholder is just a zero-hop walk) and subsumes the narrower `extract_quant_params_through_permute`. Differential Revision: D107922730
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20139
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit e9b1f53 with merge base dc55469 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@ethansfng has exported this pull request. If you are a Meta employee, you can view the originating Diff in D107922730. |
This PR needs a
|
Summary:
extract_input_quant_params_from_graph(used byQuantizedInputWrapperto dequantize pre-quantized inputs) only matched aquantize_per_tensorplaced directly on the input placeholder. Inputs that pass through a shape-only op first -- an nhwcpermute, or a patchifyreshape-- defeated it, so callers had to pre-compute the quant params themselves.Walk from each input placeholder through a chain of transparent ops (
view/reshape/permute/transpose/slice/to/...) to the firstquantize_per_tensor, soQuantizedInputWrapper(module, input_names)resolves those inputs automatically. Backward compatible (a quantize directly on the placeholder is just a zero-hop walk) and subsumes the narrowerextract_quant_params_through_permute.Differential Revision: D107922730