MLIR
15.0.0git
|
#include "mlir/Dialect/Linalg/IR/Linalg.h"
#include "mlir/Dialect/Affine/IR/AffineOps.h"
#include "mlir/Dialect/Arithmetic/IR/Arithmetic.h"
#include "mlir/Dialect/Arithmetic/Utils/Utils.h"
#include "mlir/Dialect/Complex/IR/Complex.h"
#include "mlir/Dialect/Math/IR/Math.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/Dialect/SparseTensor/IR/SparseTensor.h"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
#include "mlir/Dialect/Utils/ReshapeOpsUtils.h"
#include "mlir/Dialect/Utils/StaticValueUtils.h"
#include "mlir/IR/AffineExprVisitor.h"
#include "mlir/IR/AffineMap.h"
#include "mlir/IR/Matchers.h"
#include "mlir/IR/OpImplementation.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Interfaces/InferTypeOpInterface.h"
#include "mlir/Parser/Parser.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include "mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yamlgen.cpp.inc"
#include "mlir/Dialect/Linalg/IR/LinalgOps.cpp.inc"
#include "mlir/Dialect/Linalg/IR/LinalgStructuredOps.cpp.inc"
Go to the source code of this file.
Macros | |
#define | GET_OP_CLASSES |
#define | GET_OP_CLASSES |
Typedefs | |
using | RegionBuilderFn = llvm::function_ref< void(ImplicitLocOpBuilder &, Block &, ArrayRef< NamedAttribute >)> |
Functions | |
static void | fillStructuredOpRegion (OpBuilder &opBuilder, Region ®ion, TypeRange inputTypes, TypeRange outputTypes, ArrayRef< NamedAttribute > attrs, RegionBuilderFn regionBuilder) |
Fills the region of a structured operation using the provided regionBuilder . More... | |
static void | buildStructuredOp (OpBuilder &b, OperationState &state, llvm::Optional< TypeRange > resultTensorTypes, ValueRange inputs, ValueRange outputs, ArrayRef< NamedAttribute > attributes, RegionBuilderFn regionBuilder) |
Creates a structured operation given inputs , outputs , and attributes . More... | |
static ParseResult | parseCommonStructuredOpParts (OpAsmParser &parser, OperationState &result, SmallVectorImpl< Type > &inputTypes, SmallVectorImpl< Type > &outputTypes) |
Common parsing used for both named structured ops created by ods-gen and by manually defined C++ ops. More... | |
static void | printCommonStructuredOpParts (OpAsmPrinter &p, ValueRange inputs, ValueRange outputs) |
static ParseResult | parseNamedStructuredOpRegion (OpAsmParser &parser, Region ®ion, unsigned numRegionArgs, TypeRange inputTypes, TypeRange outputTypes, ArrayRef< NamedAttribute > attrs, RegionBuilderFn regionBuilder) |
static ParseResult | parseNamedStructuredOpResults (OpAsmParser &parser, SmallVectorImpl< Type > &resultTypes) |
static ParseResult | parseNamedStructuredOp (OpAsmParser &parser, OperationState &result, unsigned numRegionArgs, RegionBuilderFn regionBuilder) |
static void | printNamedStructuredOpResults (OpAsmPrinter &p, TypeRange resultTypes) |
static void | printNamedStructuredOp (OpAsmPrinter &p, Operation *op, ValueRange inputs, ValueRange outputs) |
static LogicalResult | foldMemRefCast (Operation *op) |
This is a common class used for patterns of the form someop(memrefcast(%src)) -> someop(%src) It folds the source of the memref.cast into the root operation directly. More... | |
static void | getGenericEffectsImpl (SmallVectorImpl< SideEffects::EffectInstance< MemoryEffects::Effect >> &effects, ValueRange results, ValueRange inputBuffers, ValueRange outputs) |
static LogicalResult | verifyYield (linalg::YieldOp op, LinalgOp linalgOp) |
static void | appendMangledType (llvm::raw_string_ostream &ss, Type t) |
#define GET_OP_CLASSES |
Definition at line 1453 of file LinalgOps.cpp.
#define GET_OP_CLASSES |
Definition at line 1453 of file LinalgOps.cpp.
using RegionBuilderFn = llvm::function_ref<void(ImplicitLocOpBuilder &, Block &, ArrayRef<NamedAttribute>)> |
Definition at line 51 of file LinalgOps.cpp.
Definition at line 1500 of file LinalgOps.cpp.
References mlir::Type::dyn_cast(), and mlir::Type::isSignlessIntOrIndexOrFloat().
Referenced by mlir::linalg::generateLibraryCallName().
|
static |
Creates a structured operation given inputs
, outputs
, and attributes
.
The result types are derived automatically if resultTensorTypes
is none. The body of the operation is filled using regionBuilder
. All ods-gen created structured operations use the method to implement their builders.
Definition at line 96 of file LinalgOps.cpp.
References mlir::OperationState::addAttribute(), mlir::OperationState::addAttributes(), mlir::OperationState::addOperands(), mlir::OperationState::addRegion(), mlir::OperationState::addTypes(), mlir::OperationState::attributes, fillStructuredOpRegion(), mlir::NamedAttrList::getAttrs(), mlir::Builder::getI32VectorAttr(), and mlir::ValueRange::getTypes().
|
static |
Fills the region of a structured operation using the provided regionBuilder
.
The method is used by both named structured ops created by ods-gen and by manually defined C++ ops. It is called by both builders and parsers and creates a block with arguments corresponding to the elemental types of inputTypes
and outputTypes
. All output types are asserted to be ShapedType.
Definition at line 59 of file LinalgOps.cpp.
References mlir::OpBuilder::createBlock(), mlir::getElementTypeOrSelf(), mlir::Builder::getUnknownLoc(), mlir::Type::isa(), and mlir::OpBuilder::setInsertionPointToStart().
Referenced by buildStructuredOp(), and parseNamedStructuredOpRegion().
|
static |
This is a common class used for patterns of the form
It folds the source of the memref.cast into the root operation directly.
Definition at line 260 of file LinalgOps.cpp.
References mlir::presburger::detail::abs(), mlir::RewritePatternSet::add(), mlir::OperationState::addAttributes(), mlir::OperationState::addRegion(), mlir::OperationState::addTypes(), mlir::applyMapToValues(), mlir::NamedAttrList::assign(), mlir::OperationState::attributes, mlir::bindSymbols(), mlir::tensor::canFoldIntoConsumerOp(), mlir::presburger::ceil(), mlir::OpBuilder::create(), mlir::OpBuilder::createBlock(), mlir::Type::dyn_cast(), mlir::emitWarning(), mlir::failed(), mlir::failure(), mlir::presburger::floor(), mlir::AffineMap::get(), mlir::Builder::getAffineMapArrayAttr(), mlir::Block::getArguments(), mlir::Builder::getContext(), mlir::Value::getDefiningOp(), mlir::getElementTypeOrSelf(), mlir::Value::getLoc(), mlir::Operation::getOpOperands(), mlir::Builder::getStrArrayAttr(), mlir::Builder::getStringAttr(), mlir::Attribute::getType(), mlir::Value::getType(), mlir::Builder::getUnknownLoc(), mlir::getValueOrCreateConstantIndexOp(), mlir::Type::isa(), mlir::Type::isIndex(), mlir::OperationState::location, mlir::RewriterBase::notifyMatchFailure(), mlir::OpRewritePattern< SourceOp >::OpRewritePattern(), mlir::parseAttribute(), mlir::AsmParser::parseAttribute(), parseCommonStructuredOpParts(), mlir::AsmParser::parseEqual(), parseNamedStructuredOpResults(), mlir::AsmParser::parseOptionalAttrDict(), mlir::AsmParser::parseOptionalKeyword(), mlir::OpAsmParser::parseRegion(), print(), printCommonStructuredOpParts(), printNamedStructuredOpResults(), mlir::OpAsmPrinter::printOptionalAttrDict(), mlir::OpAsmPrinter::printRegion(), mlir::OperationState::regions, mlir::RewriterBase::replaceOpWithNewOp(), mlir::OpBuilder::setInsertionPointToEnd(), mlir::succeeded(), mlir::success(), and value.
Referenced by getGenericEffectsImpl().
|
static |
Definition at line 818 of file LinalgOps.cpp.
References mlir::RewritePatternSet::add(), mlir::OperationState::addAttributes(), mlir::OperationState::attributes, mlir::tensor::canFoldIntoProducerOp(), mlir::Attribute::cast(), mlir::OpBuilder::create(), mlir::dispatchIndexOpFoldResults(), mlir::emitError(), mlir::detail::enumerate(), mlir::RewriterBase::eraseOp(), mlir::failed(), mlir::failure(), foldMemRefCast(), mlir::Block::front(), mlir::SideEffects::Effect::Base< DerivedEffect, BaseEffect >::get(), mlir::SideEffects::Resource::Base< DefaultResource >::get(), mlir::Builder::getAffineMapArrayAttr(), mlir::BlockArgument::getArgNumber(), mlir::Block::getArgument(), mlir::getAsOpFoldResult(), mlir::AsmParser::getCurrentLocation(), mlir::Value::getDefiningOp(), mlir::Builder::getI64ArrayAttr(), mlir::Builder::getIndexAttr(), mlir::getMixedSizes(), mlir::Block::getNumArguments(), getShape(), mlir::sparse_tensor::getSparseTensorEncoding(), mlir::Block::getTerminator(), mlir::Value::getType(), mlir::RewriterBase::mergeBlocks(), mlir::RewriterBase::notifyMatchFailure(), mlir::OperationState::operands, mlir::AsmParser::parseColonTypeList(), mlir::OpAsmParser::parseOperandList(), mlir::AsmParser::parseOptionalAttrDict(), print(), mlir::OpAsmPrinter::printOptionalAttrDict(), mlir::RewriterBase::replaceOp(), mlir::RewriterBase::replaceOpWithNewOp(), mlir::OpAsmParser::resolveOperands(), mlir::OpBuilder::setInsertionPoint(), mlir::success(), mlir::Value::use_empty(), value, mlir::verify(), and mlir::verifyListOfOperandsOrIntegers().
|
static |
Common parsing used for both named structured ops created by ods-gen and by manually defined C++ ops.
Does not handle regions.
Definition at line 126 of file LinalgOps.cpp.
References mlir::OperationState::addAttribute(), mlir::OperationState::attributes, mlir::failure(), mlir::AsmParser::getBuilder(), mlir::AsmParser::getCurrentLocation(), mlir::Builder::getI32VectorAttr(), mlir::OperationState::operands, mlir::AsmParser::parseColonTypeList(), mlir::AsmParser::parseLParen(), mlir::OpAsmParser::parseOperandList(), mlir::AsmParser::parseOptionalAttrDict(), mlir::AsmParser::parseOptionalKeyword(), mlir::AsmParser::parseRParen(), mlir::OpAsmParser::resolveOperands(), mlir::succeeded(), and mlir::success().
Referenced by foldMemRefCast(), and parseNamedStructuredOp().
|
static |
Definition at line 204 of file LinalgOps.cpp.
References mlir::OperationState::addRegion(), mlir::OperationState::addTypes(), mlir::OperationState::attributes, mlir::failure(), mlir::NamedAttrList::getAttrs(), parseCommonStructuredOpParts(), parseNamedStructuredOpRegion(), parseNamedStructuredOpResults(), and mlir::success().
|
static |
Definition at line 178 of file LinalgOps.cpp.
References mlir::AsmParser::emitError(), fillStructuredOpRegion(), mlir::AsmParser::getContext(), mlir::AsmParser::getCurrentLocation(), and mlir::success().
Referenced by parseNamedStructuredOp().
|
static |
Definition at line 197 of file LinalgOps.cpp.
References mlir::failure(), mlir::AsmParser::parseOptionalArrowTypeList(), and mlir::success().
Referenced by foldMemRefCast(), and parseNamedStructuredOp().
|
static |
Definition at line 166 of file LinalgOps.cpp.
References mlir::ValueRange::getTypes().
Referenced by foldMemRefCast(), and printNamedStructuredOp().
|
static |
Definition at line 237 of file LinalgOps.cpp.
References mlir::Operation::getAttrs(), mlir::Operation::getResultTypes(), printCommonStructuredOpParts(), printNamedStructuredOpResults(), and mlir::OpAsmPrinter::printOptionalAttrDict().
|
static |
Definition at line 230 of file LinalgOps.cpp.
References mlir::AsmPrinter::printOptionalArrowTypeList().
Referenced by foldMemRefCast(), and printNamedStructuredOp().
|
static |
Definition at line 1399 of file LinalgOps.cpp.
References mlir::IROperand< DerivedT, IRValueT >::get(), mlir::getElementTypeOrSelf(), mlir::Value::getType(), mlir::success(), and mlir::verify().