MLIR  20.0.0git
Functions
TypeParser.cpp File Reference
#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...
 

Function Documentation

◆ parseAnyType()

static Type parseAnyType ( DialectAsmParser parser)
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.

◆ parseCalibratedType()

static Type parseCalibratedType ( DialectAsmParser parser)
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().

◆ parseExpressedTypeAndRange()

static FloatType parseExpressedTypeAndRange ( DialectAsmParser parser,
double &  min,
double &  max 
)
static

◆ parseQuantParams()

static ParseResult parseQuantParams ( DialectAsmParser parser,
double &  scale,
int64_t &  zeroPoint 
)
static

◆ parseStorageRange()

static ParseResult parseStorageRange ( DialectAsmParser parser,
IntegerType  storageType,
bool  isSigned,
int64_t &  storageTypeMin,
int64_t &  storageTypeMax 
)
static

◆ parseStorageType()

static IntegerType parseStorageType ( DialectAsmParser parser,
bool &  isSigned 
)
static

◆ parseUniformType()

static Type parseUniformType ( DialectAsmParser parser)
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.

◆ printAnyQuantizedType()

static void printAnyQuantizedType ( AnyQuantizedType  type,
DialectAsmPrinter out 
)
static

Helper that prints a AnyQuantizedType.

Definition at line 364 of file TypeParser.cpp.

References printStorageType().

◆ printCalibratedQuantizedType()

static void printCalibratedQuantizedType ( CalibratedQuantizedType  type,
DialectAsmPrinter out 
)
static

Helper that prints a CalibratedQuantizedType.

Definition at line 409 of file TypeParser.cpp.

References mlir::quant::CalibratedQuantizedType::getMax(), and mlir::quant::CalibratedQuantizedType::getMin().

◆ printQuantParams()

static void printQuantParams ( double  scale,
int64_t  zeroPoint,
DialectAsmPrinter out 
)
static

Definition at line 355 of file TypeParser.cpp.

Referenced by printUniformQuantizedType().

◆ printStorageType()

static void printStorageType ( QuantizedType  type,
DialectAsmPrinter out 
)
static

◆ printUniformQuantizedPerAxisType()

static void printUniformQuantizedPerAxisType ( UniformQuantizedPerAxisType  type,
DialectAsmPrinter out 
)
static

◆ printUniformQuantizedType()

static void printUniformQuantizedType ( UniformQuantizedType  type,
DialectAsmPrinter out 
)
static