Hide some public API of QuantizedType inherited from Type.

It is for preventing subtle bugs when writing predicates with wrong APIs. For example,

// BAD example for checking a quant type has an i8 or i16 storage type.
auto qtype = type.dyn_cast<mlir::quant::UniformQuantizedType>()
if (qtype.isSigned() && (qtype.isInteger(8) || qtype.isInteger(16)))

PiperOrigin-RevId: 257823263
This commit is contained in:
Jing Pu 2019-07-12 10:10:42 -07:00 committed by Mehdi Amini
parent bd484f17a0
commit 8956838930
1 changed files with 12 additions and 0 deletions

View File

@ -192,6 +192,18 @@ public:
/// Example (for this = !quant.uniform<i8:f32, 1.0>):
/// tensor<4xf32> -> tensor<4xi8>
Type castExpressedToStorageType(Type candidateType);
private:
/// Hide the following methods inherited from `Type`. It is almost certainly
/// a bug to call them from a `QuantizedType` object. Users should call
/// `getStorageType` or `getExpressedType` to get the underlying types
/// they want to inspect.
using Type::isBF16;
using Type::isF16;
using Type::isF32;
using Type::isF64;
using Type::isIndex;
using Type::isInteger;
};
/// A quantized type that maps storage to/from expressed types in an