[all-commits] [llvm/llvm-project] 90a574: Remove redundant checks related to quantized type ...

Sandeep Dasgupta via All-commits all-commits at lists.llvm.org
Mon Oct 7 12:16:51 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 90a5744bebffafb88abf2343a1a70a37e12abef4
      https://github.com/llvm/llvm-project/commit/90a5744bebffafb88abf2343a1a70a37e12abef4
  Author: Sandeep Dasgupta <sdasgup at google.com>
  Date:   2024-10-07 (Mon, 07 Oct 2024)

  Changed paths:
    M mlir/lib/Dialect/Quant/IR/QuantTypes.cpp
    M mlir/test/Dialect/Quant/parse-uniform-invalid.mlir

  Log Message:
  -----------
  Remove redundant checks related to quantized type (#110604)

[APFloat::getSmallest](https://github.com/llvm/llvm-project/blob/915df1ae41652e2f595ce741dcd8f01878ef4e30/llvm/include/llvm/ADT/APFloat.h#L1060)
(and similarly `APFloat:getLargest`)
```
APFloat getSmallest(const fltSemantics &Sem, bool Negative = false); 
```
return the positive number when the default value for the second
argument is used.

With that being said, the check
[QuantTypes.cpp#L325](https://github.com/llvm/llvm-project/blob/96f37ae45310885e09195be09d9c05e1c1dff86b/mlir/lib/Dialect/Quant/IR/QuantTypes.cpp#L325)

```c++
 if (scale <= 0.0 || std::isinf(scale) || std::isnan(scale))
    return emitError() << "illegal scale: " << scale;
```  

is already covered by the check which follows
[QuantTypes.cpp#L327](https://github.com/llvm/llvm-project/blob/96f37ae45310885e09195be09d9c05e1c1dff86b/mlir/lib/Dialect/Quant/IR/QuantTypes.cpp#L327)

```c++
  if (scale < minScale || scale > maxScale)
    return emitError() << "scale out of expressed type range [" << minScale
                       << ", " << maxScale << "]";
```

given that range `[positive-smallest-finite-number,
positive-largest-finite-number]` does not include `inf` and `nan`s.

I propose to remove the redundant check. Any suggestion for improving
the error message is welcome.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list