openxla / stablehlo

Backward compatible ML compute opset inspired by HLO/MHLO
Apache License 2.0
357 stars 100 forks source link

Fix quant type handling in stablehlo-legalize-quant-to-int pass #2385

Closed sdasgup3 closed 3 weeks ago

sdasgup3 commented 4 weeks ago

Originally brought up at https://github.com/openxla/stablehlo/pull/2383#discussion_r1630510134

The stablehlo-legalize-quant-to-int pass propagated from mho (#2383 ) uses std::variant to handle per-tensor and per-axis quantized type. However, the base class quant::QuantizedType provides a better polymorphic way to accomplish the same.

Direction to reviewers

Please review the change only in the following commit: https://github.com/openxla/stablehlo/pull/2385/commits/ee8b499fa691bbb7b6b3948bdc581dce05abaa39

Reason: This PR is based on https://github.com/openxla/stablehlo/pull/2383 which is not merged yet and hence has many files which are already reviewed as part of #2383.

mlevesquedion commented 3 weeks ago

Can you merge main and push? Will make reviewing a bit easier.