MLIR 22.0.0git
TosaCanonicalizations.cpp File Reference
#include "mlir/Dialect/Quant/IR/Quant.h"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
#include "mlir/Dialect/Tosa/IR/TosaOps.h"
#include "mlir/Dialect/Tosa/Utils/ConversionUtils.h"
#include "mlir/IR/BuiltinTypeInterfaces.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Matchers.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Transforms/FoldUtils.h"
#include "mlir/Transforms/InliningUtils.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/APInt.h"
#include <functional>

Go to the source code of this file.

Classes

struct  MaxPool2dIsNoOp
struct  ConcatOptimization
struct  ConsolidateTransposeOptimization
struct  TransposeIsReshape
struct  ClampIsNoOp
struct  ClampClampOptimization
struct  ClampClampOptimization::ClampRange< T >
struct  ConcatSliceOptimization
struct  PadSliceOptimization
struct  SliceDynamicSizeCanonicalization

Macros

#define REDUCE_FOLDER(OP)

Functions

static bool checkMatchingPadConstAndZp (Value padConst, Value zp)
template<typename IntFolder, typename FloatFolder>
static DenseElementsAttr binaryFolder (DenseElementsAttr lhs, DenseElementsAttr rhs, RankedTensorType returnTy)
static bool isSplatZero (Type elemType, DenseElementsAttr val)
static bool isSplatOne (Type elemType, DenseElementsAttr val, int64_t shift)

Macro Definition Documentation

◆ REDUCE_FOLDER

#define REDUCE_FOLDER ( OP)
Value:
OpFoldResult OP::fold(FoldAdaptor adaptor) { \
ShapedType inputTy = llvm::cast<ShapedType>(getInput().getType()); \
if (!inputTy.hasRank()) \
return {}; \
if (inputTy != getType()) \
return {}; \
if (inputTy.getRank() == 0 || inputTy.getDimSize(getAxis()) == 1) \
return getInput(); \
return {}; \
}
This class represents a single result from folding an operation.
Type getType(OpFoldResult ofr)
Returns the int type of the integer in ofr.
Definition Utils.cpp:304

Definition at line 1305 of file TosaCanonicalizations.cpp.

Function Documentation

◆ binaryFolder()

template<typename IntFolder, typename FloatFolder>
DenseElementsAttr binaryFolder ( DenseElementsAttr lhs,
DenseElementsAttr rhs,
RankedTensorType returnTy )
static

Definition at line 892 of file TosaCanonicalizations.cpp.

References mlir::DenseElementsAttr::get(), lhs, result, and rhs.

◆ checkMatchingPadConstAndZp()

bool checkMatchingPadConstAndZp ( Value padConst,
Value zp )
static

◆ isSplatOne()

bool isSplatOne ( Type elemType,
DenseElementsAttr val,
int64_t shift )
static

◆ isSplatZero()

bool isSplatZero ( Type elemType,
DenseElementsAttr val )
static