My Project
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
mlir::quantizer::TargetConfiguration Class Referenceabstract

#include <Configuration.h>

Inheritance diagram for mlir::quantizer::TargetConfiguration:
Inheritance graph
[legend]

Public Types

using OpHandlerFn = std::function< void(Operation *op, CAGSlice &cag)>
 

Public Member Functions

 TargetConfiguration (SolverContext &context)
 
virtual ~TargetConfiguration ()=default
 
unsigned addCandidateType (quant::AnyQuantizedType quantizedType, CandidateQuantizedType::Scheme scheme)
 Adds a candidate type, returning its ordinal. More...
 
const CandidateQuantizedTypegetCandidateType (unsigned index) const
 Gets a prototype scheme by index. More...
 
ArrayRef< CandidateQuantizedTypegetCandidateTypes () const
 
llvm::SmallBitVector getAllCandidateTypesMask () const
 Gets a mask of all enabled candidate types by ordinal. More...
 
llvm::SmallBitVector getCandidateTypeDisabledExceptMask (ArrayRef< unsigned > exceptOrdinals) const
 Gets a mask with every candidate type except those in the given mask. More...
 
template<typename OpTy >
void addOpHandler (OpHandlerFn fn)
 Adds an op handler. More...
 
template<typename OpTy >
void addRequireStatsOp ()
 
bool isRequireStatsOp (Operation *op) const
 Returns whether opName is a RequireStatsOp. More...
 
template<typename OpTy >
void addValueIdentityOp ()
 
void handleOp (Operation *op, CAGSlice &cag) const
 Handles the operation if a handler is defined for it. More...
 
virtual void finalizeAnchors (CAGSlice &cag) const
 Finalizes the CAG after all anchors have been added. More...
 
virtual bool isHandledType (Type t) const =0
 Whether an operand or result type is subject to analysis by this config. More...
 

Static Public Attributes

static constexpr size_t MaxSchemeIndex = 31
 

Protected Member Functions

virtual void addValueIdentityOpByName (StringRef opName)=0
 
void addOpHandlerByName (StringRef name, OpHandlerFn fn)
 

Detailed Description

Defines quantization configuration for the target. The settings here depend on a variety of details about the deployment environment, although, where we have control over such things, we do try to standardize as possible.

Non-const methods are used to setup the configuration. It is expected that const instances/references are used post-build.

Member Typedef Documentation

◆ OpHandlerFn

Constructor & Destructor Documentation

◆ TargetConfiguration()

TargetConfiguration::TargetConfiguration ( SolverContext context)

◆ ~TargetConfiguration()

virtual mlir::quantizer::TargetConfiguration::~TargetConfiguration ( )
virtualdefault

Member Function Documentation

◆ addCandidateType()

unsigned mlir::quantizer::TargetConfiguration::addCandidateType ( quant::AnyQuantizedType  quantizedType,
CandidateQuantizedType::Scheme  scheme 
)
inline

Adds a candidate type, returning its ordinal.

◆ addOpHandler()

template<typename OpTy >
void mlir::quantizer::TargetConfiguration::addOpHandler ( OpHandlerFn  fn)
inline

Adds an op handler.

◆ addOpHandlerByName()

void TargetConfiguration::addOpHandlerByName ( StringRef  name,
OpHandlerFn  fn 
)
protected

◆ addRequireStatsOp()

template<typename OpTy >
void mlir::quantizer::TargetConfiguration::addRequireStatsOp ( )
inline

Adds an operation which requires statistics at its result nodes for best quantization performance. Note that the opName StringRef is expected to come from getOperationName() and be static.

◆ addValueIdentityOp()

template<typename OpTy >
void mlir::quantizer::TargetConfiguration::addValueIdentityOp ( )
inline

Adds an op which does not mutate its values but may mutate its shape or combine its operands in an arbitrary way. Such ops are expected to have the same types for operands and results and must be capable of operating on storage types.

◆ addValueIdentityOpByName()

virtual void mlir::quantizer::TargetConfiguration::addValueIdentityOpByName ( StringRef  opName)
protectedpure virtual

◆ finalizeAnchors()

virtual void mlir::quantizer::TargetConfiguration::finalizeAnchors ( CAGSlice cag) const
inlinevirtual

Finalizes the CAG after all anchors have been added.

◆ getAllCandidateTypesMask()

llvm::SmallBitVector mlir::quantizer::TargetConfiguration::getAllCandidateTypesMask ( ) const
inline

Gets a mask of all enabled candidate types by ordinal.

◆ getCandidateType()

const CandidateQuantizedType& mlir::quantizer::TargetConfiguration::getCandidateType ( unsigned  index) const
inline

Gets a prototype scheme by index.

◆ getCandidateTypeDisabledExceptMask()

llvm::SmallBitVector mlir::quantizer::TargetConfiguration::getCandidateTypeDisabledExceptMask ( ArrayRef< unsigned >  exceptOrdinals) const
inline

Gets a mask with every candidate type except those in the given mask.

◆ getCandidateTypes()

ArrayRef<CandidateQuantizedType> mlir::quantizer::TargetConfiguration::getCandidateTypes ( ) const
inline

◆ handleOp()

void TargetConfiguration::handleOp ( Operation op,
CAGSlice cag 
) const

Handles the operation if a handler is defined for it.

◆ isHandledType()

virtual bool mlir::quantizer::TargetConfiguration::isHandledType ( Type  t) const
pure virtual

Whether an operand or result type is subject to analysis by this config.

◆ isRequireStatsOp()

bool TargetConfiguration::isRequireStatsOp ( Operation op) const

Returns whether opName is a RequireStatsOp.

Member Data Documentation

◆ MaxSchemeIndex

constexpr size_t mlir::quantizer::TargetConfiguration::MaxSchemeIndex = 31
static

The documentation for this class was generated from the following files: