MLIR
20.0.0git
|
#include "mlir/Dialect/Quant/IR/Quant.h"
#include "mlir/Dialect/Quant/IR/QuantTypes.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/DialectImplementation.h"
#include "mlir/IR/Location.h"
#include "mlir/IR/Types.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/raw_ostream.h"
Go to the source code of this file.
Functions | |
static IntegerType | parseStorageType (DialectAsmParser &parser, bool &isSigned) |
static ParseResult | parseStorageRange (DialectAsmParser &parser, IntegerType storageType, bool isSigned, int64_t &storageTypeMin, int64_t &storageTypeMax) |
static FloatType | parseExpressedTypeAndRange (DialectAsmParser &parser, double &min, double &max) |
static Type | parseAnyType (DialectAsmParser &parser) |
Parses an AnyQuantizedType. More... | |
static ParseResult | parseQuantParams (DialectAsmParser &parser, double &scale, int64_t &zeroPoint) |
static Type | parseUniformType (DialectAsmParser &parser) |
Parses a UniformQuantizedType. More... | |
static Type | parseCalibratedType (DialectAsmParser &parser) |
Parses an CalibratedQuantizedType. More... | |
static void | printStorageType (QuantizedType type, DialectAsmPrinter &out) |
static void | printQuantParams (double scale, int64_t zeroPoint, DialectAsmPrinter &out) |
static void | printAnyQuantizedType (AnyQuantizedType type, DialectAsmPrinter &out) |
Helper that prints a AnyQuantizedType. More... | |
static void | printUniformQuantizedType (UniformQuantizedType type, DialectAsmPrinter &out) |
Helper that prints a UniformQuantizedType. More... | |
static void | printUniformQuantizedPerAxisType (UniformQuantizedPerAxisType type, DialectAsmPrinter &out) |
Helper that prints a UniformQuantizedPerAxisType. More... | |
static void | printCalibratedQuantizedType (CalibratedQuantizedType type, DialectAsmPrinter &out) |
Helper that prints a CalibratedQuantizedType. More... | |
|
static |
Parses an AnyQuantizedType.
any ::= any<
storage-spec (expressed-type-spec)?>
storage-spec ::= storage-type (<
storage-range >
)? storage-range ::= integer-literal :
integer-literal storage-type ::= (i
| u
) integer-literal expressed-type-spec ::= :
f
integer-literal
Definition at line 120 of file TypeParser.cpp.
References mlir::AsmParser::getChecked(), mlir::AsmParser::parseGreater(), mlir::AsmParser::parseLess(), mlir::AsmParser::parseOptionalColon(), parseStorageRange(), parseStorageType(), mlir::AsmParser::parseType(), and mlir::quant::QuantizationFlags::Signed.
|
static |
Parses an CalibratedQuantizedType.
calibrated ::= calibrated<
expressed-spec >
expressed-spec ::= expressed-type <
calibrated-range >
expressed-type ::= f
integer-literal calibrated-range ::= float-literal :
float-literal
Definition at line 297 of file TypeParser.cpp.
References mlir::AsmParser::getChecked(), max(), min(), parseExpressedTypeAndRange(), mlir::AsmParser::parseGreater(), and mlir::AsmParser::parseLess().
|
static |
Definition at line 94 of file TypeParser.cpp.
References mlir::AsmParser::emitError(), mlir::AsmParser::getCurrentLocation(), max(), min(), mlir::AsmParser::parseColon(), mlir::AsmParser::parseFloat(), mlir::AsmParser::parseGreater(), mlir::AsmParser::parseLess(), and mlir::AsmParser::parseType().
Referenced by parseCalibratedType().
|
static |
Definition at line 162 of file TypeParser.cpp.
References mlir::AsmParser::parseFloat(), mlir::AsmParser::parseInteger(), and mlir::AsmParser::parseOptionalColon().
Referenced by parseUniformType().
|
static |
Definition at line 63 of file TypeParser.cpp.
References mlir::AsmParser::emitError(), mlir::AsmParser::getCurrentLocation(), mlir::quant::QuantizedType::getDefaultMaximumForInteger(), mlir::quant::QuantizedType::getDefaultMinimumForInteger(), mlir::AsmParser::parseColon(), mlir::AsmParser::parseGreater(), mlir::AsmParser::parseInteger(), and mlir::AsmParser::parseOptionalLess().
Referenced by parseAnyType(), and parseUniformType().
|
static |
Definition at line 24 of file TypeParser.cpp.
References mlir::AsmParser::emitError(), mlir::AsmParser::getBuilder(), mlir::AsmParser::getCurrentLocation(), mlir::Builder::getIntegerType(), mlir::OptionalParseResult::has_value(), mlir::quant::QuantizedType::MaxStorageBits, mlir::AsmParser::parseKeyword(), and mlir::AsmParser::parseOptionalType().
Referenced by parseAnyType(), and parseUniformType().
|
static |
Parses a UniformQuantizedType.
uniform_type ::= uniform_per_layer | uniform_per_axis uniform_per_layer ::= uniform<
storage-spec expressed-type-spec ,
scale-zero >
uniform_per_axis ::= uniform<
storage-spec expressed-type-spec axis-spec ,
scale-zero-list >
storage-spec ::= storage-type (<
storage-range >
)? storage-range ::= integer-literal :
integer-literal storage-type ::= (i
| u
) integer-literal expressed-type-spec ::= :
f
integer-literal axis-spec ::= :
integer-literal scale-zero ::= float-literal :
integer-literal scale-zero-list ::= {
scale-zero (,
scale-zero)* }
Definition at line 194 of file TypeParser.cpp.
References mlir::AsmParser::emitError(), mlir::AsmParser::getChecked(), mlir::AsmParser::getCurrentLocation(), mlir::AsmParser::parseColon(), mlir::AsmParser::parseComma(), mlir::AsmParser::parseGreater(), mlir::AsmParser::parseInteger(), mlir::AsmParser::parseLBrace(), mlir::AsmParser::parseLess(), mlir::AsmParser::parseOptionalColon(), mlir::AsmParser::parseOptionalComma(), parseQuantParams(), mlir::AsmParser::parseRBrace(), parseStorageRange(), parseStorageType(), mlir::AsmParser::parseType(), and mlir::quant::QuantizationFlags::Signed.
|
static |
Helper that prints a AnyQuantizedType.
Definition at line 364 of file TypeParser.cpp.
References printStorageType().
|
static |
Helper that prints a CalibratedQuantizedType.
Definition at line 409 of file TypeParser.cpp.
References mlir::quant::CalibratedQuantizedType::getMax(), and mlir::quant::CalibratedQuantizedType::getMin().
|
static |
Definition at line 355 of file TypeParser.cpp.
Referenced by printUniformQuantizedType().
|
static |
Definition at line 338 of file TypeParser.cpp.
References mlir::quant::QuantizedType::getStorageTypeIntegralWidth(), mlir::quant::QuantizedType::getStorageTypeMax(), mlir::quant::QuantizedType::getStorageTypeMin(), mlir::quant::QuantizedType::hasStorageTypeBounds(), and mlir::quant::QuantizedType::isSigned().
Referenced by printAnyQuantizedType(), printUniformQuantizedPerAxisType(), and printUniformQuantizedType().
|
static |
Helper that prints a UniformQuantizedPerAxisType.
Definition at line 387 of file TypeParser.cpp.
References mlir::quant::UniformQuantizedPerAxisType::getQuantizedDimension(), mlir::quant::UniformQuantizedPerAxisType::getScales(), mlir::quant::UniformQuantizedPerAxisType::getZeroPoints(), and printStorageType().
|
static |
Helper that prints a UniformQuantizedType.
Definition at line 375 of file TypeParser.cpp.
References mlir::quant::UniformQuantizedType::getScale(), mlir::quant::UniformQuantizedType::getZeroPoint(), printQuantParams(), and printStorageType().