forked from OSchip/llvm-project
[NFC] Rename ExpressedToUniformQuantizedType to ExpressedToQuantizedType
PiperOrigin-RevId: 268090906
This commit is contained in:
parent
27d776fa6d
commit
d3a6dbc0b8
|
@ -29,7 +29,7 @@ namespace mlir {
|
|||
namespace quant {
|
||||
|
||||
/// Performs type conversion from an arbitrary input type to a type
|
||||
/// that is expressed by a UniformQuantizedType.
|
||||
/// that is expressed by a QuantizedType.
|
||||
///
|
||||
/// This handles cases where the inputType is a supported primitive type
|
||||
/// (i.e. f32, bf16, etc) or a vector/tensor type based on a supported
|
||||
|
@ -38,14 +38,13 @@ namespace quant {
|
|||
/// Since conversion often involves introspecting some attributes of the
|
||||
/// input type in order to determine how to represent it, this is a two step
|
||||
/// process.
|
||||
struct ExpressedToUniformQuantizedConverter {
|
||||
struct ExpressedToQuantizedConverter {
|
||||
/// Creates a converter for the given input type.
|
||||
static const ExpressedToUniformQuantizedConverter
|
||||
forInputType(Type inputType);
|
||||
static const ExpressedToQuantizedConverter forInputType(Type inputType);
|
||||
|
||||
/// Converts the inputType to be based on the given elemental type,
|
||||
/// returning the new type (or nullptr and emit an error on failure).
|
||||
Type convert(UniformQuantizedType elementalType) const;
|
||||
Type convert(QuantizedType elementalType) const;
|
||||
|
||||
/// Whether the conversion is legal.
|
||||
explicit operator bool() const { return (bool)expressedType; }
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
auto fqOp = cast<ConstFakeQuant>(op);
|
||||
|
||||
auto converter =
|
||||
ExpressedToUniformQuantizedConverter::forInputType(fqOp.getType());
|
||||
ExpressedToQuantizedConverter::forInputType(fqOp.getType());
|
||||
if (!converter) {
|
||||
return (op->emitError("unsupported quantized type conversion"), true);
|
||||
}
|
||||
|
|
|
@ -25,32 +25,31 @@ static bool isQuantizablePrimitiveType(Type inputType) {
|
|||
return inputType.isa<FloatType>();
|
||||
}
|
||||
|
||||
const ExpressedToUniformQuantizedConverter
|
||||
ExpressedToUniformQuantizedConverter::forInputType(Type inputType) {
|
||||
const ExpressedToQuantizedConverter
|
||||
ExpressedToQuantizedConverter::forInputType(Type inputType) {
|
||||
switch (inputType.getKind()) {
|
||||
default:
|
||||
if (isQuantizablePrimitiveType(inputType)) {
|
||||
// Supported primitive type (which just is the expressed type).
|
||||
return ExpressedToUniformQuantizedConverter{inputType, inputType};
|
||||
return ExpressedToQuantizedConverter{inputType, inputType};
|
||||
}
|
||||
// Unsupported.
|
||||
return ExpressedToUniformQuantizedConverter{inputType, nullptr};
|
||||
return ExpressedToQuantizedConverter{inputType, nullptr};
|
||||
case StandardTypes::RankedTensor:
|
||||
case StandardTypes::UnrankedTensor:
|
||||
case StandardTypes::Vector: {
|
||||
Type elementType = inputType.cast<ShapedType>().getElementType();
|
||||
if (!isQuantizablePrimitiveType(elementType)) {
|
||||
// Unsupported.
|
||||
return ExpressedToUniformQuantizedConverter{inputType, nullptr};
|
||||
return ExpressedToQuantizedConverter{inputType, nullptr};
|
||||
}
|
||||
return ExpressedToUniformQuantizedConverter{
|
||||
return ExpressedToQuantizedConverter{
|
||||
inputType, inputType.cast<ShapedType>().getElementType()};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Type ExpressedToUniformQuantizedConverter::convert(
|
||||
UniformQuantizedType elementalType) const {
|
||||
Type ExpressedToQuantizedConverter::convert(QuantizedType elementalType) const {
|
||||
assert(expressedType && "convert() on unsupported conversion");
|
||||
|
||||
switch (inputType.getKind()) {
|
||||
|
|
Loading…
Reference in New Issue