From d3a6dbc0b895bdfdae3627c00d35066c4f51b032 Mon Sep 17 00:00:00 2001 From: Feng Liu Date: Mon, 9 Sep 2019 15:29:30 -0700 Subject: [PATCH] [NFC] Rename ExpressedToUniformQuantizedType to ExpressedToQuantizedType PiperOrigin-RevId: 268090906 --- mlir/include/mlir/Dialect/QuantOps/UniformSupport.h | 9 ++++----- mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp | 2 +- mlir/lib/Dialect/QuantOps/Utils/UniformSupport.cpp | 15 +++++++-------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/mlir/include/mlir/Dialect/QuantOps/UniformSupport.h b/mlir/include/mlir/Dialect/QuantOps/UniformSupport.h index 5d11c769..4236684 100644 --- a/mlir/include/mlir/Dialect/QuantOps/UniformSupport.h +++ b/mlir/include/mlir/Dialect/QuantOps/UniformSupport.h @@ -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; } diff --git a/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp b/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp index 1296719..4f6eb8c 100644 --- a/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp +++ b/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp @@ -62,7 +62,7 @@ public: auto fqOp = cast(op); auto converter = - ExpressedToUniformQuantizedConverter::forInputType(fqOp.getType()); + ExpressedToQuantizedConverter::forInputType(fqOp.getType()); if (!converter) { return (op->emitError("unsupported quantized type conversion"), true); } diff --git a/mlir/lib/Dialect/QuantOps/Utils/UniformSupport.cpp b/mlir/lib/Dialect/QuantOps/Utils/UniformSupport.cpp index db8a584..aec45d4 100644 --- a/mlir/lib/Dialect/QuantOps/Utils/UniformSupport.cpp +++ b/mlir/lib/Dialect/QuantOps/Utils/UniformSupport.cpp @@ -25,32 +25,31 @@ static bool isQuantizablePrimitiveType(Type inputType) { return inputType.isa(); } -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().getElementType(); if (!isQuantizablePrimitiveType(elementType)) { // Unsupported. - return ExpressedToUniformQuantizedConverter{inputType, nullptr}; + return ExpressedToQuantizedConverter{inputType, nullptr}; } - return ExpressedToUniformQuantizedConverter{ + return ExpressedToQuantizedConverter{ inputType, inputType.cast().getElementType()}; } } } -Type ExpressedToUniformQuantizedConverter::convert( - UniformQuantizedType elementalType) const { +Type ExpressedToQuantizedConverter::convert(QuantizedType elementalType) const { assert(expressedType && "convert() on unsupported conversion"); switch (inputType.getKind()) { -- 2.7.4