13 #ifndef DIALECT_TOSA_UTILS_COVERSION_UTILS_H_ 14 #define DIALECT_TOSA_UTILS_COVERSION_UTILS_H_ 28 SmallVector<Value>
condenseValues(
const SmallVector<Value> &values);
31 template <
typename T,
typename P>
33 arith::ConstantOp
max, P pred,
35 auto smallerThanMin = rewriter.
create<T>(loc, pred, arg,
min);
37 rewriter.
create<arith::SelectOp>(loc, smallerThanMin,
min, arg);
38 auto largerThanMax = rewriter.
create<T>(loc, pred,
max, arg);
39 return rewriter.
create<arith::SelectOp>(loc, largerThanMax,
max, minOrArg);
47 arrayValues.push_back(val.cast<IntegerAttr>().getValue().getSExtValue());
53 template <
typename Op>
59 for (
const Value ¶m : params) {
60 auto paramTy = param.getType().cast<ShapedType>();
61 if (!paramTy.hasStaticShape())
62 dynTypes.push_back(paramTy);
68 for (
const ShapedType &dynTy : dynTypes) {
69 if (llvm::any_of(dynTy.getShape().drop_front(), ShapedType::isDynamic)) {
71 op,
"input can only be dynamic for batch size");
76 dynamicDims.push_back(
77 rewriter.
create<tensor::DimOp>(op->
getLoc(), params[0], 0));
84 #endif // DIALECT_TOSA_UTILS_COVERSION_UTILS_H_ Include the generated interface declarations.
A special type of RewriterBase that coordinates the application of a rewrite pattern on the current I...
void getValuesFromIntArrayAttribute(ArrayAttr attr, SmallVector< T > &arrayValues)
SmallVector< Value > condenseValues(const SmallVector< Value > &values)
SmallVector< StringRef > getNParallelLoopsAttrs(unsigned nParallelLoops)
Optional< SmallVector< Value > > checkHasDynamicBatchDims(PatternRewriter &rewriter, Op op, ArrayRef< Value > params)
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
Operation * create(const OperationState &state)
Creates an operation given the fields represented as an OperationState.
Attributes are known-constant values of operations.
static Value min(ImplicitLocOpBuilder &builder, Value value, Value bound)
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Location getLoc()
The source location the operation was defined or derived from.
arith::SelectOp clampHelper(Location loc, Value arg, arith::ConstantOp min, arith::ConstantOp max, P pred, OpBuilder &rewriter)
This provides public APIs that all operations should have.
std::enable_if_t<!std::is_convertible< CallbackT, Twine >::value, LogicalResult > notifyMatchFailure(Location loc, CallbackT &&reasonCallback)
Used to notify the rewriter that the IR failed to be rewritten because of a match failure...
This class helps build Operations.
static Value max(ImplicitLocOpBuilder &builder, Value value, Value bound)