diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/DeviceMappingAttributes.cpp.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/DeviceMappingAttributes.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..259e3a58c3573dd05a3f123da584386006590944 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/DeviceMappingAttributes.cpp.inc @@ -0,0 +1,8 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* AttrDef Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/DeviceMappingAttributes.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/DeviceMappingAttributes.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..87b6307fd48a60e8a2fa2c1ec7ee2d50023e3b49 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/DeviceMappingAttributes.h.inc @@ -0,0 +1,19 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* AttrDef Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifdef GET_ATTRDEF_CLASSES +#undef GET_ATTRDEF_CLASSES + + +namespace mlir { +class AsmParser; +class AsmPrinter; +} // namespace mlir + +#endif // GET_ATTRDEF_CLASSES + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/DeviceMappingInterface.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/DeviceMappingInterface.h new file mode 100644 index 0000000000000000000000000000000000000000..0a7fdbb4f39029d915e740b86cda5a0cc0c89e96 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/DeviceMappingInterface.h @@ -0,0 +1,22 @@ +//===- DeviceMappingInterface.h - -------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file contains the definitions of the device mapping interface defined in +// `DeviceMappingInterface.td`. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DEVICEMAPPINGINTERFACE_H +#define MLIR_DEVICEMAPPINGINTERFACE_H + +#include "mlir/IR/OpDefinition.h" + +/// Include the generated interface declarations. +#include "mlir/Dialect/SCF/IR/DeviceMappingAttrInterface.h.inc" + +#endif // MLIR_DEVICEMAPPINGINTERFACE_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/SCF.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/SCF.h new file mode 100644 index 0000000000000000000000000000000000000000..644118ca884c6b1dd8d8e7b334eb93267e2c9de1 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/SCF.h @@ -0,0 +1,112 @@ +//===- SCFOps.h - Structured Control Flow -----------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file defines structured control flow operations. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_SCF_SCF_H +#define MLIR_DIALECT_SCF_SCF_H + +#include "mlir/Dialect/Arith/Utils/Utils.h" +#include "mlir/Dialect/SCF/IR/DeviceMappingInterface.h" +#include "mlir/IR/Builders.h" +#include "mlir/IR/BuiltinTypes.h" +#include "mlir/IR/RegionKindInterface.h" +#include "mlir/Interfaces/ControlFlowInterfaces.h" +#include "mlir/Interfaces/DestinationStyleOpInterface.h" +#include "mlir/Interfaces/InferTypeOpInterface.h" +#include "mlir/Interfaces/LoopLikeInterface.h" +#include "mlir/Interfaces/ParallelCombiningOpInterface.h" +#include "mlir/Interfaces/SideEffectInterfaces.h" +#include "mlir/Interfaces/ViewLikeInterface.h" + +namespace mlir { +namespace scf { +void buildTerminatedBody(OpBuilder &builder, Location loc); +} // namespace scf +} // namespace mlir + +#include "mlir/Dialect/SCF/IR/SCFOpsDialect.h.inc" + +#define GET_OP_CLASSES +#include "mlir/Dialect/SCF/IR/SCFOps.h.inc" + +namespace mlir { +namespace scf { + +// Insert `loop.yield` at the end of the only region's only block if it +// does not have a terminator already. If a new `loop.yield` is inserted, +// the location is specified by `loc`. If the region is empty, insert a new +// block first. +void ensureLoopTerminator(Region ®ion, Builder &builder, Location loc); + +/// Returns the loop parent of an induction variable. If the provided value is +/// not an induction variable, then return nullptr. +ForOp getForInductionVarOwner(Value val); + +/// Returns the parallel loop parent of an induction variable. If the provided +/// value is not an induction variable, then return nullptr. +ParallelOp getParallelForInductionVarOwner(Value val); + +/// Returns the ForallOp parent of an thread index variable. +/// If the provided value is not a thread index variable, then return nullptr. +ForallOp getForallOpThreadIndexOwner(Value val); + +/// Return true if ops a and b (or their ancestors) are in mutually exclusive +/// regions/blocks of an IfOp. +// TODO: Consider moving this functionality to RegionBranchOpInterface. +bool insideMutuallyExclusiveBranches(Operation *a, Operation *b); + +/// Promotes the loop body of a scf::ForallOp to its containing block. +void promote(RewriterBase &rewriter, scf::ForallOp forallOp); + +/// An owning vector of values, handy to return from functions. +using ValueVector = SmallVector; +using LoopVector = SmallVector; +struct LoopNest { + LoopVector loops; + ValueVector results; +}; + +/// Creates a perfect nest of "for" loops, i.e. all loops but the innermost +/// contain only another loop and a terminator. The lower, upper bounds and +/// steps are provided as `lbs`, `ubs` and `steps`, which are expected to be of +/// the same size. `iterArgs` points to the initial values of the loop iteration +/// arguments, which will be forwarded through the nest to the innermost loop. +/// The body of the loop is populated using `bodyBuilder`, which accepts an +/// ordered list of induction variables of all loops, followed by a list of +/// iteration arguments of the innermost loop, in the same order as provided to +/// `iterArgs`. This function is expected to return as many values as +/// `iterArgs`, of the same type and in the same order, that will be treated as +/// yielded from the loop body and forwarded back through the loop nest. If the +/// function is not provided, the loop nest is not expected to have iteration +/// arguments, the body of the innermost loop will be left empty, containing +/// only the zero-operand terminator. Returns the LoopNest containing the list +/// of perfectly nest scf::ForOp build during the call. +/// If bound arrays are empty, the body builder will be called +/// once to construct the IR outside of the loop with an empty list of induction +/// variables. +LoopNest buildLoopNest( + OpBuilder &builder, Location loc, ValueRange lbs, ValueRange ubs, + ValueRange steps, ValueRange iterArgs, + function_ref + bodyBuilder = nullptr); + +/// A convenience version for building loop nests without iteration arguments +/// (like for reductions). Does not take the initial value of reductions or +/// expect the body building functions to return their current value. +/// The built nested scf::For are captured in `capturedLoops` when non-null. +LoopNest buildLoopNest(OpBuilder &builder, Location loc, ValueRange lbs, + ValueRange ubs, ValueRange steps, + function_ref + bodyBuilder = nullptr); + +} // namespace scf +} // namespace mlir +#endif // MLIR_DIALECT_SCF_SCF_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/SCFOps.cpp.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/SCFOps.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..4cd74ac25906915683cfb13a39f6c8b71b52a363 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/SCFOps.cpp.inc @@ -0,0 +1,2793 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Op Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: SCFOps.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifdef GET_OP_LIST +#undef GET_OP_LIST + +::mlir::scf::ConditionOp, +::mlir::scf::ExecuteRegionOp, +::mlir::scf::ForOp, +::mlir::scf::ForallOp, +::mlir::scf::IfOp, +::mlir::scf::InParallelOp, +::mlir::scf::IndexSwitchOp, +::mlir::scf::ParallelOp, +::mlir::scf::ReduceOp, +::mlir::scf::ReduceReturnOp, +::mlir::scf::WhileOp, +::mlir::scf::YieldOp +#endif // GET_OP_LIST + +#ifdef GET_OP_CLASSES +#undef GET_OP_CLASSES + + +//===----------------------------------------------------------------------===// +// Local Utility Method Definitions +//===----------------------------------------------------------------------===// + +namespace mlir { +namespace scf { + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_SCFOps0( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((type.isSignlessInteger(1)))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be 1-bit signless integer, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_SCFOps1( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((true))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be any type, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_SCFOps2( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((type.isSignlessIntOrIndex()))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be signless integer or index, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_SCFOps3( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((::llvm::isa<::mlir::IndexType>(type)))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be index, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_SCFOps4( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return (true); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be ranked tensor of any type values, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_SCFOps0( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: i64 dense array attribute"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_SCFOps0( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_SCFOps0(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_SCFOps1( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !(((::llvm::isa<::mlir::ArrayAttr>(attr))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(attr), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::DeviceMappingAttrInterface>(attr))); })))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: Device Mapping array attribute"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_SCFOps1( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_SCFOps1(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_region_constraint_SCFOps0( + ::mlir::Operation *op, ::mlir::Region ®ion, ::llvm::StringRef regionName, + unsigned regionIndex) { + if (!((true))) { + return op->emitOpError("region #") << regionIndex + << (regionName.empty() ? " " : " ('" + regionName + "') ") + << "failed to verify constraint: any region"; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_region_constraint_SCFOps1( + ::mlir::Operation *op, ::mlir::Region ®ion, ::llvm::StringRef regionName, + unsigned regionIndex) { + if (!((::llvm::hasNItems(region, 1)))) { + return op->emitOpError("region #") << regionIndex + << (regionName.empty() ? " " : " ('" + regionName + "') ") + << "failed to verify constraint: region with 1 blocks"; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_region_constraint_SCFOps2( + ::mlir::Operation *op, ::mlir::Region ®ion, ::llvm::StringRef regionName, + unsigned regionIndex) { + if (!((::llvm::hasNItemsOrLess(region, 1)))) { + return op->emitOpError("region #") << regionIndex + << (regionName.empty() ? " " : " ('" + regionName + "') ") + << "failed to verify constraint: region with at most 1 blocks"; + } + return ::mlir::success(); +} +} // namespace scf +} // namespace mlir +namespace mlir { +namespace scf { + +//===----------------------------------------------------------------------===// +// ::mlir::scf::ConditionOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ConditionOpGenericAdaptorBase::ConditionOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("scf.condition", odsAttrs.getContext()); +} + +ConditionOpGenericAdaptorBase::ConditionOpGenericAdaptorBase(ConditionOp op) : ConditionOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ConditionOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr ConditionOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +ConditionOpAdaptor::ConditionOpAdaptor(ConditionOp op) : ConditionOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ConditionOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair ConditionOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range ConditionOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::IntegerType> ConditionOp::getCondition() { + return ::llvm::cast<::mlir::TypedValue<::mlir::IntegerType>>(*getODSOperands(0).begin()); +} + +::mlir::Operation::operand_range ConditionOp::getArgs() { + return getODSOperands(1); +} + +::mlir::OpOperand &ConditionOp::getConditionMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange ConditionOp::getArgsMutable() { + auto range = getODSOperandIndexAndLength(1); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair ConditionOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ConditionOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +void ConditionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value condition, ::mlir::ValueRange args) { + odsState.addOperands(condition); + odsState.addOperands(args); +} + +void ConditionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value condition, ::mlir::ValueRange args) { + odsState.addOperands(condition); + odsState.addOperands(args); + assert(resultTypes.size() == 0u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ConditionOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ConditionOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SCFOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SCFOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ConditionOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult ConditionOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand conditionRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> conditionOperands(conditionRawOperands); ::llvm::SMLoc conditionOperandsLoc; + (void)conditionOperandsLoc; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> argsOperands; + ::llvm::SMLoc argsOperandsLoc; + (void)argsOperandsLoc; + ::llvm::SmallVector<::mlir::Type, 1> argsTypes; + if (parser.parseLParen()) + return ::mlir::failure(); + + conditionOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(conditionRawOperands[0])) + return ::mlir::failure(); + if (parser.parseRParen()) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + + argsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(argsOperands)) + return ::mlir::failure(); + if (!argsOperands.empty()) { + if (parser.parseColon()) + return ::mlir::failure(); + + if (parser.parseTypeList(argsTypes)) + return ::mlir::failure(); + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(1); + if (parser.resolveOperands(conditionOperands, odsBuildableType0, conditionOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(argsOperands, argsTypes, argsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ConditionOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << "("; + _odsPrinter << getCondition(); + _odsPrinter << ")"; + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + if (!getArgs().empty()) { + _odsPrinter << ' '; + _odsPrinter << getArgs(); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter << getArgs().getTypes(); + } +} + +void ConditionOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace scf +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::scf::ConditionOp) + +namespace mlir { +namespace scf { + +//===----------------------------------------------------------------------===// +// ::mlir::scf::ExecuteRegionOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ExecuteRegionOpGenericAdaptorBase::ExecuteRegionOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("scf.execute_region", odsAttrs.getContext()); +} + +ExecuteRegionOpGenericAdaptorBase::ExecuteRegionOpGenericAdaptorBase(ExecuteRegionOp op) : ExecuteRegionOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ExecuteRegionOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ExecuteRegionOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::Region &ExecuteRegionOpGenericAdaptorBase::getRegion() { + return *odsRegions[0]; +} + +::mlir::RegionRange ExecuteRegionOpGenericAdaptorBase::getRegions() { + return odsRegions; +} + +} // namespace detail +ExecuteRegionOpAdaptor::ExecuteRegionOpAdaptor(ExecuteRegionOp op) : ExecuteRegionOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ExecuteRegionOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair ExecuteRegionOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ExecuteRegionOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +std::pair ExecuteRegionOp::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::result_range ExecuteRegionOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Region &ExecuteRegionOp::getRegion() { + return (*this)->getRegion(0); +} + +void ExecuteRegionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0) { + (void)odsState.addRegion(); + odsState.addTypes(resultType0); +} + +void ExecuteRegionOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ExecuteRegionOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SCFOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_SCFOps0(*this, region, "region", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ExecuteRegionOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +} // namespace scf +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::scf::ExecuteRegionOp) + +namespace mlir { +namespace scf { + +//===----------------------------------------------------------------------===// +// ::mlir::scf::ForOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ForOpGenericAdaptorBase::ForOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("scf.for", odsAttrs.getContext()); +} + +ForOpGenericAdaptorBase::ForOpGenericAdaptorBase(ForOp op) : ForOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ForOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, false, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 3) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr ForOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::Region &ForOpGenericAdaptorBase::getRegion() { + return *odsRegions[0]; +} + +::mlir::RegionRange ForOpGenericAdaptorBase::getRegions() { + return odsRegions; +} + +} // namespace detail +ForOpAdaptor::ForOpAdaptor(ForOp op) : ForOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ForOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair ForOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, false, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 3) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range ForOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value ForOp::getLowerBound() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin()); +} + +::mlir::Value ForOp::getUpperBound() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(1).begin()); +} + +::mlir::Value ForOp::getStep() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(2).begin()); +} + +::mlir::Operation::operand_range ForOp::getInitArgs() { + return getODSOperands(3); +} + +::mlir::OpOperand &ForOp::getLowerBoundMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &ForOp::getUpperBoundMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &ForOp::getStepMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange ForOp::getInitArgsMutable() { + auto range = getODSOperandIndexAndLength(3); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair ForOp::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::result_range ForOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::result_range ForOp::getResults() { + return getODSResults(0); +} + +::mlir::Region &ForOp::getRegion() { + return (*this)->getRegion(0); +} + +::mlir::LogicalResult ForOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SCFOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SCFOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SCFOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup3 = getODSOperands(3); + + for (auto v : valueGroup3) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SCFOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SCFOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((((*this->getODSOperands(0).begin()).getType()) == ((*this->getODSOperands(1).begin()).getType()) && ((*this->getODSOperands(1).begin()).getType()) == ((*this->getODSOperands(2).begin()).getType()) && ((*this->getODSOperands(2).begin()).getType()) == ((*this->getODSOperands(0).begin()).getType())))) + return emitOpError("failed to verify that all of {lowerBound, upperBound, step} have same type"); + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_SCFOps1(*this, region, "region", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ForOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +} // namespace scf +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::scf::ForOp) + +namespace mlir { +namespace scf { + +//===----------------------------------------------------------------------===// +// ::mlir::scf::ForallOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ForallOpGenericAdaptorBase::ForallOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("scf.forall", odsAttrs.getContext()); +} + +ForallOpGenericAdaptorBase::ForallOpGenericAdaptorBase(ForallOp op) : ForallOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ForallOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; + + unsigned start = 0; + for (unsigned i = 0; i < index; ++i) + start += sizeAttr[i]; + return {start, sizeAttr[index]}; +} + +::mlir::DictionaryAttr ForallOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::DenseI64ArrayAttr ForallOpGenericAdaptorBase::getStaticLowerBoundAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().staticLowerBound); + return attr; +} + +::llvm::ArrayRef ForallOpGenericAdaptorBase::getStaticLowerBound() { + auto attr = getStaticLowerBoundAttr(); + return attr; +} + +::mlir::DenseI64ArrayAttr ForallOpGenericAdaptorBase::getStaticUpperBoundAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().staticUpperBound); + return attr; +} + +::llvm::ArrayRef ForallOpGenericAdaptorBase::getStaticUpperBound() { + auto attr = getStaticUpperBoundAttr(); + return attr; +} + +::mlir::DenseI64ArrayAttr ForallOpGenericAdaptorBase::getStaticStepAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().staticStep); + return attr; +} + +::llvm::ArrayRef ForallOpGenericAdaptorBase::getStaticStep() { + auto attr = getStaticStepAttr(); + return attr; +} + +::mlir::ArrayAttr ForallOpGenericAdaptorBase::getMappingAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().mapping); + return attr; +} + +::std::optional< ::mlir::ArrayAttr > ForallOpGenericAdaptorBase::getMapping() { + auto attr = getMappingAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +::mlir::Region &ForallOpGenericAdaptorBase::getRegion() { + return *odsRegions[0]; +} + +::mlir::RegionRange ForallOpGenericAdaptorBase::getRegions() { + return odsRegions; +} + +} // namespace detail +ForallOpAdaptor::ForallOpAdaptor(ForallOp op) : ForallOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ForallOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_mapping = getProperties().mapping; (void)tblgen_mapping; + auto tblgen_staticLowerBound = getProperties().staticLowerBound; (void)tblgen_staticLowerBound; + if (!tblgen_staticLowerBound) return emitError(loc, "'scf.forall' op ""requires attribute 'staticLowerBound'"); + auto tblgen_staticStep = getProperties().staticStep; (void)tblgen_staticStep; + if (!tblgen_staticStep) return emitError(loc, "'scf.forall' op ""requires attribute 'staticStep'"); + auto tblgen_staticUpperBound = getProperties().staticUpperBound; (void)tblgen_staticUpperBound; + if (!tblgen_staticUpperBound) return emitError(loc, "'scf.forall' op ""requires attribute 'staticUpperBound'"); + + if (tblgen_staticLowerBound && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_staticLowerBound)))) + return emitError(loc, "'scf.forall' op ""attribute 'staticLowerBound' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_staticUpperBound && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_staticUpperBound)))) + return emitError(loc, "'scf.forall' op ""attribute 'staticUpperBound' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_staticStep && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_staticStep)))) + return emitError(loc, "'scf.forall' op ""attribute 'staticStep' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_mapping && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_mapping))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_mapping), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::DeviceMappingAttrInterface>(attr))); })))) + return emitError(loc, "'scf.forall' op ""attribute 'mapping' failed to satisfy constraint: Device Mapping array attribute"); + return ::mlir::success(); +} + +std::pair ForallOp::getODSOperandIndexAndLength(unsigned index) { + ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; + + unsigned start = 0; + for (unsigned i = 0; i < index; ++i) + start += sizeAttr[i]; + return {start, sizeAttr[index]}; +} + +::mlir::Operation::operand_range ForallOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::operand_range ForallOp::getDynamicLowerBound() { + return getODSOperands(0); +} + +::mlir::Operation::operand_range ForallOp::getDynamicUpperBound() { + return getODSOperands(1); +} + +::mlir::Operation::operand_range ForallOp::getDynamicStep() { + return getODSOperands(2); +} + +::mlir::Operation::operand_range ForallOp::getOutputs() { + return getODSOperands(3); +} + +::mlir::MutableOperandRange ForallOp::getDynamicLowerBoundMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(0u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); + return mutableRange; +} + +::mlir::MutableOperandRange ForallOp::getDynamicUpperBoundMutable() { + auto range = getODSOperandIndexAndLength(1); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); + return mutableRange; +} + +::mlir::MutableOperandRange ForallOp::getDynamicStepMutable() { + auto range = getODSOperandIndexAndLength(2); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); + return mutableRange; +} + +::mlir::MutableOperandRange ForallOp::getOutputsMutable() { + auto range = getODSOperandIndexAndLength(3); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); + return mutableRange; +} + +std::pair ForallOp::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::result_range ForallOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::result_range ForallOp::getResults() { + return getODSResults(0); +} + +::mlir::Region &ForallOp::getRegion() { + return (*this)->getRegion(0); +} + +::mlir::LogicalResult ForallOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.mapping; + auto attr = dict.get("mapping"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for mapping in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `mapping` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.staticLowerBound; + auto attr = dict.get("staticLowerBound"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for staticLowerBound in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `staticLowerBound` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.staticStep; + auto attr = dict.get("staticStep"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for staticStep in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `staticStep` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.staticUpperBound; + auto attr = dict.get("staticUpperBound"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for staticUpperBound in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `staticUpperBound` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } +; + { + auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, + ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return convertFromAttribute(propStorage, propAttr, emitError);; + }; + auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; + if (!attr) { + emitError() << "expected key entry for operandSegmentSizes in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + if (::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute ForallOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.mapping; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("mapping", + propStorage)); + } + + { + const auto &propStorage = prop.staticLowerBound; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("staticLowerBound", + propStorage)); + } + + { + const auto &propStorage = prop.staticStep; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("staticStep", + propStorage)); + } + + { + const auto &propStorage = prop.staticUpperBound; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("staticUpperBound", + propStorage)); + } + + { + const auto &propStorage = prop.operandSegmentSizes; + attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", + ::mlir::DenseI32ArrayAttr::get(ctx, propStorage))); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ForallOp::computePropertiesHash(const Properties &prop) { + auto hash_operandSegmentSizes = [] (const auto &propStorage) -> llvm::hash_code { + return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; + }; + return llvm::hash_combine( + llvm::hash_value(prop.mapping.getAsOpaquePointer()), + llvm::hash_value(prop.staticLowerBound.getAsOpaquePointer()), + llvm::hash_value(prop.staticStep.getAsOpaquePointer()), + llvm::hash_value(prop.staticUpperBound.getAsOpaquePointer()), + hash_operandSegmentSizes(prop.operandSegmentSizes)); +} + +std::optional ForallOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "mapping") + return prop.mapping; + + if (name == "staticLowerBound") + return prop.staticLowerBound; + + if (name == "staticStep") + return prop.staticStep; + + if (name == "staticUpperBound") + return prop.staticUpperBound; + if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); + return std::nullopt; +} + +void ForallOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "mapping") { + prop.mapping = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "staticLowerBound") { + prop.staticLowerBound = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "staticStep") { + prop.staticStep = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "staticUpperBound") { + prop.staticUpperBound = ::llvm::dyn_cast_or_null>(value); + return; + } + if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { + auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); + if (!arrAttr) return; + if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) + return; + llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); + return; + } +} + +void ForallOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.mapping) attrs.append("mapping", prop.mapping); + + if (prop.staticLowerBound) attrs.append("staticLowerBound", prop.staticLowerBound); + + if (prop.staticStep) attrs.append("staticStep", prop.staticStep); + + if (prop.staticUpperBound) attrs.append("staticUpperBound", prop.staticUpperBound); + attrs.append("operandSegmentSizes", ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes)); +} + +::mlir::LogicalResult ForallOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getMappingAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_SCFOps1(attr, "mapping", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getStaticLowerBoundAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_SCFOps0(attr, "staticLowerBound", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getStaticStepAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_SCFOps0(attr, "staticStep", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getStaticUpperBoundAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_SCFOps0(attr, "staticUpperBound", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ForallOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.mapping))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.staticLowerBound))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.staticStep))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.staticUpperBound))) + return ::mlir::failure(); + + { + auto &propStorage = prop.operandSegmentSizes; + auto readProp = [&]() { + +if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { + ::mlir::DenseI32ArrayAttr attr; + if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); + if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { + reader.emitError("size mismatch for operand/result_segment_size"); + return ::mlir::failure(); + } + ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); +} else { + return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); +} +; + return ::mlir::success(); + }; + if (::mlir::failed(readProp())) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +void ForallOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.mapping); + writer.writeAttribute(prop.staticLowerBound); + writer.writeAttribute(prop.staticStep); + writer.writeAttribute(prop.staticUpperBound); + + { + auto &propStorage = prop.operandSegmentSizes; + +if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) + writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(getContext(), propStorage)); +else + writer.writeSparseArray(::llvm::ArrayRef(propStorage)); +; + } +} + +::mlir::DenseI64ArrayAttr ForallOp::getStaticLowerBoundAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().staticLowerBound); +} + +::llvm::ArrayRef ForallOp::getStaticLowerBound() { + auto attr = getStaticLowerBoundAttr(); + return attr; +} + +::mlir::DenseI64ArrayAttr ForallOp::getStaticUpperBoundAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().staticUpperBound); +} + +::llvm::ArrayRef ForallOp::getStaticUpperBound() { + auto attr = getStaticUpperBoundAttr(); + return attr; +} + +::mlir::DenseI64ArrayAttr ForallOp::getStaticStepAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().staticStep); +} + +::llvm::ArrayRef ForallOp::getStaticStep() { + auto attr = getStaticStepAttr(); + return attr; +} + +::mlir::ArrayAttr ForallOp::getMappingAttr() { + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().mapping); +} + +::std::optional< ::mlir::ArrayAttr > ForallOp::getMapping() { + auto attr = getMappingAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +void ForallOp::setStaticLowerBoundAttr(::mlir::DenseI64ArrayAttr attr) { + (*this)->setAttr(getStaticLowerBoundAttrName(), attr); +} + +void ForallOp::setStaticLowerBound(::llvm::ArrayRef attrValue) { + (*this)->setAttr(getStaticLowerBoundAttrName(), ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue)); +} + +void ForallOp::setStaticUpperBoundAttr(::mlir::DenseI64ArrayAttr attr) { + (*this)->setAttr(getStaticUpperBoundAttrName(), attr); +} + +void ForallOp::setStaticUpperBound(::llvm::ArrayRef attrValue) { + (*this)->setAttr(getStaticUpperBoundAttrName(), ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue)); +} + +void ForallOp::setStaticStepAttr(::mlir::DenseI64ArrayAttr attr) { + (*this)->setAttr(getStaticStepAttrName(), attr); +} + +void ForallOp::setStaticStep(::llvm::ArrayRef attrValue) { + (*this)->setAttr(getStaticStepAttrName(), ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue)); +} + +void ForallOp::setMappingAttr(::mlir::ArrayAttr attr) { + (*this)->setAttr(getMappingAttrName(), attr); +} + +::mlir::Attribute ForallOp::removeMappingAttr() { + auto &attr = getProperties().mapping; + attr = {}; + return attr; +} + +::mlir::LogicalResult ForallOp::verifyInvariantsImpl() { + auto tblgen_mapping = getProperties().mapping; (void)tblgen_mapping; + auto tblgen_staticLowerBound = getProperties().staticLowerBound; (void)tblgen_staticLowerBound; + if (!tblgen_staticLowerBound) return emitOpError("requires attribute 'staticLowerBound'"); + auto tblgen_staticStep = getProperties().staticStep; (void)tblgen_staticStep; + if (!tblgen_staticStep) return emitOpError("requires attribute 'staticStep'"); + auto tblgen_staticUpperBound = getProperties().staticUpperBound; (void)tblgen_staticUpperBound; + if (!tblgen_staticUpperBound) return emitOpError("requires attribute 'staticUpperBound'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_SCFOps0(*this, tblgen_staticLowerBound, "staticLowerBound"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_SCFOps0(*this, tblgen_staticUpperBound, "staticUpperBound"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_SCFOps0(*this, tblgen_staticStep, "staticStep"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_SCFOps1(*this, tblgen_mapping, "mapping"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SCFOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SCFOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SCFOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup3 = getODSOperands(3); + + for (auto v : valueGroup3) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SCFOps4(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SCFOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_SCFOps1(*this, region, "region", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ForallOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +} // namespace scf +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::scf::ForallOp) + +namespace mlir { +namespace scf { + +//===----------------------------------------------------------------------===// +// ::mlir::scf::IfOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +IfOpGenericAdaptorBase::IfOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("scf.if", odsAttrs.getContext()); +} + +IfOpGenericAdaptorBase::IfOpGenericAdaptorBase(IfOp op) : IfOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair IfOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr IfOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::Region &IfOpGenericAdaptorBase::getThenRegion() { + return *odsRegions[0]; +} + +::mlir::Region &IfOpGenericAdaptorBase::getElseRegion() { + return *odsRegions[1]; +} + +::mlir::RegionRange IfOpGenericAdaptorBase::getRegions() { + return odsRegions; +} + +} // namespace detail +IfOpAdaptor::IfOpAdaptor(IfOp op) : IfOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult IfOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair IfOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range IfOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::IntegerType> IfOp::getCondition() { + return ::llvm::cast<::mlir::TypedValue<::mlir::IntegerType>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &IfOp::getConditionMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair IfOp::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::result_range IfOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::result_range IfOp::getResults() { + return getODSResults(0); +} + +::mlir::Region &IfOp::getThenRegion() { + return (*this)->getRegion(0); +} + +::mlir::Region &IfOp::getElseRegion() { + return (*this)->getRegion(1); +} + +::mlir::LogicalResult IfOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SCFOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SCFOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_SCFOps1(*this, region, "thenRegion", index++))) + return ::mlir::failure(); + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(1))) + if (::mlir::failed(__mlir_ods_local_region_constraint_SCFOps2(*this, region, "elseRegion", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult IfOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::LogicalResult +IfOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + IfOp::Adaptor adaptor(operands, attributes, properties, regions); + return IfOp::inferReturnTypes(context, + location, adaptor, inferredReturnTypes); +} + +} // namespace scf +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::scf::IfOp) + +namespace mlir { +namespace scf { + +//===----------------------------------------------------------------------===// +// ::mlir::scf::InParallelOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +InParallelOpGenericAdaptorBase::InParallelOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("scf.forall.in_parallel", odsAttrs.getContext()); +} + +InParallelOpGenericAdaptorBase::InParallelOpGenericAdaptorBase(InParallelOp op) : InParallelOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair InParallelOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr InParallelOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::Region &InParallelOpGenericAdaptorBase::getRegion() { + return *odsRegions[0]; +} + +::mlir::RegionRange InParallelOpGenericAdaptorBase::getRegions() { + return odsRegions; +} + +} // namespace detail +InParallelOpAdaptor::InParallelOpAdaptor(InParallelOp op) : InParallelOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult InParallelOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair InParallelOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range InParallelOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +std::pair InParallelOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range InParallelOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Region &InParallelOp::getRegion() { + return (*this)->getRegion(0); +} + +::mlir::LogicalResult InParallelOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_SCFOps1(*this, region, "region", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult InParallelOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +void InParallelOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace scf +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::scf::InParallelOp) + +namespace mlir { +namespace scf { + +//===----------------------------------------------------------------------===// +// ::mlir::scf::IndexSwitchOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +IndexSwitchOpGenericAdaptorBase::IndexSwitchOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("scf.index_switch", odsAttrs.getContext()); +} + +IndexSwitchOpGenericAdaptorBase::IndexSwitchOpGenericAdaptorBase(IndexSwitchOp op) : IndexSwitchOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair IndexSwitchOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr IndexSwitchOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::DenseI64ArrayAttr IndexSwitchOpGenericAdaptorBase::getCasesAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().cases); + return attr; +} + +::llvm::ArrayRef IndexSwitchOpGenericAdaptorBase::getCases() { + auto attr = getCasesAttr(); + return attr; +} + +::mlir::Region &IndexSwitchOpGenericAdaptorBase::getDefaultRegion() { + return *odsRegions[0]; +} + +::mlir::RegionRange IndexSwitchOpGenericAdaptorBase::getCaseRegions() { + return odsRegions.drop_front(1); +} + +::mlir::RegionRange IndexSwitchOpGenericAdaptorBase::getRegions() { + return odsRegions; +} + +} // namespace detail +IndexSwitchOpAdaptor::IndexSwitchOpAdaptor(IndexSwitchOp op) : IndexSwitchOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult IndexSwitchOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_cases = getProperties().cases; (void)tblgen_cases; + if (!tblgen_cases) return emitError(loc, "'scf.index_switch' op ""requires attribute 'cases'"); + + if (tblgen_cases && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_cases)))) + return emitError(loc, "'scf.index_switch' op ""attribute 'cases' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +std::pair IndexSwitchOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range IndexSwitchOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::IndexType> IndexSwitchOp::getArg() { + return ::llvm::cast<::mlir::TypedValue<::mlir::IndexType>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &IndexSwitchOp::getArgMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair IndexSwitchOp::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::result_range IndexSwitchOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::result_range IndexSwitchOp::getResults() { + return getODSResults(0); +} + +::mlir::Region &IndexSwitchOp::getDefaultRegion() { + return (*this)->getRegion(0); +} + +::mlir::MutableArrayRef<::mlir::Region> IndexSwitchOp::getCaseRegions() { + return (*this)->getRegions().drop_front(1); +} + +::mlir::LogicalResult IndexSwitchOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.cases; + auto attr = dict.get("cases"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for cases in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `cases` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute IndexSwitchOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.cases; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("cases", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code IndexSwitchOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.cases.getAsOpaquePointer())); +} + +std::optional IndexSwitchOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "cases") + return prop.cases; + return std::nullopt; +} + +void IndexSwitchOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "cases") { + prop.cases = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void IndexSwitchOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.cases) attrs.append("cases", prop.cases); +} + +::mlir::LogicalResult IndexSwitchOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getCasesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_SCFOps0(attr, "cases", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult IndexSwitchOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.cases))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void IndexSwitchOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.cases); +} + +::mlir::DenseI64ArrayAttr IndexSwitchOp::getCasesAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().cases); +} + +::llvm::ArrayRef IndexSwitchOp::getCases() { + auto attr = getCasesAttr(); + return attr; +} + +void IndexSwitchOp::setCasesAttr(::mlir::DenseI64ArrayAttr attr) { + (*this)->setAttr(getCasesAttrName(), attr); +} + +void IndexSwitchOp::setCases(::llvm::ArrayRef attrValue) { + (*this)->setAttr(getCasesAttrName(), ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue)); +} + +void IndexSwitchOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::Value arg, ::mlir::DenseI64ArrayAttr cases, unsigned caseRegionsCount) { + odsState.addOperands(arg); + odsState.getOrAddProperties().cases = cases; + (void)odsState.addRegion(); + for (unsigned i = 0; i < caseRegionsCount; ++i) + (void)odsState.addRegion(); + odsState.addTypes(results); +} + +void IndexSwitchOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::Value arg, ::llvm::ArrayRef cases, unsigned caseRegionsCount) { + odsState.addOperands(arg); + odsState.getOrAddProperties().cases = odsBuilder.getDenseI64ArrayAttr(cases); + (void)odsState.addRegion(); + for (unsigned i = 0; i < caseRegionsCount; ++i) + (void)odsState.addRegion(); + odsState.addTypes(results); +} + +void IndexSwitchOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes, unsigned numRegions) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != numRegions; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult IndexSwitchOp::verifyInvariantsImpl() { + auto tblgen_cases = getProperties().cases; (void)tblgen_cases; + if (!tblgen_cases) return emitOpError("requires attribute 'cases'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_SCFOps0(*this, tblgen_cases, "cases"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SCFOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SCFOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_SCFOps1(*this, region, "defaultRegion", index++))) + return ::mlir::failure(); + + for (auto ®ion : getCaseRegions()) + if (::mlir::failed(__mlir_ods_local_region_constraint_SCFOps1(*this, region, "caseRegions", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult IndexSwitchOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult IndexSwitchOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand argRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> argOperands(argRawOperands); ::llvm::SMLoc argOperandsLoc; + (void)argOperandsLoc; + ::llvm::SmallVector<::mlir::Type, 1> resultsTypes; + ::mlir::DenseI64ArrayAttr casesAttr; + ::llvm::SmallVector, 2> caseRegionsRegions; + std::unique_ptr<::mlir::Region> defaultRegionRegion = std::make_unique<::mlir::Region>(); + + argOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(argRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (::mlir::succeeded(parser.parseOptionalArrow())) { + + if (parser.parseTypeList(resultsTypes)) + return ::mlir::failure(); + } + { + auto odsResult = parseSwitchCases(parser, casesAttr, caseRegionsRegions); + if (odsResult) return ::mlir::failure(); + result.getOrAddProperties().cases = casesAttr; + } + if (parser.parseKeyword("default")) + return ::mlir::failure(); + + if (parser.parseRegion(*defaultRegionRegion)) + return ::mlir::failure(); + + ensureTerminator(*defaultRegionRegion, parser.getBuilder(), result.location); + result.addRegion(std::move(defaultRegionRegion)); + result.addRegions(caseRegionsRegions); + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + result.addTypes(resultsTypes); + if (parser.resolveOperands(argOperands, odsBuildableType0, argOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void IndexSwitchOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getArg(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("cases"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + if (!getResults().empty()) { + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + _odsPrinter << getResults().getTypes(); + } + _odsPrinter << ' '; + printSwitchCases(_odsPrinter, *this, getCasesAttr(), getCaseRegions()); + _odsPrinter.printNewline(); + _odsPrinter << "default"; + _odsPrinter << ' '; + + { + bool printTerminator = true; + if (auto *term = getDefaultRegion().empty() ? nullptr : getDefaultRegion().begin()->getTerminator()) { + printTerminator = !term->getAttrDictionary().empty() || + term->getNumOperands() != 0 || + term->getNumResults() != 0; + } + _odsPrinter.printRegion(getDefaultRegion(), /*printEntryBlockArgs=*/true, + /*printBlockTerminators=*/printTerminator); + } +} + +} // namespace scf +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::scf::IndexSwitchOp) + +namespace mlir { +namespace scf { + +//===----------------------------------------------------------------------===// +// ::mlir::scf::ParallelOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ParallelOpGenericAdaptorBase::ParallelOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("scf.parallel", odsAttrs.getContext()); +} + +ParallelOpGenericAdaptorBase::ParallelOpGenericAdaptorBase(ParallelOp op) : ParallelOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ParallelOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; + + unsigned start = 0; + for (unsigned i = 0; i < index; ++i) + start += sizeAttr[i]; + return {start, sizeAttr[index]}; +} + +::mlir::DictionaryAttr ParallelOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::Region &ParallelOpGenericAdaptorBase::getRegion() { + return *odsRegions[0]; +} + +::mlir::RegionRange ParallelOpGenericAdaptorBase::getRegions() { + return odsRegions; +} + +} // namespace detail +ParallelOpAdaptor::ParallelOpAdaptor(ParallelOp op) : ParallelOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ParallelOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair ParallelOp::getODSOperandIndexAndLength(unsigned index) { + ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; + + unsigned start = 0; + for (unsigned i = 0; i < index; ++i) + start += sizeAttr[i]; + return {start, sizeAttr[index]}; +} + +::mlir::Operation::operand_range ParallelOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::operand_range ParallelOp::getLowerBound() { + return getODSOperands(0); +} + +::mlir::Operation::operand_range ParallelOp::getUpperBound() { + return getODSOperands(1); +} + +::mlir::Operation::operand_range ParallelOp::getStep() { + return getODSOperands(2); +} + +::mlir::Operation::operand_range ParallelOp::getInitVals() { + return getODSOperands(3); +} + +::mlir::MutableOperandRange ParallelOp::getLowerBoundMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(0u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); + return mutableRange; +} + +::mlir::MutableOperandRange ParallelOp::getUpperBoundMutable() { + auto range = getODSOperandIndexAndLength(1); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); + return mutableRange; +} + +::mlir::MutableOperandRange ParallelOp::getStepMutable() { + auto range = getODSOperandIndexAndLength(2); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); + return mutableRange; +} + +::mlir::MutableOperandRange ParallelOp::getInitValsMutable() { + auto range = getODSOperandIndexAndLength(3); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); + return mutableRange; +} + +std::pair ParallelOp::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::result_range ParallelOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::result_range ParallelOp::getResults() { + return getODSResults(0); +} + +::mlir::Region &ParallelOp::getRegion() { + return (*this)->getRegion(0); +} + +::mlir::LogicalResult ParallelOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + ; + { + auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, + ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return convertFromAttribute(propStorage, propAttr, emitError);; + }; + auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; + if (!attr) { + emitError() << "expected key entry for operandSegmentSizes in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + if (::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute ParallelOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.operandSegmentSizes; + attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", + ::mlir::DenseI32ArrayAttr::get(ctx, propStorage))); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ParallelOp::computePropertiesHash(const Properties &prop) { + auto hash_operandSegmentSizes = [] (const auto &propStorage) -> llvm::hash_code { + return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; + }; + return llvm::hash_combine( + hash_operandSegmentSizes(prop.operandSegmentSizes)); +} + +std::optional ParallelOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); + return std::nullopt; +} + +void ParallelOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { + auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); + if (!arrAttr) return; + if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) + return; + llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); + return; + } +} + +void ParallelOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + attrs.append("operandSegmentSizes", ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes)); +} + +::mlir::LogicalResult ParallelOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return ::mlir::success(); +} + +::mlir::LogicalResult ParallelOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + { + auto &propStorage = prop.operandSegmentSizes; + auto readProp = [&]() { + +if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { + ::mlir::DenseI32ArrayAttr attr; + if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); + if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { + reader.emitError("size mismatch for operand/result_segment_size"); + return ::mlir::failure(); + } + ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); +} else { + return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); +} +; + return ::mlir::success(); + }; + if (::mlir::failed(readProp())) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +void ParallelOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + { + auto &propStorage = prop.operandSegmentSizes; + +if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) + writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(getContext(), propStorage)); +else + writer.writeSparseArray(::llvm::ArrayRef(propStorage)); +; + } +} + +::mlir::LogicalResult ParallelOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SCFOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SCFOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SCFOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup3 = getODSOperands(3); + + for (auto v : valueGroup3) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SCFOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SCFOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_SCFOps1(*this, region, "region", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ParallelOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +} // namespace scf +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::scf::ParallelOp) + +namespace mlir { +namespace scf { + +//===----------------------------------------------------------------------===// +// ::mlir::scf::ReduceOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ReduceOpGenericAdaptorBase::ReduceOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("scf.reduce", odsAttrs.getContext()); +} + +ReduceOpGenericAdaptorBase::ReduceOpGenericAdaptorBase(ReduceOp op) : ReduceOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ReduceOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ReduceOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::Region &ReduceOpGenericAdaptorBase::getReductionOperator() { + return *odsRegions[0]; +} + +::mlir::RegionRange ReduceOpGenericAdaptorBase::getRegions() { + return odsRegions; +} + +} // namespace detail +ReduceOpAdaptor::ReduceOpAdaptor(ReduceOp op) : ReduceOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ReduceOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair ReduceOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ReduceOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value ReduceOp::getOperand() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &ReduceOp::getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair ReduceOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ReduceOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Region &ReduceOp::getReductionOperator() { + return (*this)->getRegion(0); +} + +::mlir::LogicalResult ReduceOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SCFOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_SCFOps1(*this, region, "reductionOperator", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ReduceOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +} // namespace scf +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::scf::ReduceOp) + +namespace mlir { +namespace scf { + +//===----------------------------------------------------------------------===// +// ::mlir::scf::ReduceReturnOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ReduceReturnOpGenericAdaptorBase::ReduceReturnOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("scf.reduce.return", odsAttrs.getContext()); +} + +ReduceReturnOpGenericAdaptorBase::ReduceReturnOpGenericAdaptorBase(ReduceReturnOp op) : ReduceReturnOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ReduceReturnOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ReduceReturnOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +ReduceReturnOpAdaptor::ReduceReturnOpAdaptor(ReduceReturnOp op) : ReduceReturnOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ReduceReturnOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair ReduceReturnOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ReduceReturnOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value ReduceReturnOp::getResult() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &ReduceReturnOp::getResultMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair ReduceReturnOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ReduceReturnOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +void ReduceReturnOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value result) { + odsState.addOperands(result); +} + +void ReduceReturnOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value result) { + odsState.addOperands(result); + assert(resultTypes.size() == 0u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ReduceReturnOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ReduceReturnOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SCFOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ReduceReturnOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult ReduceReturnOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand resultRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> resultOperands(resultRawOperands); ::llvm::SMLoc resultOperandsLoc; + (void)resultOperandsLoc; + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + resultOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(resultRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + if (parser.resolveOperands(resultOperands, resultTypes, resultOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ReduceReturnOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getResult(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void ReduceReturnOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace scf +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::scf::ReduceReturnOp) + +namespace mlir { +namespace scf { + +//===----------------------------------------------------------------------===// +// ::mlir::scf::WhileOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +WhileOpGenericAdaptorBase::WhileOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("scf.while", odsAttrs.getContext()); +} + +WhileOpGenericAdaptorBase::WhileOpGenericAdaptorBase(WhileOp op) : WhileOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair WhileOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr WhileOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::Region &WhileOpGenericAdaptorBase::getBefore() { + return *odsRegions[0]; +} + +::mlir::Region &WhileOpGenericAdaptorBase::getAfter() { + return *odsRegions[1]; +} + +::mlir::RegionRange WhileOpGenericAdaptorBase::getRegions() { + return odsRegions; +} + +} // namespace detail +WhileOpAdaptor::WhileOpAdaptor(WhileOp op) : WhileOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult WhileOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair WhileOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range WhileOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::operand_range WhileOp::getInits() { + return getODSOperands(0); +} + +::mlir::MutableOperandRange WhileOp::getInitsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair WhileOp::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::result_range WhileOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::result_range WhileOp::getResults() { + return getODSResults(0); +} + +::mlir::Region &WhileOp::getBefore() { + return (*this)->getRegion(0); +} + +::mlir::Region &WhileOp::getAfter() { + return (*this)->getRegion(1); +} + +void WhileOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 2; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult WhileOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SCFOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SCFOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_SCFOps1(*this, region, "before", index++))) + return ::mlir::failure(); + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(1))) + if (::mlir::failed(__mlir_ods_local_region_constraint_SCFOps1(*this, region, "after", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult WhileOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +} // namespace scf +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::scf::WhileOp) + +namespace mlir { +namespace scf { + +//===----------------------------------------------------------------------===// +// ::mlir::scf::YieldOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +YieldOpGenericAdaptorBase::YieldOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("scf.yield", odsAttrs.getContext()); +} + +YieldOpGenericAdaptorBase::YieldOpGenericAdaptorBase(YieldOp op) : YieldOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair YieldOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr YieldOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +YieldOpAdaptor::YieldOpAdaptor(YieldOp op) : YieldOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult YieldOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair YieldOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range YieldOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::operand_range YieldOp::getResults() { + return getODSOperands(0); +} + +::mlir::MutableOperandRange YieldOp::getResultsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair YieldOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range YieldOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +void YieldOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { + /* nothing to do */ +} + +void YieldOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange results) { + odsState.addOperands(results); +} + +void YieldOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult YieldOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SCFOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult YieldOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult YieldOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> resultsOperands; + ::llvm::SMLoc resultsOperandsLoc; + (void)resultsOperandsLoc; + ::llvm::SmallVector<::mlir::Type, 1> resultsTypes; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + + resultsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(resultsOperands)) + return ::mlir::failure(); + if (!resultsOperands.empty()) { + if (parser.parseColon()) + return ::mlir::failure(); + + if (parser.parseTypeList(resultsTypes)) + return ::mlir::failure(); + } + if (parser.resolveOperands(resultsOperands, resultsTypes, resultsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void YieldOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + if (!getResults().empty()) { + _odsPrinter << ' '; + _odsPrinter << getResults(); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter << getResults().getTypes(); + } +} + +void YieldOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::mlir::MutableOperandRange YieldOp::getMutableSuccessorOperands( + ::mlir::RegionBranchPoint point) { + return ::mlir::MutableOperandRange(*this); +} + +} // namespace scf +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::scf::YieldOp) + + +#endif // GET_OP_CLASSES + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/SCFOps.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/SCFOps.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..3fcc357693213dcacbd5dfdd5345d4dd0e6dd60a --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/SCFOps.h.inc @@ -0,0 +1,1885 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Op Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: SCFOps.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#if defined(GET_OP_CLASSES) || defined(GET_OP_FWD_DEFINES) +#undef GET_OP_FWD_DEFINES +namespace mlir { +namespace scf { +class ConditionOp; +} // namespace scf +} // namespace mlir +namespace mlir { +namespace scf { +class ExecuteRegionOp; +} // namespace scf +} // namespace mlir +namespace mlir { +namespace scf { +class ForOp; +} // namespace scf +} // namespace mlir +namespace mlir { +namespace scf { +class ForallOp; +} // namespace scf +} // namespace mlir +namespace mlir { +namespace scf { +class IfOp; +} // namespace scf +} // namespace mlir +namespace mlir { +namespace scf { +class InParallelOp; +} // namespace scf +} // namespace mlir +namespace mlir { +namespace scf { +class IndexSwitchOp; +} // namespace scf +} // namespace mlir +namespace mlir { +namespace scf { +class ParallelOp; +} // namespace scf +} // namespace mlir +namespace mlir { +namespace scf { +class ReduceOp; +} // namespace scf +} // namespace mlir +namespace mlir { +namespace scf { +class ReduceReturnOp; +} // namespace scf +} // namespace mlir +namespace mlir { +namespace scf { +class WhileOp; +} // namespace scf +} // namespace mlir +namespace mlir { +namespace scf { +class YieldOp; +} // namespace scf +} // namespace mlir +#endif + +#ifdef GET_OP_CLASSES +#undef GET_OP_CLASSES + + +//===----------------------------------------------------------------------===// +// Local Utility Method Definitions +//===----------------------------------------------------------------------===// + +namespace mlir { +namespace scf { + +//===----------------------------------------------------------------------===// +// ::mlir::scf::ConditionOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ConditionOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + ConditionOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + ConditionOpGenericAdaptorBase(ConditionOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class ConditionOpGenericAdaptor : public detail::ConditionOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ConditionOpGenericAdaptorBase; +public: + ConditionOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ConditionOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ConditionOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + ConditionOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getCondition() { + return (*getODSOperands(0).begin()); + } + + RangeT getArgs() { + return getODSOperands(1); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ConditionOpAdaptor : public ConditionOpGenericAdaptor<::mlir::ValueRange> { +public: + using ConditionOpGenericAdaptor::ConditionOpGenericAdaptor; + ConditionOpAdaptor(ConditionOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ConditionOp : public ::mlir::Op::Impl, ::mlir::OpTrait::HasParent::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::RegionBranchTerminatorOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::IsTerminator> { +public: + using Op::Op; + using Op::print; + using Adaptor = ConditionOpAdaptor; + template + using GenericAdaptor = ConditionOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("scf.condition"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::IntegerType> getCondition(); + ::mlir::Operation::operand_range getArgs(); + ::mlir::OpOperand &getConditionMutable(); + ::mlir::MutableOperandRange getArgsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value condition, ::mlir::ValueRange args); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value condition, ::mlir::ValueRange args); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::MutableOperandRange getMutableSuccessorOperands(::mlir::RegionBranchPoint point); + void getSuccessorRegions(::llvm::ArrayRef<::mlir::Attribute> operands, ::llvm::SmallVectorImpl<::mlir::RegionSuccessor> ®ions); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace scf +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::ConditionOp) + +namespace mlir { +namespace scf { + +//===----------------------------------------------------------------------===// +// ::mlir::scf::ExecuteRegionOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ExecuteRegionOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + ExecuteRegionOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + ExecuteRegionOpGenericAdaptorBase(ExecuteRegionOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); + ::mlir::Region &getRegion(); + ::mlir::RegionRange getRegions(); +}; +} // namespace detail +template +class ExecuteRegionOpGenericAdaptor : public detail::ExecuteRegionOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ExecuteRegionOpGenericAdaptorBase; +public: + ExecuteRegionOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ExecuteRegionOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ExecuteRegionOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + ExecuteRegionOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ExecuteRegionOpAdaptor : public ExecuteRegionOpGenericAdaptor<::mlir::ValueRange> { +public: + using ExecuteRegionOpGenericAdaptor::ExecuteRegionOpGenericAdaptor; + ExecuteRegionOpAdaptor(ExecuteRegionOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ExecuteRegionOp : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = ExecuteRegionOpAdaptor; + template + using GenericAdaptor = ExecuteRegionOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("scf.execute_region"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Region &getRegion(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &p); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + void getSuccessorRegions(::mlir::RegionBranchPoint point, ::llvm::SmallVectorImpl<::mlir::RegionSuccessor> ®ions); +public: +}; +} // namespace scf +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::ExecuteRegionOp) + +namespace mlir { +namespace scf { + +//===----------------------------------------------------------------------===// +// ::mlir::scf::ForOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ForOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + ForOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + ForOpGenericAdaptorBase(ForOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); + ::mlir::Region &getRegion(); + ::mlir::RegionRange getRegions(); +}; +} // namespace detail +template +class ForOpGenericAdaptor : public detail::ForOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ForOpGenericAdaptorBase; +public: + ForOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ForOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ForOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + ForOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLowerBound() { + return (*getODSOperands(0).begin()); + } + + ValueT getUpperBound() { + return (*getODSOperands(1).begin()); + } + + ValueT getStep() { + return (*getODSOperands(2).begin()); + } + + RangeT getInitArgs() { + return getODSOperands(3); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ForOpAdaptor : public ForOpGenericAdaptor<::mlir::ValueRange> { +public: + using ForOpGenericAdaptor::ForOpGenericAdaptor; + ForOpAdaptor(ForOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ForOp : public ::mlir::Op::Impl, ::mlir::OpTrait::SingleBlock, ::mlir::OpTrait::SingleBlockImplicitTerminator::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::OpTrait::AutomaticAllocationScope, ::mlir::LoopLikeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::RegionBranchOpInterface::Trait, ::mlir::OpTrait::HasRecursiveMemoryEffects> { +public: + using Op::Op; + using Op::print; + using Adaptor = ForOpAdaptor; + template + using GenericAdaptor = ForOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("scf.for"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getLowerBound(); + ::mlir::Value getUpperBound(); + ::mlir::Value getStep(); + ::mlir::Operation::operand_range getInitArgs(); + ::mlir::OpOperand &getLowerBoundMutable(); + ::mlir::OpOperand &getUpperBoundMutable(); + ::mlir::OpOperand &getStepMutable(); + ::mlir::MutableOperandRange getInitArgsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Operation::result_range getResults(); + ::mlir::Region &getRegion(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value lowerBound, Value upperBound, Value step, ValueRange iterArgs = std::nullopt, function_ref odsArg4 = nullptr); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &p); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + ::mlir::LogicalResult verifyRegions(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::llvm::SmallVector<::mlir::Region *> getLoopRegions(); + ::mlir::LogicalResult promoteIfSingleIteration(::mlir::RewriterBase &rewriter); + ::std::optional<::mlir::Value> getSingleInductionVar(); + ::std::optional<::mlir::OpFoldResult> getSingleLowerBound(); + ::std::optional<::mlir::OpFoldResult> getSingleStep(); + ::std::optional<::mlir::OpFoldResult> getSingleUpperBound(); + ::mlir::OperandRange getInits(); + ::mlir::FailureOr<::mlir::LoopLikeOpInterface> replaceWithAdditionalYields(::mlir::RewriterBase &rewriter, ::mlir::ValueRange newInitOperands, bool replaceInitOperandUsesInLoop, const ::mlir::NewYieldValuesFn &newYieldValuesFn); + ::mlir::OperandRange getEntrySuccessorOperands(::mlir::RegionBranchPoint point); + void getSuccessorRegions(::mlir::RegionBranchPoint point, ::llvm::SmallVectorImpl<::mlir::RegionSuccessor> ®ions); +public: + using BodyBuilderFn = + function_ref; + + Value getInductionVar() { return getBody()->getArgument(0); } + Block::BlockArgListType getRegionIterArgs() { + return getBody()->getArguments().drop_front(getNumInductionVars()); + } + /// Return the `index`-th region iteration argument. + BlockArgument getRegionIterArg(unsigned index) { + assert(index < getNumRegionIterArgs() && + "expected an index less than the number of region iter args"); + return getBody()->getArguments().drop_front(getNumInductionVars())[index]; + } + + void setLowerBound(Value bound) { getOperation()->setOperand(0, bound); } + void setUpperBound(Value bound) { getOperation()->setOperand(1, bound); } + void setStep(Value step) { getOperation()->setOperand(2, step); } + + /// Number of induction variables, always 1 for scf::ForOp. + unsigned getNumInductionVars() { return 1; } + /// Number of region arguments for loop-carried values + unsigned getNumRegionIterArgs() { + return getBody()->getNumArguments() - getNumInductionVars(); + } + /// Number of operands controlling the loop: lb, ub, step + unsigned getNumControlOperands() { return 3; } + + /// Get the region iter arg that corresponds to an OpOperand. + /// This helper prevents internal op implementation detail leakage to + /// clients by hiding the operand / block argument mapping. + BlockArgument getRegionIterArgForOpOperand(OpOperand &opOperand) { + assert(opOperand.getOperandNumber() >= getNumControlOperands() && + "expected an iter args operand"); + assert(opOperand.getOwner() == getOperation() && + "opOperand does not belong to this scf::ForOp operation"); + return getRegionIterArgs()[ + opOperand.getOperandNumber() - getNumControlOperands()]; + } + /// Get the OpOperand& that corresponds to a region iter arg. + /// This helper prevents internal op implementation detail leakage to + /// clients by hiding the operand / block argument mapping. + OpOperand &getOpOperandForRegionIterArg(BlockArgument bbArg) { + assert(bbArg.getArgNumber() >= getNumInductionVars() && + "expected a bbArg that is not an induction variable"); + assert(bbArg.getOwner()->getParentOp() == getOperation() && + "bbArg does not belong to the scf::ForOp body"); + return getOperation()->getOpOperand( + getNumControlOperands() + bbArg.getArgNumber() - getNumInductionVars()); + } + /// Get the OpResult that corresponds to an OpOperand. + /// Assert that opOperand is an iterArg. + /// This helper prevents internal op implementation detail leakage to + /// clients by hiding the operand / block argument mapping. + OpResult getResultForOpOperand(OpOperand &opOperand) { + assert(opOperand.getOperandNumber() >= getNumControlOperands() && + "expected an iter args operand"); + assert(opOperand.getOwner() == getOperation() && + "opOperand does not belong to this scf::ForOp operation"); + return getOperation()->getResult( + opOperand.getOperandNumber() - getNumControlOperands()); + } + /// Get the OpOperand& that corresponds to an OpResultOpOperand. + /// This helper prevents internal op implementation detail leakage to + /// clients by hiding the operand / block argument mapping. + OpOperand &getOpOperandForResult(OpResult opResult) { + assert(opResult.getDefiningOp() == getOperation() && + "opResult does not belong to the scf::ForOp operation"); + return getOperation()->getOpOperand( + getNumControlOperands() + opResult.getResultNumber()); + } + + /// Returns the step as an `APInt` if it is constant. + std::optional getConstantStep(); + + /// Interface method for ConditionallySpeculatable. + Speculation::Speculatability getSpeculatability(); +}; +} // namespace scf +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::ForOp) + +namespace mlir { +namespace scf { + +//===----------------------------------------------------------------------===// +// ::mlir::scf::ForallOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ForallOpGenericAdaptorBase { +public: + struct Properties { + using mappingTy = ::mlir::ArrayAttr; + mappingTy mapping; + + auto getMapping() { + auto &propStorage = this->mapping; + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(propStorage); + } + void setMapping(const ::mlir::ArrayAttr &propValue) { + this->mapping = propValue; + } + using staticLowerBoundTy = ::mlir::DenseI64ArrayAttr; + staticLowerBoundTy staticLowerBound; + + auto getStaticLowerBound() { + auto &propStorage = this->staticLowerBound; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setStaticLowerBound(const ::mlir::DenseI64ArrayAttr &propValue) { + this->staticLowerBound = propValue; + } + using staticStepTy = ::mlir::DenseI64ArrayAttr; + staticStepTy staticStep; + + auto getStaticStep() { + auto &propStorage = this->staticStep; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setStaticStep(const ::mlir::DenseI64ArrayAttr &propValue) { + this->staticStep = propValue; + } + using staticUpperBoundTy = ::mlir::DenseI64ArrayAttr; + staticUpperBoundTy staticUpperBound; + + auto getStaticUpperBound() { + auto &propStorage = this->staticUpperBound; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setStaticUpperBound(const ::mlir::DenseI64ArrayAttr &propValue) { + this->staticUpperBound = propValue; + } + using operandSegmentSizesTy = std::array; + operandSegmentSizesTy operandSegmentSizes; + ::llvm::ArrayRef getOperandSegmentSizes() { + auto &propStorage = this->operandSegmentSizes; + return propStorage; + } + void setOperandSegmentSizes(const ::llvm::ArrayRef &propValue) { + auto &propStorage = this->operandSegmentSizes; + ::llvm::copy(propValue, propStorage.begin()); + } + bool operator==(const Properties &rhs) const { + return + rhs.mapping == this->mapping && + rhs.staticLowerBound == this->staticLowerBound && + rhs.staticStep == this->staticStep && + rhs.staticUpperBound == this->staticUpperBound && + rhs.operandSegmentSizes == this->operandSegmentSizes && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ForallOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + ForallOpGenericAdaptorBase(ForallOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::DenseI64ArrayAttr getStaticLowerBoundAttr(); + ::llvm::ArrayRef getStaticLowerBound(); + ::mlir::DenseI64ArrayAttr getStaticUpperBoundAttr(); + ::llvm::ArrayRef getStaticUpperBound(); + ::mlir::DenseI64ArrayAttr getStaticStepAttr(); + ::llvm::ArrayRef getStaticStep(); + ::mlir::ArrayAttr getMappingAttr(); + ::std::optional< ::mlir::ArrayAttr > getMapping(); + ::mlir::Region &getRegion(); + ::mlir::RegionRange getRegions(); +}; +} // namespace detail +template +class ForallOpGenericAdaptor : public detail::ForallOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ForallOpGenericAdaptorBase; +public: + ForallOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ForallOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ForallOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + ForallOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getDynamicLowerBound() { + return getODSOperands(0); + } + + RangeT getDynamicUpperBound() { + return getODSOperands(1); + } + + RangeT getDynamicStep() { + return getODSOperands(2); + } + + RangeT getOutputs() { + return getODSOperands(3); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ForallOpAdaptor : public ForallOpGenericAdaptor<::mlir::ValueRange> { +public: + using ForallOpGenericAdaptor::ForallOpGenericAdaptor; + ForallOpAdaptor(ForallOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ForallOp : public ::mlir::Op::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpTrait::AutomaticAllocationScope, ::mlir::LoopLikeOpInterface::Trait, ::mlir::OpTrait::HasRecursiveMemoryEffects, ::mlir::RegionBranchOpInterface::Trait, ::mlir::DestinationStyleOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ForallOpAdaptor; + template + using GenericAdaptor = ForallOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("mapping"), ::llvm::StringRef("staticLowerBound"), ::llvm::StringRef("staticStep"), ::llvm::StringRef("staticUpperBound"), ::llvm::StringRef("operandSegmentSizes")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getMappingAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getMappingAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getStaticLowerBoundAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getStaticLowerBoundAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getStaticStepAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getStaticStepAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getStaticUpperBoundAttrName() { + return getAttributeNameForIndex(3); + } + + static ::mlir::StringAttr getStaticUpperBoundAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 3); + } + + ::mlir::StringAttr getOperandSegmentSizesAttrName() { + return (*this)->getName().getAttributeNames().back(); + } + + static ::mlir::StringAttr getOperandSegmentSizesAttrName(::mlir::OperationName name) { + return name.getAttributeNames().back(); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("scf.forall"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Operation::operand_range getDynamicLowerBound(); + ::mlir::Operation::operand_range getDynamicUpperBound(); + ::mlir::Operation::operand_range getDynamicStep(); + ::mlir::Operation::operand_range getOutputs(); + ::mlir::MutableOperandRange getDynamicLowerBoundMutable(); + ::mlir::MutableOperandRange getDynamicUpperBoundMutable(); + ::mlir::MutableOperandRange getDynamicStepMutable(); + ::mlir::MutableOperandRange getOutputsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Operation::result_range getResults(); + ::mlir::Region &getRegion(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getStaticLowerBoundAttr(); + ::llvm::ArrayRef getStaticLowerBound(); + ::mlir::DenseI64ArrayAttr getStaticUpperBoundAttr(); + ::llvm::ArrayRef getStaticUpperBound(); + ::mlir::DenseI64ArrayAttr getStaticStepAttr(); + ::llvm::ArrayRef getStaticStep(); + ::mlir::ArrayAttr getMappingAttr(); + ::std::optional< ::mlir::ArrayAttr > getMapping(); + void setStaticLowerBoundAttr(::mlir::DenseI64ArrayAttr attr); + void setStaticLowerBound(::llvm::ArrayRef attrValue); + void setStaticUpperBoundAttr(::mlir::DenseI64ArrayAttr attr); + void setStaticUpperBound(::llvm::ArrayRef attrValue); + void setStaticStepAttr(::mlir::DenseI64ArrayAttr attr); + void setStaticStep(::llvm::ArrayRef attrValue); + void setMappingAttr(::mlir::ArrayAttr attr); + ::mlir::Attribute removeMappingAttr(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ArrayRef lbs, ArrayRef ubs, ArrayRef steps, ValueRange outputs, std::optional mapping, function_ref bodyBuilderFn = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ArrayRef ubs, ValueRange outputs, std::optional mapping, function_ref bodyBuilderFn = nullptr); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &p); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::llvm::SmallVector<::mlir::Region *> getLoopRegions(); + ::mlir::LogicalResult promoteIfSingleIteration(::mlir::RewriterBase &rewriter); + void getSuccessorRegions(::mlir::RegionBranchPoint point, ::llvm::SmallVectorImpl<::mlir::RegionSuccessor> ®ions); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 4 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + // Get lower bounds as OpFoldResult. + SmallVector getMixedLowerBound() { + Builder b(getOperation()->getContext()); + return getMixedValues(getStaticLowerBound(), getDynamicLowerBound(), b); + } + + // Get upper bounds as OpFoldResult. + SmallVector getMixedUpperBound() { + Builder b(getOperation()->getContext()); + return getMixedValues(getStaticUpperBound(), getDynamicUpperBound(), b); + } + + // Get steps as OpFoldResult. + SmallVector getMixedStep() { + Builder b(getOperation()->getContext()); + return getMixedValues(getStaticStep(), getDynamicStep(), b); + } + + /// Get lower bounds as values. + SmallVector getLowerBound(OpBuilder &b) { + return getValueOrCreateConstantIndexOp(b, getLoc(), getMixedLowerBound()); + } + + /// Get upper bounds as values. + SmallVector getUpperBound(OpBuilder &b) { + return getValueOrCreateConstantIndexOp(b, getLoc(), getMixedUpperBound()); + } + + /// Get steps as values. + SmallVector getStep(OpBuilder &b) { + return getValueOrCreateConstantIndexOp(b, getLoc(), getMixedStep()); + } + + int64_t getRank() { return getStaticLowerBound().size(); } + + /// Number of operands controlling the loop: lbs, ubs, steps + unsigned getNumControlOperands() { return 3 * getRank(); } + + /// Number of dynamic operands controlling the loop: lbs, ubs, steps + unsigned getNumDynamicControlOperands() { + return getODSOperandIndexAndLength(3).first; + } + + OpResult getTiedOpResult(OpOperand *opOperand) { + assert(opOperand->getOperandNumber() >= getNumDynamicControlOperands() && + "invalid operand"); + return getOperation()->getOpResult( + opOperand->getOperandNumber() - getNumDynamicControlOperands()); + } + + /// Return the num_threads operand that is tied to the given thread id + /// block argument. + OpOperand *getTiedOpOperand(BlockArgument bbArg) { + assert(bbArg.getArgNumber() >= getRank() && "invalid bbArg"); + + return &getOperation()->getOpOperand(getNumDynamicControlOperands() + + bbArg.getArgNumber() - getRank()); + } + + /// Return the shared_outs operand that is tied to the given OpResult. + OpOperand *getTiedOpOperand(OpResult opResult) { + assert(opResult.getDefiningOp() == getOperation() && "invalid OpResult"); + return &getOperation()->getOpOperand(getNumDynamicControlOperands() + + opResult.getResultNumber()); + } + + BlockArgument getTiedBlockArgument(OpOperand *opOperand) { + assert(opOperand->getOperandNumber() >= getNumDynamicControlOperands() && + "invalid operand"); + + return getBody()->getArgument(opOperand->getOperandNumber() - + getNumDynamicControlOperands() + getRank()); + } + + ArrayRef getOutputBlockArguments() { + return getBody()->getArguments().drop_front(getRank()); + } + + ::mlir::ValueRange getInductionVars() { + return getBody()->getArguments().take_front(getRank()); + } + + ::mlir::Value getInductionVar(int64_t idx) { + return getInductionVars()[idx]; + } + + ::mlir::Block::BlockArgListType getRegionOutArgs() { + return getBody()->getArguments().drop_front(getRank()); + } + + /// Checks if the lbs are zeros and steps are ones. + bool isNormalized(); + + // The ensureTerminator method generated by SingleBlockImplicitTerminator is + // unaware of the fact that our terminator also needs a region to be + // well-formed. We override it here to ensure that we do the right thing. + static void ensureTerminator(Region & region, OpBuilder & builder, + Location loc); + + InParallelOp getTerminator(); + + // Declare the shared_outs as inits/outs to DestinationStyleOpInterface. + MutableOperandRange getDpsInitsMutable() { return getOutputsMutable(); } +}; +} // namespace scf +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::ForallOp) + +namespace mlir { +namespace scf { + +//===----------------------------------------------------------------------===// +// ::mlir::scf::IfOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class IfOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + IfOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + IfOpGenericAdaptorBase(IfOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); + ::mlir::Region &getThenRegion(); + ::mlir::Region &getElseRegion(); + ::mlir::RegionRange getRegions(); +}; +} // namespace detail +template +class IfOpGenericAdaptor : public detail::IfOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::IfOpGenericAdaptorBase; +public: + IfOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + IfOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : IfOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + IfOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getCondition() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class IfOpAdaptor : public IfOpGenericAdaptor<::mlir::ValueRange> { +public: + using IfOpGenericAdaptor::IfOpGenericAdaptor; + IfOpAdaptor(IfOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class IfOp : public ::mlir::Op::Impl, ::mlir::OpTrait::VariadicResults, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::SingleBlock, ::mlir::OpTrait::SingleBlockImplicitTerminator::Impl, ::mlir::OpTrait::NoRegionArguments, ::mlir::OpTrait::OpInvariants, ::mlir::RegionBranchOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::OpTrait::InferTypeOpAdaptor, ::mlir::OpTrait::HasRecursiveMemoryEffects> { +public: + using Op::Op; + using Op::print; + using Adaptor = IfOpAdaptor; + template + using GenericAdaptor = IfOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("scf.if"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::IntegerType> getCondition(); + ::mlir::OpOperand &getConditionMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Operation::result_range getResults(); + ::mlir::Region &getThenRegion(); + ::mlir::Region &getElseRegion(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, TypeRange resultTypes, Value cond); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, TypeRange resultTypes, Value cond, bool addThenBlock, bool addElseBlock); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value cond, bool withElseRegion); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, TypeRange resultTypes, Value cond, bool withElseRegion); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value cond, function_ref thenBuilder = buildTerminatedBody, function_ref elseBuilder = nullptr); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &p); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::mlir::LogicalResult fold(FoldAdaptor adaptor, ::llvm::SmallVectorImpl<::mlir::OpFoldResult> &results); + void getEntrySuccessorRegions(::llvm::ArrayRef<::mlir::Attribute> operands, ::llvm::SmallVectorImpl<::mlir::RegionSuccessor> ®ions); + void getSuccessorRegions(::mlir::RegionBranchPoint point, ::llvm::SmallVectorImpl<::mlir::RegionSuccessor> ®ions); + void getRegionInvocationBounds(::llvm::ArrayRef<::mlir::Attribute> operands, ::llvm::SmallVectorImpl<::mlir::InvocationBounds> &invocationBounds); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); +public: + static ::mlir::LogicalResult + inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + Adaptor adaptor, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes); + + + OpBuilder getThenBodyBuilder(OpBuilder::Listener *listener = nullptr) { + Block* body = getBody(0); + return getResults().empty() ? OpBuilder::atBlockTerminator(body, listener) + : OpBuilder::atBlockEnd(body, listener); + } + OpBuilder getElseBodyBuilder(OpBuilder::Listener *listener = nullptr) { + Block* body = getBody(1); + return getResults().empty() ? OpBuilder::atBlockTerminator(body, listener) + : OpBuilder::atBlockEnd(body, listener); + } + Block* thenBlock(); + YieldOp thenYield(); + Block* elseBlock(); + YieldOp elseYield(); +}; +} // namespace scf +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::IfOp) + +namespace mlir { +namespace scf { + +//===----------------------------------------------------------------------===// +// ::mlir::scf::InParallelOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class InParallelOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + InParallelOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + InParallelOpGenericAdaptorBase(InParallelOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); + ::mlir::Region &getRegion(); + ::mlir::RegionRange getRegions(); +}; +} // namespace detail +template +class InParallelOpGenericAdaptor : public detail::InParallelOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::InParallelOpGenericAdaptorBase; +public: + InParallelOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + InParallelOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : InParallelOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + InParallelOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class InParallelOpAdaptor : public InParallelOpGenericAdaptor<::mlir::ValueRange> { +public: + using InParallelOpGenericAdaptor::InParallelOpGenericAdaptor; + InParallelOpAdaptor(InParallelOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class InParallelOp : public ::mlir::Op::Impl, ::mlir::OpTrait::NoTerminator, ::mlir::OpTrait::SingleBlock, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::IsTerminator, ::mlir::ParallelCombiningOpInterface::Trait, ::mlir::RegionKindInterface::Trait, ::mlir::OpTrait::HasOnlyGraphRegion> { +public: + using Op::Op; + using Op::print; + using Adaptor = InParallelOpAdaptor; + template + using GenericAdaptor = InParallelOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("scf.forall.in_parallel"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Region &getRegion(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &p); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + ::llvm::SmallVector<::mlir::BlockArgument> getDests(); + ::llvm::iterator_range<::mlir::Block::iterator> getYieldingOps(); + ::mlir::OpResult getParentResult(int64_t idx); +}; +} // namespace scf +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::InParallelOp) + +namespace mlir { +namespace scf { + +//===----------------------------------------------------------------------===// +// ::mlir::scf::IndexSwitchOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class IndexSwitchOpGenericAdaptorBase { +public: + struct Properties { + using casesTy = ::mlir::DenseI64ArrayAttr; + casesTy cases; + + auto getCases() { + auto &propStorage = this->cases; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setCases(const ::mlir::DenseI64ArrayAttr &propValue) { + this->cases = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.cases == this->cases && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + IndexSwitchOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + IndexSwitchOpGenericAdaptorBase(IndexSwitchOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::DenseI64ArrayAttr getCasesAttr(); + ::llvm::ArrayRef getCases(); + ::mlir::Region &getDefaultRegion(); + ::mlir::RegionRange getCaseRegions(); + ::mlir::RegionRange getRegions(); +}; +} // namespace detail +template +class IndexSwitchOpGenericAdaptor : public detail::IndexSwitchOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::IndexSwitchOpGenericAdaptorBase; +public: + IndexSwitchOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + IndexSwitchOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : IndexSwitchOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + IndexSwitchOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getArg() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class IndexSwitchOpAdaptor : public IndexSwitchOpGenericAdaptor<::mlir::ValueRange> { +public: + using IndexSwitchOpGenericAdaptor::IndexSwitchOpGenericAdaptor; + IndexSwitchOpAdaptor(IndexSwitchOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class IndexSwitchOp : public ::mlir::Op::Impl, ::mlir::OpTrait::VariadicResults, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::SingleBlock, ::mlir::OpTrait::SingleBlockImplicitTerminator::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpTrait::HasRecursiveMemoryEffects, ::mlir::RegionBranchOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = IndexSwitchOpAdaptor; + template + using GenericAdaptor = IndexSwitchOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("cases")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getCasesAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getCasesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("scf.index_switch"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::IndexType> getArg(); + ::mlir::OpOperand &getArgMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Operation::result_range getResults(); + ::mlir::Region &getDefaultRegion(); + ::mlir::MutableArrayRef<::mlir::Region> getCaseRegions(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getCasesAttr(); + ::llvm::ArrayRef getCases(); + void setCasesAttr(::mlir::DenseI64ArrayAttr attr); + void setCases(::llvm::ArrayRef attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::Value arg, ::mlir::DenseI64ArrayAttr cases, unsigned caseRegionsCount); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::Value arg, ::llvm::ArrayRef cases, unsigned caseRegionsCount); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes, unsigned numRegions); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + void getEntrySuccessorRegions(::llvm::ArrayRef<::mlir::Attribute> operands, ::llvm::SmallVectorImpl<::mlir::RegionSuccessor> ®ions); + void getSuccessorRegions(::mlir::RegionBranchPoint point, ::llvm::SmallVectorImpl<::mlir::RegionSuccessor> ®ions); + void getRegionInvocationBounds(::llvm::ArrayRef<::mlir::Attribute> operands, ::llvm::SmallVectorImpl<::mlir::InvocationBounds> &invocationBounds); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + /// Get the number of cases. + unsigned getNumCases(); + + /// Get the default region body. + Block &getDefaultBlock(); + + /// Get the body of a case region. + Block &getCaseBlock(unsigned idx); +}; +} // namespace scf +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::IndexSwitchOp) + +namespace mlir { +namespace scf { + +//===----------------------------------------------------------------------===// +// ::mlir::scf::ParallelOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ParallelOpGenericAdaptorBase { +public: + struct Properties { + using operandSegmentSizesTy = std::array; + operandSegmentSizesTy operandSegmentSizes; + ::llvm::ArrayRef getOperandSegmentSizes() { + auto &propStorage = this->operandSegmentSizes; + return propStorage; + } + void setOperandSegmentSizes(const ::llvm::ArrayRef &propValue) { + auto &propStorage = this->operandSegmentSizes; + ::llvm::copy(propValue, propStorage.begin()); + } + bool operator==(const Properties &rhs) const { + return + rhs.operandSegmentSizes == this->operandSegmentSizes && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ParallelOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + ParallelOpGenericAdaptorBase(ParallelOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::Region &getRegion(); + ::mlir::RegionRange getRegions(); +}; +} // namespace detail +template +class ParallelOpGenericAdaptor : public detail::ParallelOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ParallelOpGenericAdaptorBase; +public: + ParallelOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ParallelOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ParallelOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + ParallelOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getLowerBound() { + return getODSOperands(0); + } + + RangeT getUpperBound() { + return getODSOperands(1); + } + + RangeT getStep() { + return getODSOperands(2); + } + + RangeT getInitVals() { + return getODSOperands(3); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ParallelOpAdaptor : public ParallelOpGenericAdaptor<::mlir::ValueRange> { +public: + using ParallelOpGenericAdaptor::ParallelOpGenericAdaptor; + ParallelOpAdaptor(ParallelOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ParallelOp : public ::mlir::Op::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpTrait::AutomaticAllocationScope, ::mlir::LoopLikeOpInterface::Trait, ::mlir::OpTrait::HasRecursiveMemoryEffects, ::mlir::RegionBranchOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ParallelOpAdaptor; + template + using GenericAdaptor = ParallelOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("operandSegmentSizes")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getOperandSegmentSizesAttrName() { + return (*this)->getName().getAttributeNames().back(); + } + + static ::mlir::StringAttr getOperandSegmentSizesAttrName(::mlir::OperationName name) { + return name.getAttributeNames().back(); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("scf.parallel"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Operation::operand_range getLowerBound(); + ::mlir::Operation::operand_range getUpperBound(); + ::mlir::Operation::operand_range getStep(); + ::mlir::Operation::operand_range getInitVals(); + ::mlir::MutableOperandRange getLowerBoundMutable(); + ::mlir::MutableOperandRange getUpperBoundMutable(); + ::mlir::MutableOperandRange getStepMutable(); + ::mlir::MutableOperandRange getInitValsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Operation::result_range getResults(); + ::mlir::Region &getRegion(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ValueRange lowerBounds, ValueRange upperBounds, ValueRange steps, ValueRange initVals, function_ref bodyBuilderFn = nullptr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ValueRange lowerBounds, ValueRange upperBounds, ValueRange steps, function_ref bodyBuilderFn = nullptr); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &p); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::llvm::SmallVector<::mlir::Region *> getLoopRegions(); + void getSuccessorRegions(::mlir::RegionBranchPoint point, ::llvm::SmallVectorImpl<::mlir::RegionSuccessor> ®ions); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + return {}; + } + +public: + ValueRange getInductionVars() { + return getBody()->getArguments(); + } + unsigned getNumLoops() { return getStep().size(); } + unsigned getNumReductions() { return getInitVals().size(); } +}; +} // namespace scf +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::ParallelOp) + +namespace mlir { +namespace scf { + +//===----------------------------------------------------------------------===// +// ::mlir::scf::ReduceOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ReduceOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + ReduceOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + ReduceOpGenericAdaptorBase(ReduceOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); + ::mlir::Region &getReductionOperator(); + ::mlir::RegionRange getRegions(); +}; +} // namespace detail +template +class ReduceOpGenericAdaptor : public detail::ReduceOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ReduceOpGenericAdaptorBase; +public: + ReduceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ReduceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ReduceOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + ReduceOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ReduceOpAdaptor : public ReduceOpGenericAdaptor<::mlir::ValueRange> { +public: + using ReduceOpGenericAdaptor::ReduceOpGenericAdaptor; + ReduceOpAdaptor(ReduceOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ReduceOp : public ::mlir::Op::Impl, ::mlir::OpTrait::OpInvariants> { +public: + using Op::Op; + using Op::print; + using Adaptor = ReduceOpAdaptor; + template + using GenericAdaptor = ReduceOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("scf.reduce"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getOperand(); + ::mlir::OpOperand &getOperandMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Region &getReductionOperator(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value operand, function_ref bodyBuilderFn = nullptr); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &p); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verifyRegions(); +public: +}; +} // namespace scf +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::ReduceOp) + +namespace mlir { +namespace scf { + +//===----------------------------------------------------------------------===// +// ::mlir::scf::ReduceReturnOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ReduceReturnOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + ReduceReturnOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + ReduceReturnOpGenericAdaptorBase(ReduceReturnOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class ReduceReturnOpGenericAdaptor : public detail::ReduceReturnOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ReduceReturnOpGenericAdaptorBase; +public: + ReduceReturnOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ReduceReturnOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ReduceReturnOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + ReduceReturnOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getResult() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ReduceReturnOpAdaptor : public ReduceReturnOpGenericAdaptor<::mlir::ValueRange> { +public: + using ReduceReturnOpGenericAdaptor::ReduceReturnOpGenericAdaptor; + ReduceReturnOpAdaptor(ReduceReturnOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ReduceReturnOp : public ::mlir::Op::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::IsTerminator> { +public: + using Op::Op; + using Op::print; + using Adaptor = ReduceReturnOpAdaptor; + template + using GenericAdaptor = ReduceReturnOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("scf.reduce.return"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getResult(); + ::mlir::OpOperand &getResultMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value result); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value result); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace scf +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::ReduceReturnOp) + +namespace mlir { +namespace scf { + +//===----------------------------------------------------------------------===// +// ::mlir::scf::WhileOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class WhileOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + WhileOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + WhileOpGenericAdaptorBase(WhileOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); + ::mlir::Region &getBefore(); + ::mlir::Region &getAfter(); + ::mlir::RegionRange getRegions(); +}; +} // namespace detail +template +class WhileOpGenericAdaptor : public detail::WhileOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::WhileOpGenericAdaptorBase; +public: + WhileOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + WhileOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : WhileOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + WhileOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getInits() { + return getODSOperands(0); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class WhileOpAdaptor : public WhileOpGenericAdaptor<::mlir::ValueRange> { +public: + using WhileOpGenericAdaptor::WhileOpGenericAdaptor; + WhileOpAdaptor(WhileOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class WhileOp : public ::mlir::Op::Impl, ::mlir::OpTrait::VariadicResults, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::SingleBlock, ::mlir::OpTrait::OpInvariants, ::mlir::RegionBranchOpInterface::Trait, ::mlir::LoopLikeOpInterface::Trait, ::mlir::OpTrait::HasRecursiveMemoryEffects> { +public: + using Op::Op; + using Op::print; + using Adaptor = WhileOpAdaptor; + template + using GenericAdaptor = WhileOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("scf.while"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Operation::operand_range getInits(); + ::mlir::MutableOperandRange getInitsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Operation::result_range getResults(); + ::mlir::Region &getBefore(); + ::mlir::Region &getAfter(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, TypeRange resultTypes, ValueRange operands, function_ref beforeBuilder, function_ref afterBuilder); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &p); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::mlir::OperandRange getEntrySuccessorOperands(::mlir::RegionBranchPoint point); + void getSuccessorRegions(::mlir::RegionBranchPoint point, ::llvm::SmallVectorImpl<::mlir::RegionSuccessor> ®ions); + ::llvm::SmallVector<::mlir::Region *> getLoopRegions(); + ::mlir::Block::BlockArgListType getRegionIterArgs(); +public: + using BodyBuilderFn = + function_ref; + + ConditionOp getConditionOp(); + YieldOp getYieldOp(); + Block::BlockArgListType getBeforeArguments(); + Block::BlockArgListType getAfterArguments(); + Block *getBeforeBody() { return &getBefore().front(); } + Block *getAfterBody() { return &getAfter().front(); } +}; +} // namespace scf +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::WhileOp) + +namespace mlir { +namespace scf { + +//===----------------------------------------------------------------------===// +// ::mlir::scf::YieldOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class YieldOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + YieldOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + YieldOpGenericAdaptorBase(YieldOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class YieldOpGenericAdaptor : public detail::YieldOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::YieldOpGenericAdaptorBase; +public: + YieldOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + YieldOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : YieldOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + YieldOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getResults() { + return getODSOperands(0); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class YieldOpAdaptor : public YieldOpGenericAdaptor<::mlir::ValueRange> { +public: + using YieldOpGenericAdaptor::YieldOpGenericAdaptor; + YieldOpAdaptor(YieldOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class YieldOp : public ::mlir::Op::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::RegionBranchTerminatorOpInterface::Trait, ::mlir::OpTrait::ReturnLike, ::mlir::OpTrait::IsTerminator> { +public: + using Op::Op; + using Op::print; + using Adaptor = YieldOpAdaptor; + template + using GenericAdaptor = YieldOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("scf.yield"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Operation::operand_range getResults(); + ::mlir::MutableOperandRange getResultsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange results); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::MutableOperandRange getMutableSuccessorOperands(::mlir::RegionBranchPoint point); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace scf +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::YieldOp) + + +#endif // GET_OP_CLASSES + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/SCFOpsDialect.cpp.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/SCFOpsDialect.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..11fa79a66a02ed743c5b29d76a5f070944bf64b8 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/SCFOpsDialect.cpp.inc @@ -0,0 +1,25 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Dialect Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: SCFOps.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::scf::SCFDialect) +namespace mlir { +namespace scf { + +SCFDialect::SCFDialect(::mlir::MLIRContext *context) + : ::mlir::Dialect(getDialectNamespace(), context, ::mlir::TypeID::get()) { + + getContext()->loadDialect(); + + initialize(); +} + +SCFDialect::~SCFDialect() = default; + +} // namespace scf +} // namespace mlir diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/SCFOpsDialect.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/SCFOpsDialect.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..8b8c3fdcba15bfef6727f01d7575a1fa7c2b7a18 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/SCFOpsDialect.h.inc @@ -0,0 +1,26 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Dialect Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: SCFOps.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace scf { + +class SCFDialect : public ::mlir::Dialect { + explicit SCFDialect(::mlir::MLIRContext *context); + + void initialize(); + friend class ::mlir::MLIRContext; +public: + ~SCFDialect() override; + static constexpr ::llvm::StringLiteral getDialectNamespace() { + return ::llvm::StringLiteral("scf"); + } +}; +} // namespace scf +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::SCFDialect) diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/ValueBoundsOpInterfaceImpl.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/ValueBoundsOpInterfaceImpl.h new file mode 100644 index 0000000000000000000000000000000000000000..1d4e8c9799c688baa414cba243d5969a0bbfe715 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/ValueBoundsOpInterfaceImpl.h @@ -0,0 +1,20 @@ +//===- ValueBoundsOpInterfaceImpl.h - Impl. of ValueBoundsOpInterface -----===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_SCF_IR_VALUEBOUNDSOPINTERFACEIMPL_H +#define MLIR_DIALECT_SCF_IR_VALUEBOUNDSOPINTERFACEIMPL_H + +namespace mlir { +class DialectRegistry; + +namespace scf { +void registerValueBoundsOpInterfaceExternalModels(DialectRegistry ®istry); +} // namespace scf +} // namespace mlir + +#endif // MLIR_DIALECT_SCF_IR_VALUEBOUNDSOPINTERFACEIMPL_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Transforms/BufferDeallocationOpInterfaceImpl.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Transforms/BufferDeallocationOpInterfaceImpl.h new file mode 100644 index 0000000000000000000000000000000000000000..cbfb490c7ab098cd3ea6f59cb247acd0dbb57a31 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Transforms/BufferDeallocationOpInterfaceImpl.h @@ -0,0 +1,22 @@ +//===- BufferDeallocationOpInterfaceImpl.h ----------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_SCF_TRANSFORMS_BUFFERDEALLOCATIONOPINTERFACEIMPL_H +#define MLIR_DIALECT_SCF_TRANSFORMS_BUFFERDEALLOCATIONOPINTERFACEIMPL_H + +namespace mlir { + +class DialectRegistry; + +namespace scf { +void registerBufferDeallocationOpInterfaceExternalModels( + DialectRegistry ®istry); +} // namespace scf +} // namespace mlir + +#endif // MLIR_DIALECT_SCF_TRANSFORMS_BUFFERDEALLOCATIONOPINTERFACEIMPL_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.h new file mode 100644 index 0000000000000000000000000000000000000000..bd6bcf5c32eb77c1313223533385e6c16698f928 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.h @@ -0,0 +1,20 @@ +//===- BufferizableOpInterfaceImpl.h - Impl. of BufferizableOpInterface ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_SCF_TRANSFORMS_BUFFERIZABLEOPINTERFACEIMPL_H +#define MLIR_DIALECT_SCF_TRANSFORMS_BUFFERIZABLEOPINTERFACEIMPL_H + +namespace mlir { +class DialectRegistry; + +namespace scf { +void registerBufferizableOpInterfaceExternalModels(DialectRegistry ®istry); +} // namespace scf +} // namespace mlir + +#endif // MLIR_DIALECT_SCF_BUFFERIZABLEOPINTERFACEIMPL_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Transforms/Passes.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Transforms/Passes.h new file mode 100644 index 0000000000000000000000000000000000000000..90b315e83a8cfdb5765c4912d27bc4a94e7004bf --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Transforms/Passes.h @@ -0,0 +1,75 @@ +//===- Passes.h - Pass Entrypoints ------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This header file defines prototypes that expose pass constructors. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_SCF_TRANSFORMS_PASSES_H_ +#define MLIR_DIALECT_SCF_TRANSFORMS_PASSES_H_ + +#include "mlir/Pass/Pass.h" + +namespace mlir { + +#define GEN_PASS_DECL +#include "mlir/Dialect/SCF/Transforms/Passes.h.inc" + +/// Creates a pass that bufferizes the SCF dialect. +std::unique_ptr createSCFBufferizePass(); + +/// Creates a pass that specializes for loop for unrolling and +/// vectorization. +std::unique_ptr createForLoopSpecializationPass(); + +/// Creates a pass that peels for loops at their upper bounds for +/// better vectorization. +std::unique_ptr createForLoopPeelingPass(); + +/// Creates a pass that canonicalizes affine.min and affine.max operations +/// inside of scf.for loops with known lower and upper bounds. +std::unique_ptr createSCFForLoopCanonicalizationPass(); + +/// Creates a pass that transforms a single ParallelLoop over N induction +/// variables into another ParallelLoop over less than N induction variables. +std::unique_ptr createTestSCFParallelLoopCollapsingPass(); + +/// Creates a loop fusion pass which fuses parallel loops. +std::unique_ptr createParallelLoopFusionPass(); + +/// Creates a pass that specializes parallel loop for unrolling and +/// vectorization. +std::unique_ptr createParallelLoopSpecializationPass(); + +/// Creates a pass which tiles innermost parallel loops. +/// If noMinMaxBounds, the upper bound of the inner loop will +/// be a same value among different outter loop iterations, and +/// an additional inbound check will be emitted inside the internal +/// loops. +std::unique_ptr +createParallelLoopTilingPass(llvm::ArrayRef tileSize = {}, + bool noMinMaxBounds = false); + +/// Creates a pass which folds arith ops on induction variable into +/// loop range. +std::unique_ptr createForLoopRangeFoldingPass(); + +// Creates a pass which lowers for loops into while loops. +std::unique_ptr createForToWhileLoopPass(); + +//===----------------------------------------------------------------------===// +// Registration +//===----------------------------------------------------------------------===// + +/// Generate the code for registering passes. +#define GEN_PASS_REGISTRATION +#include "mlir/Dialect/SCF/Transforms/Passes.h.inc" + +} // namespace mlir + +#endif // MLIR_DIALECT_SCF_TRANSFORMS_PASSES_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Transforms/Passes.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Transforms/Passes.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..5fe45c19c948a3f9eb7ee915047804924d93e69d --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Transforms/Passes.h.inc @@ -0,0 +1,1304 @@ +/* Autogenerated by mlir-tblgen; don't manually edit */ + +#ifdef GEN_PASS_DECL +// Generate declarations for all passes. +#define GEN_PASS_DECL_SCFBUFFERIZE +#define GEN_PASS_DECL_SCFFORLOOPCANONICALIZATION +#define GEN_PASS_DECL_SCFFORLOOPPEELING +#define GEN_PASS_DECL_SCFFORLOOPRANGEFOLDING +#define GEN_PASS_DECL_SCFFORLOOPSPECIALIZATION +#define GEN_PASS_DECL_SCFFORTOWHILELOOP +#define GEN_PASS_DECL_SCFPARALLELLOOPFUSION +#define GEN_PASS_DECL_SCFPARALLELLOOPSPECIALIZATION +#define GEN_PASS_DECL_SCFPARALLELLOOPTILING +#define GEN_PASS_DECL_TESTSCFPARALLELLOOPCOLLAPSING +#undef GEN_PASS_DECL +#endif // GEN_PASS_DECL + +//===----------------------------------------------------------------------===// +// SCFBufferize +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_SCFBUFFERIZE +#undef GEN_PASS_DECL_SCFBUFFERIZE +#endif // GEN_PASS_DECL_SCFBUFFERIZE +#ifdef GEN_PASS_DEF_SCFBUFFERIZE +namespace impl { + +template +class SCFBufferizeBase : public ::mlir::OperationPass<> { +public: + using Base = SCFBufferizeBase; + + SCFBufferizeBase() : ::mlir::OperationPass<>(::mlir::TypeID::get()) {} + SCFBufferizeBase(const SCFBufferizeBase &other) : ::mlir::OperationPass<>(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("scf-bufferize"); + } + ::llvm::StringRef getArgument() const override { return "scf-bufferize"; } + + ::llvm::StringRef getDescription() const override { return "Bufferize the scf dialect."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("SCFBufferize"); + } + ::llvm::StringRef getName() const override { return "SCFBufferize"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFBufferizeBase) + +protected: +private: +}; +} // namespace impl +#undef GEN_PASS_DEF_SCFBUFFERIZE +#endif // GEN_PASS_DEF_SCFBUFFERIZE + +//===----------------------------------------------------------------------===// +// SCFForLoopCanonicalization +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_SCFFORLOOPCANONICALIZATION +#undef GEN_PASS_DECL_SCFFORLOOPCANONICALIZATION +#endif // GEN_PASS_DECL_SCFFORLOOPCANONICALIZATION +#ifdef GEN_PASS_DEF_SCFFORLOOPCANONICALIZATION +namespace impl { + +template +class SCFForLoopCanonicalizationBase : public ::mlir::OperationPass<> { +public: + using Base = SCFForLoopCanonicalizationBase; + + SCFForLoopCanonicalizationBase() : ::mlir::OperationPass<>(::mlir::TypeID::get()) {} + SCFForLoopCanonicalizationBase(const SCFForLoopCanonicalizationBase &other) : ::mlir::OperationPass<>(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("scf-for-loop-canonicalization"); + } + ::llvm::StringRef getArgument() const override { return "scf-for-loop-canonicalization"; } + + ::llvm::StringRef getDescription() const override { return "Canonicalize operations within scf.for loop bodies"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("SCFForLoopCanonicalization"); + } + ::llvm::StringRef getName() const override { return "SCFForLoopCanonicalization"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + registry.insert(); + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFForLoopCanonicalizationBase) + +protected: +private: +}; +} // namespace impl +#undef GEN_PASS_DEF_SCFFORLOOPCANONICALIZATION +#endif // GEN_PASS_DEF_SCFFORLOOPCANONICALIZATION + +//===----------------------------------------------------------------------===// +// SCFForLoopPeeling +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_SCFFORLOOPPEELING +struct SCFForLoopPeelingOptions { + bool skipPartial = true; +}; +#undef GEN_PASS_DECL_SCFFORLOOPPEELING +#endif // GEN_PASS_DECL_SCFFORLOOPPEELING +#ifdef GEN_PASS_DEF_SCFFORLOOPPEELING +namespace impl { + +template +class SCFForLoopPeelingBase : public ::mlir::OperationPass<> { +public: + using Base = SCFForLoopPeelingBase; + + SCFForLoopPeelingBase() : ::mlir::OperationPass<>(::mlir::TypeID::get()) {} + SCFForLoopPeelingBase(const SCFForLoopPeelingBase &other) : ::mlir::OperationPass<>(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("scf-for-loop-peeling"); + } + ::llvm::StringRef getArgument() const override { return "scf-for-loop-peeling"; } + + ::llvm::StringRef getDescription() const override { return "Peel `for` loops at their upper bounds."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("SCFForLoopPeeling"); + } + ::llvm::StringRef getName() const override { return "SCFForLoopPeeling"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFForLoopPeelingBase) + + SCFForLoopPeelingBase(const SCFForLoopPeelingOptions &options) : SCFForLoopPeelingBase() { + skipPartial = options.skipPartial; + } +protected: + ::mlir::Pass::Option skipPartial{*this, "skip-partial", ::llvm::cl::desc("Do not peel loops inside of the last, partial iteration of another already peeled loop."), ::llvm::cl::init(true)}; +private: +}; +} // namespace impl +#undef GEN_PASS_DEF_SCFFORLOOPPEELING +#endif // GEN_PASS_DEF_SCFFORLOOPPEELING + +//===----------------------------------------------------------------------===// +// SCFForLoopRangeFolding +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_SCFFORLOOPRANGEFOLDING +#undef GEN_PASS_DECL_SCFFORLOOPRANGEFOLDING +#endif // GEN_PASS_DECL_SCFFORLOOPRANGEFOLDING +#ifdef GEN_PASS_DEF_SCFFORLOOPRANGEFOLDING +namespace impl { + +template +class SCFForLoopRangeFoldingBase : public ::mlir::OperationPass<> { +public: + using Base = SCFForLoopRangeFoldingBase; + + SCFForLoopRangeFoldingBase() : ::mlir::OperationPass<>(::mlir::TypeID::get()) {} + SCFForLoopRangeFoldingBase(const SCFForLoopRangeFoldingBase &other) : ::mlir::OperationPass<>(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("scf-for-loop-range-folding"); + } + ::llvm::StringRef getArgument() const override { return "scf-for-loop-range-folding"; } + + ::llvm::StringRef getDescription() const override { return "Fold add/mul ops into loop range"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("SCFForLoopRangeFolding"); + } + ::llvm::StringRef getName() const override { return "SCFForLoopRangeFolding"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFForLoopRangeFoldingBase) + +protected: +private: +}; +} // namespace impl +#undef GEN_PASS_DEF_SCFFORLOOPRANGEFOLDING +#endif // GEN_PASS_DEF_SCFFORLOOPRANGEFOLDING + +//===----------------------------------------------------------------------===// +// SCFForLoopSpecialization +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_SCFFORLOOPSPECIALIZATION +#undef GEN_PASS_DECL_SCFFORLOOPSPECIALIZATION +#endif // GEN_PASS_DECL_SCFFORLOOPSPECIALIZATION +#ifdef GEN_PASS_DEF_SCFFORLOOPSPECIALIZATION +namespace impl { + +template +class SCFForLoopSpecializationBase : public ::mlir::OperationPass<> { +public: + using Base = SCFForLoopSpecializationBase; + + SCFForLoopSpecializationBase() : ::mlir::OperationPass<>(::mlir::TypeID::get()) {} + SCFForLoopSpecializationBase(const SCFForLoopSpecializationBase &other) : ::mlir::OperationPass<>(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("scf-for-loop-specialization"); + } + ::llvm::StringRef getArgument() const override { return "scf-for-loop-specialization"; } + + ::llvm::StringRef getDescription() const override { return "Specialize `for` loops for vectorization"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("SCFForLoopSpecialization"); + } + ::llvm::StringRef getName() const override { return "SCFForLoopSpecialization"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFForLoopSpecializationBase) + +protected: +private: +}; +} // namespace impl +#undef GEN_PASS_DEF_SCFFORLOOPSPECIALIZATION +#endif // GEN_PASS_DEF_SCFFORLOOPSPECIALIZATION + +//===----------------------------------------------------------------------===// +// SCFForToWhileLoop +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_SCFFORTOWHILELOOP +#undef GEN_PASS_DECL_SCFFORTOWHILELOOP +#endif // GEN_PASS_DECL_SCFFORTOWHILELOOP +#ifdef GEN_PASS_DEF_SCFFORTOWHILELOOP +namespace impl { + +template +class SCFForToWhileLoopBase : public ::mlir::OperationPass<> { +public: + using Base = SCFForToWhileLoopBase; + + SCFForToWhileLoopBase() : ::mlir::OperationPass<>(::mlir::TypeID::get()) {} + SCFForToWhileLoopBase(const SCFForToWhileLoopBase &other) : ::mlir::OperationPass<>(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("scf-for-to-while"); + } + ::llvm::StringRef getArgument() const override { return "scf-for-to-while"; } + + ::llvm::StringRef getDescription() const override { return "Convert SCF for loops to SCF while loops"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("SCFForToWhileLoop"); + } + ::llvm::StringRef getName() const override { return "SCFForToWhileLoop"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFForToWhileLoopBase) + +protected: +private: +}; +} // namespace impl +#undef GEN_PASS_DEF_SCFFORTOWHILELOOP +#endif // GEN_PASS_DEF_SCFFORTOWHILELOOP + +//===----------------------------------------------------------------------===// +// SCFParallelLoopFusion +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_SCFPARALLELLOOPFUSION +#undef GEN_PASS_DECL_SCFPARALLELLOOPFUSION +#endif // GEN_PASS_DECL_SCFPARALLELLOOPFUSION +#ifdef GEN_PASS_DEF_SCFPARALLELLOOPFUSION +namespace impl { + +template +class SCFParallelLoopFusionBase : public ::mlir::OperationPass<> { +public: + using Base = SCFParallelLoopFusionBase; + + SCFParallelLoopFusionBase() : ::mlir::OperationPass<>(::mlir::TypeID::get()) {} + SCFParallelLoopFusionBase(const SCFParallelLoopFusionBase &other) : ::mlir::OperationPass<>(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("scf-parallel-loop-fusion"); + } + ::llvm::StringRef getArgument() const override { return "scf-parallel-loop-fusion"; } + + ::llvm::StringRef getDescription() const override { return "Fuse adjacent parallel loops"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("SCFParallelLoopFusion"); + } + ::llvm::StringRef getName() const override { return "SCFParallelLoopFusion"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFParallelLoopFusionBase) + +protected: +private: +}; +} // namespace impl +#undef GEN_PASS_DEF_SCFPARALLELLOOPFUSION +#endif // GEN_PASS_DEF_SCFPARALLELLOOPFUSION + +//===----------------------------------------------------------------------===// +// SCFParallelLoopSpecialization +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_SCFPARALLELLOOPSPECIALIZATION +#undef GEN_PASS_DECL_SCFPARALLELLOOPSPECIALIZATION +#endif // GEN_PASS_DECL_SCFPARALLELLOOPSPECIALIZATION +#ifdef GEN_PASS_DEF_SCFPARALLELLOOPSPECIALIZATION +namespace impl { + +template +class SCFParallelLoopSpecializationBase : public ::mlir::OperationPass<> { +public: + using Base = SCFParallelLoopSpecializationBase; + + SCFParallelLoopSpecializationBase() : ::mlir::OperationPass<>(::mlir::TypeID::get()) {} + SCFParallelLoopSpecializationBase(const SCFParallelLoopSpecializationBase &other) : ::mlir::OperationPass<>(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("scf-parallel-loop-specialization"); + } + ::llvm::StringRef getArgument() const override { return "scf-parallel-loop-specialization"; } + + ::llvm::StringRef getDescription() const override { return "Specialize parallel loops for vectorization"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("SCFParallelLoopSpecialization"); + } + ::llvm::StringRef getName() const override { return "SCFParallelLoopSpecialization"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFParallelLoopSpecializationBase) + +protected: +private: +}; +} // namespace impl +#undef GEN_PASS_DEF_SCFPARALLELLOOPSPECIALIZATION +#endif // GEN_PASS_DEF_SCFPARALLELLOOPSPECIALIZATION + +//===----------------------------------------------------------------------===// +// SCFParallelLoopTiling +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_SCFPARALLELLOOPTILING +struct SCFParallelLoopTilingOptions { + ::llvm::ArrayRef tileSizes; + bool noMinMaxBounds = false; +}; +#undef GEN_PASS_DECL_SCFPARALLELLOOPTILING +#endif // GEN_PASS_DECL_SCFPARALLELLOOPTILING +#ifdef GEN_PASS_DEF_SCFPARALLELLOOPTILING +namespace impl { + +template +class SCFParallelLoopTilingBase : public ::mlir::OperationPass<> { +public: + using Base = SCFParallelLoopTilingBase; + + SCFParallelLoopTilingBase() : ::mlir::OperationPass<>(::mlir::TypeID::get()) {} + SCFParallelLoopTilingBase(const SCFParallelLoopTilingBase &other) : ::mlir::OperationPass<>(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("scf-parallel-loop-tiling"); + } + ::llvm::StringRef getArgument() const override { return "scf-parallel-loop-tiling"; } + + ::llvm::StringRef getDescription() const override { return "Tile parallel loops"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("SCFParallelLoopTiling"); + } + ::llvm::StringRef getName() const override { return "SCFParallelLoopTiling"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFParallelLoopTilingBase) + + SCFParallelLoopTilingBase(const SCFParallelLoopTilingOptions &options) : SCFParallelLoopTilingBase() { + tileSizes = options.tileSizes; + noMinMaxBounds = options.noMinMaxBounds; + } +protected: + ::mlir::Pass::ListOption tileSizes{*this, "parallel-loop-tile-sizes", ::llvm::cl::desc("Factors to tile parallel loops by")}; + ::mlir::Pass::Option noMinMaxBounds{*this, "no-min-max-bounds", ::llvm::cl::desc("Perform tiling with fixed upper bound with inbound check inside the internal loops"), ::llvm::cl::init(false)}; +private: +}; +} // namespace impl +#undef GEN_PASS_DEF_SCFPARALLELLOOPTILING +#endif // GEN_PASS_DEF_SCFPARALLELLOOPTILING + +//===----------------------------------------------------------------------===// +// TestSCFParallelLoopCollapsing +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_TESTSCFPARALLELLOOPCOLLAPSING +struct TestSCFParallelLoopCollapsingOptions { + ::llvm::ArrayRef clCollapsedIndices0; + ::llvm::ArrayRef clCollapsedIndices1; + ::llvm::ArrayRef clCollapsedIndices2; +}; +#undef GEN_PASS_DECL_TESTSCFPARALLELLOOPCOLLAPSING +#endif // GEN_PASS_DECL_TESTSCFPARALLELLOOPCOLLAPSING +#ifdef GEN_PASS_DEF_TESTSCFPARALLELLOOPCOLLAPSING +namespace impl { + +template +class TestSCFParallelLoopCollapsingBase : public ::mlir::OperationPass<> { +public: + using Base = TestSCFParallelLoopCollapsingBase; + + TestSCFParallelLoopCollapsingBase() : ::mlir::OperationPass<>(::mlir::TypeID::get()) {} + TestSCFParallelLoopCollapsingBase(const TestSCFParallelLoopCollapsingBase &other) : ::mlir::OperationPass<>(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("test-scf-parallel-loop-collapsing"); + } + ::llvm::StringRef getArgument() const override { return "test-scf-parallel-loop-collapsing"; } + + ::llvm::StringRef getDescription() const override { return "Test parallel loops collapsing transformation"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("TestSCFParallelLoopCollapsing"); + } + ::llvm::StringRef getName() const override { return "TestSCFParallelLoopCollapsing"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestSCFParallelLoopCollapsingBase) + + TestSCFParallelLoopCollapsingBase(const TestSCFParallelLoopCollapsingOptions &options) : TestSCFParallelLoopCollapsingBase() { + clCollapsedIndices0 = options.clCollapsedIndices0; + clCollapsedIndices1 = options.clCollapsedIndices1; + clCollapsedIndices2 = options.clCollapsedIndices2; + } +protected: + ::mlir::Pass::ListOption clCollapsedIndices0{*this, "collapsed-indices-0", ::llvm::cl::desc("Which loop indices to combine 0th loop index")}; + ::mlir::Pass::ListOption clCollapsedIndices1{*this, "collapsed-indices-1", ::llvm::cl::desc("Which loop indices to combine into the position 1 loop index")}; + ::mlir::Pass::ListOption clCollapsedIndices2{*this, "collapsed-indices-2", ::llvm::cl::desc("Which loop indices to combine into the position 2 loop index")}; +private: +}; +} // namespace impl +#undef GEN_PASS_DEF_TESTSCFPARALLELLOOPCOLLAPSING +#endif // GEN_PASS_DEF_TESTSCFPARALLELLOOPCOLLAPSING +#ifdef GEN_PASS_REGISTRATION + +//===----------------------------------------------------------------------===// +// SCFBufferize Registration +//===----------------------------------------------------------------------===// + +inline void registerSCFBufferize() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createSCFBufferizePass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerSCFBufferizePass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createSCFBufferizePass(); + }); +} + +//===----------------------------------------------------------------------===// +// SCFForLoopCanonicalization Registration +//===----------------------------------------------------------------------===// + +inline void registerSCFForLoopCanonicalization() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createSCFForLoopCanonicalizationPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerSCFForLoopCanonicalizationPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createSCFForLoopCanonicalizationPass(); + }); +} + +//===----------------------------------------------------------------------===// +// SCFForLoopPeeling Registration +//===----------------------------------------------------------------------===// + +inline void registerSCFForLoopPeeling() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createForLoopPeelingPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerSCFForLoopPeelingPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createForLoopPeelingPass(); + }); +} + +//===----------------------------------------------------------------------===// +// SCFForLoopRangeFolding Registration +//===----------------------------------------------------------------------===// + +inline void registerSCFForLoopRangeFolding() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createForLoopRangeFoldingPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerSCFForLoopRangeFoldingPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createForLoopRangeFoldingPass(); + }); +} + +//===----------------------------------------------------------------------===// +// SCFForLoopSpecialization Registration +//===----------------------------------------------------------------------===// + +inline void registerSCFForLoopSpecialization() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createForLoopSpecializationPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerSCFForLoopSpecializationPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createForLoopSpecializationPass(); + }); +} + +//===----------------------------------------------------------------------===// +// SCFForToWhileLoop Registration +//===----------------------------------------------------------------------===// + +inline void registerSCFForToWhileLoop() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createForToWhileLoopPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerSCFForToWhileLoopPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createForToWhileLoopPass(); + }); +} + +//===----------------------------------------------------------------------===// +// SCFParallelLoopFusion Registration +//===----------------------------------------------------------------------===// + +inline void registerSCFParallelLoopFusion() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createParallelLoopFusionPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerSCFParallelLoopFusionPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createParallelLoopFusionPass(); + }); +} + +//===----------------------------------------------------------------------===// +// SCFParallelLoopSpecialization Registration +//===----------------------------------------------------------------------===// + +inline void registerSCFParallelLoopSpecialization() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createParallelLoopSpecializationPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerSCFParallelLoopSpecializationPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createParallelLoopSpecializationPass(); + }); +} + +//===----------------------------------------------------------------------===// +// SCFParallelLoopTiling Registration +//===----------------------------------------------------------------------===// + +inline void registerSCFParallelLoopTiling() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createParallelLoopTilingPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerSCFParallelLoopTilingPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createParallelLoopTilingPass(); + }); +} + +//===----------------------------------------------------------------------===// +// TestSCFParallelLoopCollapsing Registration +//===----------------------------------------------------------------------===// + +inline void registerTestSCFParallelLoopCollapsing() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createTestSCFParallelLoopCollapsingPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerTestSCFParallelLoopCollapsingPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createTestSCFParallelLoopCollapsingPass(); + }); +} + +//===----------------------------------------------------------------------===// +// SCF Registration +//===----------------------------------------------------------------------===// + +inline void registerSCFPasses() { + registerSCFBufferize(); + registerSCFForLoopCanonicalization(); + registerSCFForLoopPeeling(); + registerSCFForLoopRangeFolding(); + registerSCFForLoopSpecialization(); + registerSCFForToWhileLoop(); + registerSCFParallelLoopFusion(); + registerSCFParallelLoopSpecialization(); + registerSCFParallelLoopTiling(); + registerTestSCFParallelLoopCollapsing(); +} +#undef GEN_PASS_REGISTRATION +#endif // GEN_PASS_REGISTRATION +// Deprecated. Please use the new per-pass macros. +#ifdef GEN_PASS_CLASSES + +template +class SCFBufferizeBase : public ::mlir::OperationPass<> { +public: + using Base = SCFBufferizeBase; + + SCFBufferizeBase() : ::mlir::OperationPass<>(::mlir::TypeID::get()) {} + SCFBufferizeBase(const SCFBufferizeBase &other) : ::mlir::OperationPass<>(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("scf-bufferize"); + } + ::llvm::StringRef getArgument() const override { return "scf-bufferize"; } + + ::llvm::StringRef getDescription() const override { return "Bufferize the scf dialect."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("SCFBufferize"); + } + ::llvm::StringRef getName() const override { return "SCFBufferize"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFBufferizeBase) + +protected: +}; + +template +class SCFForLoopCanonicalizationBase : public ::mlir::OperationPass<> { +public: + using Base = SCFForLoopCanonicalizationBase; + + SCFForLoopCanonicalizationBase() : ::mlir::OperationPass<>(::mlir::TypeID::get()) {} + SCFForLoopCanonicalizationBase(const SCFForLoopCanonicalizationBase &other) : ::mlir::OperationPass<>(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("scf-for-loop-canonicalization"); + } + ::llvm::StringRef getArgument() const override { return "scf-for-loop-canonicalization"; } + + ::llvm::StringRef getDescription() const override { return "Canonicalize operations within scf.for loop bodies"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("SCFForLoopCanonicalization"); + } + ::llvm::StringRef getName() const override { return "SCFForLoopCanonicalization"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + registry.insert(); + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFForLoopCanonicalizationBase) + +protected: +}; + +template +class SCFForLoopPeelingBase : public ::mlir::OperationPass<> { +public: + using Base = SCFForLoopPeelingBase; + + SCFForLoopPeelingBase() : ::mlir::OperationPass<>(::mlir::TypeID::get()) {} + SCFForLoopPeelingBase(const SCFForLoopPeelingBase &other) : ::mlir::OperationPass<>(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("scf-for-loop-peeling"); + } + ::llvm::StringRef getArgument() const override { return "scf-for-loop-peeling"; } + + ::llvm::StringRef getDescription() const override { return "Peel `for` loops at their upper bounds."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("SCFForLoopPeeling"); + } + ::llvm::StringRef getName() const override { return "SCFForLoopPeeling"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFForLoopPeelingBase) + +protected: + ::mlir::Pass::Option skipPartial{*this, "skip-partial", ::llvm::cl::desc("Do not peel loops inside of the last, partial iteration of another already peeled loop."), ::llvm::cl::init(true)}; +}; + +template +class SCFForLoopRangeFoldingBase : public ::mlir::OperationPass<> { +public: + using Base = SCFForLoopRangeFoldingBase; + + SCFForLoopRangeFoldingBase() : ::mlir::OperationPass<>(::mlir::TypeID::get()) {} + SCFForLoopRangeFoldingBase(const SCFForLoopRangeFoldingBase &other) : ::mlir::OperationPass<>(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("scf-for-loop-range-folding"); + } + ::llvm::StringRef getArgument() const override { return "scf-for-loop-range-folding"; } + + ::llvm::StringRef getDescription() const override { return "Fold add/mul ops into loop range"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("SCFForLoopRangeFolding"); + } + ::llvm::StringRef getName() const override { return "SCFForLoopRangeFolding"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFForLoopRangeFoldingBase) + +protected: +}; + +template +class SCFForLoopSpecializationBase : public ::mlir::OperationPass<> { +public: + using Base = SCFForLoopSpecializationBase; + + SCFForLoopSpecializationBase() : ::mlir::OperationPass<>(::mlir::TypeID::get()) {} + SCFForLoopSpecializationBase(const SCFForLoopSpecializationBase &other) : ::mlir::OperationPass<>(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("scf-for-loop-specialization"); + } + ::llvm::StringRef getArgument() const override { return "scf-for-loop-specialization"; } + + ::llvm::StringRef getDescription() const override { return "Specialize `for` loops for vectorization"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("SCFForLoopSpecialization"); + } + ::llvm::StringRef getName() const override { return "SCFForLoopSpecialization"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFForLoopSpecializationBase) + +protected: +}; + +template +class SCFForToWhileLoopBase : public ::mlir::OperationPass<> { +public: + using Base = SCFForToWhileLoopBase; + + SCFForToWhileLoopBase() : ::mlir::OperationPass<>(::mlir::TypeID::get()) {} + SCFForToWhileLoopBase(const SCFForToWhileLoopBase &other) : ::mlir::OperationPass<>(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("scf-for-to-while"); + } + ::llvm::StringRef getArgument() const override { return "scf-for-to-while"; } + + ::llvm::StringRef getDescription() const override { return "Convert SCF for loops to SCF while loops"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("SCFForToWhileLoop"); + } + ::llvm::StringRef getName() const override { return "SCFForToWhileLoop"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFForToWhileLoopBase) + +protected: +}; + +template +class SCFParallelLoopFusionBase : public ::mlir::OperationPass<> { +public: + using Base = SCFParallelLoopFusionBase; + + SCFParallelLoopFusionBase() : ::mlir::OperationPass<>(::mlir::TypeID::get()) {} + SCFParallelLoopFusionBase(const SCFParallelLoopFusionBase &other) : ::mlir::OperationPass<>(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("scf-parallel-loop-fusion"); + } + ::llvm::StringRef getArgument() const override { return "scf-parallel-loop-fusion"; } + + ::llvm::StringRef getDescription() const override { return "Fuse adjacent parallel loops"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("SCFParallelLoopFusion"); + } + ::llvm::StringRef getName() const override { return "SCFParallelLoopFusion"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFParallelLoopFusionBase) + +protected: +}; + +template +class SCFParallelLoopSpecializationBase : public ::mlir::OperationPass<> { +public: + using Base = SCFParallelLoopSpecializationBase; + + SCFParallelLoopSpecializationBase() : ::mlir::OperationPass<>(::mlir::TypeID::get()) {} + SCFParallelLoopSpecializationBase(const SCFParallelLoopSpecializationBase &other) : ::mlir::OperationPass<>(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("scf-parallel-loop-specialization"); + } + ::llvm::StringRef getArgument() const override { return "scf-parallel-loop-specialization"; } + + ::llvm::StringRef getDescription() const override { return "Specialize parallel loops for vectorization"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("SCFParallelLoopSpecialization"); + } + ::llvm::StringRef getName() const override { return "SCFParallelLoopSpecialization"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFParallelLoopSpecializationBase) + +protected: +}; + +template +class SCFParallelLoopTilingBase : public ::mlir::OperationPass<> { +public: + using Base = SCFParallelLoopTilingBase; + + SCFParallelLoopTilingBase() : ::mlir::OperationPass<>(::mlir::TypeID::get()) {} + SCFParallelLoopTilingBase(const SCFParallelLoopTilingBase &other) : ::mlir::OperationPass<>(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("scf-parallel-loop-tiling"); + } + ::llvm::StringRef getArgument() const override { return "scf-parallel-loop-tiling"; } + + ::llvm::StringRef getDescription() const override { return "Tile parallel loops"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("SCFParallelLoopTiling"); + } + ::llvm::StringRef getName() const override { return "SCFParallelLoopTiling"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFParallelLoopTilingBase) + +protected: + ::mlir::Pass::ListOption tileSizes{*this, "parallel-loop-tile-sizes", ::llvm::cl::desc("Factors to tile parallel loops by")}; + ::mlir::Pass::Option noMinMaxBounds{*this, "no-min-max-bounds", ::llvm::cl::desc("Perform tiling with fixed upper bound with inbound check inside the internal loops"), ::llvm::cl::init(false)}; +}; + +template +class TestSCFParallelLoopCollapsingBase : public ::mlir::OperationPass<> { +public: + using Base = TestSCFParallelLoopCollapsingBase; + + TestSCFParallelLoopCollapsingBase() : ::mlir::OperationPass<>(::mlir::TypeID::get()) {} + TestSCFParallelLoopCollapsingBase(const TestSCFParallelLoopCollapsingBase &other) : ::mlir::OperationPass<>(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("test-scf-parallel-loop-collapsing"); + } + ::llvm::StringRef getArgument() const override { return "test-scf-parallel-loop-collapsing"; } + + ::llvm::StringRef getDescription() const override { return "Test parallel loops collapsing transformation"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("TestSCFParallelLoopCollapsing"); + } + ::llvm::StringRef getName() const override { return "TestSCFParallelLoopCollapsing"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestSCFParallelLoopCollapsingBase) + +protected: + ::mlir::Pass::ListOption clCollapsedIndices0{*this, "collapsed-indices-0", ::llvm::cl::desc("Which loop indices to combine 0th loop index")}; + ::mlir::Pass::ListOption clCollapsedIndices1{*this, "collapsed-indices-1", ::llvm::cl::desc("Which loop indices to combine into the position 1 loop index")}; + ::mlir::Pass::ListOption clCollapsedIndices2{*this, "collapsed-indices-2", ::llvm::cl::desc("Which loop indices to combine into the position 2 loop index")}; +}; +#undef GEN_PASS_CLASSES +#endif // GEN_PASS_CLASSES diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Transforms/Patterns.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Transforms/Patterns.h new file mode 100644 index 0000000000000000000000000000000000000000..5c0d5643c01986d45600721672fc5606ce322bfd --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Transforms/Patterns.h @@ -0,0 +1,85 @@ +//===- Patterns.h - SCF dialect rewrite patterns ----------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_SCF_TRANSFORMS_PATTERNS_H +#define MLIR_DIALECT_SCF_TRANSFORMS_PATTERNS_H + +#include "mlir/Dialect/SCF/IR/SCF.h" +#include "mlir/Dialect/SCF/Transforms/Transforms.h" +#include "mlir/IR/PatternMatch.h" + +namespace mlir { + +class ConversionTarget; +class TypeConverter; + +namespace scf { + +// TODO: such patterns should be auto-generated. +class ForLoopPipeliningPattern : public OpRewritePattern { +public: + ForLoopPipeliningPattern(const PipeliningOption &options, + MLIRContext *context) + : OpRewritePattern(context), options(options) {} + LogicalResult matchAndRewrite(ForOp forOp, + PatternRewriter &rewriter) const override { + return returningMatchAndRewrite(forOp, rewriter); + } + + FailureOr returningMatchAndRewrite(ForOp forOp, + PatternRewriter &rewriter) const { + return pipelineForLoop(rewriter, forOp, options); + } + +protected: + PipeliningOption options; +}; + +/// Populates patterns for SCF structural type conversions and sets up the +/// provided ConversionTarget with the appropriate legality configuration for +/// the ops to get converted properly. +/// +/// A "structural" type conversion is one where the underlying ops are +/// completely agnostic to the actual types involved and simply need to update +/// their types. An example of this is scf.if -- the scf.if op and the +/// corresponding scf.yield ops need to update their types accordingly to the +/// TypeConverter, but otherwise don't care what type conversions are happening. +void populateSCFStructuralTypeConversionsAndLegality( + TypeConverter &typeConverter, RewritePatternSet &patterns, + ConversionTarget &target); + +/// Similar to `populateSCFStructuralTypeConversionsAndLegality` but does not +/// populate the conversion target. +void populateSCFStructuralTypeConversions(TypeConverter &typeConverter, + RewritePatternSet &patterns); + +/// Updates the ConversionTarget with dynamic legality of SCF operations based +/// on the provided type converter. +void populateSCFStructuralTypeConversionTarget( + const TypeConverter &typeConverter, ConversionTarget &target); + +/// Populates the provided pattern set with patterns that do 1:N type +/// conversions on (some) SCF ops. This is intended to be used with +/// applyPartialOneToNConversion. +void populateSCFStructuralOneToNTypeConversions(TypeConverter &typeConverter, + RewritePatternSet &patterns); + +/// Populate patterns for SCF software pipelining transformation. See the +/// ForLoopPipeliningPattern for the transformation details. +void populateSCFLoopPipeliningPatterns(RewritePatternSet &patterns, + const PipeliningOption &options); + +/// Populate patterns for canonicalizing operations inside SCF loop bodies. +/// At the moment, only affine.min/max computations with iteration variables, +/// loop bounds and loop steps are canonicalized. +void populateSCFForLoopCanonicalizationPatterns(RewritePatternSet &patterns); + +} // namespace scf +} // namespace mlir + +#endif // MLIR_DIALECT_SCF_TRANSFORMS_PATTERNS_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Transforms/TileUsingInterface.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Transforms/TileUsingInterface.h new file mode 100644 index 0000000000000000000000000000000000000000..9f49d97e141e0c82d273ed0fbd44a0978480f2fe --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Transforms/TileUsingInterface.h @@ -0,0 +1,246 @@ +//===- TileUsingInterface.h - Tiling ops using TilingInterface --*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_SCF_TRANSFORMS_TILEUSINGINTERFACE_H +#define MLIR_DIALECT_SCF_TRANSFORMS_TILEUSINGINTERFACE_H + +#include "mlir/Dialect/SCF/IR/SCF.h" +#include "mlir/Dialect/Tensor/Transforms/Transforms.h" +#include "mlir/IR/PatternMatch.h" +#include "mlir/Interfaces/TilingInterface.h" + +#include + +namespace mlir { +class Operation; +class RewriterBase; +class TilingInterface; +} // namespace mlir + +namespace mlir { +namespace scf { + +using SCFTileSizeComputationFunction = + std::function(OpBuilder &, Operation *)>; + +/// Options to use to control tiling. +struct SCFTilingOptions { + /// Computation function that returns the tile sizes for each operation. + /// Delayed construction of constant tile sizes should occur to interoperate + /// with folding. + SCFTileSizeComputationFunction tileSizeComputationFunction = nullptr; + + SCFTilingOptions & + setTileSizeComputationFunction(SCFTileSizeComputationFunction fun) { + tileSizeComputationFunction = std::move(fun); + return *this; + } + /// Convenience function to set the `tileSizeComputationFunction` to a + /// function that computes tile sizes at the point they are needed. Allows + /// proper interaction with folding. + SCFTilingOptions &setTileSizes(ArrayRef ts); + + /// The interchange vector to reorder the tiled loops. + SmallVector interchangeVector = {}; + SCFTilingOptions &setInterchange(ArrayRef interchange) { + interchangeVector = llvm::to_vector(interchange); + return *this; + } +}; + +/// Transformation information returned after tiling. +struct SCFTilingResult { + /// Tiled operations that are generated during tiling. The order does not + /// matter except the last op. The replacements are expected to be the results + /// of the last op. + SmallVector tiledOps; + /// The `scf.for` operations that iterate over the tiles. + SmallVector loops; + /// Values to use as replacements for the untiled op. Is the same size as the + /// number of results of the untiled op. + SmallVector replacements; +}; + +/// Method to tile an op that implements the `TilingInterface` using +/// `scf.for` for iterating over the tiles. +FailureOr tileUsingSCFForOp(RewriterBase &rewriter, + TilingInterface op, + const SCFTilingOptions &options); + +/// Options used to control tile + fuse. +struct SCFTileAndFuseOptions { + /// The tiling options used to control the tiling of the consumer. + SCFTilingOptions tilingOptions; + SCFTileAndFuseOptions &setTilingOptions(SCFTilingOptions options) { + tilingOptions = options; + return *this; + } +}; + +/// Fuse the producer of the source of `candidateSliceOp` by computing the +/// required slice of the producer in-place. Note that the method +/// replaces the uses of `candidateSliceOp` with the tiled and fused producer +/// value but does not delete the slice operation. +struct SCFFuseProducerOfSliceResult { + OpResult origProducer; // Original untiled producer. + Value tiledAndFusedProducer; // Tile and fused producer value. + SmallVector tiledOps; +}; +std::optional +tileAndFuseProducerOfSlice(RewriterBase &rewriter, + tensor::ExtractSliceOp candidateSliceOp, + MutableArrayRef loops); + +/// Reconstruct the fused producer from within the tiled-and-fused code. Based +/// on the slice of the producer computed in place it is possible that within +/// the loop nest same slice of the producer is computed multiple times. It is +/// in general not possible to recompute the value of the fused producer from +/// the tiled loop code in such cases. For the cases where no slice of the +/// producer is computed in a redundant fashion it is possible to reconstruct +/// the value of the original producer from within the tiled loop. It is upto +/// the caller to ensure that the producer is not computed redundantly within +/// the tiled loop nest. For example, consider +/// +/// ```mlir +/// %0 = linalg.matmul ins(...) outs(...) -> tensor +/// %1 = linalg.matmul ins(%0, ..) outs(...) -> tensor +/// ``` +/// +/// If `%1` is tiled in a 2D fashion and `%0` is fused with it, the resulting IR +/// is, +/// +/// ```mlir +/// %t1_0 = scf.for .... iter_args(%arg0 = ...) { +/// %t1_1 = scf.for ... iter_args(%arg1 = %arg0) { +/// ... +/// %t1_2 = linalg.matmul ins(...) outs(...) -> tensor +/// %t1_3 = linalg.matmul ins(%t1_2, ...) +/// %t1_4 = tensor.insert_slice %t1_3 into %arg1 ... +/// scf.yield %t1_4 +/// } +/// scf.yield %t1_1 +/// } +/// ``` +/// +/// Here `%t1_2` is the same for all iterations of the inner `scf.for`. Instead +/// if `%1` were tiled only along the rows, the resultant code would be +/// +/// ```mlir +/// %t2_0 = scf.for .... iter_args(%arg0 = ...) { +/// ... +/// %t2_1 = linalg.matmul ins(...) outs(...) -> tensor +/// %t2_2 = linalg.matmul ins(%t2_1, ...) +/// %t2_3 = tensor.insert_slice %t2_2 into %arg0 ... +/// scf.yield %t2_3 +/// } +/// ``` +/// +/// Here there is no intersection in the different slices of `%t2_1` computed +/// across iterations of the `scf.for`. In such cases, the value of the original +/// `%0` can be reconstructed from within the loop body. This is useful in cases +/// where `%0` had other uses as well. If not reconstructed from within the loop +/// body, uses of `%0` could not be replaced, making it still live and the +/// fusion immaterial. +void yieldReplacementForFusedProducer( + RewriterBase &rewriter, tensor::ExtractSliceOp sliceOp, + scf::SCFFuseProducerOfSliceResult fusedProducerInfo, + MutableArrayRef loops); + +/// Transformation information returned after tile and fuse. +struct SCFTileAndFuseResult { + /// List of untiled operations that were fused with the tiled consumer. + llvm::SetVector fusedProducers; + /// List of tiled and fused operations generated. The first one in this list + /// is guaranteed to be the tiled operations generated during tiling of the + /// generated operation. + llvm::SetVector tiledAndFusedOps; + /// The `scf.for` operations that iterate over the tiles. + SmallVector loops; + /// The replacement values to use for the tiled and fused operations. + llvm::DenseMap replacements; +}; + +/// Method to tile and fuse a sequence of operations, by tiling the consumer +/// and fusing its producers. Note that this assumes that it is valid to +/// tile+fuse the producer into the innermost tiled loop. Its up to the caller +/// to ensure that the tile sizes provided make this fusion valid. +/// +/// For example, for the following sequence +/// +/// ```mlir +/// %0 = +/// %1 = linalg.fill ... outs(%0 : ... ) +/// %2 = linalg.matmul ... outs(%1 : ...) ... +/// ``` +/// +/// it is legal to fuse the fill with the matmul only if the matmul is tiled +/// along the parallel dimensions and not the reduction dimension, i.e. the tile +/// size for the reduction dimension should be 0. The resulting fused +/// transformation is +/// +/// ```mlir +/// %1 = scf.for ... iter_args(%arg0 = %0) +/// %2 = tensor.extract_slice %arg0 +/// %3 = linalg.fill .. outs(%2 : ... ) +/// %4 = linalg.matmul .. outs(%3 : ...) +/// } +/// ``` +FailureOr +tileConsumerAndFuseProducerGreedilyUsingSCFForOp( + RewriterBase &rewriter, TilingInterface consumer, + const SCFTileAndFuseOptions &options); + +/// Method to lower an `op` that implements the `TilingInterface` to +/// loops/scalars. +FailureOr> +lowerToLoopsUsingSCFForOp(RewriterBase &rewriter, TilingInterface op); + +/// Transformation information returned after reduction tiling. +struct SCFReductionTilingResult { + /// The partial reduction tiled op generated. + Operation *parallelTiledOp; + /// The final reduction operation merging all the partial reductions. + Operation *mergeOp; + /// Initial op + Operation *initialOp; + /// The `scf.for` operations that iterate over the tiles. + SmallVector loops; +}; + +/// Method to tile a reduction and generate a parallel op within a serial loop. +/// Each of the partial reductions are calculated in parallel. Then after the +/// loop all the partial reduction are merged into a final reduction. +/// For example for the following sequence +/// +/// ```mlir +/// %0 = linalg.generic %in ["parallel", "reduction"] +/// : tensor<7x9xf32> -> tensor<7xf32> +/// ``` +/// +/// into: +/// +/// ```mlir +/// %0 = linalg.fill ... : tensor<7x4xf32> +/// %1 = scf.for ... iter_args(%arg0 = %0) +/// %2 = tensor.extract_slice %arg0 : tensor<7x4xf32> -> tensor<7x?xf32> +/// %3 = tensor.extract_slice %in : tensor<7x9xf32> -> tensor<7x?xf32> +/// %4 = linalg.generic %2, %3 ["parallel", "parallel"] +/// : tensor<7x?xf32> -> tensor<7x?xf32> +/// %5 = tensor.insert_slice %3, %0[0, 0] : tensor<7x4xf32> +/// } +/// %6 = linalg.generic %1 ["parallel", "reduction"] +/// : tensor<7x4xf32> -> tensor<7xf32> +/// ``` +FailureOr +tileReductionUsingScf(RewriterBase &b, PartialReductionOpInterface op, + ArrayRef tileSize); + +} // namespace scf +} // namespace mlir + +#endif // MLIR_DIALECT_SCF_TRANSFORMS_TILEUSINGINTERFACE_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Transforms/Transforms.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Transforms/Transforms.h new file mode 100644 index 0000000000000000000000000000000000000000..347beb9e4c64f8cf0660781a3cf91e748795f422 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Transforms/Transforms.h @@ -0,0 +1,172 @@ +//===- Transforms.h - SCF dialect transformation utilities ------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This header file defines transformations on SCF operations. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_SCF_TRANSFORMS_TRANSFORMS_H_ +#define MLIR_DIALECT_SCF_TRANSFORMS_TRANSFORMS_H_ + +#include "mlir/Dialect/SCF/Utils/AffineCanonicalizationUtils.h" +#include "mlir/Support/LLVM.h" +#include "llvm/ADT/ArrayRef.h" + +namespace mlir { + +struct LogicalResult; +class Region; +class RewriterBase; +class Operation; +class Value; + +namespace scf { + +class IfOp; +class ForOp; +class ParallelOp; + +/// Fuses all adjacent scf.parallel operations with identical bounds and step +/// into one scf.parallel operations. Uses a naive aliasing and dependency +/// analysis. +void naivelyFuseParallelOps(Region ®ion); + +/// Rewrite a for loop with bounds/step that potentially do not divide evenly +/// into a for loop where the step divides the iteration space evenly, followed +/// by another scf.for for the last (partial) iteration (if any; returned via +/// `partialIteration`). This transformation is called "loop peeling". +/// +/// This transformation is beneficial for a wide range of transformations such +/// as vectorization or loop tiling: It enables additional canonicalizations +/// inside the peeled loop body such as rewriting masked loads into unmaked +/// loads. +/// +/// E.g., assuming a lower bound of 0 (for illustration purposes): +/// ``` +/// scf.for %iv = %c0 to %ub step %c4 { +/// (loop body) +/// } +/// ``` +/// is rewritten into the following pseudo IR: +/// ``` +/// %newUb = %ub - (%ub mod %c4) +/// scf.for %iv = %c0 to %newUb step %c4 { +/// (loop body) +/// } +/// scf.for %iv2 = %newUb to %ub { +/// (loop body) +/// } +/// ``` +/// +/// After loop peeling, this function tries to simplify affine.min and +/// affine.max ops in the body of the peeled loop and in the body of the partial +/// iteration loop, taking advantage of the fact that the peeled loop has only +/// "full" iterations. This simplification is expected to enable further +/// canonicalization opportunities through other patterns. +/// +/// The return value indicates whether the loop was rewritten or not. Loops are +/// not rewritten if: +/// * Loop step size is 1 or +/// * Loop bounds and step size are static, and step already divides the +/// iteration space evenly. +/// +/// Note: This function rewrites the given scf.for loop in-place and creates a +/// new scf.for operation for the last iteration. It replaces all uses of the +/// unpeeled loop with the results of the newly generated scf.for. +LogicalResult peelForLoopAndSimplifyBounds(RewriterBase &rewriter, ForOp forOp, + scf::ForOp &partialIteration); + +/// Tile a parallel loop of the form +/// scf.parallel (%i0, %i1) = (%arg0, %arg1) to (%arg2, %arg3) +/// step (%arg4, %arg5) +/// +/// into +/// scf.parallel (%i0, %i1) = (%arg0, %arg1) to (%arg2, %arg3) +/// step (%arg4*tileSize[0], +/// %arg5*tileSize[1]) +/// scf.parallel (%j0, %j1) = (0, 0) to (min(tileSize[0], %arg2-%j0) +/// min(tileSize[1], %arg3-%j1)) +/// step (%arg4, %arg5) +/// The old loop is replaced with the new one. +/// +/// The function returns the resulting ParallelOps, i.e. {outer_loop_op, +/// inner_loop_op}. +std::pair +tileParallelLoop(ParallelOp op, llvm::ArrayRef tileSizes, + bool noMinMaxBounds); + +/// Options to dictate how loops should be pipelined. +struct PipeliningOption { + /// Lambda returning all the operation in the forOp, with their stage, in the + /// order picked for the pipelined loop. + using GetScheduleFnType = std::function> &)>; + GetScheduleFnType getScheduleFn = nullptr; + enum class PipelinerPart { + Prologue, + Kernel, + Epilogue, + }; + /// Lambda called by the pipeliner to allow the user to annotate the IR while + /// it is generated. + /// The callback passes the operation created along with the part of the + /// pipeline and the iteration index. The iteration index is always 0 for the + /// kernel. For the prologue and epilogue, it corresponds to the iteration + /// peeled out of the loop in the range [0, maxStage[. + using AnnotationlFnType = + std::function; + AnnotationlFnType annotateFn = nullptr; + + /// Control whether the epilogue should be peeled out of the loop or + /// operations should be predicated to skip the early stages in the last loop + /// iterations. If the epilogue is predicated; the user needs to provide a + /// lambda to generate the predicated version of operations. + bool peelEpilogue = true; + + // Callback to predicate operations when the prologue or epilogue are not + // peeled. This takes the original operation, an i1 predicate value and the + // pattern rewriter. It is expected to replace the given operation with + // the predicated equivalent and return it, or return nullptr if the + // predication is impossible. In the latter case, pipelining will fail and + // may leave IR in a partially transformed state. + using PredicateOpFn = + std::function; + PredicateOpFn predicateFn = nullptr; + + // TODO: add option to decide if the prologue should be peeled. +}; + +/// Generate a pipelined version of the scf.for loop based on the schedule given +/// as option. This applies the mechanical transformation of changing the loop +/// and generating the prologue/epilogue for the pipelining and doesn't make any +/// decision regarding the schedule. +/// Based on the options the loop is split into several stages. +/// The transformation assumes that the scheduling given by user is valid. +/// For example if we break a loop into 3 stages named S0, S1, S2 we would +/// generate the following code with the number in parenthesis as the iteration +/// index: +/// +/// S0(0) // Prologue +/// S0(1) S1(0) // Prologue +/// scf.for %I = %C0 to %N - 2 { +/// S0(I+2) S1(I+1) S2(I) // Pipelined kernel +/// } +/// S1(N) S2(N-1) // Epilogue +/// S2(N) // Epilogue +/// +/// If `modifiedIR` is provided, it will be set to a value that indicates +/// whether pipelining modified the IR before failing, signaling to the caller +/// whether they can proceed with different transformations. +FailureOr pipelineForLoop(RewriterBase &rewriter, ForOp forOp, + const PipeliningOption &options, + bool *modifiedIR = nullptr); + +} // namespace scf +} // namespace mlir + +#endif // MLIR_DIALECT_SCF_TRANSFORMS_TRANSFORMS_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Utils/AffineCanonicalizationUtils.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Utils/AffineCanonicalizationUtils.h new file mode 100644 index 0000000000000000000000000000000000000000..5022cbf898ec17869e9d9a9a02534938c6e91e2a --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Utils/AffineCanonicalizationUtils.h @@ -0,0 +1,85 @@ +//===- AffineCanonicalizationUtils.h ----------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This header file defines utility functions to canonicalize affine ops +// within SCF op regions. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_SCF_UTILS_AFFINECANONICALIZATIONUTILS_H_ +#define MLIR_DIALECT_SCF_UTILS_AFFINECANONICALIZATIONUTILS_H_ + +#include "mlir/Support/LLVM.h" +#include "mlir/Support/LogicalResult.h" + +namespace mlir { +class AffineMap; +struct LogicalResult; +class Operation; +class OpFoldResult; +class RewriterBase; +class Value; +class ValueRange; + +namespace affine { +class FlatAffineValueConstraints; +} // namespace affine + +namespace scf { +class IfOp; + +/// Match "for loop"-like operations: If the first parameter is an iteration +/// variable, return lower/upper bounds via the second/third parameter and the +/// step size via the last parameter. The function should return `success` in +/// that case. If the first parameter is not an iteration variable, return +/// `failure`. +using LoopMatcherFn = function_ref; + +/// Match "for loop"-like operations from the SCF dialect. +LogicalResult matchForLikeLoop(Value iv, OpFoldResult &lb, OpFoldResult &ub, + OpFoldResult &step); + +/// Populate the given constraint set with induction variable constraints of a +/// "for" loop with the given range and step. +LogicalResult addLoopRangeConstraints(affine::FlatAffineValueConstraints &cstr, + Value iv, OpFoldResult lb, + OpFoldResult ub, OpFoldResult step); + +/// Try to canonicalize the given affine.min/max operation in the context of +/// for `loops` with a known range. +/// +/// `loopMatcher` is used to retrieve loop bounds and the step size for a given +/// iteration variable. +/// +/// Note: `loopMatcher` allows this function to be used with any "for loop"-like +/// operation (scf.for, scf.parallel and even ops defined in other dialects). +LogicalResult canonicalizeMinMaxOpInLoop(RewriterBase &rewriter, Operation *op, + LoopMatcherFn loopMatcher); + +/// Try to simplify the given affine.min/max operation `op` after loop peeling. +/// This function can simplify min/max operations such as (ub is the previous +/// upper bound of the unpeeled loop): +/// ``` +/// #map = affine_map<(d0)[s0, s1] -> (s0, -d0 + s1)> +/// %r = affine.min #map(%iv)[%step, %ub] +/// ``` +/// and rewrites them into (in the case the peeled loop): +/// ``` +/// %r = %step +/// ``` +/// min/max operations inside the partial iteration are rewritten in a similar +/// way. +LogicalResult rewritePeeledMinMaxOp(RewriterBase &rewriter, Operation *op, + Value iv, Value ub, Value step, + bool insideLoop); + +} // namespace scf +} // namespace mlir + +#endif // MLIR_DIALECT_SCF_UTILS_AFFINECANONICALIZATIONUTILS_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Utils/Utils.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Utils/Utils.h new file mode 100644 index 0000000000000000000000000000000000000000..9bdd6eb833876f09a63bfa367e8614d938b0b9f0 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Utils/Utils.h @@ -0,0 +1,167 @@ +//===- Utils.h - SCF dialect utilities --------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This header file defines prototypes for various SCF utilities. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_SCF_UTILS_UTILS_H_ +#define MLIR_DIALECT_SCF_UTILS_UTILS_H_ + +#include "mlir/Dialect/SCF/IR/SCF.h" +#include "mlir/IR/PatternMatch.h" +#include "mlir/Support/LLVM.h" +#include "mlir/Support/LogicalResult.h" +#include "llvm/ADT/STLExtras.h" +#include + +namespace mlir { +class Location; +class Operation; +class OpBuilder; +class Region; +class RewriterBase; +class ValueRange; +class Value; + +namespace func { +class CallOp; +class FuncOp; +} // namespace func + +/// Update a perfectly nested loop nest to yield new values from the innermost +/// loop and propagating it up through the loop nest. This function +/// - Expects `loopNest` to be a perfectly nested loop with outer most loop +/// first and innermost loop last. +/// - `newIterOperands` are the initialization values to be used for the +/// outermost loop +/// - `newYielValueFn` is the callback that generates the new values to be +/// yielded from within the innermost loop. +/// - The original loops are not erased, but are left in a "no-op" state where +/// the body of the loop just yields the basic block arguments that correspond +/// to the initialization values of a loop. The original loops are dead after +/// this method. +/// - If `replaceIterOperandsUsesInLoop` is true, all uses of the +/// `newIterOperands` within the generated new loop are replaced with the +/// corresponding `BlockArgument` in the loop body. +SmallVector replaceLoopNestWithNewYields( + RewriterBase &rewriter, MutableArrayRef loopNest, + ValueRange newIterOperands, const NewYieldValuesFn &newYieldValuesFn, + bool replaceIterOperandsUsesInLoop = true); + +/// Outline a region with a single block into a new FuncOp. +/// Assumes the FuncOp result types is the type of the yielded operands of the +/// single block. This constraint makes it easy to determine the result. +/// This method also clones the `arith::ConstantIndexOp` at the start of +/// `outlinedFuncBody` to alloc simple canonicalizations. +/// Creates a new FuncOp and thus cannot be used in a FuncOp pass. +/// The client is responsible for providing a unique `funcName` that will not +/// collide with another FuncOp name. If `callOp` is provided, it will be set +/// to point to the operation that calls the outlined function. +// TODO: support more than single-block regions. +// TODO: more flexible constant handling. +FailureOr +outlineSingleBlockRegion(RewriterBase &rewriter, Location loc, Region ®ion, + StringRef funcName, func::CallOp *callOp = nullptr); + +/// Outline the then and/or else regions of `ifOp` as follows: +/// - if `thenFn` is not null, `thenFnName` must be specified and the `then` +/// region is inlined into a new FuncOp that is captured by the pointer. +/// - if `elseFn` is not null, `elseFnName` must be specified and the `else` +/// region is inlined into a new FuncOp that is captured by the pointer. +/// Creates new FuncOps and thus cannot be used in a FuncOp pass. +/// The client is responsible for providing a unique `thenFnName`/`elseFnName` +/// that will not collide with another FuncOp name. +LogicalResult outlineIfOp(RewriterBase &b, scf::IfOp ifOp, func::FuncOp *thenFn, + StringRef thenFnName, func::FuncOp *elseFn, + StringRef elseFnName); + +/// Get a list of innermost parallel loops contained in `rootOp`. Innermost +/// parallel loops are those that do not contain further parallel loops +/// themselves. +bool getInnermostParallelLoops(Operation *rootOp, + SmallVectorImpl &result); + +/// Return the min/max expressions for `value` if it is an induction variable +/// from scf.for or scf.parallel loop. +/// if `loopFilter` is passed, the filter determines which loop to consider. +/// Other induction variables are ignored. +std::optional> +getSCFMinMaxExpr(Value value, SmallVectorImpl &dims, + SmallVectorImpl &symbols, + llvm::function_ref loopFilter = nullptr); + +/// Replace a perfect nest of "for" loops with a single linearized loop. Assumes +/// `loops` contains a list of perfectly nested loops with bounds and steps +/// independent of any loop induction variable involved in the nest. +LogicalResult coalesceLoops(MutableArrayRef loops); + +/// Take the ParallelLoop and for each set of dimension indices, combine them +/// into a single dimension. combinedDimensions must contain each index into +/// loops exactly once. +void collapseParallelLoops(scf::ParallelOp loops, + ArrayRef> combinedDimensions); + +/// Unrolls this for operation by the specified unroll factor. Returns failure +/// if the loop cannot be unrolled either due to restrictions or due to invalid +/// unroll factors. Requires positive loop bounds and step. If specified, +/// annotates the Ops in each unrolled iteration by applying `annotateFn`. +LogicalResult loopUnrollByFactor( + scf::ForOp forOp, uint64_t unrollFactor, + function_ref annotateFn = nullptr); + +/// Tile a nest of standard for loops rooted at `rootForOp` by finding such +/// parametric tile sizes that the outer loops have a fixed number of iterations +/// as defined in `sizes`. +using Loops = SmallVector; +using TileLoops = std::pair; +TileLoops extractFixedOuterLoops(scf::ForOp rootFOrOp, ArrayRef sizes); + +/// Performs tiling fo imperfectly nested loops (with interchange) by +/// strip-mining the `forOps` by `sizes` and sinking them, in their order of +/// occurrence in `forOps`, under each of the `targets`. +/// Returns the new AffineForOps, one per each of (`forOps`, `targets`) pair, +/// nested immediately under each of `targets`. +SmallVector tile(ArrayRef forOps, ArrayRef sizes, + ArrayRef targets); + +/// Performs tiling (with interchange) by strip-mining the `forOps` by `sizes` +/// and sinking them, in their order of occurrence in `forOps`, under `target`. +/// Returns the new AffineForOps, one per `forOps`, nested immediately under +/// `target`. +Loops tile(ArrayRef forOps, ArrayRef sizes, + scf::ForOp target); + +/// Tile a nest of scf::ForOp loops rooted at `rootForOp` with the given +/// (parametric) sizes. Sizes are expected to be strictly positive values at +/// runtime. If more sizes than loops are provided, discard the trailing values +/// in sizes. Assumes the loop nest is permutable. +/// Returns the newly created intra-tile loops. +Loops tilePerfectlyNested(scf::ForOp rootForOp, ArrayRef sizes); + +/// Get perfectly nested sequence of loops starting at root of loop nest +/// (the first op being another AffineFor, and the second op - a terminator). +/// A loop is perfectly nested iff: the first op in the loop's body is another +/// AffineForOp, and the second op is a terminator). +void getPerfectlyNestedLoops(SmallVectorImpl &nestedLoops, + scf::ForOp root); + +/// Given two scf.forall loops, `target` and `source`, fuses `target` into +/// `source`. Assumes that the given loops are siblings and are independent of +/// each other. +/// +/// This function does not perform any legality checks and simply fuses the +/// loops. The caller is responsible for ensuring that the loops are legal to +/// fuse. +scf::ForallOp fuseIndependentSiblingForallLoops(scf::ForallOp target, + scf::ForallOp source, + RewriterBase &rewriter); + +} // namespace mlir + +#endif // MLIR_DIALECT_SCF_UTILS_UTILS_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/Analysis/ShapeMappingAnalysis.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/Analysis/ShapeMappingAnalysis.h new file mode 100644 index 0000000000000000000000000000000000000000..25befa359085618096c9b45835e3239441b3d7db --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/Analysis/ShapeMappingAnalysis.h @@ -0,0 +1,60 @@ +//===- ShapeMappingAnalysis.h - Preserve shape Info ------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_SHAPE_ANALYSIS_SHAPEMAPPINGANALYSIS_H_ +#define MLIR_DIALECT_SHAPE_ANALYSIS_SHAPEMAPPINGANALYSIS_H_ + +#include "mlir/IR/BuiltinAttributes.h" +#include "mlir/IR/Value.h" +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/SmallVector.h" + +namespace mlir { + +namespace shape { + +/// ShapeMappingValue works as the value of ShapeMappingAnalysis table, where +/// `funcSymbol` is the symbol of mapping function, and `inputs` are the actual +/// parameters for the function. +struct ShapeMappingValue { + ShapeMappingValue() = default; + ShapeMappingValue(FlatSymbolRefAttr symbol, llvm::SmallVector &&inps) + : funcSymbol(symbol), inputs(inps) {} + + FlatSymbolRefAttr funcSymbol; + llvm::SmallVector inputs; +}; + +/// ShapeMappingAnalysis is used together with OutlineShapeComputationPass to +/// preserve Value and corresponding shape function / arguments mapping +/// information +struct ShapeMappingAnalysis { + ShapeMappingAnalysis(Operation *op) : operation(op) { (void)operation; } + + /// Dumps the shape mapping information to the given stream. + void print(raw_ostream &os) const { + os << "// ---- Shape Mapping Information -----\n"; + for (const auto &it : shapeMapping) { + const ShapeMappingValue &mappingValue = it.second; + os << "// Shape for " << it.first << " :: " << mappingValue.funcSymbol; + llvm::interleaveComma(mappingValue.inputs, os << "("); + os << ")\n"; + } + } + + llvm::DenseMap shapeMapping; + +private: + Operation *operation; +}; + +} // namespace shape +} // namespace mlir + +#endif // MLIR_DIALECT_SHAPE_ANALYSIS_SHAPEMAPPINGANALYSIS_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/Shape.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/Shape.h new file mode 100644 index 0000000000000000000000000000000000000000..1f75f9411d37b562bc1839e721d25c6e7dedd3a2 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/Shape.h @@ -0,0 +1,56 @@ +//===- Shape.h - MLIR Shape dialect -----------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file defines the shape dialect that is used to describe and solve shape +// relations of MLIR operations using ShapedType. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_SHAPE_IR_SHAPE_H +#define MLIR_DIALECT_SHAPE_IR_SHAPE_H + +#include "mlir/Bytecode/BytecodeOpInterface.h" +#include "mlir/IR/BuiltinOps.h" +#include "mlir/IR/Dialect.h" +#include "mlir/IR/OpDefinition.h" +#include "mlir/IR/OpImplementation.h" +#include "mlir/IR/SymbolTable.h" +#include "mlir/Interfaces/CallInterfaces.h" +#include "mlir/Interfaces/CastInterfaces.h" +#include "mlir/Interfaces/ControlFlowInterfaces.h" +#include "mlir/Interfaces/FunctionInterfaces.h" +#include "mlir/Interfaces/InferTypeOpInterface.h" +#include "mlir/Interfaces/SideEffectInterfaces.h" + +#define GET_TYPEDEF_CLASSES +#include "mlir/Dialect/Shape/IR/ShapeOpsTypes.h.inc" + +namespace mlir { +class PatternRewriter; + +namespace shape { + +/// Alias type for extent tensors. +RankedTensorType getExtentTensorType(MLIRContext *ctx, + int64_t rank = ShapedType::kDynamic); + +// Check if a type is an extent tensor, e.g., tensor. +bool isExtentTensorType(Type); + +// Given an input shape Value, try to obtain the shape's values. +LogicalResult getShapeVec(Value input, SmallVectorImpl &shapeValues); + +} // namespace shape +} // namespace mlir + +#define GET_OP_CLASSES +#include "mlir/Dialect/Shape/IR/ShapeOps.h.inc" + +#include "mlir/Dialect/Shape/IR/ShapeOpsDialect.h.inc" + +#endif // MLIR_DIALECT_SHAPE_IR_SHAPE_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/ShapeCanonicalization.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/ShapeCanonicalization.inc new file mode 100644 index 0000000000000000000000000000000000000000..6703867d20387f58528d33d6353e9c55b462f937 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/ShapeCanonicalization.inc @@ -0,0 +1,384 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Rewriters *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: ShapeCanonicalization.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +/* Generated from: + external/llvm-project/mlir/lib/Dialect/Shape/IR/ShapeCanonicalization.td:22 +*/ +struct AssumingAllOneOp : public ::mlir::RewritePattern { + AssumingAllOneOp(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("shape.assuming_all", 1, context, {}) {} + ::mlir::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range args(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::shape::AssumingAllOp>(op0); (void)castedOp0; + args = castedOp0.getODSOperands(0); + if (!(( + args.size() == 1 + ))){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "entities 'args' failed to satisfy constraint: ''"; + }); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ args }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + }; +}; + +/* Generated from: + external/llvm-project/mlir/lib/Dialect/Shape/IR/ShapeCanonicalization.td:26 +*/ +struct CstrBroadcastableEqOps : public ::mlir::RewritePattern { + CstrBroadcastableEqOps(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("shape.cstr_broadcastable", 1, context, {"shape.const_witness"}) {} + ::mlir::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range shapes(op0->getOperands()); + ::mlir::shape::CstrBroadcastableOp op; + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::shape::CstrBroadcastableOp>(op0); (void)castedOp0; + op = castedOp0; + shapes = castedOp0.getODSOperands(0); + if (!(( + llvm::all_equal(shapes) + ))){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "entities 'shapes' failed to satisfy constraint: ''"; + }); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::shape::ConstWitnessOp tblgen_ConstWitnessOp_0; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::llvm::SmallVector<::mlir::NamedAttribute, 4> tblgen_attrs; (void)tblgen_attrs; + if (auto tmpAttr = rewriter.getBoolAttr(true)) { + tblgen_attrs.emplace_back(rewriter.getStringAttr("passing"), tmpAttr); + } + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_ConstWitnessOp_0 = rewriter.create<::mlir::shape::ConstWitnessOp>(odsLoc, tblgen_types, tblgen_values, tblgen_attrs); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_ConstWitnessOp_0.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + }; +}; + +/* Generated from: + external/llvm-project/mlir/lib/Dialect/Shape/IR/ShapeCanonicalization.td:30 +*/ +struct CstrEqEqOps : public ::mlir::RewritePattern { + CstrEqEqOps(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("shape.cstr_eq", 1, context, {"shape.const_witness"}) {} + ::mlir::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range shapes(op0->getOperands()); + ::mlir::shape::CstrEqOp op; + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::shape::CstrEqOp>(op0); (void)castedOp0; + op = castedOp0; + shapes = castedOp0.getODSOperands(0); + if (!(( + llvm::all_equal(shapes) + ))){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "entities 'shapes' failed to satisfy constraint: ''"; + }); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::shape::ConstWitnessOp tblgen_ConstWitnessOp_0; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::llvm::SmallVector<::mlir::NamedAttribute, 4> tblgen_attrs; (void)tblgen_attrs; + if (auto tmpAttr = rewriter.getBoolAttr(true)) { + tblgen_attrs.emplace_back(rewriter.getStringAttr("passing"), tmpAttr); + } + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_ConstWitnessOp_0 = rewriter.create<::mlir::shape::ConstWitnessOp>(odsLoc, tblgen_types, tblgen_values, tblgen_attrs); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_ConstWitnessOp_0.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + }; +}; + +/* Generated from: + external/llvm-project/mlir/lib/Dialect/Shape/IR/ShapeCanonicalization.td:50 +*/ +struct ExtractFromShapeOfExtentTensor : public ::mlir::RewritePattern { + ExtractFromShapeOfExtentTensor(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("tensor.extract", 2, context, {"tensor.dim"}) {} + ::mlir::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range indices(op0->getOperands()); + ::mlir::Operation::operand_range arg(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::tensor::ExtractOp>(op0); (void)castedOp0; + { + auto *op1 = (*castedOp0.getODSOperands(0).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 0 of castedOp0"; + }); + } + auto castedOp1 = ::llvm::dyn_cast<::mlir::shape::ShapeOfOp>(op1); (void)castedOp1; + if (!(castedOp1)){ + return rewriter.notifyMatchFailure(op1, [&](::mlir::Diagnostic &diag) { + diag << "castedOp1 is not ::mlir::shape::ShapeOfOp type"; + }); + } + arg = castedOp1.getODSOperands(0); + tblgen_ops.push_back(op1); + } + indices = castedOp0.getODSOperands(1); + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + auto nativeVar_0 = indices.front(); (void)nativeVar_0; + ::mlir::tensor::DimOp tblgen_DimOp_1; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::llvm::SmallVector<::mlir::NamedAttribute, 4> tblgen_attrs; (void)tblgen_attrs; + tblgen_values.push_back((*arg.begin())); + tblgen_values.push_back(nativeVar_0); + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_DimOp_1 = rewriter.create<::mlir::tensor::DimOp>(odsLoc, tblgen_types, tblgen_values, tblgen_attrs); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_DimOp_1.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + }; +}; + +/* Generated from: + external/llvm-project/mlir/lib/Dialect/Shape/IR/ShapeCanonicalization.td:34 +*/ +struct IndexToSizeToIndexCanonicalization : public ::mlir::RewritePattern { + IndexToSizeToIndexCanonicalization(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("shape.size_to_index", 2, context, {}) {} + ::mlir::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range arg(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::shape::SizeToIndexOp>(op0); (void)castedOp0; + { + auto *op1 = (*castedOp0.getODSOperands(0).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 0 of castedOp0"; + }); + } + auto castedOp1 = ::llvm::dyn_cast<::mlir::shape::IndexToSizeOp>(op1); (void)castedOp1; + if (!(castedOp1)){ + return rewriter.notifyMatchFailure(op1, [&](::mlir::Diagnostic &diag) { + diag << "castedOp1 is not ::mlir::shape::IndexToSizeOp type"; + }); + } + arg = castedOp1.getODSOperands(0); + tblgen_ops.push_back(op1); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ arg }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + }; +}; + +/* Generated from: + external/llvm-project/mlir/lib/Dialect/Shape/IR/ShapeCanonicalization.td:38 +*/ +struct SizeToIndexToSizeCanonicalization : public ::mlir::RewritePattern { + SizeToIndexToSizeCanonicalization(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("shape.index_to_size", 2, context, {}) {} + ::mlir::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::Operation::operand_range arg(op0->getOperands()); + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::shape::IndexToSizeOp>(op0); (void)castedOp0; + { + auto *op1 = (*castedOp0.getODSOperands(0).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 0 of castedOp0"; + }); + } + auto castedOp1 = ::llvm::dyn_cast<::mlir::shape::SizeToIndexOp>(op1); (void)castedOp1; + if (!(castedOp1)){ + return rewriter.notifyMatchFailure(op1, [&](::mlir::Diagnostic &diag) { + diag << "castedOp1 is not ::mlir::shape::SizeToIndexOp type"; + }); + } + arg = castedOp1.getODSOperands(0); + tblgen_ops.push_back(op1); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ arg }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + }; +}; + +/* Generated from: + external/llvm-project/mlir/lib/Dialect/Shape/IR/ShapeCanonicalization.td:44 +*/ +struct TensorCastConstShape : public ::mlir::RewritePattern { + TensorCastConstShape(::mlir::MLIRContext *context) + : ::mlir::RewritePattern("tensor.cast", 2, context, {"shape.const_shape"}) {} + ::mlir::LogicalResult matchAndRewrite(::mlir::Operation *op0, + ::mlir::PatternRewriter &rewriter) const override { + // Variables for capturing values and attributes used while creating ops + ::mlir::DenseIntElementsAttr arg; + ::mlir::tensor::CastOp res; + ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; + + // Match + tblgen_ops.push_back(op0); + auto castedOp0 = ::llvm::dyn_cast<::mlir::tensor::CastOp>(op0); (void)castedOp0; + res = castedOp0; + { + auto *op1 = (*castedOp0.getODSOperands(0).begin()).getDefiningOp(); + if (!(op1)){ + return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) { + diag << "There's no operation that defines operand 0 of castedOp0"; + }); + } + auto castedOp1 = ::llvm::dyn_cast<::mlir::shape::ConstShapeOp>(op1); (void)castedOp1; + if (!(castedOp1)){ + return rewriter.notifyMatchFailure(op1, [&](::mlir::Diagnostic &diag) { + diag << "castedOp1 is not ::mlir::shape::ConstShapeOp type"; + }); + } + { + auto tblgen_attr = op1->getAttrOfType<::mlir::DenseIntElementsAttr>("shape");(void)tblgen_attr; + if (!(tblgen_attr)){ + return rewriter.notifyMatchFailure(op1, [&](::mlir::Diagnostic &diag) { + diag << "expected op 'shape.const_shape' to have attribute 'shape' of type '::mlir::DenseIntElementsAttr'"; + }); + } + arg = tblgen_attr; + } + tblgen_ops.push_back(op1); + } + if (!(( + ::llvm::dyn_cast((*res.getODSResults(0).begin()).getType()).hasStaticShape() + ))){ + return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) { + diag << "entities 'res' failed to satisfy constraint: ''"; + }); + } + + // Rewrite + auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; + ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; + ::mlir::shape::ConstShapeOp tblgen_ConstShapeOp_0; + { + ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; + ::llvm::SmallVector<::mlir::NamedAttribute, 4> tblgen_attrs; (void)tblgen_attrs; + if (auto tmpAttr = arg) { + tblgen_attrs.emplace_back(rewriter.getStringAttr("shape"), tmpAttr); + } + ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; + for (auto v: castedOp0.getODSResults(0)) { + tblgen_types.push_back(v.getType()); + } + tblgen_ConstShapeOp_0 = rewriter.create<::mlir::shape::ConstShapeOp>(odsLoc, tblgen_types, tblgen_values, tblgen_attrs); + } + + for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_ConstShapeOp_0.getODSResults(0) }) { + tblgen_repl_values.push_back(v); + } + + rewriter.replaceOp(op0, tblgen_repl_values); + return ::mlir::success(); + }; +}; + +void LLVM_ATTRIBUTE_UNUSED populateWithGenerated(::mlir::RewritePatternSet &patterns) { + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); + patterns.add(patterns.getContext()); +} diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.cpp.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..b8715c61004847912a909191f19413cb80f45d00 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.cpp.inc @@ -0,0 +1,10021 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Op Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: ShapeOps.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifdef GET_OP_LIST +#undef GET_OP_LIST + +::mlir::shape::AddOp, +::mlir::shape::AnyOp, +::mlir::shape::AssumingAllOp, +::mlir::shape::AssumingOp, +::mlir::shape::AssumingYieldOp, +::mlir::shape::BroadcastOp, +::mlir::shape::ConcatOp, +::mlir::shape::ConstShapeOp, +::mlir::shape::ConstSizeOp, +::mlir::shape::ConstWitnessOp, +::mlir::shape::CstrBroadcastableOp, +::mlir::shape::CstrEqOp, +::mlir::shape::CstrRequireOp, +::mlir::shape::DebugPrintOp, +::mlir::shape::DimOp, +::mlir::shape::DivOp, +::mlir::shape::FromExtentTensorOp, +::mlir::shape::FromExtentsOp, +::mlir::shape::FuncOp, +::mlir::shape::FunctionLibraryOp, +::mlir::shape::GetExtentOp, +::mlir::shape::IndexToSizeOp, +::mlir::shape::IsBroadcastableOp, +::mlir::shape::MaxOp, +::mlir::shape::MeetOp, +::mlir::shape::MinOp, +::mlir::shape::MulOp, +::mlir::shape::NumElementsOp, +::mlir::shape::RankOp, +::mlir::shape::ReduceOp, +::mlir::shape::ReturnOp, +::mlir::shape::ShapeEqOp, +::mlir::shape::ShapeOfOp, +::mlir::shape::SizeToIndexOp, +::mlir::shape::SplitAtOp, +::mlir::shape::ToExtentTensorOp, +::mlir::shape::ValueAsShapeOp, +::mlir::shape::ValueOfOp, +::mlir::shape::WithOp, +::mlir::shape::YieldOp +#endif // GET_OP_LIST + +#ifdef GET_OP_CLASSES +#undef GET_OP_CLASSES + + +//===----------------------------------------------------------------------===// +// Local Utility Method Definitions +//===----------------------------------------------------------------------===// + +namespace mlir { +namespace shape { + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_ShapeOps0( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::shape::SizeType>(type))) || ((::llvm::isa<::mlir::IndexType>(type))))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be size or index, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_ShapeOps1( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::shape::ShapeType>(type))) || ((((::llvm::isa<::mlir::RankedTensorType>(type))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank() + == 1)))) && ([](::mlir::Type elementType) { return (::llvm::isa<::mlir::IndexType>(elementType)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be shape or extent tensor, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_ShapeOps2( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((::llvm::isa<::mlir::shape::WitnessType>(type)))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be , but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_ShapeOps3( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((true))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be any type, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_ShapeOps4( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((::llvm::isa<::mlir::shape::SizeType>(type)))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be , but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_ShapeOps5( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((type.isSignlessInteger(1)))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be 1-bit signless integer, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_ShapeOps6( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::shape::SizeType>(type))) || ((::llvm::isa<::mlir::shape::ShapeType>(type))))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be shape or size, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_ShapeOps7( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::ShapedType>(type))) && ([](::mlir::Type elementType) { return (true); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be shaped of any type values, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_ShapeOps8( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::RankedTensorType>(type))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank() + == 1)))) && ([](::mlir::Type elementType) { return (::llvm::isa<::mlir::IndexType>(elementType)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be 1D tensor of index values, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_ShapeOps9( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((::llvm::isa<::mlir::shape::ShapeType>(type)))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be , but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_ShapeOps10( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((::llvm::isa<::mlir::IndexType>(type)))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be index, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_ShapeOps11( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::shape::SizeType>(type))) || ((::llvm::isa<::mlir::IndexType>(type)))) || (((::llvm::isa<::mlir::shape::ShapeType>(type))) || ((((::llvm::isa<::mlir::RankedTensorType>(type))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank() + == 1)))) && ([](::mlir::Type elementType) { return (::llvm::isa<::mlir::IndexType>(elementType)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be any shape or size, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_ShapeOps12( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::ShapedType>(type))) && ([](::mlir::Type elementType) { return (true); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((::llvm::isa<::mlir::shape::ValueShapeType>(type))))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be shaped of any type values or , but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_ShapeOps13( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::TensorType>(type))) && ([](::mlir::Type elementType) { return (::llvm::isa<::mlir::IndexType>(elementType)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be tensor of index values, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_ShapeOps14( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((((::llvm::isa<::mlir::RankedTensorType>(type))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank() + == 1)))) && ([](::mlir::Type elementType) { return ((::llvm::isa<::mlir::IntegerType>(elementType))) || ((::llvm::isa<::mlir::IndexType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((::llvm::isa<::mlir::shape::ValueShapeType>(type))))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be 1D tensor of integer or index values or , but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_ShapeOps15( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((::llvm::isa<::mlir::shape::ValueShapeType>(type)))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be , but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_ShapeOps0( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::StringAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: string attribute"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_ShapeOps0( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_ShapeOps0(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_ShapeOps1( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !(((::llvm::isa<::mlir::DenseIntElementsAttr>(attr))) && ((::llvm::cast<::mlir::DenseIntElementsAttr>(attr) + .getType() + .getElementType() + .isIndex())))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: index elements attribute"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_ShapeOps1( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_ShapeOps1(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_ShapeOps2( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !(((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::isa<::mlir::IndexType>(::llvm::cast<::mlir::IntegerAttr>(attr).getType()))))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: index attribute"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_ShapeOps2( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_ShapeOps2(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_ShapeOps3( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::BoolAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: bool attribute"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_ShapeOps3( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_ShapeOps3(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_ShapeOps4( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !(((::llvm::isa<::mlir::TypeAttr>(attr))) && ((::llvm::isa<::mlir::FunctionType>(::llvm::cast<::mlir::TypeAttr>(attr).getValue()))) && ((::llvm::isa<::mlir::FunctionType>(::llvm::cast<::mlir::TypeAttr>(attr).getValue()))))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: type attribute of function type"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_ShapeOps4( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_ShapeOps4(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_ShapeOps5( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !(((::llvm::isa<::mlir::ArrayAttr>(attr))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(attr), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::DictionaryAttr>(attr))); })))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: Array of dictionary attributes"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_ShapeOps5( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_ShapeOps5(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_ShapeOps6( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::DictionaryAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: dictionary of named attribute values"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_ShapeOps6( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_ShapeOps6(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_region_constraint_ShapeOps0( + ::mlir::Operation *op, ::mlir::Region ®ion, ::llvm::StringRef regionName, + unsigned regionIndex) { + if (!((::llvm::hasNItems(region, 1)))) { + return op->emitOpError("region #") << regionIndex + << (regionName.empty() ? " " : " ('" + regionName + "') ") + << "failed to verify constraint: region with 1 blocks"; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_region_constraint_ShapeOps1( + ::mlir::Operation *op, ::mlir::Region ®ion, ::llvm::StringRef regionName, + unsigned regionIndex) { + if (!((true))) { + return op->emitOpError("region #") << regionIndex + << (regionName.empty() ? " " : " ('" + regionName + "') ") + << "failed to verify constraint: any region"; + } + return ::mlir::success(); +} +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::AddOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +AddOpGenericAdaptorBase::AddOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.add", odsAttrs.getContext()); +} + +AddOpGenericAdaptorBase::AddOpGenericAdaptorBase(AddOp op) : AddOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair AddOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr AddOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +AddOpAdaptor::AddOpAdaptor(AddOp op) : AddOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult AddOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair AddOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range AddOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value AddOp::getLhs() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin()); +} + +::mlir::Value AddOp::getRhs() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(1).begin()); +} + +::mlir::OpOperand &AddOp::getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &AddOp::getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +std::pair AddOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range AddOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value AddOp::getResult() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +void AddOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void AddOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AddOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void AddOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void AddOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void AddOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AddOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult AddOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps0(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult AddOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult AddOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(lhsRawOperands); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(rhsRawOperands); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(lhsRawTypes); + ::mlir::Type rhsRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(rhsRawTypes); + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + lhsRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + rhsRawTypes[0] = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void AddOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getLhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getRhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void AddOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::mlir::LogicalResult +AddOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + AddOp::Adaptor adaptor(operands, attributes, properties, regions); + return AddOp::inferReturnTypes(context, + location, adaptor, inferredReturnTypes); +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::AddOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::AnyOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +AnyOpGenericAdaptorBase::AnyOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.any", odsAttrs.getContext()); +} + +AnyOpGenericAdaptorBase::AnyOpGenericAdaptorBase(AnyOp op) : AnyOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair AnyOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr AnyOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +AnyOpAdaptor::AnyOpAdaptor(AnyOp op) : AnyOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult AnyOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair AnyOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range AnyOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::operand_range AnyOp::getInputs() { + return getODSOperands(0); +} + +::mlir::MutableOperandRange AnyOp::getInputsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair AnyOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range AnyOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value AnyOp::getResult() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +void AnyOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange inputs) { + odsState.addOperands(inputs); + odsState.addTypes(result); +} + +void AnyOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult AnyOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult AnyOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult AnyOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> inputsOperands; + ::llvm::SMLoc inputsOperandsLoc; + (void)inputsOperandsLoc; + ::llvm::SmallVector<::mlir::Type, 1> inputsTypes; + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + inputsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(inputsOperands)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + if (parser.parseTypeList(inputsTypes)) + return ::mlir::failure(); + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(inputsOperands, inputsTypes, inputsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void AnyOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getInputs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter << getInputs().getTypes(); + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void AnyOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::AnyOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::AssumingAllOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +AssumingAllOpGenericAdaptorBase::AssumingAllOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.assuming_all", odsAttrs.getContext()); +} + +AssumingAllOpGenericAdaptorBase::AssumingAllOpGenericAdaptorBase(AssumingAllOp op) : AssumingAllOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair AssumingAllOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr AssumingAllOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +AssumingAllOpAdaptor::AssumingAllOpAdaptor(AssumingAllOp op) : AssumingAllOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult AssumingAllOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair AssumingAllOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range AssumingAllOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::operand_range AssumingAllOp::getInputs() { + return getODSOperands(0); +} + +::mlir::MutableOperandRange AssumingAllOp::getInputsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair AssumingAllOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range AssumingAllOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::shape::WitnessType> AssumingAllOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::shape::WitnessType>>(*getODSResults(0).begin()); +} + +void AssumingAllOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange inputs) { + odsState.addOperands(inputs); + odsState.addTypes(result); +} + +void AssumingAllOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void AssumingAllOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(AssumingAllOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult AssumingAllOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult AssumingAllOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::LogicalResult AssumingAllOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = odsBuilder.getType<::mlir::shape::WitnessType>(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult AssumingAllOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> inputsOperands; + ::llvm::SMLoc inputsOperandsLoc; + (void)inputsOperandsLoc; + + inputsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(inputsOperands)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::shape::WitnessType>(); + result.addTypes(odsBuildableType0); + if (parser.resolveOperands(inputsOperands, odsBuildableType0, inputsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void AssumingAllOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getInputs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); +} + +void AssumingAllOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::AssumingAllOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::AssumingOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +AssumingOpGenericAdaptorBase::AssumingOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.assuming", odsAttrs.getContext()); +} + +AssumingOpGenericAdaptorBase::AssumingOpGenericAdaptorBase(AssumingOp op) : AssumingOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair AssumingOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr AssumingOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::Region &AssumingOpGenericAdaptorBase::getDoRegion() { + return *odsRegions[0]; +} + +::mlir::RegionRange AssumingOpGenericAdaptorBase::getRegions() { + return odsRegions; +} + +} // namespace detail +AssumingOpAdaptor::AssumingOpAdaptor(AssumingOp op) : AssumingOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult AssumingOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair AssumingOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range AssumingOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::shape::WitnessType> AssumingOp::getWitness() { + return ::llvm::cast<::mlir::TypedValue<::mlir::shape::WitnessType>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &AssumingOp::getWitnessMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair AssumingOp::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::result_range AssumingOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::result_range AssumingOp::getResults() { + return getODSResults(0); +} + +::mlir::Region &AssumingOp::getDoRegion() { + return (*this)->getRegion(0); +} + +void AssumingOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::Value witness) { + odsState.addOperands(witness); + (void)odsState.addRegion(); + odsState.addTypes(results); +} + +void AssumingOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult AssumingOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_ShapeOps0(*this, region, "doRegion", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult AssumingOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::AssumingOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::AssumingYieldOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +AssumingYieldOpGenericAdaptorBase::AssumingYieldOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.assuming_yield", odsAttrs.getContext()); +} + +AssumingYieldOpGenericAdaptorBase::AssumingYieldOpGenericAdaptorBase(AssumingYieldOp op) : AssumingYieldOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair AssumingYieldOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr AssumingYieldOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +AssumingYieldOpAdaptor::AssumingYieldOpAdaptor(AssumingYieldOp op) : AssumingYieldOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult AssumingYieldOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair AssumingYieldOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range AssumingYieldOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::operand_range AssumingYieldOp::getOperands() { + return getODSOperands(0); +} + +::mlir::MutableOperandRange AssumingYieldOp::getOperandsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair AssumingYieldOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range AssumingYieldOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +void AssumingYieldOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { + /* nothing to do */ +} + +void AssumingYieldOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands) { + odsState.addOperands(operands); +} + +void AssumingYieldOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult AssumingYieldOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult AssumingYieldOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult AssumingYieldOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> operandsOperands; + ::llvm::SMLoc operandsOperandsLoc; + (void)operandsOperandsLoc; + ::llvm::SmallVector<::mlir::Type, 1> operandsTypes; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + + operandsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(operandsOperands)) + return ::mlir::failure(); + if (!operandsOperands.empty()) { + if (parser.parseColon()) + return ::mlir::failure(); + + if (parser.parseTypeList(operandsTypes)) + return ::mlir::failure(); + } + if (parser.resolveOperands(operandsOperands, operandsTypes, operandsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void AssumingYieldOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + if (!getOperands().empty()) { + _odsPrinter << ' '; + _odsPrinter << getOperands(); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter << getOperands().getTypes(); + } +} + +void AssumingYieldOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::mlir::MutableOperandRange AssumingYieldOp::getMutableSuccessorOperands( + ::mlir::RegionBranchPoint point) { + return ::mlir::MutableOperandRange(*this); +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::AssumingYieldOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::BroadcastOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BroadcastOpGenericAdaptorBase::BroadcastOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.broadcast", odsAttrs.getContext()); +} + +BroadcastOpGenericAdaptorBase::BroadcastOpGenericAdaptorBase(BroadcastOp op) : BroadcastOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair BroadcastOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr BroadcastOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::StringAttr BroadcastOpGenericAdaptorBase::getErrorAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::StringAttr>(getProperties().error); + return attr; +} + +::std::optional< ::llvm::StringRef > BroadcastOpGenericAdaptorBase::getError() { + auto attr = getErrorAttr(); + return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); +} + +} // namespace detail +BroadcastOpAdaptor::BroadcastOpAdaptor(BroadcastOp op) : BroadcastOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult BroadcastOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_error = getProperties().error; (void)tblgen_error; + + if (tblgen_error && !((::llvm::isa<::mlir::StringAttr>(tblgen_error)))) + return emitError(loc, "'shape.broadcast' op ""attribute 'error' failed to satisfy constraint: string attribute"); + return ::mlir::success(); +} + +std::pair BroadcastOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range BroadcastOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::operand_range BroadcastOp::getShapes() { + return getODSOperands(0); +} + +::mlir::MutableOperandRange BroadcastOp::getShapesMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair BroadcastOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range BroadcastOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value BroadcastOp::getResult() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult BroadcastOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.error; + auto attr = dict.get("error"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for error in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `error` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute BroadcastOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.error; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("error", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BroadcastOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.error.getAsOpaquePointer())); +} + +std::optional BroadcastOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "error") + return prop.error; + return std::nullopt; +} + +void BroadcastOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "error") { + prop.error = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void BroadcastOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.error) attrs.append("error", prop.error); +} + +::mlir::LogicalResult BroadcastOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getErrorAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ShapeOps0(attr, "error", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult BroadcastOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.error))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.error); +} + +::mlir::StringAttr BroadcastOp::getErrorAttr() { + return ::llvm::dyn_cast_or_null<::mlir::StringAttr>(getProperties().error); +} + +::std::optional< ::llvm::StringRef > BroadcastOp::getError() { + auto attr = getErrorAttr(); + return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); +} + +void BroadcastOp::setErrorAttr(::mlir::StringAttr attr) { + (*this)->setAttr(getErrorAttrName(), attr); +} + +void BroadcastOp::setError(::std::optional<::llvm::StringRef> attrValue) { + if (attrValue) + return (*this)->setAttr(getErrorAttrName(), ::mlir::Builder((*this)->getContext()).getStringAttr(*attrValue)); + (*this)->removeAttr(getErrorAttrName()); +} + +::mlir::Attribute BroadcastOp::removeErrorAttr() { + auto &attr = getProperties().error; + attr = {}; + return attr; +} + +void BroadcastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/ ::mlir::StringAttr error) { + build(odsBuilder, odsState, result, ::llvm::ArrayRef({lhs, rhs}), + error); + +} + +void BroadcastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange shapes, /*optional*/::mlir::StringAttr error) { + odsState.addOperands(shapes); + if (error) { + odsState.getOrAddProperties().error = error; + } + odsState.addTypes(result); +} + +void BroadcastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange shapes, /*optional*/::mlir::StringAttr error) { + odsState.addOperands(shapes); + if (error) { + odsState.getOrAddProperties().error = error; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BroadcastOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult BroadcastOp::verifyInvariantsImpl() { + auto tblgen_error = getProperties().error; (void)tblgen_error; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ShapeOps0(*this, tblgen_error, "error"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult BroadcastOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult BroadcastOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> shapesOperands; + ::llvm::SMLoc shapesOperandsLoc; + (void)shapesOperandsLoc; + ::llvm::SmallVector<::mlir::Type, 1> shapesTypes; + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + shapesOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(shapesOperands)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + if (parser.parseTypeList(shapesTypes)) + return ::mlir::failure(); + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(shapesOperands, shapesTypes, shapesOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getShapes(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter << getShapes().getTypes(); + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void BroadcastOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::BroadcastOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::ConcatOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ConcatOpGenericAdaptorBase::ConcatOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.concat", odsAttrs.getContext()); +} + +ConcatOpGenericAdaptorBase::ConcatOpGenericAdaptorBase(ConcatOp op) : ConcatOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ConcatOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ConcatOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +ConcatOpAdaptor::ConcatOpAdaptor(ConcatOp op) : ConcatOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ConcatOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair ConcatOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ConcatOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value ConcatOp::getLhs() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin()); +} + +::mlir::Value ConcatOp::getRhs() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(1).begin()); +} + +::mlir::OpOperand &ConcatOp::getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &ConcatOp::getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +std::pair ConcatOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ConcatOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value ConcatOp::getResult() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +void ConcatOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void ConcatOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ConcatOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ConcatOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ConcatOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult ConcatOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(lhsRawOperands); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(rhsRawOperands); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(lhsRawTypes); + ::mlir::Type rhsRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(rhsRawTypes); + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + lhsRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + rhsRawTypes[0] = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ConcatOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getLhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getRhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void ConcatOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::ConcatOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::ConstShapeOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ConstShapeOpGenericAdaptorBase::ConstShapeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.const_shape", odsAttrs.getContext()); +} + +ConstShapeOpGenericAdaptorBase::ConstShapeOpGenericAdaptorBase(ConstShapeOp op) : ConstShapeOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ConstShapeOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ConstShapeOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::DenseIntElementsAttr ConstShapeOpGenericAdaptorBase::getShapeAttr() { + auto attr = ::llvm::cast<::mlir::DenseIntElementsAttr>(getProperties().shape); + return attr; +} + +::mlir::DenseIntElementsAttr ConstShapeOpGenericAdaptorBase::getShape() { + auto attr = getShapeAttr(); + return attr; +} + +} // namespace detail +ConstShapeOpAdaptor::ConstShapeOpAdaptor(ConstShapeOp op) : ConstShapeOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ConstShapeOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_shape = getProperties().shape; (void)tblgen_shape; + if (!tblgen_shape) return emitError(loc, "'shape.const_shape' op ""requires attribute 'shape'"); + + if (tblgen_shape && !(((::llvm::isa<::mlir::DenseIntElementsAttr>(tblgen_shape))) && ((::llvm::cast<::mlir::DenseIntElementsAttr>(tblgen_shape) + .getType() + .getElementType() + .isIndex())))) + return emitError(loc, "'shape.const_shape' op ""attribute 'shape' failed to satisfy constraint: index elements attribute"); + return ::mlir::success(); +} + +std::pair ConstShapeOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ConstShapeOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +std::pair ConstShapeOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ConstShapeOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value ConstShapeOp::getResult() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult ConstShapeOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.shape; + auto attr = dict.get("shape"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for shape in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `shape` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ConstShapeOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.shape; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("shape", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ConstShapeOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.shape.getAsOpaquePointer())); +} + +std::optional ConstShapeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "shape") + return prop.shape; + return std::nullopt; +} + +void ConstShapeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "shape") { + prop.shape = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ConstShapeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.shape) attrs.append("shape", prop.shape); +} + +::mlir::LogicalResult ConstShapeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getShapeAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ShapeOps1(attr, "shape", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ConstShapeOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.shape))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ConstShapeOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.shape); +} + +::mlir::DenseIntElementsAttr ConstShapeOp::getShapeAttr() { + return ::llvm::cast<::mlir::DenseIntElementsAttr>(getProperties().shape); +} + +::mlir::DenseIntElementsAttr ConstShapeOp::getShape() { + auto attr = getShapeAttr(); + return attr; +} + +void ConstShapeOp::setShapeAttr(::mlir::DenseIntElementsAttr attr) { + (*this)->setAttr(getShapeAttrName(), attr); +} + +void ConstShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::DenseIntElementsAttr shape) { + odsState.getOrAddProperties().shape = shape; + odsState.addTypes(result); +} + +void ConstShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::DenseIntElementsAttr shape) { + odsState.getOrAddProperties().shape = shape; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ConstShapeOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void ConstShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::DenseIntElementsAttr shape) { + odsState.getOrAddProperties().shape = shape; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ConstShapeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ConstShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ConstShapeOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult ConstShapeOp::verifyInvariantsImpl() { + auto tblgen_shape = getProperties().shape; (void)tblgen_shape; + if (!tblgen_shape) return emitOpError("requires attribute 'shape'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ShapeOps1(*this, tblgen_shape, "shape"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ConstShapeOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +void ConstShapeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::mlir::LogicalResult +ConstShapeOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ConstShapeOp::Adaptor adaptor(operands, attributes, properties, regions); + return ConstShapeOp::inferReturnTypes(context, + location, adaptor, inferredReturnTypes); +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::ConstShapeOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::ConstSizeOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ConstSizeOpGenericAdaptorBase::ConstSizeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.const_size", odsAttrs.getContext()); +} + +ConstSizeOpGenericAdaptorBase::ConstSizeOpGenericAdaptorBase(ConstSizeOp op) : ConstSizeOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ConstSizeOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ConstSizeOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::IntegerAttr ConstSizeOpGenericAdaptorBase::getValueAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().value); + return attr; +} + +::llvm::APInt ConstSizeOpGenericAdaptorBase::getValue() { + auto attr = getValueAttr(); + return attr.getValue(); +} + +} // namespace detail +ConstSizeOpAdaptor::ConstSizeOpAdaptor(ConstSizeOp op) : ConstSizeOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ConstSizeOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_value = getProperties().value; (void)tblgen_value; + if (!tblgen_value) return emitError(loc, "'shape.const_size' op ""requires attribute 'value'"); + + if (tblgen_value && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_value))) && ((::llvm::isa<::mlir::IndexType>(::llvm::cast<::mlir::IntegerAttr>(tblgen_value).getType()))))) + return emitError(loc, "'shape.const_size' op ""attribute 'value' failed to satisfy constraint: index attribute"); + return ::mlir::success(); +} + +std::pair ConstSizeOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ConstSizeOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +std::pair ConstSizeOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ConstSizeOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::shape::SizeType> ConstSizeOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::shape::SizeType>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult ConstSizeOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.value; + auto attr = dict.get("value"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for value in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `value` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ConstSizeOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.value; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("value", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ConstSizeOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.value.getAsOpaquePointer())); +} + +std::optional ConstSizeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "value") + return prop.value; + return std::nullopt; +} + +void ConstSizeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "value") { + prop.value = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ConstSizeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.value) attrs.append("value", prop.value); +} + +::mlir::LogicalResult ConstSizeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getValueAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ShapeOps2(attr, "value", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ConstSizeOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.value))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ConstSizeOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.value); +} + +::mlir::IntegerAttr ConstSizeOp::getValueAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().value); +} + +::llvm::APInt ConstSizeOp::getValue() { + auto attr = getValueAttr(); + return attr.getValue(); +} + +void ConstSizeOp::setValueAttr(::mlir::IntegerAttr attr) { + (*this)->setAttr(getValueAttrName(), attr); +} + +void ConstSizeOp::setValue(::llvm::APInt attrValue) { + (*this)->setAttr(getValueAttrName(), ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIndexType(), attrValue)); +} + +void ConstSizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::IntegerAttr value) { + odsState.getOrAddProperties().value = value; + odsState.addTypes(result); +} + +void ConstSizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::IntegerAttr value) { + odsState.getOrAddProperties().value = value; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ConstSizeOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void ConstSizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::IntegerAttr value) { + odsState.getOrAddProperties().value = value; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ConstSizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::llvm::APInt value) { + odsState.getOrAddProperties().value = odsBuilder.getIntegerAttr(odsBuilder.getIndexType(), value); + odsState.addTypes(result); +} + +void ConstSizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llvm::APInt value) { + odsState.getOrAddProperties().value = odsBuilder.getIntegerAttr(odsBuilder.getIndexType(), value); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ConstSizeOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void ConstSizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::llvm::APInt value) { + odsState.getOrAddProperties().value = odsBuilder.getIntegerAttr(odsBuilder.getIndexType(), value); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ConstSizeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ConstSizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ConstSizeOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult ConstSizeOp::verifyInvariantsImpl() { + auto tblgen_value = getProperties().value; (void)tblgen_value; + if (!tblgen_value) return emitOpError("requires attribute 'value'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ShapeOps2(*this, tblgen_value, "value"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps4(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ConstSizeOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::LogicalResult ConstSizeOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = odsBuilder.getType<::mlir::shape::SizeType>(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult ConstSizeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::IntegerAttr valueAttr; + + if (parser.parseCustomAttributeWithFallback(valueAttr, parser.getBuilder().getIndexType())) { + return ::mlir::failure(); + } + if (valueAttr) result.getOrAddProperties().value = valueAttr; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::shape::SizeType>(); + result.addTypes(odsBuildableType0); + return ::mlir::success(); +} + +void ConstSizeOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter.printAttributeWithoutType(getValueAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("value"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); +} + +void ConstSizeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::ConstSizeOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::ConstWitnessOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ConstWitnessOpGenericAdaptorBase::ConstWitnessOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.const_witness", odsAttrs.getContext()); +} + +ConstWitnessOpGenericAdaptorBase::ConstWitnessOpGenericAdaptorBase(ConstWitnessOp op) : ConstWitnessOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ConstWitnessOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ConstWitnessOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::BoolAttr ConstWitnessOpGenericAdaptorBase::getPassingAttr() { + auto attr = ::llvm::cast<::mlir::BoolAttr>(getProperties().passing); + return attr; +} + +bool ConstWitnessOpGenericAdaptorBase::getPassing() { + auto attr = getPassingAttr(); + return attr.getValue(); +} + +} // namespace detail +ConstWitnessOpAdaptor::ConstWitnessOpAdaptor(ConstWitnessOp op) : ConstWitnessOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ConstWitnessOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_passing = getProperties().passing; (void)tblgen_passing; + if (!tblgen_passing) return emitError(loc, "'shape.const_witness' op ""requires attribute 'passing'"); + + if (tblgen_passing && !((::llvm::isa<::mlir::BoolAttr>(tblgen_passing)))) + return emitError(loc, "'shape.const_witness' op ""attribute 'passing' failed to satisfy constraint: bool attribute"); + return ::mlir::success(); +} + +std::pair ConstWitnessOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ConstWitnessOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +std::pair ConstWitnessOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ConstWitnessOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::shape::WitnessType> ConstWitnessOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::shape::WitnessType>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult ConstWitnessOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.passing; + auto attr = dict.get("passing"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for passing in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `passing` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ConstWitnessOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.passing; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("passing", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ConstWitnessOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.passing.getAsOpaquePointer())); +} + +std::optional ConstWitnessOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "passing") + return prop.passing; + return std::nullopt; +} + +void ConstWitnessOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "passing") { + prop.passing = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ConstWitnessOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.passing) attrs.append("passing", prop.passing); +} + +::mlir::LogicalResult ConstWitnessOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getPassingAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ShapeOps3(attr, "passing", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ConstWitnessOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.passing))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ConstWitnessOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.passing); +} + +::mlir::BoolAttr ConstWitnessOp::getPassingAttr() { + return ::llvm::cast<::mlir::BoolAttr>(getProperties().passing); +} + +bool ConstWitnessOp::getPassing() { + auto attr = getPassingAttr(); + return attr.getValue(); +} + +void ConstWitnessOp::setPassingAttr(::mlir::BoolAttr attr) { + (*this)->setAttr(getPassingAttrName(), attr); +} + +void ConstWitnessOp::setPassing(bool attrValue) { + (*this)->setAttr(getPassingAttrName(), ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue)); +} + +void ConstWitnessOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::BoolAttr passing) { + odsState.getOrAddProperties().passing = passing; + odsState.addTypes(result); +} + +void ConstWitnessOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::BoolAttr passing) { + odsState.getOrAddProperties().passing = passing; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ConstWitnessOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void ConstWitnessOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::BoolAttr passing) { + odsState.getOrAddProperties().passing = passing; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ConstWitnessOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, bool passing) { + odsState.getOrAddProperties().passing = odsBuilder.getBoolAttr(passing); + odsState.addTypes(result); +} + +void ConstWitnessOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, bool passing) { + odsState.getOrAddProperties().passing = odsBuilder.getBoolAttr(passing); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ConstWitnessOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void ConstWitnessOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, bool passing) { + odsState.getOrAddProperties().passing = odsBuilder.getBoolAttr(passing); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ConstWitnessOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ConstWitnessOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ConstWitnessOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult ConstWitnessOp::verifyInvariantsImpl() { + auto tblgen_passing = getProperties().passing; (void)tblgen_passing; + if (!tblgen_passing) return emitOpError("requires attribute 'passing'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ShapeOps3(*this, tblgen_passing, "passing"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ConstWitnessOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::LogicalResult ConstWitnessOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = odsBuilder.getType<::mlir::shape::WitnessType>(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult ConstWitnessOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::BoolAttr passingAttr; + + if (parser.parseCustomAttributeWithFallback(passingAttr, parser.getBuilder().getIntegerType(1))) { + return ::mlir::failure(); + } + if (passingAttr) result.getOrAddProperties().passing = passingAttr; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::shape::WitnessType>(); + result.addTypes(odsBuildableType0); + return ::mlir::success(); +} + +void ConstWitnessOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter.printAttributeWithoutType(getPassingAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("passing"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); +} + +void ConstWitnessOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::ConstWitnessOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::CstrBroadcastableOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CstrBroadcastableOpGenericAdaptorBase::CstrBroadcastableOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.cstr_broadcastable", odsAttrs.getContext()); +} + +CstrBroadcastableOpGenericAdaptorBase::CstrBroadcastableOpGenericAdaptorBase(CstrBroadcastableOp op) : CstrBroadcastableOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair CstrBroadcastableOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr CstrBroadcastableOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +CstrBroadcastableOpAdaptor::CstrBroadcastableOpAdaptor(CstrBroadcastableOp op) : CstrBroadcastableOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult CstrBroadcastableOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair CstrBroadcastableOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range CstrBroadcastableOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::operand_range CstrBroadcastableOp::getShapes() { + return getODSOperands(0); +} + +::mlir::MutableOperandRange CstrBroadcastableOp::getShapesMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair CstrBroadcastableOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range CstrBroadcastableOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::shape::WitnessType> CstrBroadcastableOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::shape::WitnessType>>(*getODSResults(0).begin()); +} + +void CstrBroadcastableOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { + build(odsBuilder, odsState, ::llvm::ArrayRef({lhs, rhs})); +} + +void CstrBroadcastableOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange shapes) { + odsState.addOperands(shapes); + odsState.addTypes(result); +} + +void CstrBroadcastableOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void CstrBroadcastableOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CstrBroadcastableOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult CstrBroadcastableOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult CstrBroadcastableOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::LogicalResult CstrBroadcastableOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = odsBuilder.getType<::mlir::shape::WitnessType>(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult CstrBroadcastableOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> shapesOperands; + ::llvm::SMLoc shapesOperandsLoc; + (void)shapesOperandsLoc; + ::llvm::SmallVector<::mlir::Type, 1> shapesTypes; + + shapesOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(shapesOperands)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + if (parser.parseTypeList(shapesTypes)) + return ::mlir::failure(); + ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::shape::WitnessType>(); + result.addTypes(odsBuildableType0); + if (parser.resolveOperands(shapesOperands, shapesTypes, shapesOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CstrBroadcastableOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getShapes(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter << getShapes().getTypes(); +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::CstrBroadcastableOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::CstrEqOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CstrEqOpGenericAdaptorBase::CstrEqOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.cstr_eq", odsAttrs.getContext()); +} + +CstrEqOpGenericAdaptorBase::CstrEqOpGenericAdaptorBase(CstrEqOp op) : CstrEqOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair CstrEqOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr CstrEqOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +CstrEqOpAdaptor::CstrEqOpAdaptor(CstrEqOp op) : CstrEqOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult CstrEqOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair CstrEqOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range CstrEqOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::operand_range CstrEqOp::getShapes() { + return getODSOperands(0); +} + +::mlir::MutableOperandRange CstrEqOp::getShapesMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair CstrEqOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range CstrEqOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::shape::WitnessType> CstrEqOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::shape::WitnessType>>(*getODSResults(0).begin()); +} + +void CstrEqOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange shapes) { + odsState.addOperands(shapes); + odsState.addTypes(result); +} + +void CstrEqOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void CstrEqOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CstrEqOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult CstrEqOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult CstrEqOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::LogicalResult CstrEqOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = odsBuilder.getType<::mlir::shape::WitnessType>(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult CstrEqOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> shapesOperands; + ::llvm::SMLoc shapesOperandsLoc; + (void)shapesOperandsLoc; + ::llvm::SmallVector<::mlir::Type, 1> shapesTypes; + + shapesOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(shapesOperands)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + if (parser.parseTypeList(shapesTypes)) + return ::mlir::failure(); + ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::shape::WitnessType>(); + result.addTypes(odsBuildableType0); + if (parser.resolveOperands(shapesOperands, shapesTypes, shapesOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CstrEqOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getShapes(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter << getShapes().getTypes(); +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::CstrEqOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::CstrRequireOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CstrRequireOpGenericAdaptorBase::CstrRequireOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.cstr_require", odsAttrs.getContext()); +} + +CstrRequireOpGenericAdaptorBase::CstrRequireOpGenericAdaptorBase(CstrRequireOp op) : CstrRequireOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair CstrRequireOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr CstrRequireOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::StringAttr CstrRequireOpGenericAdaptorBase::getMsgAttr() { + auto attr = ::llvm::cast<::mlir::StringAttr>(getProperties().msg); + return attr; +} + +::llvm::StringRef CstrRequireOpGenericAdaptorBase::getMsg() { + auto attr = getMsgAttr(); + return attr.getValue(); +} + +} // namespace detail +CstrRequireOpAdaptor::CstrRequireOpAdaptor(CstrRequireOp op) : CstrRequireOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult CstrRequireOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_msg = getProperties().msg; (void)tblgen_msg; + if (!tblgen_msg) return emitError(loc, "'shape.cstr_require' op ""requires attribute 'msg'"); + + if (tblgen_msg && !((::llvm::isa<::mlir::StringAttr>(tblgen_msg)))) + return emitError(loc, "'shape.cstr_require' op ""attribute 'msg' failed to satisfy constraint: string attribute"); + return ::mlir::success(); +} + +std::pair CstrRequireOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range CstrRequireOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::IntegerType> CstrRequireOp::getPred() { + return ::llvm::cast<::mlir::TypedValue<::mlir::IntegerType>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &CstrRequireOp::getPredMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair CstrRequireOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range CstrRequireOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::shape::WitnessType> CstrRequireOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::shape::WitnessType>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult CstrRequireOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.msg; + auto attr = dict.get("msg"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for msg in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `msg` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute CstrRequireOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.msg; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("msg", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code CstrRequireOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.msg.getAsOpaquePointer())); +} + +std::optional CstrRequireOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "msg") + return prop.msg; + return std::nullopt; +} + +void CstrRequireOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "msg") { + prop.msg = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void CstrRequireOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.msg) attrs.append("msg", prop.msg); +} + +::mlir::LogicalResult CstrRequireOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getMsgAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ShapeOps0(attr, "msg", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult CstrRequireOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.msg))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CstrRequireOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.msg); +} + +::mlir::StringAttr CstrRequireOp::getMsgAttr() { + return ::llvm::cast<::mlir::StringAttr>(getProperties().msg); +} + +::llvm::StringRef CstrRequireOp::getMsg() { + auto attr = getMsgAttr(); + return attr.getValue(); +} + +void CstrRequireOp::setMsgAttr(::mlir::StringAttr attr) { + (*this)->setAttr(getMsgAttrName(), attr); +} + +void CstrRequireOp::setMsg(::llvm::StringRef attrValue) { + (*this)->setAttr(getMsgAttrName(), ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue)); +} + +void CstrRequireOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value pred, ::mlir::StringAttr msg) { + odsState.addOperands(pred); + odsState.getOrAddProperties().msg = msg; + odsState.addTypes(result); +} + +void CstrRequireOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value pred, ::mlir::StringAttr msg) { + odsState.addOperands(pred); + odsState.getOrAddProperties().msg = msg; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CstrRequireOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void CstrRequireOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value pred, ::mlir::StringAttr msg) { + odsState.addOperands(pred); + odsState.getOrAddProperties().msg = msg; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void CstrRequireOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value pred, ::llvm::StringRef msg) { + odsState.addOperands(pred); + odsState.getOrAddProperties().msg = odsBuilder.getStringAttr(msg); + odsState.addTypes(result); +} + +void CstrRequireOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value pred, ::llvm::StringRef msg) { + odsState.addOperands(pred); + odsState.getOrAddProperties().msg = odsBuilder.getStringAttr(msg); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CstrRequireOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void CstrRequireOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value pred, ::llvm::StringRef msg) { + odsState.addOperands(pred); + odsState.getOrAddProperties().msg = odsBuilder.getStringAttr(msg); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void CstrRequireOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void CstrRequireOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CstrRequireOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult CstrRequireOp::verifyInvariantsImpl() { + auto tblgen_msg = getProperties().msg; (void)tblgen_msg; + if (!tblgen_msg) return emitOpError("requires attribute 'msg'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ShapeOps0(*this, tblgen_msg, "msg"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps5(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult CstrRequireOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::LogicalResult CstrRequireOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = odsBuilder.getType<::mlir::shape::WitnessType>(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult CstrRequireOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand predRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> predOperands(predRawOperands); ::llvm::SMLoc predOperandsLoc; + (void)predOperandsLoc; + ::mlir::StringAttr msgAttr; + + predOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(predRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(msgAttr, parser.getBuilder().getType<::mlir::NoneType>())) { + return ::mlir::failure(); + } + if (msgAttr) result.getOrAddProperties().msg = msgAttr; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::shape::WitnessType>(); + ::mlir::Type odsBuildableType1 = parser.getBuilder().getIntegerType(1); + result.addTypes(odsBuildableType0); + if (parser.resolveOperands(predOperands, odsBuildableType1, predOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CstrRequireOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getPred(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter.printAttributeWithoutType(getMsgAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("msg"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::CstrRequireOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::DebugPrintOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +DebugPrintOpGenericAdaptorBase::DebugPrintOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.debug_print", odsAttrs.getContext()); +} + +DebugPrintOpGenericAdaptorBase::DebugPrintOpGenericAdaptorBase(DebugPrintOp op) : DebugPrintOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair DebugPrintOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr DebugPrintOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +DebugPrintOpAdaptor::DebugPrintOpAdaptor(DebugPrintOp op) : DebugPrintOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult DebugPrintOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair DebugPrintOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range DebugPrintOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value DebugPrintOp::getInput() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &DebugPrintOp::getInputMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair DebugPrintOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range DebugPrintOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value DebugPrintOp::getOutput() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +void DebugPrintOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input) { + odsState.addOperands(input); + odsState.addTypes(output); +} + +void DebugPrintOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input) { + odsState.addOperands(input); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DebugPrintOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult DebugPrintOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps6(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult DebugPrintOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::DebugPrintOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::DimOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +DimOpGenericAdaptorBase::DimOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.dim", odsAttrs.getContext()); +} + +DimOpGenericAdaptorBase::DimOpGenericAdaptorBase(DimOp op) : DimOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair DimOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr DimOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +DimOpAdaptor::DimOpAdaptor(DimOp op) : DimOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult DimOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair DimOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range DimOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::ShapedType> DimOp::getValue() { + return ::llvm::cast<::mlir::TypedValue<::mlir::ShapedType>>(*getODSOperands(0).begin()); +} + +::mlir::Value DimOp::getIndex() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(1).begin()); +} + +::mlir::OpOperand &DimOp::getValueMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &DimOp::getIndexMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +std::pair DimOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range DimOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value DimOp::getExtent() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +void DimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type extent, ::mlir::Value value, ::mlir::Value index) { + odsState.addOperands(value); + odsState.addOperands(index); + odsState.addTypes(extent); +} + +void DimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value value, ::mlir::Value index) { + odsState.addOperands(value); + odsState.addOperands(index); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(DimOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void DimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value value, ::mlir::Value index) { + odsState.addOperands(value); + odsState.addOperands(index); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DimOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void DimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(DimOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult DimOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps7(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps0(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult DimOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult DimOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand valueRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> valueOperands(valueRawOperands); ::llvm::SMLoc valueOperandsLoc; + (void)valueOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand indexRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> indexOperands(indexRawOperands); ::llvm::SMLoc indexOperandsLoc; + (void)indexOperandsLoc; + ::mlir::Type valueRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> valueTypes(valueRawTypes); + ::mlir::Type indexRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> indexTypes(indexRawTypes); + ::mlir::Type extentRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> extentTypes(extentRawTypes); + + valueOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(valueRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + indexOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(indexRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::ShapedType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + valueRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + indexRawTypes[0] = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + extentRawTypes[0] = type; + } + result.addTypes(extentTypes); + if (parser.resolveOperands(valueOperands, valueTypes, valueOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(indexOperands, indexTypes, indexOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void DimOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getValue(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getIndex(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getValue().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::ShapedType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getIndex().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getExtent().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void DimOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::mlir::LogicalResult +DimOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + DimOp::Adaptor adaptor(operands, attributes, properties, regions); + return DimOp::inferReturnTypes(context, + location, adaptor, inferredReturnTypes); +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::DimOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::DivOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +DivOpGenericAdaptorBase::DivOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.div", odsAttrs.getContext()); +} + +DivOpGenericAdaptorBase::DivOpGenericAdaptorBase(DivOp op) : DivOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair DivOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr DivOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +DivOpAdaptor::DivOpAdaptor(DivOp op) : DivOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult DivOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair DivOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range DivOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value DivOp::getLhs() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin()); +} + +::mlir::Value DivOp::getRhs() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(1).begin()); +} + +::mlir::OpOperand &DivOp::getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &DivOp::getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +std::pair DivOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range DivOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value DivOp::getResult() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +void DivOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void DivOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(DivOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void DivOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DivOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void DivOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(DivOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult DivOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps0(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult DivOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult DivOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(lhsRawOperands); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(rhsRawOperands); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(lhsRawTypes); + ::mlir::Type rhsRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(rhsRawTypes); + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + lhsRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + rhsRawTypes[0] = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void DivOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getLhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getRhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void DivOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::mlir::LogicalResult +DivOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + DivOp::Adaptor adaptor(operands, attributes, properties, regions); + return DivOp::inferReturnTypes(context, + location, adaptor, inferredReturnTypes); +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::DivOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::FromExtentTensorOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +FromExtentTensorOpGenericAdaptorBase::FromExtentTensorOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.from_extent_tensor", odsAttrs.getContext()); +} + +FromExtentTensorOpGenericAdaptorBase::FromExtentTensorOpGenericAdaptorBase(FromExtentTensorOp op) : FromExtentTensorOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair FromExtentTensorOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr FromExtentTensorOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +FromExtentTensorOpAdaptor::FromExtentTensorOpAdaptor(FromExtentTensorOp op) : FromExtentTensorOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult FromExtentTensorOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair FromExtentTensorOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range FromExtentTensorOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::RankedTensorType> FromExtentTensorOp::getInput() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &FromExtentTensorOp::getInputMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair FromExtentTensorOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range FromExtentTensorOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::shape::ShapeType> FromExtentTensorOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::shape::ShapeType>>(*getODSResults(0).begin()); +} + +void FromExtentTensorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value input) { + odsState.addOperands(input); + odsState.addTypes(result); +} + +void FromExtentTensorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value input) { + odsState.addOperands(input); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(FromExtentTensorOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void FromExtentTensorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input) { + odsState.addOperands(input); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void FromExtentTensorOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void FromExtentTensorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(FromExtentTensorOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult FromExtentTensorOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps9(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult FromExtentTensorOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::LogicalResult FromExtentTensorOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = odsBuilder.getType<::mlir::shape::ShapeType>(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult FromExtentTensorOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand inputRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> inputOperands(inputRawOperands); ::llvm::SMLoc inputOperandsLoc; + (void)inputOperandsLoc; + ::mlir::Type inputRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> inputTypes(inputRawTypes); + + inputOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(inputRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::RankedTensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + inputRawTypes[0] = type; + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::shape::ShapeType>(); + result.addTypes(odsBuildableType0); + if (parser.resolveOperands(inputOperands, inputTypes, inputOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void FromExtentTensorOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getInput(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getInput().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::RankedTensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void FromExtentTensorOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::FromExtentTensorOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::FromExtentsOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +FromExtentsOpGenericAdaptorBase::FromExtentsOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.from_extents", odsAttrs.getContext()); +} + +FromExtentsOpGenericAdaptorBase::FromExtentsOpGenericAdaptorBase(FromExtentsOp op) : FromExtentsOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair FromExtentsOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr FromExtentsOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +FromExtentsOpAdaptor::FromExtentsOpAdaptor(FromExtentsOp op) : FromExtentsOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult FromExtentsOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair FromExtentsOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range FromExtentsOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::operand_range FromExtentsOp::getExtents() { + return getODSOperands(0); +} + +::mlir::MutableOperandRange FromExtentsOp::getExtentsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair FromExtentsOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range FromExtentsOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::shape::ShapeType> FromExtentsOp::getShape() { + return ::llvm::cast<::mlir::TypedValue<::mlir::shape::ShapeType>>(*getODSResults(0).begin()); +} + +void FromExtentsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type shape, ::mlir::ValueRange extents) { + odsState.addOperands(extents); + odsState.addTypes(shape); +} + +void FromExtentsOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void FromExtentsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(FromExtentsOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult FromExtentsOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps9(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult FromExtentsOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::LogicalResult FromExtentsOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = odsBuilder.getType<::mlir::shape::ShapeType>(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult FromExtentsOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> extentsOperands; + ::llvm::SMLoc extentsOperandsLoc; + (void)extentsOperandsLoc; + ::llvm::SmallVector<::mlir::Type, 1> extentsTypes; + + extentsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(extentsOperands)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + if (parser.parseTypeList(extentsTypes)) + return ::mlir::failure(); + ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::shape::ShapeType>(); + result.addTypes(odsBuildableType0); + if (parser.resolveOperands(extentsOperands, extentsTypes, extentsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void FromExtentsOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getExtents(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter << getExtents().getTypes(); +} + +void FromExtentsOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::FromExtentsOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::FuncOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +FuncOpGenericAdaptorBase::FuncOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.func", odsAttrs.getContext()); +} + +FuncOpGenericAdaptorBase::FuncOpGenericAdaptorBase(FuncOp op) : FuncOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair FuncOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr FuncOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::StringAttr FuncOpGenericAdaptorBase::getSymNameAttr() { + auto attr = ::llvm::cast<::mlir::StringAttr>(getProperties().sym_name); + return attr; +} + +::llvm::StringRef FuncOpGenericAdaptorBase::getSymName() { + auto attr = getSymNameAttr(); + return attr.getValue(); +} + +::mlir::TypeAttr FuncOpGenericAdaptorBase::getFunctionTypeAttr() { + auto attr = ::llvm::cast<::mlir::TypeAttr>(getProperties().function_type); + return attr; +} + +::mlir::FunctionType FuncOpGenericAdaptorBase::getFunctionType() { + auto attr = getFunctionTypeAttr(); + return ::llvm::cast<::mlir::FunctionType>(attr.getValue()); +} + +::mlir::ArrayAttr FuncOpGenericAdaptorBase::getArgAttrsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().arg_attrs); + return attr; +} + +::std::optional< ::mlir::ArrayAttr > FuncOpGenericAdaptorBase::getArgAttrs() { + auto attr = getArgAttrsAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +::mlir::ArrayAttr FuncOpGenericAdaptorBase::getResAttrsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().res_attrs); + return attr; +} + +::std::optional< ::mlir::ArrayAttr > FuncOpGenericAdaptorBase::getResAttrs() { + auto attr = getResAttrsAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +::mlir::StringAttr FuncOpGenericAdaptorBase::getSymVisibilityAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::StringAttr>(getProperties().sym_visibility); + return attr; +} + +::std::optional< ::llvm::StringRef > FuncOpGenericAdaptorBase::getSymVisibility() { + auto attr = getSymVisibilityAttr(); + return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); +} + +::mlir::Region &FuncOpGenericAdaptorBase::getBody() { + return *odsRegions[0]; +} + +::mlir::RegionRange FuncOpGenericAdaptorBase::getRegions() { + return odsRegions; +} + +} // namespace detail +FuncOpAdaptor::FuncOpAdaptor(FuncOp op) : FuncOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult FuncOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_arg_attrs = getProperties().arg_attrs; (void)tblgen_arg_attrs; + auto tblgen_function_type = getProperties().function_type; (void)tblgen_function_type; + if (!tblgen_function_type) return emitError(loc, "'shape.func' op ""requires attribute 'function_type'"); + auto tblgen_res_attrs = getProperties().res_attrs; (void)tblgen_res_attrs; + auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name; + if (!tblgen_sym_name) return emitError(loc, "'shape.func' op ""requires attribute 'sym_name'"); + auto tblgen_sym_visibility = getProperties().sym_visibility; (void)tblgen_sym_visibility; + + if (tblgen_sym_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_sym_name)))) + return emitError(loc, "'shape.func' op ""attribute 'sym_name' failed to satisfy constraint: string attribute"); + + if (tblgen_function_type && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_function_type))) && ((::llvm::isa<::mlir::FunctionType>(::llvm::cast<::mlir::TypeAttr>(tblgen_function_type).getValue()))) && ((::llvm::isa<::mlir::FunctionType>(::llvm::cast<::mlir::TypeAttr>(tblgen_function_type).getValue()))))) + return emitError(loc, "'shape.func' op ""attribute 'function_type' failed to satisfy constraint: type attribute of function type"); + + if (tblgen_arg_attrs && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_arg_attrs))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_arg_attrs), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::DictionaryAttr>(attr))); })))) + return emitError(loc, "'shape.func' op ""attribute 'arg_attrs' failed to satisfy constraint: Array of dictionary attributes"); + + if (tblgen_res_attrs && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_res_attrs))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_res_attrs), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::DictionaryAttr>(attr))); })))) + return emitError(loc, "'shape.func' op ""attribute 'res_attrs' failed to satisfy constraint: Array of dictionary attributes"); + + if (tblgen_sym_visibility && !((::llvm::isa<::mlir::StringAttr>(tblgen_sym_visibility)))) + return emitError(loc, "'shape.func' op ""attribute 'sym_visibility' failed to satisfy constraint: string attribute"); + return ::mlir::success(); +} + +std::pair FuncOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range FuncOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +std::pair FuncOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range FuncOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Region &FuncOp::getBody() { + return (*this)->getRegion(0); +} + +::mlir::LogicalResult FuncOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.arg_attrs; + auto attr = dict.get("arg_attrs"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for arg_attrs in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `arg_attrs` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.function_type; + auto attr = dict.get("function_type"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for function_type in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `function_type` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.res_attrs; + auto attr = dict.get("res_attrs"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for res_attrs in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `res_attrs` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.sym_name; + auto attr = dict.get("sym_name"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for sym_name in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `sym_name` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.sym_visibility; + auto attr = dict.get("sym_visibility"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for sym_visibility in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `sym_visibility` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute FuncOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.arg_attrs; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("arg_attrs", + propStorage)); + } + + { + const auto &propStorage = prop.function_type; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("function_type", + propStorage)); + } + + { + const auto &propStorage = prop.res_attrs; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("res_attrs", + propStorage)); + } + + { + const auto &propStorage = prop.sym_name; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("sym_name", + propStorage)); + } + + { + const auto &propStorage = prop.sym_visibility; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("sym_visibility", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code FuncOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.arg_attrs.getAsOpaquePointer()), + llvm::hash_value(prop.function_type.getAsOpaquePointer()), + llvm::hash_value(prop.res_attrs.getAsOpaquePointer()), + llvm::hash_value(prop.sym_name.getAsOpaquePointer()), + llvm::hash_value(prop.sym_visibility.getAsOpaquePointer())); +} + +std::optional FuncOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "arg_attrs") + return prop.arg_attrs; + + if (name == "function_type") + return prop.function_type; + + if (name == "res_attrs") + return prop.res_attrs; + + if (name == "sym_name") + return prop.sym_name; + + if (name == "sym_visibility") + return prop.sym_visibility; + return std::nullopt; +} + +void FuncOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "arg_attrs") { + prop.arg_attrs = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "function_type") { + prop.function_type = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "res_attrs") { + prop.res_attrs = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "sym_name") { + prop.sym_name = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "sym_visibility") { + prop.sym_visibility = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void FuncOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.arg_attrs) attrs.append("arg_attrs", prop.arg_attrs); + + if (prop.function_type) attrs.append("function_type", prop.function_type); + + if (prop.res_attrs) attrs.append("res_attrs", prop.res_attrs); + + if (prop.sym_name) attrs.append("sym_name", prop.sym_name); + + if (prop.sym_visibility) attrs.append("sym_visibility", prop.sym_visibility); +} + +::mlir::LogicalResult FuncOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getArgAttrsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ShapeOps5(attr, "arg_attrs", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getFunctionTypeAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ShapeOps4(attr, "function_type", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getResAttrsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ShapeOps5(attr, "res_attrs", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getSymNameAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ShapeOps0(attr, "sym_name", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getSymVisibilityAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ShapeOps0(attr, "sym_visibility", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult FuncOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.arg_attrs))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.function_type))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.res_attrs))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.sym_name))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.sym_visibility))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void FuncOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.arg_attrs); + writer.writeAttribute(prop.function_type); + + writer.writeOptionalAttribute(prop.res_attrs); + writer.writeAttribute(prop.sym_name); + + writer.writeOptionalAttribute(prop.sym_visibility); +} + +::mlir::StringAttr FuncOp::getSymNameAttr() { + return ::llvm::cast<::mlir::StringAttr>(getProperties().sym_name); +} + +::llvm::StringRef FuncOp::getSymName() { + auto attr = getSymNameAttr(); + return attr.getValue(); +} + +::mlir::TypeAttr FuncOp::getFunctionTypeAttr() { + return ::llvm::cast<::mlir::TypeAttr>(getProperties().function_type); +} + +::mlir::FunctionType FuncOp::getFunctionType() { + auto attr = getFunctionTypeAttr(); + return ::llvm::cast<::mlir::FunctionType>(attr.getValue()); +} + +::mlir::ArrayAttr FuncOp::getArgAttrsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().arg_attrs); +} + +::std::optional< ::mlir::ArrayAttr > FuncOp::getArgAttrs() { + auto attr = getArgAttrsAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +::mlir::ArrayAttr FuncOp::getResAttrsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().res_attrs); +} + +::std::optional< ::mlir::ArrayAttr > FuncOp::getResAttrs() { + auto attr = getResAttrsAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +::mlir::StringAttr FuncOp::getSymVisibilityAttr() { + return ::llvm::dyn_cast_or_null<::mlir::StringAttr>(getProperties().sym_visibility); +} + +::std::optional< ::llvm::StringRef > FuncOp::getSymVisibility() { + auto attr = getSymVisibilityAttr(); + return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); +} + +void FuncOp::setSymNameAttr(::mlir::StringAttr attr) { + (*this)->setAttr(getSymNameAttrName(), attr); +} + +void FuncOp::setSymName(::llvm::StringRef attrValue) { + (*this)->setAttr(getSymNameAttrName(), ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue)); +} + +void FuncOp::setFunctionTypeAttr(::mlir::TypeAttr attr) { + (*this)->setAttr(getFunctionTypeAttrName(), attr); +} + +void FuncOp::setFunctionType(::mlir::FunctionType attrValue) { + (*this)->setAttr(getFunctionTypeAttrName(), ::mlir::TypeAttr::get(attrValue)); +} + +void FuncOp::setArgAttrsAttr(::mlir::ArrayAttr attr) { + (*this)->setAttr(getArgAttrsAttrName(), attr); +} + +void FuncOp::setResAttrsAttr(::mlir::ArrayAttr attr) { + (*this)->setAttr(getResAttrsAttrName(), attr); +} + +void FuncOp::setSymVisibilityAttr(::mlir::StringAttr attr) { + (*this)->setAttr(getSymVisibilityAttrName(), attr); +} + +void FuncOp::setSymVisibility(::std::optional<::llvm::StringRef> attrValue) { + if (attrValue) + return (*this)->setAttr(getSymVisibilityAttrName(), ::mlir::Builder((*this)->getContext()).getStringAttr(*attrValue)); + (*this)->removeAttr(getSymVisibilityAttrName()); +} + +::mlir::Attribute FuncOp::removeArgAttrsAttr() { + auto &attr = getProperties().arg_attrs; + attr = {}; + return attr; +} + +::mlir::Attribute FuncOp::removeResAttrsAttr() { + auto &attr = getProperties().res_attrs; + attr = {}; + return attr; +} + +::mlir::Attribute FuncOp::removeSymVisibilityAttr() { + auto &attr = getProperties().sym_visibility; + attr = {}; + return attr; +} + +void FuncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::StringAttr sym_name, ::mlir::TypeAttr function_type, /*optional*/::mlir::ArrayAttr arg_attrs, /*optional*/::mlir::ArrayAttr res_attrs, /*optional*/::mlir::StringAttr sym_visibility) { + odsState.getOrAddProperties().sym_name = sym_name; + odsState.getOrAddProperties().function_type = function_type; + if (arg_attrs) { + odsState.getOrAddProperties().arg_attrs = arg_attrs; + } + if (res_attrs) { + odsState.getOrAddProperties().res_attrs = res_attrs; + } + if (sym_visibility) { + odsState.getOrAddProperties().sym_visibility = sym_visibility; + } + (void)odsState.addRegion(); +} + +void FuncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, ::mlir::TypeAttr function_type, /*optional*/::mlir::ArrayAttr arg_attrs, /*optional*/::mlir::ArrayAttr res_attrs, /*optional*/::mlir::StringAttr sym_visibility) { + odsState.getOrAddProperties().sym_name = sym_name; + odsState.getOrAddProperties().function_type = function_type; + if (arg_attrs) { + odsState.getOrAddProperties().arg_attrs = arg_attrs; + } + if (res_attrs) { + odsState.getOrAddProperties().res_attrs = res_attrs; + } + if (sym_visibility) { + odsState.getOrAddProperties().sym_visibility = sym_visibility; + } + (void)odsState.addRegion(); + assert(resultTypes.size() == 0u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void FuncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llvm::StringRef sym_name, ::mlir::FunctionType function_type, /*optional*/::mlir::ArrayAttr arg_attrs, /*optional*/::mlir::ArrayAttr res_attrs, /*optional*/::mlir::StringAttr sym_visibility) { + odsState.getOrAddProperties().sym_name = odsBuilder.getStringAttr(sym_name); + odsState.getOrAddProperties().function_type = ::mlir::TypeAttr::get(function_type); + if (arg_attrs) { + odsState.getOrAddProperties().arg_attrs = arg_attrs; + } + if (res_attrs) { + odsState.getOrAddProperties().res_attrs = res_attrs; + } + if (sym_visibility) { + odsState.getOrAddProperties().sym_visibility = sym_visibility; + } + (void)odsState.addRegion(); +} + +void FuncOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, ::mlir::FunctionType function_type, /*optional*/::mlir::ArrayAttr arg_attrs, /*optional*/::mlir::ArrayAttr res_attrs, /*optional*/::mlir::StringAttr sym_visibility) { + odsState.getOrAddProperties().sym_name = odsBuilder.getStringAttr(sym_name); + odsState.getOrAddProperties().function_type = ::mlir::TypeAttr::get(function_type); + if (arg_attrs) { + odsState.getOrAddProperties().arg_attrs = arg_attrs; + } + if (res_attrs) { + odsState.getOrAddProperties().res_attrs = res_attrs; + } + if (sym_visibility) { + odsState.getOrAddProperties().sym_visibility = sym_visibility; + } + (void)odsState.addRegion(); + assert(resultTypes.size() == 0u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void FuncOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult FuncOp::verifyInvariantsImpl() { + auto tblgen_arg_attrs = getProperties().arg_attrs; (void)tblgen_arg_attrs; + auto tblgen_function_type = getProperties().function_type; (void)tblgen_function_type; + if (!tblgen_function_type) return emitOpError("requires attribute 'function_type'"); + auto tblgen_res_attrs = getProperties().res_attrs; (void)tblgen_res_attrs; + auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name; + if (!tblgen_sym_name) return emitOpError("requires attribute 'sym_name'"); + auto tblgen_sym_visibility = getProperties().sym_visibility; (void)tblgen_sym_visibility; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ShapeOps0(*this, tblgen_sym_name, "sym_name"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ShapeOps4(*this, tblgen_function_type, "function_type"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ShapeOps5(*this, tblgen_arg_attrs, "arg_attrs"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ShapeOps5(*this, tblgen_res_attrs, "res_attrs"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ShapeOps0(*this, tblgen_sym_visibility, "sym_visibility"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_ShapeOps1(*this, region, "body", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult FuncOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::FuncOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::FunctionLibraryOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +FunctionLibraryOpGenericAdaptorBase::FunctionLibraryOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.function_library", odsAttrs.getContext()); +} + +FunctionLibraryOpGenericAdaptorBase::FunctionLibraryOpGenericAdaptorBase(FunctionLibraryOp op) : FunctionLibraryOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair FunctionLibraryOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr FunctionLibraryOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::StringAttr FunctionLibraryOpGenericAdaptorBase::getSymNameAttr() { + auto attr = ::llvm::cast<::mlir::StringAttr>(getProperties().sym_name); + return attr; +} + +::llvm::StringRef FunctionLibraryOpGenericAdaptorBase::getSymName() { + auto attr = getSymNameAttr(); + return attr.getValue(); +} + +::mlir::StringAttr FunctionLibraryOpGenericAdaptorBase::getSymVisibilityAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::StringAttr>(getProperties().sym_visibility); + return attr; +} + +::std::optional< ::llvm::StringRef > FunctionLibraryOpGenericAdaptorBase::getSymVisibility() { + auto attr = getSymVisibilityAttr(); + return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); +} + +::mlir::DictionaryAttr FunctionLibraryOpGenericAdaptorBase::getMappingAttr() { + auto attr = ::llvm::cast<::mlir::DictionaryAttr>(getProperties().mapping); + return attr; +} + +::mlir::DictionaryAttr FunctionLibraryOpGenericAdaptorBase::getMapping() { + auto attr = getMappingAttr(); + return attr; +} + +::mlir::Region &FunctionLibraryOpGenericAdaptorBase::getBody() { + return *odsRegions[0]; +} + +::mlir::RegionRange FunctionLibraryOpGenericAdaptorBase::getRegions() { + return odsRegions; +} + +} // namespace detail +FunctionLibraryOpAdaptor::FunctionLibraryOpAdaptor(FunctionLibraryOp op) : FunctionLibraryOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult FunctionLibraryOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_mapping = getProperties().mapping; (void)tblgen_mapping; + if (!tblgen_mapping) return emitError(loc, "'shape.function_library' op ""requires attribute 'mapping'"); + auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name; + if (!tblgen_sym_name) return emitError(loc, "'shape.function_library' op ""requires attribute 'sym_name'"); + auto tblgen_sym_visibility = getProperties().sym_visibility; (void)tblgen_sym_visibility; + + if (tblgen_sym_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_sym_name)))) + return emitError(loc, "'shape.function_library' op ""attribute 'sym_name' failed to satisfy constraint: string attribute"); + + if (tblgen_sym_visibility && !((::llvm::isa<::mlir::StringAttr>(tblgen_sym_visibility)))) + return emitError(loc, "'shape.function_library' op ""attribute 'sym_visibility' failed to satisfy constraint: string attribute"); + + if (tblgen_mapping && !((::llvm::isa<::mlir::DictionaryAttr>(tblgen_mapping)))) + return emitError(loc, "'shape.function_library' op ""attribute 'mapping' failed to satisfy constraint: dictionary of named attribute values"); + return ::mlir::success(); +} + +std::pair FunctionLibraryOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range FunctionLibraryOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +std::pair FunctionLibraryOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range FunctionLibraryOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Region &FunctionLibraryOp::getBody() { + return (*this)->getRegion(0); +} + +::mlir::LogicalResult FunctionLibraryOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.mapping; + auto attr = dict.get("mapping"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for mapping in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `mapping` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.sym_name; + auto attr = dict.get("sym_name"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for sym_name in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `sym_name` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.sym_visibility; + auto attr = dict.get("sym_visibility"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for sym_visibility in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `sym_visibility` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute FunctionLibraryOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.mapping; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("mapping", + propStorage)); + } + + { + const auto &propStorage = prop.sym_name; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("sym_name", + propStorage)); + } + + { + const auto &propStorage = prop.sym_visibility; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("sym_visibility", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code FunctionLibraryOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.mapping.getAsOpaquePointer()), + llvm::hash_value(prop.sym_name.getAsOpaquePointer()), + llvm::hash_value(prop.sym_visibility.getAsOpaquePointer())); +} + +std::optional FunctionLibraryOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "mapping") + return prop.mapping; + + if (name == "sym_name") + return prop.sym_name; + + if (name == "sym_visibility") + return prop.sym_visibility; + return std::nullopt; +} + +void FunctionLibraryOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "mapping") { + prop.mapping = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "sym_name") { + prop.sym_name = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "sym_visibility") { + prop.sym_visibility = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void FunctionLibraryOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.mapping) attrs.append("mapping", prop.mapping); + + if (prop.sym_name) attrs.append("sym_name", prop.sym_name); + + if (prop.sym_visibility) attrs.append("sym_visibility", prop.sym_visibility); +} + +::mlir::LogicalResult FunctionLibraryOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getMappingAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ShapeOps6(attr, "mapping", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getSymNameAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ShapeOps0(attr, "sym_name", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getSymVisibilityAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ShapeOps0(attr, "sym_visibility", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult FunctionLibraryOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.mapping))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.sym_name))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.sym_visibility))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void FunctionLibraryOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.mapping); + writer.writeAttribute(prop.sym_name); + + writer.writeOptionalAttribute(prop.sym_visibility); +} + +::mlir::StringAttr FunctionLibraryOp::getSymNameAttr() { + return ::llvm::cast<::mlir::StringAttr>(getProperties().sym_name); +} + +::llvm::StringRef FunctionLibraryOp::getSymName() { + auto attr = getSymNameAttr(); + return attr.getValue(); +} + +::mlir::StringAttr FunctionLibraryOp::getSymVisibilityAttr() { + return ::llvm::dyn_cast_or_null<::mlir::StringAttr>(getProperties().sym_visibility); +} + +::std::optional< ::llvm::StringRef > FunctionLibraryOp::getSymVisibility() { + auto attr = getSymVisibilityAttr(); + return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); +} + +::mlir::DictionaryAttr FunctionLibraryOp::getMappingAttr() { + return ::llvm::cast<::mlir::DictionaryAttr>(getProperties().mapping); +} + +::mlir::DictionaryAttr FunctionLibraryOp::getMapping() { + auto attr = getMappingAttr(); + return attr; +} + +void FunctionLibraryOp::setSymNameAttr(::mlir::StringAttr attr) { + (*this)->setAttr(getSymNameAttrName(), attr); +} + +void FunctionLibraryOp::setSymName(::llvm::StringRef attrValue) { + (*this)->setAttr(getSymNameAttrName(), ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue)); +} + +void FunctionLibraryOp::setSymVisibilityAttr(::mlir::StringAttr attr) { + (*this)->setAttr(getSymVisibilityAttrName(), attr); +} + +void FunctionLibraryOp::setSymVisibility(::std::optional<::llvm::StringRef> attrValue) { + if (attrValue) + return (*this)->setAttr(getSymVisibilityAttrName(), ::mlir::Builder((*this)->getContext()).getStringAttr(*attrValue)); + (*this)->removeAttr(getSymVisibilityAttrName()); +} + +void FunctionLibraryOp::setMappingAttr(::mlir::DictionaryAttr attr) { + (*this)->setAttr(getMappingAttrName(), attr); +} + +::mlir::Attribute FunctionLibraryOp::removeSymVisibilityAttr() { + auto &attr = getProperties().sym_visibility; + attr = {}; + return attr; +} + +::mlir::LogicalResult FunctionLibraryOp::verifyInvariantsImpl() { + auto tblgen_mapping = getProperties().mapping; (void)tblgen_mapping; + if (!tblgen_mapping) return emitOpError("requires attribute 'mapping'"); + auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name; + if (!tblgen_sym_name) return emitOpError("requires attribute 'sym_name'"); + auto tblgen_sym_visibility = getProperties().sym_visibility; (void)tblgen_sym_visibility; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ShapeOps0(*this, tblgen_sym_name, "sym_name"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ShapeOps0(*this, tblgen_sym_visibility, "sym_visibility"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ShapeOps6(*this, tblgen_mapping, "mapping"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_ShapeOps1(*this, region, "body", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult FunctionLibraryOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::FunctionLibraryOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::GetExtentOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +GetExtentOpGenericAdaptorBase::GetExtentOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.get_extent", odsAttrs.getContext()); +} + +GetExtentOpGenericAdaptorBase::GetExtentOpGenericAdaptorBase(GetExtentOp op) : GetExtentOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair GetExtentOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr GetExtentOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +GetExtentOpAdaptor::GetExtentOpAdaptor(GetExtentOp op) : GetExtentOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult GetExtentOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair GetExtentOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range GetExtentOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value GetExtentOp::getShape() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin()); +} + +::mlir::Value GetExtentOp::getDim() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(1).begin()); +} + +::mlir::OpOperand &GetExtentOp::getShapeMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &GetExtentOp::getDimMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +std::pair GetExtentOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range GetExtentOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value GetExtentOp::getExtent() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +void GetExtentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type extent, ::mlir::Value shape, ::mlir::Value dim) { + odsState.addOperands(shape); + odsState.addOperands(dim); + odsState.addTypes(extent); +} + +void GetExtentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value shape, ::mlir::Value dim) { + odsState.addOperands(shape); + odsState.addOperands(dim); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(GetExtentOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void GetExtentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value shape, ::mlir::Value dim) { + odsState.addOperands(shape); + odsState.addOperands(dim); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void GetExtentOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void GetExtentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(GetExtentOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult GetExtentOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps0(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult GetExtentOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult GetExtentOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand shapeRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> shapeOperands(shapeRawOperands); ::llvm::SMLoc shapeOperandsLoc; + (void)shapeOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand dimRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> dimOperands(dimRawOperands); ::llvm::SMLoc dimOperandsLoc; + (void)dimOperandsLoc; + ::mlir::Type shapeRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> shapeTypes(shapeRawTypes); + ::mlir::Type dimRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> dimTypes(dimRawTypes); + ::mlir::Type extentRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> extentTypes(extentRawTypes); + + shapeOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(shapeRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + dimOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(dimRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + shapeRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + dimRawTypes[0] = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + extentRawTypes[0] = type; + } + result.addTypes(extentTypes); + if (parser.resolveOperands(shapeOperands, shapeTypes, shapeOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(dimOperands, dimTypes, dimOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void GetExtentOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getShape(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getDim(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getShape().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getDim().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getExtent().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void GetExtentOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::mlir::LogicalResult +GetExtentOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + GetExtentOp::Adaptor adaptor(operands, attributes, properties, regions); + return GetExtentOp::inferReturnTypes(context, + location, adaptor, inferredReturnTypes); +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::GetExtentOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::IndexToSizeOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +IndexToSizeOpGenericAdaptorBase::IndexToSizeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.index_to_size", odsAttrs.getContext()); +} + +IndexToSizeOpGenericAdaptorBase::IndexToSizeOpGenericAdaptorBase(IndexToSizeOp op) : IndexToSizeOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair IndexToSizeOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr IndexToSizeOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +IndexToSizeOpAdaptor::IndexToSizeOpAdaptor(IndexToSizeOp op) : IndexToSizeOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult IndexToSizeOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair IndexToSizeOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range IndexToSizeOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::IndexType> IndexToSizeOp::getArg() { + return ::llvm::cast<::mlir::TypedValue<::mlir::IndexType>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &IndexToSizeOp::getArgMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair IndexToSizeOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range IndexToSizeOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::shape::SizeType> IndexToSizeOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::shape::SizeType>>(*getODSResults(0).begin()); +} + +void IndexToSizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value arg) { + odsState.addOperands(arg); + odsState.addTypes(result); +} + +void IndexToSizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value arg) { + odsState.addOperands(arg); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(IndexToSizeOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void IndexToSizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value arg) { + odsState.addOperands(arg); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void IndexToSizeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void IndexToSizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(IndexToSizeOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult IndexToSizeOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps10(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps4(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult IndexToSizeOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::LogicalResult IndexToSizeOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = odsBuilder.getType<::mlir::shape::SizeType>(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult IndexToSizeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand argRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> argOperands(argRawOperands); ::llvm::SMLoc argOperandsLoc; + (void)argOperandsLoc; + + argOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(argRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::shape::SizeType>(); + ::mlir::Type odsBuildableType1 = parser.getBuilder().getIndexType(); + result.addTypes(odsBuildableType0); + if (parser.resolveOperands(argOperands, odsBuildableType1, argOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void IndexToSizeOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getArg(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); +} + +void IndexToSizeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::IndexToSizeOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::IsBroadcastableOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +IsBroadcastableOpGenericAdaptorBase::IsBroadcastableOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.is_broadcastable", odsAttrs.getContext()); +} + +IsBroadcastableOpGenericAdaptorBase::IsBroadcastableOpGenericAdaptorBase(IsBroadcastableOp op) : IsBroadcastableOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair IsBroadcastableOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr IsBroadcastableOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +IsBroadcastableOpAdaptor::IsBroadcastableOpAdaptor(IsBroadcastableOp op) : IsBroadcastableOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult IsBroadcastableOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair IsBroadcastableOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range IsBroadcastableOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::operand_range IsBroadcastableOp::getShapes() { + return getODSOperands(0); +} + +::mlir::MutableOperandRange IsBroadcastableOp::getShapesMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair IsBroadcastableOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range IsBroadcastableOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::IntegerType> IsBroadcastableOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::IntegerType>>(*getODSResults(0).begin()); +} + +void IsBroadcastableOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { + build(odsBuilder, odsState, ::llvm::ArrayRef({lhs, rhs})); +} + +void IsBroadcastableOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange shapes) { + odsState.addOperands(shapes); + odsState.addTypes(result); +} + +void IsBroadcastableOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void IsBroadcastableOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(IsBroadcastableOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult IsBroadcastableOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps5(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult IsBroadcastableOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::LogicalResult IsBroadcastableOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(1); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult IsBroadcastableOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> shapesOperands; + ::llvm::SMLoc shapesOperandsLoc; + (void)shapesOperandsLoc; + ::llvm::SmallVector<::mlir::Type, 1> shapesTypes; + + shapesOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(shapesOperands)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + if (parser.parseTypeList(shapesTypes)) + return ::mlir::failure(); + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(1); + result.addTypes(odsBuildableType0); + if (parser.resolveOperands(shapesOperands, shapesTypes, shapesOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void IsBroadcastableOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getShapes(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter << getShapes().getTypes(); +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::IsBroadcastableOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::MaxOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +MaxOpGenericAdaptorBase::MaxOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.max", odsAttrs.getContext()); +} + +MaxOpGenericAdaptorBase::MaxOpGenericAdaptorBase(MaxOp op) : MaxOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair MaxOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr MaxOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +MaxOpAdaptor::MaxOpAdaptor(MaxOp op) : MaxOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult MaxOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair MaxOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range MaxOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value MaxOp::getLhs() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin()); +} + +::mlir::Value MaxOp::getRhs() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(1).begin()); +} + +::mlir::OpOperand &MaxOp::getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MaxOp::getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +std::pair MaxOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range MaxOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value MaxOp::getResult() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +void MaxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void MaxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MaxOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void MaxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void MaxOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void MaxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MaxOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult MaxOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps6(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult MaxOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult MaxOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(lhsRawOperands); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(rhsRawOperands); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(lhsRawTypes); + ::mlir::Type rhsRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(rhsRawTypes); + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + lhsRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + rhsRawTypes[0] = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void MaxOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getLhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getRhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void MaxOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::mlir::LogicalResult +MaxOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + MaxOp::Adaptor adaptor(operands, attributes, properties, regions); + return MaxOp::inferReturnTypes(context, + location, adaptor, inferredReturnTypes); +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::MaxOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::MeetOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +MeetOpGenericAdaptorBase::MeetOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.meet", odsAttrs.getContext()); +} + +MeetOpGenericAdaptorBase::MeetOpGenericAdaptorBase(MeetOp op) : MeetOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair MeetOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr MeetOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::StringAttr MeetOpGenericAdaptorBase::getErrorAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::StringAttr>(getProperties().error); + return attr; +} + +::std::optional< ::llvm::StringRef > MeetOpGenericAdaptorBase::getError() { + auto attr = getErrorAttr(); + return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); +} + +} // namespace detail +MeetOpAdaptor::MeetOpAdaptor(MeetOp op) : MeetOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult MeetOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_error = getProperties().error; (void)tblgen_error; + + if (tblgen_error && !((::llvm::isa<::mlir::StringAttr>(tblgen_error)))) + return emitError(loc, "'shape.meet' op ""attribute 'error' failed to satisfy constraint: string attribute"); + return ::mlir::success(); +} + +std::pair MeetOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range MeetOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value MeetOp::getArg0() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin()); +} + +::mlir::Value MeetOp::getArg1() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(1).begin()); +} + +::mlir::OpOperand &MeetOp::getArg0Mutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MeetOp::getArg1Mutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +std::pair MeetOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range MeetOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value MeetOp::getResult() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult MeetOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.error; + auto attr = dict.get("error"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for error in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `error` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute MeetOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.error; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("error", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code MeetOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.error.getAsOpaquePointer())); +} + +std::optional MeetOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "error") + return prop.error; + return std::nullopt; +} + +void MeetOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "error") { + prop.error = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void MeetOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.error) attrs.append("error", prop.error); +} + +::mlir::LogicalResult MeetOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getErrorAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_ShapeOps0(attr, "error", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult MeetOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.error))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void MeetOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.error); +} + +::mlir::StringAttr MeetOp::getErrorAttr() { + return ::llvm::dyn_cast_or_null<::mlir::StringAttr>(getProperties().error); +} + +::std::optional< ::llvm::StringRef > MeetOp::getError() { + auto attr = getErrorAttr(); + return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); +} + +void MeetOp::setErrorAttr(::mlir::StringAttr attr) { + (*this)->setAttr(getErrorAttrName(), attr); +} + +void MeetOp::setError(::std::optional<::llvm::StringRef> attrValue) { + if (attrValue) + return (*this)->setAttr(getErrorAttrName(), ::mlir::Builder((*this)->getContext()).getStringAttr(*attrValue)); + (*this)->removeAttr(getErrorAttrName()); +} + +::mlir::Attribute MeetOp::removeErrorAttr() { + auto &attr = getProperties().error; + attr = {}; + return attr; +} + +void MeetOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value arg0, ::mlir::Value arg1, /*optional*/::mlir::StringAttr error) { + odsState.addOperands(arg0); + odsState.addOperands(arg1); + if (error) { + odsState.getOrAddProperties().error = error; + } + odsState.addTypes(result); +} + +void MeetOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value arg0, ::mlir::Value arg1, /*optional*/::mlir::StringAttr error) { + odsState.addOperands(arg0); + odsState.addOperands(arg1); + if (error) { + odsState.getOrAddProperties().error = error; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MeetOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void MeetOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value arg0, ::mlir::Value arg1, /*optional*/::mlir::StringAttr error) { + odsState.addOperands(arg0); + odsState.addOperands(arg1); + if (error) { + odsState.getOrAddProperties().error = error; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void MeetOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void MeetOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MeetOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult MeetOp::verifyInvariantsImpl() { + auto tblgen_error = getProperties().error; (void)tblgen_error; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_ShapeOps0(*this, tblgen_error, "error"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps11(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps11(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps11(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult MeetOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult MeetOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand arg0RawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> arg0Operands(arg0RawOperands); ::llvm::SMLoc arg0OperandsLoc; + (void)arg0OperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand arg1RawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> arg1Operands(arg1RawOperands); ::llvm::SMLoc arg1OperandsLoc; + (void)arg1OperandsLoc; + ::mlir::StringAttr errorAttr; + ::mlir::Type arg0RawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> arg0Types(arg0RawTypes); + ::mlir::Type arg1RawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> arg1Types(arg1RawTypes); + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + arg0OperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(arg0RawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + arg1OperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(arg1RawOperands[0])) + return ::mlir::failure(); + if (::mlir::succeeded(parser.parseOptionalComma())) { + if (parser.parseKeyword("error")) + return ::mlir::failure(); + if (parser.parseEqual()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(errorAttr, parser.getBuilder().getType<::mlir::NoneType>())) { + return ::mlir::failure(); + } + if (errorAttr) result.getOrAddProperties().error = errorAttr; + } + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + arg0RawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + arg1RawTypes[0] = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(arg0Operands, arg0Types, arg0OperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(arg1Operands, arg1Types, arg1OperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void MeetOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getArg0(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getArg1(); + if (getErrorAttr()) { + _odsPrinter << ","; + _odsPrinter << ' ' << "error"; + _odsPrinter << ' ' << "="; + _odsPrinter << ' '; + _odsPrinter.printAttributeWithoutType(getErrorAttr()); + } + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("error"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getArg0().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getArg1().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +::mlir::LogicalResult +MeetOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + MeetOp::Adaptor adaptor(operands, attributes, properties, regions); + return MeetOp::inferReturnTypes(context, + location, adaptor, inferredReturnTypes); +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::MeetOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::MinOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +MinOpGenericAdaptorBase::MinOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.min", odsAttrs.getContext()); +} + +MinOpGenericAdaptorBase::MinOpGenericAdaptorBase(MinOp op) : MinOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair MinOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr MinOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +MinOpAdaptor::MinOpAdaptor(MinOp op) : MinOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult MinOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair MinOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range MinOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value MinOp::getLhs() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin()); +} + +::mlir::Value MinOp::getRhs() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(1).begin()); +} + +::mlir::OpOperand &MinOp::getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MinOp::getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +std::pair MinOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range MinOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value MinOp::getResult() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +void MinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void MinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MinOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void MinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void MinOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void MinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MinOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult MinOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps6(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult MinOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult MinOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(lhsRawOperands); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(rhsRawOperands); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(lhsRawTypes); + ::mlir::Type rhsRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(rhsRawTypes); + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + lhsRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + rhsRawTypes[0] = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void MinOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getLhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getRhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void MinOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::mlir::LogicalResult +MinOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + MinOp::Adaptor adaptor(operands, attributes, properties, regions); + return MinOp::inferReturnTypes(context, + location, adaptor, inferredReturnTypes); +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::MinOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::MulOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +MulOpGenericAdaptorBase::MulOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.mul", odsAttrs.getContext()); +} + +MulOpGenericAdaptorBase::MulOpGenericAdaptorBase(MulOp op) : MulOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair MulOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr MulOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +MulOpAdaptor::MulOpAdaptor(MulOp op) : MulOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult MulOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair MulOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range MulOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value MulOp::getLhs() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin()); +} + +::mlir::Value MulOp::getRhs() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(1).begin()); +} + +::mlir::OpOperand &MulOp::getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MulOp::getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +std::pair MulOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range MulOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value MulOp::getResult() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +void MulOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addTypes(result); +} + +void MulOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MulOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void MulOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void MulOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void MulOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MulOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult MulOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps0(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult MulOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult MulOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(lhsRawOperands); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(rhsRawOperands); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(lhsRawTypes); + ::mlir::Type rhsRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(rhsRawTypes); + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + lhsRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + rhsRawTypes[0] = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void MulOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getLhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getRhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void MulOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::mlir::LogicalResult +MulOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + MulOp::Adaptor adaptor(operands, attributes, properties, regions); + return MulOp::inferReturnTypes(context, + location, adaptor, inferredReturnTypes); +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::MulOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::NumElementsOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +NumElementsOpGenericAdaptorBase::NumElementsOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.num_elements", odsAttrs.getContext()); +} + +NumElementsOpGenericAdaptorBase::NumElementsOpGenericAdaptorBase(NumElementsOp op) : NumElementsOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair NumElementsOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr NumElementsOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +NumElementsOpAdaptor::NumElementsOpAdaptor(NumElementsOp op) : NumElementsOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult NumElementsOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair NumElementsOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range NumElementsOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value NumElementsOp::getShape() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &NumElementsOp::getShapeMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair NumElementsOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range NumElementsOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value NumElementsOp::getResult() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +void NumElementsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value shape) { + odsState.addOperands(shape); + odsState.addTypes(result); +} + +void NumElementsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value shape) { + odsState.addOperands(shape); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(NumElementsOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void NumElementsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value shape) { + odsState.addOperands(shape); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void NumElementsOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void NumElementsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(NumElementsOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult NumElementsOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps0(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult NumElementsOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult NumElementsOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand shapeRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> shapeOperands(shapeRawOperands); ::llvm::SMLoc shapeOperandsLoc; + (void)shapeOperandsLoc; + ::mlir::Type shapeRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> shapeTypes(shapeRawTypes); + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + shapeOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(shapeRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + shapeRawTypes[0] = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(shapeOperands, shapeTypes, shapeOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void NumElementsOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getShape(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getShape().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void NumElementsOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::mlir::LogicalResult +NumElementsOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + NumElementsOp::Adaptor adaptor(operands, attributes, properties, regions); + return NumElementsOp::inferReturnTypes(context, + location, adaptor, inferredReturnTypes); +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::NumElementsOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::RankOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +RankOpGenericAdaptorBase::RankOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.rank", odsAttrs.getContext()); +} + +RankOpGenericAdaptorBase::RankOpGenericAdaptorBase(RankOp op) : RankOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair RankOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr RankOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +RankOpAdaptor::RankOpAdaptor(RankOp op) : RankOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult RankOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair RankOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range RankOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value RankOp::getShape() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &RankOp::getShapeMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair RankOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range RankOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value RankOp::getRank() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +void RankOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type rank, ::mlir::Value shape) { + odsState.addOperands(shape); + odsState.addTypes(rank); +} + +void RankOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value shape) { + odsState.addOperands(shape); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(RankOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void RankOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value shape) { + odsState.addOperands(shape); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void RankOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void RankOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(RankOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult RankOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps0(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult RankOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult RankOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand shapeRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> shapeOperands(shapeRawOperands); ::llvm::SMLoc shapeOperandsLoc; + (void)shapeOperandsLoc; + ::mlir::Type shapeRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> shapeTypes(shapeRawTypes); + ::mlir::Type rankRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> rankTypes(rankRawTypes); + + shapeOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(shapeRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + shapeRawTypes[0] = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + rankRawTypes[0] = type; + } + result.addTypes(rankTypes); + if (parser.resolveOperands(shapeOperands, shapeTypes, shapeOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void RankOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getShape(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getShape().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getRank().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void RankOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::mlir::LogicalResult +RankOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + RankOp::Adaptor adaptor(operands, attributes, properties, regions); + return RankOp::inferReturnTypes(context, + location, adaptor, inferredReturnTypes); +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::RankOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::ReduceOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ReduceOpGenericAdaptorBase::ReduceOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.reduce", odsAttrs.getContext()); +} + +ReduceOpGenericAdaptorBase::ReduceOpGenericAdaptorBase(ReduceOp op) : ReduceOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ReduceOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr ReduceOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::Region &ReduceOpGenericAdaptorBase::getRegion() { + return *odsRegions[0]; +} + +::mlir::RegionRange ReduceOpGenericAdaptorBase::getRegions() { + return odsRegions; +} + +} // namespace detail +ReduceOpAdaptor::ReduceOpAdaptor(ReduceOp op) : ReduceOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ReduceOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair ReduceOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range ReduceOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value ReduceOp::getShape() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin()); +} + +::mlir::Operation::operand_range ReduceOp::getInitVals() { + return getODSOperands(1); +} + +::mlir::OpOperand &ReduceOp::getShapeMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange ReduceOp::getInitValsMutable() { + auto range = getODSOperandIndexAndLength(1); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair ReduceOp::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::result_range ReduceOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::result_range ReduceOp::getResult() { + return getODSResults(0); +} + +::mlir::Region &ReduceOp::getRegion() { + return (*this)->getRegion(0); +} + +void ReduceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange result, ::mlir::Value shape, ::mlir::ValueRange initVals) { + odsState.addOperands(shape); + odsState.addOperands(initVals); + (void)odsState.addRegion(); + odsState.addTypes(result); +} + +void ReduceOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ReduceOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_ShapeOps0(*this, region, "region", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ReduceOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::ReduceOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::ReturnOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ReturnOpGenericAdaptorBase::ReturnOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.return", odsAttrs.getContext()); +} + +ReturnOpGenericAdaptorBase::ReturnOpGenericAdaptorBase(ReturnOp op) : ReturnOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ReturnOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr ReturnOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +ReturnOpAdaptor::ReturnOpAdaptor(ReturnOp op) : ReturnOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ReturnOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair ReturnOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range ReturnOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::operand_range ReturnOp::getOperands() { + return getODSOperands(0); +} + +::mlir::MutableOperandRange ReturnOp::getOperandsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair ReturnOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ReturnOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +void ReturnOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands) { + odsState.addOperands(operands); +} + +void ReturnOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ReturnOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ReturnOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult ReturnOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> operandsOperands; + ::llvm::SMLoc operandsOperandsLoc; + (void)operandsOperandsLoc; + ::llvm::SmallVector<::mlir::Type, 1> operandsTypes; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + + operandsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(operandsOperands)) + return ::mlir::failure(); + if (!operandsOperands.empty()) { + if (parser.parseColon()) + return ::mlir::failure(); + + if (parser.parseTypeList(operandsTypes)) + return ::mlir::failure(); + } + if (parser.resolveOperands(operandsOperands, operandsTypes, operandsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ReturnOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + if (!getOperands().empty()) { + _odsPrinter << ' '; + _odsPrinter << getOperands(); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter << getOperands().getTypes(); + } +} + +void ReturnOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::mlir::MutableOperandRange ReturnOp::getMutableSuccessorOperands( + ::mlir::RegionBranchPoint point) { + return ::mlir::MutableOperandRange(*this); +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::ReturnOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::ShapeEqOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ShapeEqOpGenericAdaptorBase::ShapeEqOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.shape_eq", odsAttrs.getContext()); +} + +ShapeEqOpGenericAdaptorBase::ShapeEqOpGenericAdaptorBase(ShapeEqOp op) : ShapeEqOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ShapeEqOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr ShapeEqOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +ShapeEqOpAdaptor::ShapeEqOpAdaptor(ShapeEqOp op) : ShapeEqOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ShapeEqOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair ShapeEqOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range ShapeEqOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::operand_range ShapeEqOp::getShapes() { + return getODSOperands(0); +} + +::mlir::MutableOperandRange ShapeEqOp::getShapesMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair ShapeEqOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ShapeEqOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::IntegerType> ShapeEqOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::IntegerType>>(*getODSResults(0).begin()); +} + +void ShapeEqOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) { + build(odsBuilder, odsState, ::llvm::ArrayRef({lhs, rhs})); +} + +void ShapeEqOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange shapes) { + odsState.addOperands(shapes); + odsState.addTypes(result); +} + +void ShapeEqOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ShapeEqOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ShapeEqOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult ShapeEqOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps5(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ShapeEqOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::LogicalResult ShapeEqOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = odsBuilder.getIntegerType(1); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult ShapeEqOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> shapesOperands; + ::llvm::SMLoc shapesOperandsLoc; + (void)shapesOperandsLoc; + ::llvm::SmallVector<::mlir::Type, 1> shapesTypes; + + shapesOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(shapesOperands)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + if (parser.parseTypeList(shapesTypes)) + return ::mlir::failure(); + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(1); + result.addTypes(odsBuildableType0); + if (parser.resolveOperands(shapesOperands, shapesTypes, shapesOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ShapeEqOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getShapes(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter << getShapes().getTypes(); +} + +void ShapeEqOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::ShapeEqOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::ShapeOfOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ShapeOfOpGenericAdaptorBase::ShapeOfOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.shape_of", odsAttrs.getContext()); +} + +ShapeOfOpGenericAdaptorBase::ShapeOfOpGenericAdaptorBase(ShapeOfOp op) : ShapeOfOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ShapeOfOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ShapeOfOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +ShapeOfOpAdaptor::ShapeOfOpAdaptor(ShapeOfOp op) : ShapeOfOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ShapeOfOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair ShapeOfOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ShapeOfOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value ShapeOfOp::getArg() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &ShapeOfOp::getArgMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair ShapeOfOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ShapeOfOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value ShapeOfOp::getResult() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +void ShapeOfOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value arg) { + odsState.addOperands(arg); + odsState.addTypes(result); +} + +void ShapeOfOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value arg) { + odsState.addOperands(arg); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ShapeOfOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void ShapeOfOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value arg) { + odsState.addOperands(arg); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ShapeOfOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ShapeOfOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ShapeOfOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult ShapeOfOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps12(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ShapeOfOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult ShapeOfOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand argRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> argOperands(argRawOperands); ::llvm::SMLoc argOperandsLoc; + (void)argOperandsLoc; + ::mlir::Type argRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> argTypes(argRawTypes); + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + argOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(argRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + argRawTypes[0] = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(argOperands, argTypes, argOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ShapeOfOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getArg(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getArg().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void ShapeOfOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::mlir::LogicalResult +ShapeOfOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ShapeOfOp::Adaptor adaptor(operands, attributes, properties, regions); + return ShapeOfOp::inferReturnTypes(context, + location, adaptor, inferredReturnTypes); +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::ShapeOfOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::SizeToIndexOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +SizeToIndexOpGenericAdaptorBase::SizeToIndexOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.size_to_index", odsAttrs.getContext()); +} + +SizeToIndexOpGenericAdaptorBase::SizeToIndexOpGenericAdaptorBase(SizeToIndexOp op) : SizeToIndexOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair SizeToIndexOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr SizeToIndexOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +SizeToIndexOpAdaptor::SizeToIndexOpAdaptor(SizeToIndexOp op) : SizeToIndexOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult SizeToIndexOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair SizeToIndexOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range SizeToIndexOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value SizeToIndexOp::getArg() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &SizeToIndexOp::getArgMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair SizeToIndexOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range SizeToIndexOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::IndexType> SizeToIndexOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::IndexType>>(*getODSResults(0).begin()); +} + +void SizeToIndexOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value arg) { + odsState.addOperands(arg); + odsState.addTypes(result); +} + +void SizeToIndexOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value arg) { + odsState.addOperands(arg); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SizeToIndexOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void SizeToIndexOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value arg) { + odsState.addOperands(arg); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SizeToIndexOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void SizeToIndexOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SizeToIndexOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult SizeToIndexOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps10(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult SizeToIndexOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::LogicalResult SizeToIndexOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = odsBuilder.getIndexType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult SizeToIndexOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand argRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> argOperands(argRawOperands); ::llvm::SMLoc argOperandsLoc; + (void)argOperandsLoc; + ::mlir::Type argRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> argTypes(argRawTypes); + + argOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(argRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + argRawTypes[0] = type; + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + result.addTypes(odsBuildableType0); + if (parser.resolveOperands(argOperands, argTypes, argOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SizeToIndexOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getArg(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getArg().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void SizeToIndexOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::SizeToIndexOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::SplitAtOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +SplitAtOpGenericAdaptorBase::SplitAtOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.split_at", odsAttrs.getContext()); +} + +SplitAtOpGenericAdaptorBase::SplitAtOpGenericAdaptorBase(SplitAtOp op) : SplitAtOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair SplitAtOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr SplitAtOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +SplitAtOpAdaptor::SplitAtOpAdaptor(SplitAtOp op) : SplitAtOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult SplitAtOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +void SplitAtOp::getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn) { + auto resultGroup0 = getODSResults(0); + if (!resultGroup0.empty()) + setNameFn(*resultGroup0.begin(), "head"); + auto resultGroup1 = getODSResults(1); + if (!resultGroup1.empty()) + setNameFn(*resultGroup1.begin(), "tail"); +} + +std::pair SplitAtOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range SplitAtOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value SplitAtOp::getOperand() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin()); +} + +::mlir::Value SplitAtOp::getIndex() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(1).begin()); +} + +::mlir::OpOperand &SplitAtOp::getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &SplitAtOp::getIndexMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +std::pair SplitAtOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range SplitAtOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value SplitAtOp::getHead() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +::mlir::Value SplitAtOp::getTail() { + return ::llvm::cast<::mlir::Value>(*getODSResults(1).begin()); +} + +void SplitAtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type head, ::mlir::Type tail, ::mlir::Value operand, ::mlir::Value index) { + odsState.addOperands(operand); + odsState.addOperands(index); + odsState.addTypes(head); + odsState.addTypes(tail); +} + +void SplitAtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value index) { + odsState.addOperands(operand); + odsState.addOperands(index); + assert(resultTypes.size() == 2u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SplitAtOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 2u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult SplitAtOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSResults(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult SplitAtOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +void SplitAtOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::SplitAtOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::ToExtentTensorOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ToExtentTensorOpGenericAdaptorBase::ToExtentTensorOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.to_extent_tensor", odsAttrs.getContext()); +} + +ToExtentTensorOpGenericAdaptorBase::ToExtentTensorOpGenericAdaptorBase(ToExtentTensorOp op) : ToExtentTensorOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ToExtentTensorOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ToExtentTensorOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +ToExtentTensorOpAdaptor::ToExtentTensorOpAdaptor(ToExtentTensorOp op) : ToExtentTensorOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ToExtentTensorOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair ToExtentTensorOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ToExtentTensorOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value ToExtentTensorOp::getInput() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &ToExtentTensorOp::getInputMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair ToExtentTensorOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ToExtentTensorOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::TensorType> ToExtentTensorOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); +} + +void ToExtentTensorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value input) { + odsState.addOperands(input); + odsState.addTypes(result); +} + +void ToExtentTensorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input) { + odsState.addOperands(input); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ToExtentTensorOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ToExtentTensorOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps13(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ToExtentTensorOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult ToExtentTensorOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand inputRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> inputOperands(inputRawOperands); ::llvm::SMLoc inputOperandsLoc; + (void)inputOperandsLoc; + ::mlir::Type inputRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> inputTypes(inputRawTypes); + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + inputOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(inputRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + inputRawTypes[0] = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(inputOperands, inputTypes, inputOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ToExtentTensorOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getInput(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getInput().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void ToExtentTensorOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::ToExtentTensorOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::ValueAsShapeOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ValueAsShapeOpGenericAdaptorBase::ValueAsShapeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.value_as_shape", odsAttrs.getContext()); +} + +ValueAsShapeOpGenericAdaptorBase::ValueAsShapeOpGenericAdaptorBase(ValueAsShapeOp op) : ValueAsShapeOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ValueAsShapeOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ValueAsShapeOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +ValueAsShapeOpAdaptor::ValueAsShapeOpAdaptor(ValueAsShapeOp op) : ValueAsShapeOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ValueAsShapeOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair ValueAsShapeOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ValueAsShapeOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value ValueAsShapeOp::getArg() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &ValueAsShapeOp::getArgMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair ValueAsShapeOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ValueAsShapeOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value ValueAsShapeOp::getResult() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +void ValueAsShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value arg) { + odsState.addOperands(arg); + odsState.addTypes(result); +} + +void ValueAsShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value arg) { + odsState.addOperands(arg); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ValueAsShapeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ValueAsShapeOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps14(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ValueAsShapeOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult ValueAsShapeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand argRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> argOperands(argRawOperands); ::llvm::SMLoc argOperandsLoc; + (void)argOperandsLoc; + ::mlir::Type argRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> argTypes(argRawTypes); + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + argOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(argRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + argRawTypes[0] = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(argOperands, argTypes, argOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ValueAsShapeOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getArg(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getArg().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void ValueAsShapeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::ValueAsShapeOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::ValueOfOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ValueOfOpGenericAdaptorBase::ValueOfOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.value_of", odsAttrs.getContext()); +} + +ValueOfOpGenericAdaptorBase::ValueOfOpGenericAdaptorBase(ValueOfOp op) : ValueOfOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ValueOfOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ValueOfOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +ValueOfOpAdaptor::ValueOfOpAdaptor(ValueOfOp op) : ValueOfOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ValueOfOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair ValueOfOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ValueOfOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::shape::ValueShapeType> ValueOfOp::getArg() { + return ::llvm::cast<::mlir::TypedValue<::mlir::shape::ValueShapeType>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &ValueOfOp::getArgMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair ValueOfOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ValueOfOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::ShapedType> ValueOfOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::ShapedType>>(*getODSResults(0).begin()); +} + +void ValueOfOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value arg) { + odsState.addOperands(arg); + odsState.addTypes(result); +} + +void ValueOfOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value arg) { + odsState.addOperands(arg); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ValueOfOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ValueOfOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps15(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps7(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ValueOfOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult ValueOfOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand argRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> argOperands(argRawOperands); ::llvm::SMLoc argOperandsLoc; + (void)argOperandsLoc; + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + argOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(argRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::ShapedType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::shape::ValueShapeType>(); + result.addTypes(resultTypes); + if (parser.resolveOperands(argOperands, odsBuildableType0, argOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ValueOfOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getArg(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::ShapedType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void ValueOfOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::ValueOfOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::WithOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +WithOpGenericAdaptorBase::WithOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.with_shape", odsAttrs.getContext()); +} + +WithOpGenericAdaptorBase::WithOpGenericAdaptorBase(WithOp op) : WithOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair WithOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr WithOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +WithOpAdaptor::WithOpAdaptor(WithOp op) : WithOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult WithOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair WithOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range WithOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value WithOp::getOperand() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin()); +} + +::mlir::Value WithOp::getShape() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(1).begin()); +} + +::mlir::OpOperand &WithOp::getOperandMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &WithOp::getShapeMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +std::pair WithOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range WithOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::shape::ValueShapeType> WithOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::shape::ValueShapeType>>(*getODSResults(0).begin()); +} + +void WithOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value shape) { + odsState.addOperands(operand); + odsState.addOperands(shape); + odsState.addTypes(result); +} + +void WithOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::Value shape) { + odsState.addOperands(operand); + odsState.addOperands(shape); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(WithOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void WithOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value shape) { + odsState.addOperands(operand); + odsState.addOperands(shape); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void WithOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void WithOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(WithOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult WithOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps12(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps15(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult WithOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::LogicalResult WithOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = odsBuilder.getType<::mlir::shape::ValueShapeType>(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult WithOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands; + ::mlir::Type operandRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> operandTypes(operandRawTypes); + ::mlir::Type shapeRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> shapeTypes(shapeRawTypes); + ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(allOperands)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + operandRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + shapeRawTypes[0] = type; + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::mlir::shape::ValueShapeType>(); + result.addTypes(odsBuildableType0); + if (parser.resolveOperands(allOperands, ::llvm::concat(::llvm::ArrayRef<::mlir::Type>(operandTypes), ::llvm::ArrayRef<::mlir::Type>(shapeTypes)), allOperandLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void WithOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperation()->getOperands(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getOperand().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getShape().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void WithOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::WithOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::YieldOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +YieldOpGenericAdaptorBase::YieldOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("shape.yield", odsAttrs.getContext()); +} + +YieldOpGenericAdaptorBase::YieldOpGenericAdaptorBase(YieldOp op) : YieldOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair YieldOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr YieldOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +YieldOpAdaptor::YieldOpAdaptor(YieldOp op) : YieldOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult YieldOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair YieldOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range YieldOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::operand_range YieldOp::getOperands() { + return getODSOperands(0); +} + +::mlir::MutableOperandRange YieldOp::getOperandsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair YieldOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range YieldOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +void YieldOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { + build(odsBuilder, odsState, std::nullopt); +} + +void YieldOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands) { + odsState.addOperands(operands); +} + +void YieldOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult YieldOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_ShapeOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult YieldOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult YieldOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> operandsOperands; + ::llvm::SMLoc operandsOperandsLoc; + (void)operandsOperandsLoc; + ::llvm::SmallVector<::mlir::Type, 1> operandsTypes; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + + operandsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(operandsOperands)) + return ::mlir::failure(); + if (!operandsOperands.empty()) { + if (parser.parseColon()) + return ::mlir::failure(); + + if (parser.parseTypeList(operandsTypes)) + return ::mlir::failure(); + } + if (parser.resolveOperands(operandsOperands, operandsTypes, operandsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void YieldOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + if (!getOperands().empty()) { + _odsPrinter << ' '; + _odsPrinter << getOperands(); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter << getOperands().getTypes(); + } +} + +void YieldOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::mlir::MutableOperandRange YieldOp::getMutableSuccessorOperands( + ::mlir::RegionBranchPoint point) { + return ::mlir::MutableOperandRange(*this); +} + +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::YieldOp) + + +#endif // GET_OP_CLASSES + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..8a89ca1417f2ba9323c6b50e927f9a8c8e51981d --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.h.inc @@ -0,0 +1,5179 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Op Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: ShapeOps.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#if defined(GET_OP_CLASSES) || defined(GET_OP_FWD_DEFINES) +#undef GET_OP_FWD_DEFINES +namespace mlir { +namespace shape { +class AddOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class AnyOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class AssumingAllOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class AssumingOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class AssumingYieldOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class BroadcastOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class ConcatOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class ConstShapeOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class ConstSizeOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class ConstWitnessOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class CstrBroadcastableOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class CstrEqOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class CstrRequireOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class DebugPrintOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class DimOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class DivOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class FromExtentTensorOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class FromExtentsOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class FuncOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class FunctionLibraryOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class GetExtentOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class IndexToSizeOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class IsBroadcastableOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class MaxOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class MeetOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class MinOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class MulOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class NumElementsOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class RankOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class ReduceOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class ReturnOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class ShapeEqOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class ShapeOfOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class SizeToIndexOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class SplitAtOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class ToExtentTensorOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class ValueAsShapeOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class ValueOfOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class WithOp; +} // namespace shape +} // namespace mlir +namespace mlir { +namespace shape { +class YieldOp; +} // namespace shape +} // namespace mlir +#endif + +#ifdef GET_OP_CLASSES +#undef GET_OP_CLASSES + + +//===----------------------------------------------------------------------===// +// Local Utility Method Definitions +//===----------------------------------------------------------------------===// + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::AddOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class AddOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + AddOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + AddOpGenericAdaptorBase(AddOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class AddOpGenericAdaptor : public detail::AddOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::AddOpGenericAdaptorBase; +public: + AddOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + AddOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : AddOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + AddOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class AddOpAdaptor : public AddOpGenericAdaptor<::mlir::ValueRange> { +public: + using AddOpGenericAdaptor::AddOpGenericAdaptor; + AddOpAdaptor(AddOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class AddOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::OpTrait::IsCommutative, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::OpTrait::InferTypeOpAdaptor> { +public: + using Op::Op; + using Op::print; + using Adaptor = AddOpAdaptor; + template + using GenericAdaptor = AddOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.add"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getLhs(); + ::mlir::Value getRhs(); + ::mlir::OpOperand &getLhsMutable(); + ::mlir::OpOperand &getRhsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + static ::mlir::LogicalResult + inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + Adaptor adaptor, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes); + + static bool isCompatibleReturnTypes(::mlir::TypeRange l, ::mlir::TypeRange r); + +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::AddOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::AnyOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class AnyOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + AnyOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + AnyOpGenericAdaptorBase(AnyOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class AnyOpGenericAdaptor : public detail::AnyOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::AnyOpGenericAdaptorBase; +public: + AnyOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + AnyOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : AnyOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + AnyOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getInputs() { + return getODSOperands(0); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class AnyOpAdaptor : public AnyOpGenericAdaptor<::mlir::ValueRange> { +public: + using AnyOpGenericAdaptor::AnyOpGenericAdaptor; + AnyOpAdaptor(AnyOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class AnyOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::OpInvariants, ::mlir::OpTrait::IsCommutative, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = AnyOpAdaptor; + template + using GenericAdaptor = AnyOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.any"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Operation::operand_range getInputs(); + ::mlir::MutableOperandRange getInputsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange inputs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::AnyOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::AssumingAllOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class AssumingAllOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + AssumingAllOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + AssumingAllOpGenericAdaptorBase(AssumingAllOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class AssumingAllOpGenericAdaptor : public detail::AssumingAllOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::AssumingAllOpGenericAdaptorBase; +public: + AssumingAllOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + AssumingAllOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : AssumingAllOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + AssumingAllOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getInputs() { + return getODSOperands(0); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class AssumingAllOpAdaptor : public AssumingAllOpGenericAdaptor<::mlir::ValueRange> { +public: + using AssumingAllOpGenericAdaptor::AssumingAllOpGenericAdaptor; + AssumingAllOpAdaptor(AssumingAllOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class AssumingAllOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::OpInvariants, ::mlir::OpTrait::IsCommutative, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = AssumingAllOpAdaptor; + template + using GenericAdaptor = AssumingAllOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.assuming_all"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Operation::operand_range getInputs(); + ::mlir::MutableOperandRange getInputsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::shape::WitnessType> getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange inputs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::AssumingAllOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::AssumingOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class AssumingOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + AssumingOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + AssumingOpGenericAdaptorBase(AssumingOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); + ::mlir::Region &getDoRegion(); + ::mlir::RegionRange getRegions(); +}; +} // namespace detail +template +class AssumingOpGenericAdaptor : public detail::AssumingOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::AssumingOpGenericAdaptorBase; +public: + AssumingOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + AssumingOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : AssumingOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + AssumingOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getWitness() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class AssumingOpAdaptor : public AssumingOpGenericAdaptor<::mlir::ValueRange> { +public: + using AssumingOpGenericAdaptor::AssumingOpGenericAdaptor; + AssumingOpAdaptor(AssumingOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class AssumingOp : public ::mlir::Op::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::RegionBranchOpInterface::Trait, ::mlir::OpTrait::HasRecursiveMemoryEffects> { +public: + using Op::Op; + using Op::print; + using Adaptor = AssumingOpAdaptor; + template + using GenericAdaptor = AssumingOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.assuming"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::shape::WitnessType> getWitness(); + ::mlir::OpOperand &getWitnessMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Operation::result_range getResults(); + ::mlir::Region &getDoRegion(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value witness, function_ref(OpBuilder &, Location)> odsArg1); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::Value witness); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &p); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + void getSuccessorRegions(::mlir::RegionBranchPoint point, ::llvm::SmallVectorImpl<::mlir::RegionSuccessor> ®ions); +public: + // Inline the region into the region containing the AssumingOp and delete + // the AssumingOp. + // + // This does no checks on the inputs to the AssumingOp. + static void inlineRegionIntoParent(AssumingOp &op, + PatternRewriter &rewriter); +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::AssumingOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::AssumingYieldOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class AssumingYieldOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + AssumingYieldOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + AssumingYieldOpGenericAdaptorBase(AssumingYieldOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class AssumingYieldOpGenericAdaptor : public detail::AssumingYieldOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::AssumingYieldOpGenericAdaptorBase; +public: + AssumingYieldOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + AssumingYieldOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : AssumingYieldOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + AssumingYieldOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return getODSOperands(0); + } + +private: + RangeT odsOperands; +}; +class AssumingYieldOpAdaptor : public AssumingYieldOpGenericAdaptor<::mlir::ValueRange> { +public: + using AssumingYieldOpGenericAdaptor::AssumingYieldOpGenericAdaptor; + AssumingYieldOpAdaptor(AssumingYieldOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class AssumingYieldOp : public ::mlir::Op::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::RegionBranchTerminatorOpInterface::Trait, ::mlir::OpTrait::ReturnLike, ::mlir::OpTrait::IsTerminator> { +public: + using Op::Op; + using Op::print; + using Adaptor = AssumingYieldOpAdaptor; + template + using GenericAdaptor = AssumingYieldOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.assuming_yield"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Operation::operand_range getOperands(); + ::mlir::MutableOperandRange getOperandsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::MutableOperandRange getMutableSuccessorOperands(::mlir::RegionBranchPoint point); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::AssumingYieldOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::BroadcastOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BroadcastOpGenericAdaptorBase { +public: + struct Properties { + using errorTy = ::mlir::StringAttr; + errorTy error; + + auto getError() { + auto &propStorage = this->error; + return ::llvm::dyn_cast_or_null<::mlir::StringAttr>(propStorage); + } + void setError(const ::mlir::StringAttr &propValue) { + this->error = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.error == this->error && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BroadcastOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + BroadcastOpGenericAdaptorBase(BroadcastOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::StringAttr getErrorAttr(); + ::std::optional< ::llvm::StringRef > getError(); +}; +} // namespace detail +template +class BroadcastOpGenericAdaptor : public detail::BroadcastOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BroadcastOpGenericAdaptorBase; +public: + BroadcastOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BroadcastOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BroadcastOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + BroadcastOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getShapes() { + return getODSOperands(0); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BroadcastOpAdaptor : public BroadcastOpGenericAdaptor<::mlir::ValueRange> { +public: + using BroadcastOpGenericAdaptor::BroadcastOpGenericAdaptor; + BroadcastOpAdaptor(BroadcastOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class BroadcastOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpTrait::IsCommutative, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = BroadcastOpAdaptor; + template + using GenericAdaptor = BroadcastOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("error")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getErrorAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getErrorAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.broadcast"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Operation::operand_range getShapes(); + ::mlir::MutableOperandRange getShapesMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getResult(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::StringAttr getErrorAttr(); + ::std::optional< ::llvm::StringRef > getError(); + void setErrorAttr(::mlir::StringAttr attr); + void setError(::std::optional<::llvm::StringRef> attrValue); + ::mlir::Attribute removeErrorAttr(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/ ::mlir::StringAttr error); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange shapes, /*optional*/::mlir::StringAttr error); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange shapes, /*optional*/::mlir::StringAttr error); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::BroadcastOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::ConcatOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ConcatOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + ConcatOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + ConcatOpGenericAdaptorBase(ConcatOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class ConcatOpGenericAdaptor : public detail::ConcatOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ConcatOpGenericAdaptorBase; +public: + ConcatOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ConcatOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ConcatOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + ConcatOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ConcatOpAdaptor : public ConcatOpGenericAdaptor<::mlir::ValueRange> { +public: + using ConcatOpGenericAdaptor::ConcatOpGenericAdaptor; + ConcatOpAdaptor(ConcatOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ConcatOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ConcatOpAdaptor; + template + using GenericAdaptor = ConcatOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.concat"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getLhs(); + ::mlir::Value getRhs(); + ::mlir::OpOperand &getLhsMutable(); + ::mlir::OpOperand &getRhsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::ConcatOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::ConstShapeOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ConstShapeOpGenericAdaptorBase { +public: + struct Properties { + using shapeTy = ::mlir::DenseIntElementsAttr; + shapeTy shape; + + auto getShape() { + auto &propStorage = this->shape; + return ::llvm::cast<::mlir::DenseIntElementsAttr>(propStorage); + } + void setShape(const ::mlir::DenseIntElementsAttr &propValue) { + this->shape = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.shape == this->shape && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ConstShapeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + ConstShapeOpGenericAdaptorBase(ConstShapeOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::DenseIntElementsAttr getShapeAttr(); + ::mlir::DenseIntElementsAttr getShape(); +}; +} // namespace detail +template +class ConstShapeOpGenericAdaptor : public detail::ConstShapeOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ConstShapeOpGenericAdaptorBase; +public: + ConstShapeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ConstShapeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ConstShapeOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + ConstShapeOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ConstShapeOpAdaptor : public ConstShapeOpGenericAdaptor<::mlir::ValueRange> { +public: + using ConstShapeOpGenericAdaptor::ConstShapeOpGenericAdaptor; + ConstShapeOpAdaptor(ConstShapeOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ConstShapeOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::ZeroOperands, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpTrait::ConstantLike, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::OpTrait::InferTypeOpAdaptor> { +public: + using Op::Op; + using Op::print; + using Adaptor = ConstShapeOpAdaptor; + template + using GenericAdaptor = ConstShapeOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("shape")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getShapeAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getShapeAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.const_shape"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getResult(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseIntElementsAttr getShapeAttr(); + ::mlir::DenseIntElementsAttr getShape(); + void setShapeAttr(::mlir::DenseIntElementsAttr attr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::DenseIntElementsAttr shape); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::DenseIntElementsAttr shape); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::DenseIntElementsAttr shape); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &p); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + static ::mlir::LogicalResult + inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + Adaptor adaptor, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes); + + static bool isCompatibleReturnTypes(::mlir::TypeRange l, ::mlir::TypeRange r); + +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::ConstShapeOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::ConstSizeOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ConstSizeOpGenericAdaptorBase { +public: + struct Properties { + using valueTy = ::mlir::IntegerAttr; + valueTy value; + + auto getValue() { + auto &propStorage = this->value; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setValue(const ::mlir::IntegerAttr &propValue) { + this->value = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.value == this->value && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ConstSizeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + ConstSizeOpGenericAdaptorBase(ConstSizeOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::IntegerAttr getValueAttr(); + ::llvm::APInt getValue(); +}; +} // namespace detail +template +class ConstSizeOpGenericAdaptor : public detail::ConstSizeOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ConstSizeOpGenericAdaptorBase; +public: + ConstSizeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ConstSizeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ConstSizeOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + ConstSizeOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ConstSizeOpAdaptor : public ConstSizeOpGenericAdaptor<::mlir::ValueRange> { +public: + using ConstSizeOpGenericAdaptor::ConstSizeOpGenericAdaptor; + ConstSizeOpAdaptor(ConstSizeOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ConstSizeOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::ZeroOperands, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpTrait::ConstantLike, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpAsmOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ConstSizeOpAdaptor; + template + using GenericAdaptor = ConstSizeOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("value")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getValueAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getValueAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.const_size"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::shape::SizeType> getResult(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::IntegerAttr getValueAttr(); + ::llvm::APInt getValue(); + void setValueAttr(::mlir::IntegerAttr attr); + void setValue(::llvm::APInt attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, int64_t value); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::IntegerAttr value); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::IntegerAttr value); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::IntegerAttr value); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::llvm::APInt value); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llvm::APInt value); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::llvm::APInt value); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::ConstSizeOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::ConstWitnessOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ConstWitnessOpGenericAdaptorBase { +public: + struct Properties { + using passingTy = ::mlir::BoolAttr; + passingTy passing; + + auto getPassing() { + auto &propStorage = this->passing; + return ::llvm::cast<::mlir::BoolAttr>(propStorage); + } + void setPassing(const ::mlir::BoolAttr &propValue) { + this->passing = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.passing == this->passing && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ConstWitnessOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + ConstWitnessOpGenericAdaptorBase(ConstWitnessOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::BoolAttr getPassingAttr(); + bool getPassing(); +}; +} // namespace detail +template +class ConstWitnessOpGenericAdaptor : public detail::ConstWitnessOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ConstWitnessOpGenericAdaptorBase; +public: + ConstWitnessOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ConstWitnessOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ConstWitnessOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + ConstWitnessOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ConstWitnessOpAdaptor : public ConstWitnessOpGenericAdaptor<::mlir::ValueRange> { +public: + using ConstWitnessOpGenericAdaptor::ConstWitnessOpGenericAdaptor; + ConstWitnessOpAdaptor(ConstWitnessOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ConstWitnessOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::ZeroOperands, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpTrait::ConstantLike, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ConstWitnessOpAdaptor; + template + using GenericAdaptor = ConstWitnessOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("passing")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getPassingAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getPassingAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.const_witness"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::shape::WitnessType> getResult(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::BoolAttr getPassingAttr(); + bool getPassing(); + void setPassingAttr(::mlir::BoolAttr attr); + void setPassing(bool attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::BoolAttr passing); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::BoolAttr passing); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::BoolAttr passing); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, bool passing); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, bool passing); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, bool passing); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::ConstWitnessOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::CstrBroadcastableOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CstrBroadcastableOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + CstrBroadcastableOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + CstrBroadcastableOpGenericAdaptorBase(CstrBroadcastableOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class CstrBroadcastableOpGenericAdaptor : public detail::CstrBroadcastableOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CstrBroadcastableOpGenericAdaptorBase; +public: + CstrBroadcastableOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CstrBroadcastableOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CstrBroadcastableOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + CstrBroadcastableOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getShapes() { + return getODSOperands(0); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class CstrBroadcastableOpAdaptor : public CstrBroadcastableOpGenericAdaptor<::mlir::ValueRange> { +public: + using CstrBroadcastableOpGenericAdaptor::CstrBroadcastableOpGenericAdaptor; + CstrBroadcastableOpAdaptor(CstrBroadcastableOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class CstrBroadcastableOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::OpInvariants, ::mlir::OpTrait::IsCommutative, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = CstrBroadcastableOpAdaptor; + template + using GenericAdaptor = CstrBroadcastableOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.cstr_broadcastable"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Operation::operand_range getShapes(); + ::mlir::MutableOperandRange getShapesMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::shape::WitnessType> getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange shapes); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +public: +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::CstrBroadcastableOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::CstrEqOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CstrEqOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + CstrEqOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + CstrEqOpGenericAdaptorBase(CstrEqOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class CstrEqOpGenericAdaptor : public detail::CstrEqOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CstrEqOpGenericAdaptorBase; +public: + CstrEqOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CstrEqOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CstrEqOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + CstrEqOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getShapes() { + return getODSOperands(0); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class CstrEqOpAdaptor : public CstrEqOpGenericAdaptor<::mlir::ValueRange> { +public: + using CstrEqOpGenericAdaptor::CstrEqOpGenericAdaptor; + CstrEqOpAdaptor(CstrEqOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class CstrEqOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::OpInvariants, ::mlir::OpTrait::IsCommutative, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = CstrEqOpAdaptor; + template + using GenericAdaptor = CstrEqOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.cstr_eq"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Operation::operand_range getShapes(); + ::mlir::MutableOperandRange getShapesMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::shape::WitnessType> getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange shapes); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +public: +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::CstrEqOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::CstrRequireOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CstrRequireOpGenericAdaptorBase { +public: + struct Properties { + using msgTy = ::mlir::StringAttr; + msgTy msg; + + auto getMsg() { + auto &propStorage = this->msg; + return ::llvm::cast<::mlir::StringAttr>(propStorage); + } + void setMsg(const ::mlir::StringAttr &propValue) { + this->msg = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.msg == this->msg && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + CstrRequireOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + CstrRequireOpGenericAdaptorBase(CstrRequireOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::StringAttr getMsgAttr(); + ::llvm::StringRef getMsg(); +}; +} // namespace detail +template +class CstrRequireOpGenericAdaptor : public detail::CstrRequireOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CstrRequireOpGenericAdaptorBase; +public: + CstrRequireOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CstrRequireOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CstrRequireOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + CstrRequireOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getPred() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class CstrRequireOpAdaptor : public CstrRequireOpGenericAdaptor<::mlir::ValueRange> { +public: + using CstrRequireOpGenericAdaptor::CstrRequireOpGenericAdaptor; + CstrRequireOpAdaptor(CstrRequireOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class CstrRequireOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = CstrRequireOpAdaptor; + template + using GenericAdaptor = CstrRequireOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("msg")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getMsgAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getMsgAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.cstr_require"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::IntegerType> getPred(); + ::mlir::OpOperand &getPredMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::shape::WitnessType> getResult(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::StringAttr getMsgAttr(); + ::llvm::StringRef getMsg(); + void setMsgAttr(::mlir::StringAttr attr); + void setMsg(::llvm::StringRef attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value pred, ::mlir::StringAttr msg); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value pred, ::mlir::StringAttr msg); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value pred, ::mlir::StringAttr msg); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value pred, ::llvm::StringRef msg); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value pred, ::llvm::StringRef msg); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value pred, ::llvm::StringRef msg); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::CstrRequireOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::DebugPrintOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class DebugPrintOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + DebugPrintOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + DebugPrintOpGenericAdaptorBase(DebugPrintOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class DebugPrintOpGenericAdaptor : public detail::DebugPrintOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::DebugPrintOpGenericAdaptorBase; +public: + DebugPrintOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + DebugPrintOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : DebugPrintOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + DebugPrintOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getInput() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class DebugPrintOpAdaptor : public DebugPrintOpGenericAdaptor<::mlir::ValueRange> { +public: + using DebugPrintOpGenericAdaptor::DebugPrintOpGenericAdaptor; + DebugPrintOpAdaptor(DebugPrintOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class DebugPrintOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants> { +public: + using Op::Op; + using Op::print; + using Adaptor = DebugPrintOpAdaptor; + template + using GenericAdaptor = DebugPrintOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.debug_print"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getInput(); + ::mlir::OpOperand &getInputMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getOutput(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); +public: +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::DebugPrintOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::DimOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class DimOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + DimOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + DimOpGenericAdaptorBase(DimOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class DimOpGenericAdaptor : public detail::DimOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::DimOpGenericAdaptorBase; +public: + DimOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + DimOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : DimOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + DimOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getValue() { + return (*getODSOperands(0).begin()); + } + + ValueT getIndex() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class DimOpAdaptor : public DimOpGenericAdaptor<::mlir::ValueRange> { +public: + using DimOpGenericAdaptor::DimOpGenericAdaptor; + DimOpAdaptor(DimOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class DimOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::OpTrait::InferTypeOpAdaptor> { +public: + using Op::Op; + using Op::print; + using Adaptor = DimOpAdaptor; + template + using GenericAdaptor = DimOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.dim"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::ShapedType> getValue(); + ::mlir::Value getIndex(); + ::mlir::OpOperand &getValueMutable(); + ::mlir::OpOperand &getIndexMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getExtent(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value value, int64_t index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type extent, ::mlir::Value value, ::mlir::Value index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value value, ::mlir::Value index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value value, ::mlir::Value index); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + static ::mlir::LogicalResult + inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + Adaptor adaptor, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes); + + static bool isCompatibleReturnTypes(::mlir::TypeRange l, ::mlir::TypeRange r); + + + /// Get the `index` value as integer if it is constant. + std::optional getConstantIndex(); +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::DimOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::DivOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class DivOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + DivOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + DivOpGenericAdaptorBase(DivOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class DivOpGenericAdaptor : public detail::DivOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::DivOpGenericAdaptorBase; +public: + DivOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + DivOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : DivOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + DivOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class DivOpAdaptor : public DivOpGenericAdaptor<::mlir::ValueRange> { +public: + using DivOpGenericAdaptor::DivOpGenericAdaptor; + DivOpAdaptor(DivOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class DivOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::OpTrait::InferTypeOpAdaptor> { +public: + using Op::Op; + using Op::print; + using Adaptor = DivOpAdaptor; + template + using GenericAdaptor = DivOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.div"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getLhs(); + ::mlir::Value getRhs(); + ::mlir::OpOperand &getLhsMutable(); + ::mlir::OpOperand &getRhsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + static ::mlir::LogicalResult + inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + Adaptor adaptor, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes); + + static bool isCompatibleReturnTypes(::mlir::TypeRange l, ::mlir::TypeRange r); + +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::DivOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::FromExtentTensorOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class FromExtentTensorOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + FromExtentTensorOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + FromExtentTensorOpGenericAdaptorBase(FromExtentTensorOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class FromExtentTensorOpGenericAdaptor : public detail::FromExtentTensorOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::FromExtentTensorOpGenericAdaptorBase; +public: + FromExtentTensorOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + FromExtentTensorOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : FromExtentTensorOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + FromExtentTensorOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getInput() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class FromExtentTensorOpAdaptor : public FromExtentTensorOpGenericAdaptor<::mlir::ValueRange> { +public: + using FromExtentTensorOpGenericAdaptor::FromExtentTensorOpGenericAdaptor; + FromExtentTensorOpAdaptor(FromExtentTensorOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class FromExtentTensorOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = FromExtentTensorOpAdaptor; + template + using GenericAdaptor = FromExtentTensorOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.from_extent_tensor"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::RankedTensorType> getInput(); + ::mlir::OpOperand &getInputMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::shape::ShapeType> getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value input); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value input); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::FromExtentTensorOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::FromExtentsOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class FromExtentsOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + FromExtentsOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + FromExtentsOpGenericAdaptorBase(FromExtentsOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class FromExtentsOpGenericAdaptor : public detail::FromExtentsOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::FromExtentsOpGenericAdaptorBase; +public: + FromExtentsOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + FromExtentsOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : FromExtentsOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + FromExtentsOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getExtents() { + return getODSOperands(0); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class FromExtentsOpAdaptor : public FromExtentsOpGenericAdaptor<::mlir::ValueRange> { +public: + using FromExtentsOpGenericAdaptor::FromExtentsOpGenericAdaptor; + FromExtentsOpAdaptor(FromExtentsOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class FromExtentsOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = FromExtentsOpAdaptor; + template + using GenericAdaptor = FromExtentsOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.from_extents"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Operation::operand_range getExtents(); + ::mlir::MutableOperandRange getExtentsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::shape::ShapeType> getShape(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type shape, ::mlir::ValueRange extents); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::FromExtentsOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::FuncOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class FuncOpGenericAdaptorBase { +public: + struct Properties { + using arg_attrsTy = ::mlir::ArrayAttr; + arg_attrsTy arg_attrs; + + auto getArgAttrs() { + auto &propStorage = this->arg_attrs; + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(propStorage); + } + void setArgAttrs(const ::mlir::ArrayAttr &propValue) { + this->arg_attrs = propValue; + } + using function_typeTy = ::mlir::TypeAttr; + function_typeTy function_type; + + auto getFunctionType() { + auto &propStorage = this->function_type; + return ::llvm::cast<::mlir::TypeAttr>(propStorage); + } + void setFunctionType(const ::mlir::TypeAttr &propValue) { + this->function_type = propValue; + } + using res_attrsTy = ::mlir::ArrayAttr; + res_attrsTy res_attrs; + + auto getResAttrs() { + auto &propStorage = this->res_attrs; + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(propStorage); + } + void setResAttrs(const ::mlir::ArrayAttr &propValue) { + this->res_attrs = propValue; + } + using sym_nameTy = ::mlir::StringAttr; + sym_nameTy sym_name; + + auto getSymName() { + auto &propStorage = this->sym_name; + return ::llvm::cast<::mlir::StringAttr>(propStorage); + } + void setSymName(const ::mlir::StringAttr &propValue) { + this->sym_name = propValue; + } + using sym_visibilityTy = ::mlir::StringAttr; + sym_visibilityTy sym_visibility; + + auto getSymVisibility() { + auto &propStorage = this->sym_visibility; + return ::llvm::dyn_cast_or_null<::mlir::StringAttr>(propStorage); + } + void setSymVisibility(const ::mlir::StringAttr &propValue) { + this->sym_visibility = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.arg_attrs == this->arg_attrs && + rhs.function_type == this->function_type && + rhs.res_attrs == this->res_attrs && + rhs.sym_name == this->sym_name && + rhs.sym_visibility == this->sym_visibility && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + FuncOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + FuncOpGenericAdaptorBase(FuncOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::StringAttr getSymNameAttr(); + ::llvm::StringRef getSymName(); + ::mlir::TypeAttr getFunctionTypeAttr(); + ::mlir::FunctionType getFunctionType(); + ::mlir::ArrayAttr getArgAttrsAttr(); + ::std::optional< ::mlir::ArrayAttr > getArgAttrs(); + ::mlir::ArrayAttr getResAttrsAttr(); + ::std::optional< ::mlir::ArrayAttr > getResAttrs(); + ::mlir::StringAttr getSymVisibilityAttr(); + ::std::optional< ::llvm::StringRef > getSymVisibility(); + ::mlir::Region &getBody(); + ::mlir::RegionRange getRegions(); +}; +} // namespace detail +template +class FuncOpGenericAdaptor : public detail::FuncOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::FuncOpGenericAdaptorBase; +public: + FuncOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + FuncOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : FuncOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + FuncOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class FuncOpAdaptor : public FuncOpGenericAdaptor<::mlir::ValueRange> { +public: + using FuncOpGenericAdaptor::FuncOpGenericAdaptor; + FuncOpAdaptor(FuncOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class FuncOp : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = FuncOpAdaptor; + template + using GenericAdaptor = FuncOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("arg_attrs"), ::llvm::StringRef("function_type"), ::llvm::StringRef("res_attrs"), ::llvm::StringRef("sym_name"), ::llvm::StringRef("sym_visibility")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getArgAttrsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getArgAttrsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getFunctionTypeAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getFunctionTypeAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getResAttrsAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getResAttrsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getSymNameAttrName() { + return getAttributeNameForIndex(3); + } + + static ::mlir::StringAttr getSymNameAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 3); + } + + ::mlir::StringAttr getSymVisibilityAttrName() { + return getAttributeNameForIndex(4); + } + + static ::mlir::StringAttr getSymVisibilityAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 4); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.func"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Region &getBody(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::StringAttr getSymNameAttr(); + ::llvm::StringRef getSymName(); + ::mlir::TypeAttr getFunctionTypeAttr(); + ::mlir::FunctionType getFunctionType(); + ::mlir::ArrayAttr getArgAttrsAttr(); + ::std::optional< ::mlir::ArrayAttr > getArgAttrs(); + ::mlir::ArrayAttr getResAttrsAttr(); + ::std::optional< ::mlir::ArrayAttr > getResAttrs(); + ::mlir::StringAttr getSymVisibilityAttr(); + ::std::optional< ::llvm::StringRef > getSymVisibility(); + void setSymNameAttr(::mlir::StringAttr attr); + void setSymName(::llvm::StringRef attrValue); + void setFunctionTypeAttr(::mlir::TypeAttr attr); + void setFunctionType(::mlir::FunctionType attrValue); + void setArgAttrsAttr(::mlir::ArrayAttr attr); + void setResAttrsAttr(::mlir::ArrayAttr attr); + void setSymVisibilityAttr(::mlir::StringAttr attr); + void setSymVisibility(::std::optional<::llvm::StringRef> attrValue); + ::mlir::Attribute removeArgAttrsAttr(); + ::mlir::Attribute removeResAttrsAttr(); + ::mlir::Attribute removeSymVisibilityAttr(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, StringRef name, FunctionType type, ArrayRef attrs = {}, ArrayRef argAttrs = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::StringAttr sym_name, ::mlir::TypeAttr function_type, /*optional*/::mlir::ArrayAttr arg_attrs, /*optional*/::mlir::ArrayAttr res_attrs, /*optional*/::mlir::StringAttr sym_visibility); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, ::mlir::TypeAttr function_type, /*optional*/::mlir::ArrayAttr arg_attrs, /*optional*/::mlir::ArrayAttr res_attrs, /*optional*/::mlir::StringAttr sym_visibility); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llvm::StringRef sym_name, ::mlir::FunctionType function_type, /*optional*/::mlir::ArrayAttr arg_attrs, /*optional*/::mlir::ArrayAttr res_attrs, /*optional*/::mlir::StringAttr sym_visibility); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, ::mlir::FunctionType function_type, /*optional*/::mlir::ArrayAttr arg_attrs, /*optional*/::mlir::ArrayAttr res_attrs, /*optional*/::mlir::StringAttr sym_visibility); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &p); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 5 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + static FuncOp create(Location location, StringRef name, FunctionType type, + ArrayRef attrs = {}); + static FuncOp create(Location location, StringRef name, FunctionType type, + Operation::dialect_attr_range attrs); + static FuncOp create(Location location, StringRef name, FunctionType type, + ArrayRef attrs, + ArrayRef argAttrs); + //===------------------------------------------------------------------===// + // FunctionOpInterface Methods + //===------------------------------------------------------------------===// + + /// Returns the region on the current operation that is callable. This may + /// return null in the case of an external callable object, e.g. an external + /// function. + ::mlir::Region *getCallableRegion() { + return isExternal() ? nullptr : &getBody(); + } + + /// Returns the argument types of this function. + ArrayRef getArgumentTypes() { return getFunctionType().getInputs(); } + + /// Returns the result types of this function. + ArrayRef getResultTypes() { return getFunctionType().getResults(); } + + //===------------------------------------------------------------------===// + // OpAsmOpInterface + //===------------------------------------------------------------------===// + + // This will filter the `shape.` prefix in front of operations inside the + // func body. + static StringRef getDefaultDialect() { return "shape";} + + //===------------------------------------------------------------------===// + // SymbolOpInterface Methods + //===------------------------------------------------------------------===// + + bool isDeclaration() { return isExternal(); } +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::FuncOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::FunctionLibraryOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class FunctionLibraryOpGenericAdaptorBase { +public: + struct Properties { + using mappingTy = ::mlir::DictionaryAttr; + mappingTy mapping; + + auto getMapping() { + auto &propStorage = this->mapping; + return ::llvm::cast<::mlir::DictionaryAttr>(propStorage); + } + void setMapping(const ::mlir::DictionaryAttr &propValue) { + this->mapping = propValue; + } + using sym_nameTy = ::mlir::StringAttr; + sym_nameTy sym_name; + + auto getSymName() { + auto &propStorage = this->sym_name; + return ::llvm::cast<::mlir::StringAttr>(propStorage); + } + void setSymName(const ::mlir::StringAttr &propValue) { + this->sym_name = propValue; + } + using sym_visibilityTy = ::mlir::StringAttr; + sym_visibilityTy sym_visibility; + + auto getSymVisibility() { + auto &propStorage = this->sym_visibility; + return ::llvm::dyn_cast_or_null<::mlir::StringAttr>(propStorage); + } + void setSymVisibility(const ::mlir::StringAttr &propValue) { + this->sym_visibility = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.mapping == this->mapping && + rhs.sym_name == this->sym_name && + rhs.sym_visibility == this->sym_visibility && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + FunctionLibraryOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + FunctionLibraryOpGenericAdaptorBase(FunctionLibraryOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::StringAttr getSymNameAttr(); + ::llvm::StringRef getSymName(); + ::mlir::StringAttr getSymVisibilityAttr(); + ::std::optional< ::llvm::StringRef > getSymVisibility(); + ::mlir::DictionaryAttr getMappingAttr(); + ::mlir::DictionaryAttr getMapping(); + ::mlir::Region &getBody(); + ::mlir::RegionRange getRegions(); +}; +} // namespace detail +template +class FunctionLibraryOpGenericAdaptor : public detail::FunctionLibraryOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::FunctionLibraryOpGenericAdaptorBase; +public: + FunctionLibraryOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + FunctionLibraryOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : FunctionLibraryOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + FunctionLibraryOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class FunctionLibraryOpAdaptor : public FunctionLibraryOpGenericAdaptor<::mlir::ValueRange> { +public: + using FunctionLibraryOpGenericAdaptor::FunctionLibraryOpGenericAdaptor; + FunctionLibraryOpAdaptor(FunctionLibraryOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class FunctionLibraryOp : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = FunctionLibraryOpAdaptor; + template + using GenericAdaptor = FunctionLibraryOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("mapping"), ::llvm::StringRef("sym_name"), ::llvm::StringRef("sym_visibility")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getMappingAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getMappingAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getSymNameAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getSymNameAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getSymVisibilityAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getSymVisibilityAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.function_library"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Region &getBody(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::StringAttr getSymNameAttr(); + ::llvm::StringRef getSymName(); + ::mlir::StringAttr getSymVisibilityAttr(); + ::std::optional< ::llvm::StringRef > getSymVisibility(); + ::mlir::DictionaryAttr getMappingAttr(); + ::mlir::DictionaryAttr getMapping(); + void setSymNameAttr(::mlir::StringAttr attr); + void setSymName(::llvm::StringRef attrValue); + void setSymVisibilityAttr(::mlir::StringAttr attr); + void setSymVisibility(::std::optional<::llvm::StringRef> attrValue); + void setMappingAttr(::mlir::DictionaryAttr attr); + ::mlir::Attribute removeSymVisibilityAttr(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, StringRef name); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &p); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 3 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + /// Returns an associated shape function for an operation if defined. + FuncOp getShapeFunction(Operation *op); + + //===------------------------------------------------------------------===// + // OpAsmOpInterface + //===------------------------------------------------------------------===// + + // This will filter the `shape.` prefix in front of operations inside the + // func body. + static StringRef getDefaultDialect() { return "shape";} +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::FunctionLibraryOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::GetExtentOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class GetExtentOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + GetExtentOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + GetExtentOpGenericAdaptorBase(GetExtentOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class GetExtentOpGenericAdaptor : public detail::GetExtentOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::GetExtentOpGenericAdaptorBase; +public: + GetExtentOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + GetExtentOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : GetExtentOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + GetExtentOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getShape() { + return (*getODSOperands(0).begin()); + } + + ValueT getDim() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class GetExtentOpAdaptor : public GetExtentOpGenericAdaptor<::mlir::ValueRange> { +public: + using GetExtentOpGenericAdaptor::GetExtentOpGenericAdaptor; + GetExtentOpAdaptor(GetExtentOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class GetExtentOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::OpTrait::InferTypeOpAdaptor> { +public: + using Op::Op; + using Op::print; + using Adaptor = GetExtentOpAdaptor; + template + using GenericAdaptor = GetExtentOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.get_extent"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getShape(); + ::mlir::Value getDim(); + ::mlir::OpOperand &getShapeMutable(); + ::mlir::OpOperand &getDimMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getExtent(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value shape, int64_t dim); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type extent, ::mlir::Value shape, ::mlir::Value dim); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value shape, ::mlir::Value dim); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value shape, ::mlir::Value dim); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + static ::mlir::LogicalResult + inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + Adaptor adaptor, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes); + + static bool isCompatibleReturnTypes(::mlir::TypeRange l, ::mlir::TypeRange r); + + + /// Get the `dim` value as integer if it is constant. + std::optional getConstantDim(); +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::GetExtentOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::IndexToSizeOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class IndexToSizeOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + IndexToSizeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + IndexToSizeOpGenericAdaptorBase(IndexToSizeOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class IndexToSizeOpGenericAdaptor : public detail::IndexToSizeOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::IndexToSizeOpGenericAdaptorBase; +public: + IndexToSizeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + IndexToSizeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : IndexToSizeOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + IndexToSizeOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getArg() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class IndexToSizeOpAdaptor : public IndexToSizeOpGenericAdaptor<::mlir::ValueRange> { +public: + using IndexToSizeOpGenericAdaptor::IndexToSizeOpGenericAdaptor; + IndexToSizeOpAdaptor(IndexToSizeOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class IndexToSizeOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = IndexToSizeOpAdaptor; + template + using GenericAdaptor = IndexToSizeOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.index_to_size"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::IndexType> getArg(); + ::mlir::OpOperand &getArgMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::shape::SizeType> getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value arg); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value arg); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value arg); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::IndexToSizeOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::IsBroadcastableOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class IsBroadcastableOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + IsBroadcastableOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + IsBroadcastableOpGenericAdaptorBase(IsBroadcastableOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class IsBroadcastableOpGenericAdaptor : public detail::IsBroadcastableOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::IsBroadcastableOpGenericAdaptorBase; +public: + IsBroadcastableOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + IsBroadcastableOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : IsBroadcastableOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + IsBroadcastableOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getShapes() { + return getODSOperands(0); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class IsBroadcastableOpAdaptor : public IsBroadcastableOpGenericAdaptor<::mlir::ValueRange> { +public: + using IsBroadcastableOpGenericAdaptor::IsBroadcastableOpGenericAdaptor; + IsBroadcastableOpAdaptor(IsBroadcastableOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class IsBroadcastableOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::OpInvariants, ::mlir::OpTrait::IsCommutative, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = IsBroadcastableOpAdaptor; + template + using GenericAdaptor = IsBroadcastableOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.is_broadcastable"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Operation::operand_range getShapes(); + ::mlir::MutableOperandRange getShapesMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::IntegerType> getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange shapes); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +public: +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::IsBroadcastableOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::MaxOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class MaxOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + MaxOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + MaxOpGenericAdaptorBase(MaxOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class MaxOpGenericAdaptor : public detail::MaxOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::MaxOpGenericAdaptorBase; +public: + MaxOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + MaxOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : MaxOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + MaxOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class MaxOpAdaptor : public MaxOpGenericAdaptor<::mlir::ValueRange> { +public: + using MaxOpGenericAdaptor::MaxOpGenericAdaptor; + MaxOpAdaptor(MaxOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class MaxOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::OpTrait::IsCommutative, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::OpTrait::InferTypeOpAdaptor> { +public: + using Op::Op; + using Op::print; + using Adaptor = MaxOpAdaptor; + template + using GenericAdaptor = MaxOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.max"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getLhs(); + ::mlir::Value getRhs(); + ::mlir::OpOperand &getLhsMutable(); + ::mlir::OpOperand &getRhsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + static ::mlir::LogicalResult + inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + Adaptor adaptor, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes); + + static bool isCompatibleReturnTypes(::mlir::TypeRange l, ::mlir::TypeRange r); + +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::MaxOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::MeetOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class MeetOpGenericAdaptorBase { +public: + struct Properties { + using errorTy = ::mlir::StringAttr; + errorTy error; + + auto getError() { + auto &propStorage = this->error; + return ::llvm::dyn_cast_or_null<::mlir::StringAttr>(propStorage); + } + void setError(const ::mlir::StringAttr &propValue) { + this->error = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.error == this->error && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + MeetOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + MeetOpGenericAdaptorBase(MeetOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::StringAttr getErrorAttr(); + ::std::optional< ::llvm::StringRef > getError(); +}; +} // namespace detail +template +class MeetOpGenericAdaptor : public detail::MeetOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::MeetOpGenericAdaptorBase; +public: + MeetOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + MeetOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : MeetOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + MeetOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getArg0() { + return (*getODSOperands(0).begin()); + } + + ValueT getArg1() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class MeetOpAdaptor : public MeetOpGenericAdaptor<::mlir::ValueRange> { +public: + using MeetOpGenericAdaptor::MeetOpGenericAdaptor; + MeetOpAdaptor(MeetOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class MeetOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpTrait::IsCommutative, ::mlir::InferTypeOpInterface::Trait, ::mlir::OpTrait::InferTypeOpAdaptor> { +public: + using Op::Op; + using Op::print; + using Adaptor = MeetOpAdaptor; + template + using GenericAdaptor = MeetOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("error")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getErrorAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getErrorAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.meet"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getArg0(); + ::mlir::Value getArg1(); + ::mlir::OpOperand &getArg0Mutable(); + ::mlir::OpOperand &getArg1Mutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getResult(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::StringAttr getErrorAttr(); + ::std::optional< ::llvm::StringRef > getError(); + void setErrorAttr(::mlir::StringAttr attr); + void setError(::std::optional<::llvm::StringRef> attrValue); + ::mlir::Attribute removeErrorAttr(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value arg0, ::mlir::Value arg1, /*optional*/::mlir::StringAttr error); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value arg0, ::mlir::Value arg1, /*optional*/::mlir::StringAttr error); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value arg0, ::mlir::Value arg1, /*optional*/::mlir::StringAttr error); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + static ::mlir::LogicalResult + inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + Adaptor adaptor, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes); + + static bool isCompatibleReturnTypes(::mlir::TypeRange l, ::mlir::TypeRange r); + +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::MeetOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::MinOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class MinOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + MinOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + MinOpGenericAdaptorBase(MinOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class MinOpGenericAdaptor : public detail::MinOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::MinOpGenericAdaptorBase; +public: + MinOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + MinOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : MinOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + MinOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class MinOpAdaptor : public MinOpGenericAdaptor<::mlir::ValueRange> { +public: + using MinOpGenericAdaptor::MinOpGenericAdaptor; + MinOpAdaptor(MinOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class MinOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::OpTrait::IsCommutative, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::OpTrait::InferTypeOpAdaptor> { +public: + using Op::Op; + using Op::print; + using Adaptor = MinOpAdaptor; + template + using GenericAdaptor = MinOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.min"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getLhs(); + ::mlir::Value getRhs(); + ::mlir::OpOperand &getLhsMutable(); + ::mlir::OpOperand &getRhsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + static ::mlir::LogicalResult + inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + Adaptor adaptor, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes); + + static bool isCompatibleReturnTypes(::mlir::TypeRange l, ::mlir::TypeRange r); + +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::MinOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::MulOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class MulOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + MulOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + MulOpGenericAdaptorBase(MulOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class MulOpGenericAdaptor : public detail::MulOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::MulOpGenericAdaptorBase; +public: + MulOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + MulOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : MulOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + MulOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class MulOpAdaptor : public MulOpGenericAdaptor<::mlir::ValueRange> { +public: + using MulOpGenericAdaptor::MulOpGenericAdaptor; + MulOpAdaptor(MulOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class MulOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::OpTrait::IsCommutative, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::OpTrait::InferTypeOpAdaptor> { +public: + using Op::Op; + using Op::print; + using Adaptor = MulOpAdaptor; + template + using GenericAdaptor = MulOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.mul"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getLhs(); + ::mlir::Value getRhs(); + ::mlir::OpOperand &getLhsMutable(); + ::mlir::OpOperand &getRhsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + static ::mlir::LogicalResult + inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + Adaptor adaptor, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes); + + static bool isCompatibleReturnTypes(::mlir::TypeRange l, ::mlir::TypeRange r); + +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::MulOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::NumElementsOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class NumElementsOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + NumElementsOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + NumElementsOpGenericAdaptorBase(NumElementsOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class NumElementsOpGenericAdaptor : public detail::NumElementsOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::NumElementsOpGenericAdaptorBase; +public: + NumElementsOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + NumElementsOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : NumElementsOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + NumElementsOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getShape() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class NumElementsOpAdaptor : public NumElementsOpGenericAdaptor<::mlir::ValueRange> { +public: + using NumElementsOpGenericAdaptor::NumElementsOpGenericAdaptor; + NumElementsOpAdaptor(NumElementsOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class NumElementsOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::OpTrait::InferTypeOpAdaptor> { +public: + using Op::Op; + using Op::print; + using Adaptor = NumElementsOpAdaptor; + template + using GenericAdaptor = NumElementsOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.num_elements"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getShape(); + ::mlir::OpOperand &getShapeMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value shape); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value shape); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value shape); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + static ::mlir::LogicalResult + inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + Adaptor adaptor, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes); + + static bool isCompatibleReturnTypes(::mlir::TypeRange l, ::mlir::TypeRange r); + +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::NumElementsOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::RankOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class RankOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + RankOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + RankOpGenericAdaptorBase(RankOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class RankOpGenericAdaptor : public detail::RankOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::RankOpGenericAdaptorBase; +public: + RankOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + RankOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : RankOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + RankOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getShape() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class RankOpAdaptor : public RankOpGenericAdaptor<::mlir::ValueRange> { +public: + using RankOpGenericAdaptor::RankOpGenericAdaptor; + RankOpAdaptor(RankOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class RankOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::OpTrait::InferTypeOpAdaptor> { +public: + using Op::Op; + using Op::print; + using Adaptor = RankOpAdaptor; + template + using GenericAdaptor = RankOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.rank"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getShape(); + ::mlir::OpOperand &getShapeMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getRank(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type rank, ::mlir::Value shape); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value shape); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value shape); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + static ::mlir::LogicalResult + inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + Adaptor adaptor, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes); + + static bool isCompatibleReturnTypes(::mlir::TypeRange l, ::mlir::TypeRange r); + +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::RankOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::ReduceOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ReduceOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + ReduceOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + ReduceOpGenericAdaptorBase(ReduceOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); + ::mlir::Region &getRegion(); + ::mlir::RegionRange getRegions(); +}; +} // namespace detail +template +class ReduceOpGenericAdaptor : public detail::ReduceOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ReduceOpGenericAdaptorBase; +public: + ReduceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ReduceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ReduceOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + ReduceOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getShape() { + return (*getODSOperands(0).begin()); + } + + RangeT getInitVals() { + return getODSOperands(1); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ReduceOpAdaptor : public ReduceOpGenericAdaptor<::mlir::ValueRange> { +public: + using ReduceOpGenericAdaptor::ReduceOpGenericAdaptor; + ReduceOpAdaptor(ReduceOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ReduceOp : public ::mlir::Op::Impl, ::mlir::OpTrait::SingleBlock, ::mlir::OpTrait::SingleBlockImplicitTerminator::Impl, ::mlir::OpTrait::OpInvariants> { +public: + using Op::Op; + using Op::print; + using Adaptor = ReduceOpAdaptor; + template + using GenericAdaptor = ReduceOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.reduce"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getShape(); + ::mlir::Operation::operand_range getInitVals(); + ::mlir::OpOperand &getShapeMutable(); + ::mlir::MutableOperandRange getInitValsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Operation::result_range getResult(); + ::mlir::Region &getRegion(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value shape, ValueRange initVals); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange result, ::mlir::Value shape, ::mlir::ValueRange initVals); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &p); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); +public: +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::ReduceOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::ReturnOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ReturnOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + ReturnOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + ReturnOpGenericAdaptorBase(ReturnOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class ReturnOpGenericAdaptor : public detail::ReturnOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ReturnOpGenericAdaptorBase; +public: + ReturnOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ReturnOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ReturnOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + ReturnOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return getODSOperands(0); + } + +private: + RangeT odsOperands; +}; +class ReturnOpAdaptor : public ReturnOpGenericAdaptor<::mlir::ValueRange> { +public: + using ReturnOpGenericAdaptor::ReturnOpGenericAdaptor; + ReturnOpAdaptor(ReturnOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ReturnOp : public ::mlir::Op::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::RegionBranchTerminatorOpInterface::Trait, ::mlir::OpTrait::ReturnLike, ::mlir::OpTrait::IsTerminator> { +public: + using Op::Op; + using Op::print; + using Adaptor = ReturnOpAdaptor; + template + using GenericAdaptor = ReturnOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.return"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Operation::operand_range getOperands(); + ::mlir::MutableOperandRange getOperandsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::MutableOperandRange getMutableSuccessorOperands(::mlir::RegionBranchPoint point); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::ReturnOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::ShapeEqOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ShapeEqOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + ShapeEqOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + ShapeEqOpGenericAdaptorBase(ShapeEqOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class ShapeEqOpGenericAdaptor : public detail::ShapeEqOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ShapeEqOpGenericAdaptorBase; +public: + ShapeEqOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ShapeEqOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ShapeEqOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + ShapeEqOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getShapes() { + return getODSOperands(0); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ShapeEqOpAdaptor : public ShapeEqOpGenericAdaptor<::mlir::ValueRange> { +public: + using ShapeEqOpGenericAdaptor::ShapeEqOpGenericAdaptor; + ShapeEqOpAdaptor(ShapeEqOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ShapeEqOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::IsCommutative, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ShapeEqOpAdaptor; + template + using GenericAdaptor = ShapeEqOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.shape_eq"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Operation::operand_range getShapes(); + ::mlir::MutableOperandRange getShapesMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::IntegerType> getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange shapes); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::ShapeEqOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::ShapeOfOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ShapeOfOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + ShapeOfOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + ShapeOfOpGenericAdaptorBase(ShapeOfOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class ShapeOfOpGenericAdaptor : public detail::ShapeOfOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ShapeOfOpGenericAdaptorBase; +public: + ShapeOfOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ShapeOfOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ShapeOfOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + ShapeOfOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getArg() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ShapeOfOpAdaptor : public ShapeOfOpGenericAdaptor<::mlir::ValueRange> { +public: + using ShapeOfOpGenericAdaptor::ShapeOfOpGenericAdaptor; + ShapeOfOpAdaptor(ShapeOfOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ShapeOfOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::OpTrait::InferTypeOpAdaptor> { +public: + using Op::Op; + using Op::print; + using Adaptor = ShapeOfOpAdaptor; + template + using GenericAdaptor = ShapeOfOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.shape_of"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getArg(); + ::mlir::OpOperand &getArgMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value arg); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value arg); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value arg); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + static ::mlir::LogicalResult + inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + Adaptor adaptor, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes); + + static bool isCompatibleReturnTypes(::mlir::TypeRange l, ::mlir::TypeRange r); + +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::ShapeOfOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::SizeToIndexOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class SizeToIndexOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + SizeToIndexOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + SizeToIndexOpGenericAdaptorBase(SizeToIndexOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class SizeToIndexOpGenericAdaptor : public detail::SizeToIndexOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::SizeToIndexOpGenericAdaptorBase; +public: + SizeToIndexOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + SizeToIndexOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : SizeToIndexOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + SizeToIndexOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getArg() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class SizeToIndexOpAdaptor : public SizeToIndexOpGenericAdaptor<::mlir::ValueRange> { +public: + using SizeToIndexOpGenericAdaptor::SizeToIndexOpGenericAdaptor; + SizeToIndexOpAdaptor(SizeToIndexOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class SizeToIndexOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::CastOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = SizeToIndexOpAdaptor; + template + using GenericAdaptor = SizeToIndexOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.size_to_index"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getArg(); + ::mlir::OpOperand &getArgMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::IndexType> getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value arg); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value arg); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value arg); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static bool areCastCompatible(::mlir::TypeRange inputs, ::mlir::TypeRange outputs); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::SizeToIndexOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::SplitAtOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class SplitAtOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + SplitAtOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + SplitAtOpGenericAdaptorBase(SplitAtOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class SplitAtOpGenericAdaptor : public detail::SplitAtOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::SplitAtOpGenericAdaptorBase; +public: + SplitAtOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + SplitAtOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : SplitAtOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + SplitAtOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + ValueT getIndex() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class SplitAtOpAdaptor : public SplitAtOpGenericAdaptor<::mlir::ValueRange> { +public: + using SplitAtOpGenericAdaptor::SplitAtOpGenericAdaptor; + SplitAtOpAdaptor(SplitAtOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class SplitAtOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpAsmOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = SplitAtOpAdaptor; + template + using GenericAdaptor = SplitAtOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn); + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.split_at"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getOperand(); + ::mlir::Value getIndex(); + ::mlir::OpOperand &getOperandMutable(); + ::mlir::OpOperand &getIndexMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getHead(); + ::mlir::Value getTail(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type head, ::mlir::Type tail, ::mlir::Value operand, ::mlir::Value index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value index); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult fold(FoldAdaptor adaptor, ::llvm::SmallVectorImpl<::mlir::OpFoldResult> &results); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::SplitAtOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::ToExtentTensorOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ToExtentTensorOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + ToExtentTensorOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + ToExtentTensorOpGenericAdaptorBase(ToExtentTensorOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class ToExtentTensorOpGenericAdaptor : public detail::ToExtentTensorOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ToExtentTensorOpGenericAdaptorBase; +public: + ToExtentTensorOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ToExtentTensorOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ToExtentTensorOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + ToExtentTensorOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getInput() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ToExtentTensorOpAdaptor : public ToExtentTensorOpGenericAdaptor<::mlir::ValueRange> { +public: + using ToExtentTensorOpGenericAdaptor::ToExtentTensorOpGenericAdaptor; + ToExtentTensorOpAdaptor(ToExtentTensorOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ToExtentTensorOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::CastOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ToExtentTensorOpAdaptor; + template + using GenericAdaptor = ToExtentTensorOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.to_extent_tensor"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getInput(); + ::mlir::OpOperand &getInputMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::TensorType> getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value input); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static bool areCastCompatible(::mlir::TypeRange inputs, ::mlir::TypeRange outputs); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::ToExtentTensorOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::ValueAsShapeOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ValueAsShapeOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + ValueAsShapeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + ValueAsShapeOpGenericAdaptorBase(ValueAsShapeOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class ValueAsShapeOpGenericAdaptor : public detail::ValueAsShapeOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ValueAsShapeOpGenericAdaptorBase; +public: + ValueAsShapeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ValueAsShapeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ValueAsShapeOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + ValueAsShapeOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getArg() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ValueAsShapeOpAdaptor : public ValueAsShapeOpGenericAdaptor<::mlir::ValueRange> { +public: + using ValueAsShapeOpGenericAdaptor::ValueAsShapeOpGenericAdaptor; + ValueAsShapeOpAdaptor(ValueAsShapeOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ValueAsShapeOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ValueAsShapeOpAdaptor; + template + using GenericAdaptor = ValueAsShapeOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.value_as_shape"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getArg(); + ::mlir::OpOperand &getArgMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value arg); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value arg); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::ValueAsShapeOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::ValueOfOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ValueOfOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + ValueOfOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + ValueOfOpGenericAdaptorBase(ValueOfOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class ValueOfOpGenericAdaptor : public detail::ValueOfOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ValueOfOpGenericAdaptorBase; +public: + ValueOfOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ValueOfOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ValueOfOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + ValueOfOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getArg() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ValueOfOpAdaptor : public ValueOfOpGenericAdaptor<::mlir::ValueRange> { +public: + using ValueOfOpGenericAdaptor::ValueOfOpGenericAdaptor; + ValueOfOpAdaptor(ValueOfOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ValueOfOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ValueOfOpAdaptor; + template + using GenericAdaptor = ValueOfOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.value_of"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::shape::ValueShapeType> getArg(); + ::mlir::OpOperand &getArgMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::ShapedType> getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value arg); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value arg); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::ValueOfOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::WithOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class WithOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + WithOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + WithOpGenericAdaptorBase(WithOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class WithOpGenericAdaptor : public detail::WithOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::WithOpGenericAdaptorBase; +public: + WithOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + WithOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : WithOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + WithOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperand() { + return (*getODSOperands(0).begin()); + } + + ValueT getShape() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class WithOpAdaptor : public WithOpGenericAdaptor<::mlir::ValueRange> { +public: + using WithOpGenericAdaptor::WithOpGenericAdaptor; + WithOpAdaptor(WithOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class WithOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = WithOpAdaptor; + template + using GenericAdaptor = WithOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.with_shape"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getOperand(); + ::mlir::Value getShape(); + ::mlir::OpOperand &getOperandMutable(); + ::mlir::OpOperand &getShapeMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::shape::ValueShapeType> getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value operand, ::mlir::Value shape); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand, ::mlir::Value shape); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand, ::mlir::Value shape); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::WithOp) + +namespace mlir { +namespace shape { + +//===----------------------------------------------------------------------===// +// ::mlir::shape::YieldOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class YieldOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + YieldOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + YieldOpGenericAdaptorBase(YieldOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class YieldOpGenericAdaptor : public detail::YieldOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::YieldOpGenericAdaptorBase; +public: + YieldOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + YieldOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : YieldOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + YieldOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return getODSOperands(0); + } + +private: + RangeT odsOperands; +}; +class YieldOpAdaptor : public YieldOpGenericAdaptor<::mlir::ValueRange> { +public: + using YieldOpGenericAdaptor::YieldOpGenericAdaptor; + YieldOpAdaptor(YieldOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class YieldOp : public ::mlir::Op::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::RegionBranchTerminatorOpInterface::Trait, ::mlir::OpTrait::ReturnLike, ::mlir::OpTrait::IsTerminator> { +public: + using Op::Op; + using Op::print; + using Adaptor = YieldOpAdaptor; + template + using GenericAdaptor = YieldOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("shape.yield"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Operation::operand_range getOperands(); + ::mlir::MutableOperandRange getOperandsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + ::mlir::MutableOperandRange getMutableSuccessorOperands(::mlir::RegionBranchPoint point); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::YieldOp) + + +#endif // GET_OP_CLASSES + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/ShapeOpsDialect.cpp.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/ShapeOpsDialect.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..316b0c2f5e2e4249403c19fa9cb26df675f4d604 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/ShapeOpsDialect.cpp.inc @@ -0,0 +1,27 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Dialect Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: ShapeOps.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::ShapeDialect) +namespace mlir { +namespace shape { + +ShapeDialect::ShapeDialect(::mlir::MLIRContext *context) + : ::mlir::Dialect(getDialectNamespace(), context, ::mlir::TypeID::get()) { + + getContext()->loadDialect(); + + getContext()->loadDialect(); + + initialize(); +} + +ShapeDialect::~ShapeDialect() = default; + +} // namespace shape +} // namespace mlir diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/ShapeOpsDialect.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/ShapeOpsDialect.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..594db49b0e756e7ac05f172aaca415dc85016256 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/ShapeOpsDialect.h.inc @@ -0,0 +1,45 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Dialect Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: ShapeOps.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace shape { + +class ShapeDialect : public ::mlir::Dialect { + explicit ShapeDialect(::mlir::MLIRContext *context); + + void initialize(); + friend class ::mlir::MLIRContext; +public: + ~ShapeDialect() override; + static constexpr ::llvm::StringLiteral getDialectNamespace() { + return ::llvm::StringLiteral("shape"); + } + + /// Parse a type registered to this dialect. + ::mlir::Type parseType(::mlir::DialectAsmParser &parser) const override; + + /// Print a type registered to this dialect. + void printType(::mlir::Type type, + ::mlir::DialectAsmPrinter &os) const override; + + /// Materialize a single constant operation from a given attribute value with + /// the desired resultant type. + ::mlir::Operation *materializeConstant(::mlir::OpBuilder &builder, + ::mlir::Attribute value, + ::mlir::Type type, + ::mlir::Location loc) override; + + /// Provides a hook for verifying dialect attributes attached to the given + /// op. + ::mlir::LogicalResult verifyOperationAttribute( + ::mlir::Operation *op, ::mlir::NamedAttribute attribute) override; +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::ShapeDialect) diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/ShapeOpsTypes.cpp.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/ShapeOpsTypes.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..bef2ea8f65930716e44547ef5cfd53e8572648f5 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/ShapeOpsTypes.cpp.inc @@ -0,0 +1,113 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* TypeDef Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifdef GET_TYPEDEF_LIST +#undef GET_TYPEDEF_LIST + +::mlir::shape::ShapeType, +::mlir::shape::SizeType, +::mlir::shape::ValueShapeType, +::mlir::shape::WitnessType + +#endif // GET_TYPEDEF_LIST + +#ifdef GET_TYPEDEF_CLASSES +#undef GET_TYPEDEF_CLASSES + +static ::mlir::OptionalParseResult generatedTypeParser(::mlir::AsmParser &parser, ::llvm::StringRef *mnemonic, ::mlir::Type &value) { + return ::mlir::AsmParser::KeywordSwitch<::mlir::OptionalParseResult>(parser) + .Case(::mlir::shape::ShapeType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::shape::ShapeType::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Case(::mlir::shape::SizeType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::shape::SizeType::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Case(::mlir::shape::ValueShapeType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::shape::ValueShapeType::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Case(::mlir::shape::WitnessType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::shape::WitnessType::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Default([&](llvm::StringRef keyword, llvm::SMLoc) { + *mnemonic = keyword; + return std::nullopt; + }); +} + +static ::mlir::LogicalResult generatedTypePrinter(::mlir::Type def, ::mlir::AsmPrinter &printer) { + return ::llvm::TypeSwitch<::mlir::Type, ::mlir::LogicalResult>(def) .Case<::mlir::shape::ShapeType>([&](auto t) { + printer << ::mlir::shape::ShapeType::getMnemonic(); + return ::mlir::success(); + }) + .Case<::mlir::shape::SizeType>([&](auto t) { + printer << ::mlir::shape::SizeType::getMnemonic(); + return ::mlir::success(); + }) + .Case<::mlir::shape::ValueShapeType>([&](auto t) { + printer << ::mlir::shape::ValueShapeType::getMnemonic(); + return ::mlir::success(); + }) + .Case<::mlir::shape::WitnessType>([&](auto t) { + printer << ::mlir::shape::WitnessType::getMnemonic(); + return ::mlir::success(); + }) + .Default([](auto) { return ::mlir::failure(); }); +} + +namespace mlir { +namespace shape { +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::ShapeType) +namespace mlir { +namespace shape { +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::SizeType) +namespace mlir { +namespace shape { +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::ValueShapeType) +namespace mlir { +namespace shape { +} // namespace shape +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::WitnessType) +namespace mlir { +namespace shape { + +/// Parse a type registered to this dialect. +::mlir::Type ShapeDialect::parseType(::mlir::DialectAsmParser &parser) const { + ::llvm::SMLoc typeLoc = parser.getCurrentLocation(); + ::llvm::StringRef mnemonic; + ::mlir::Type genType; + auto parseResult = generatedTypeParser(parser, &mnemonic, genType); + if (parseResult.has_value()) + return genType; + + parser.emitError(typeLoc) << "unknown type `" + << mnemonic << "` in dialect `" << getNamespace() << "`"; + return {}; +} +/// Print a type registered to this dialect. +void ShapeDialect::printType(::mlir::Type type, + ::mlir::DialectAsmPrinter &printer) const { + if (::mlir::succeeded(generatedTypePrinter(type, printer))) + return; + +} +} // namespace shape +} // namespace mlir + +#endif // GET_TYPEDEF_CLASSES + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/ShapeOpsTypes.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/ShapeOpsTypes.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..7313fc113c0561c78af131b297410d5e6ae1571b --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/ShapeOpsTypes.h.inc @@ -0,0 +1,63 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* TypeDef Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifdef GET_TYPEDEF_CLASSES +#undef GET_TYPEDEF_CLASSES + + +namespace mlir { +class AsmParser; +class AsmPrinter; +} // namespace mlir +namespace mlir { +namespace shape { +class ShapeType; +class SizeType; +class ValueShapeType; +class WitnessType; +class ShapeType : public ::mlir::Type::TypeBase { +public: + using Base::Base; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"shape"}; + } + +}; +class SizeType : public ::mlir::Type::TypeBase { +public: + using Base::Base; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"size"}; + } + +}; +class ValueShapeType : public ::mlir::Type::TypeBase { +public: + using Base::Base; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"value_shape"}; + } + +}; +class WitnessType : public ::mlir::Type::TypeBase { +public: + using Base::Base; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"witness"}; + } + +}; +} // namespace shape +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::ShapeType) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::SizeType) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::ValueShapeType) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::WitnessType) + +#endif // GET_TYPEDEF_CLASSES + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/Transforms/BufferizableOpInterfaceImpl.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/Transforms/BufferizableOpInterfaceImpl.h new file mode 100644 index 0000000000000000000000000000000000000000..bd898699de80051fb3366d494b4ab0a83d7dc03d --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/Transforms/BufferizableOpInterfaceImpl.h @@ -0,0 +1,20 @@ +//===- BufferizableOpInterfaceImpl.h - Impl. of BufferizableOpInterface ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_SHAPE_BUFFERIZABLEOPINTERFACEIMPL_H +#define MLIR_DIALECT_SHAPE_BUFFERIZABLEOPINTERFACEIMPL_H + +namespace mlir { +class DialectRegistry; + +namespace shape { +void registerBufferizableOpInterfaceExternalModels(DialectRegistry ®istry); +} // namespace shape +} // namespace mlir + +#endif // MLIR_DIALECT_SHAPE_BUFFERIZABLEOPINTERFACEIMPL_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/Transforms/Passes.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/Transforms/Passes.h new file mode 100644 index 0000000000000000000000000000000000000000..cfb637f133f54c5590ac2ef2271c2f3610c7a970 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/Transforms/Passes.h @@ -0,0 +1,71 @@ +//===- Passes.h - Pass Entrypoints ------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This header file defines prototypes that expose pass constructors in the +// shape transformation library. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_SHAPE_TRANSFORMS_PASSES_H_ +#define MLIR_DIALECT_SHAPE_TRANSFORMS_PASSES_H_ + +#include "mlir/Pass/Pass.h" + +namespace mlir { +class ConversionTarget; +class ModuleOp; +class TypeConverter; +namespace func { +class FuncOp; +} // namespace func +} // namespace mlir + +namespace mlir { + +#define GEN_PASS_DECL +#include "mlir/Dialect/Shape/Transforms/Passes.h.inc" + +/// Creates an instance of the ShapeToShapeLowering pass that legalizes Shape +/// dialect to be convertible to Arith. For example, `shape.num_elements` get +/// transformed to `shape.reduce`, which can be lowered to SCF and Arith. +std::unique_ptr createShapeToShapeLowering(); + +/// Collects a set of patterns to rewrite ops within the Shape dialect. +void populateShapeRewritePatterns(RewritePatternSet &patterns); + +// Collects a set of patterns to replace all constraints with passing witnesses. +// This is intended to then allow all ShapeConstraint related ops and data to +// have no effects and allow them to be freely removed such as through +// canonicalization and dead code elimination. +// +// After this pass, no cstr_ operations exist. +void populateRemoveShapeConstraintsPatterns(RewritePatternSet &patterns); +std::unique_ptr> createRemoveShapeConstraintsPass(); + +// Bufferizes shape dialect ops. +// +// Note that most shape dialect ops must be converted to std before +// bufferization happens, as they are intended to be bufferized at the std +// level. +std::unique_ptr> createShapeBufferizePass(); + +/// Outline the shape computation part by adding shape.func and populate +/// conrresponding mapping infomation into ShapeMappingAnalysis. +std::unique_ptr> createOutlineShapeComputationPass(); + +//===----------------------------------------------------------------------===// +// Registration +//===----------------------------------------------------------------------===// + +/// Generate the code for registering passes. +#define GEN_PASS_REGISTRATION +#include "mlir/Dialect/Shape/Transforms/Passes.h.inc" + +} // namespace mlir + +#endif // MLIR_DIALECT_SHAPE_TRANSFORMS_PASSES_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/Transforms/Passes.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/Transforms/Passes.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..f9f00a42f1e4d07f62dbd63fc0a82d787360fecf --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/Transforms/Passes.h.inc @@ -0,0 +1,520 @@ +/* Autogenerated by mlir-tblgen; don't manually edit */ + +#ifdef GEN_PASS_DECL +// Generate declarations for all passes. +#define GEN_PASS_DECL_OUTLINESHAPECOMPUTATION +#define GEN_PASS_DECL_REMOVESHAPECONSTRAINTS +#define GEN_PASS_DECL_SHAPEBUFFERIZE +#define GEN_PASS_DECL_SHAPETOSHAPELOWERING +#undef GEN_PASS_DECL +#endif // GEN_PASS_DECL + +//===----------------------------------------------------------------------===// +// OutlineShapeComputation +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_OUTLINESHAPECOMPUTATION +#undef GEN_PASS_DECL_OUTLINESHAPECOMPUTATION +#endif // GEN_PASS_DECL_OUTLINESHAPECOMPUTATION +#ifdef GEN_PASS_DEF_OUTLINESHAPECOMPUTATION +namespace impl { + +template +class OutlineShapeComputationBase : public ::mlir::OperationPass { +public: + using Base = OutlineShapeComputationBase; + + OutlineShapeComputationBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + OutlineShapeComputationBase(const OutlineShapeComputationBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("outline-shape-computation"); + } + ::llvm::StringRef getArgument() const override { return "outline-shape-computation"; } + + ::llvm::StringRef getDescription() const override { return "Using shape.func to preserve shape computation"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("OutlineShapeComputation"); + } + ::llvm::StringRef getName() const override { return "OutlineShapeComputation"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(OutlineShapeComputationBase) + +protected: +private: +}; +} // namespace impl +#undef GEN_PASS_DEF_OUTLINESHAPECOMPUTATION +#endif // GEN_PASS_DEF_OUTLINESHAPECOMPUTATION + +//===----------------------------------------------------------------------===// +// RemoveShapeConstraints +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_REMOVESHAPECONSTRAINTS +#undef GEN_PASS_DECL_REMOVESHAPECONSTRAINTS +#endif // GEN_PASS_DECL_REMOVESHAPECONSTRAINTS +#ifdef GEN_PASS_DEF_REMOVESHAPECONSTRAINTS +namespace impl { + +template +class RemoveShapeConstraintsBase : public ::mlir::OperationPass { +public: + using Base = RemoveShapeConstraintsBase; + + RemoveShapeConstraintsBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + RemoveShapeConstraintsBase(const RemoveShapeConstraintsBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("remove-shape-constraints"); + } + ::llvm::StringRef getArgument() const override { return "remove-shape-constraints"; } + + ::llvm::StringRef getDescription() const override { return "Replace all cstr_ ops with a true witness"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("RemoveShapeConstraints"); + } + ::llvm::StringRef getName() const override { return "RemoveShapeConstraints"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(RemoveShapeConstraintsBase) + +protected: +private: +}; +} // namespace impl +#undef GEN_PASS_DEF_REMOVESHAPECONSTRAINTS +#endif // GEN_PASS_DEF_REMOVESHAPECONSTRAINTS + +//===----------------------------------------------------------------------===// +// ShapeBufferize +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_SHAPEBUFFERIZE +#undef GEN_PASS_DECL_SHAPEBUFFERIZE +#endif // GEN_PASS_DECL_SHAPEBUFFERIZE +#ifdef GEN_PASS_DEF_SHAPEBUFFERIZE +namespace impl { + +template +class ShapeBufferizeBase : public ::mlir::OperationPass { +public: + using Base = ShapeBufferizeBase; + + ShapeBufferizeBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + ShapeBufferizeBase(const ShapeBufferizeBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("shape-bufferize"); + } + ::llvm::StringRef getArgument() const override { return "shape-bufferize"; } + + ::llvm::StringRef getDescription() const override { return "Bufferize the shape dialect."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("ShapeBufferize"); + } + ::llvm::StringRef getName() const override { return "ShapeBufferize"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ShapeBufferizeBase) + +protected: +private: +}; +} // namespace impl +#undef GEN_PASS_DEF_SHAPEBUFFERIZE +#endif // GEN_PASS_DEF_SHAPEBUFFERIZE + +//===----------------------------------------------------------------------===// +// ShapeToShapeLowering +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_SHAPETOSHAPELOWERING +#undef GEN_PASS_DECL_SHAPETOSHAPELOWERING +#endif // GEN_PASS_DECL_SHAPETOSHAPELOWERING +#ifdef GEN_PASS_DEF_SHAPETOSHAPELOWERING +namespace impl { + +template +class ShapeToShapeLoweringBase : public ::mlir::OperationPass { +public: + using Base = ShapeToShapeLoweringBase; + + ShapeToShapeLoweringBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + ShapeToShapeLoweringBase(const ShapeToShapeLoweringBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("shape-to-shape-lowering"); + } + ::llvm::StringRef getArgument() const override { return "shape-to-shape-lowering"; } + + ::llvm::StringRef getDescription() const override { return "Legalize Shape dialect to be convertible to Arith"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("ShapeToShapeLowering"); + } + ::llvm::StringRef getName() const override { return "ShapeToShapeLowering"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ShapeToShapeLoweringBase) + +protected: +private: +}; +} // namespace impl +#undef GEN_PASS_DEF_SHAPETOSHAPELOWERING +#endif // GEN_PASS_DEF_SHAPETOSHAPELOWERING +#ifdef GEN_PASS_REGISTRATION + +//===----------------------------------------------------------------------===// +// OutlineShapeComputation Registration +//===----------------------------------------------------------------------===// + +inline void registerOutlineShapeComputation() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createOutlineShapeComputationPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerOutlineShapeComputationPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createOutlineShapeComputationPass(); + }); +} + +//===----------------------------------------------------------------------===// +// RemoveShapeConstraints Registration +//===----------------------------------------------------------------------===// + +inline void registerRemoveShapeConstraints() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createRemoveShapeConstraintsPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerRemoveShapeConstraintsPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createRemoveShapeConstraintsPass(); + }); +} + +//===----------------------------------------------------------------------===// +// ShapeBufferize Registration +//===----------------------------------------------------------------------===// + +inline void registerShapeBufferize() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createShapeBufferizePass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerShapeBufferizePass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createShapeBufferizePass(); + }); +} + +//===----------------------------------------------------------------------===// +// ShapeToShapeLowering Registration +//===----------------------------------------------------------------------===// + +inline void registerShapeToShapeLowering() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createShapeToShapeLowering(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerShapeToShapeLoweringPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createShapeToShapeLowering(); + }); +} + +//===----------------------------------------------------------------------===// +// Shape Registration +//===----------------------------------------------------------------------===// + +inline void registerShapePasses() { + registerOutlineShapeComputation(); + registerRemoveShapeConstraints(); + registerShapeBufferize(); + registerShapeToShapeLowering(); +} +#undef GEN_PASS_REGISTRATION +#endif // GEN_PASS_REGISTRATION +// Deprecated. Please use the new per-pass macros. +#ifdef GEN_PASS_CLASSES + +template +class OutlineShapeComputationBase : public ::mlir::OperationPass { +public: + using Base = OutlineShapeComputationBase; + + OutlineShapeComputationBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + OutlineShapeComputationBase(const OutlineShapeComputationBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("outline-shape-computation"); + } + ::llvm::StringRef getArgument() const override { return "outline-shape-computation"; } + + ::llvm::StringRef getDescription() const override { return "Using shape.func to preserve shape computation"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("OutlineShapeComputation"); + } + ::llvm::StringRef getName() const override { return "OutlineShapeComputation"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(OutlineShapeComputationBase) + +protected: +}; + +template +class RemoveShapeConstraintsBase : public ::mlir::OperationPass { +public: + using Base = RemoveShapeConstraintsBase; + + RemoveShapeConstraintsBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + RemoveShapeConstraintsBase(const RemoveShapeConstraintsBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("remove-shape-constraints"); + } + ::llvm::StringRef getArgument() const override { return "remove-shape-constraints"; } + + ::llvm::StringRef getDescription() const override { return "Replace all cstr_ ops with a true witness"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("RemoveShapeConstraints"); + } + ::llvm::StringRef getName() const override { return "RemoveShapeConstraints"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(RemoveShapeConstraintsBase) + +protected: +}; + +template +class ShapeBufferizeBase : public ::mlir::OperationPass { +public: + using Base = ShapeBufferizeBase; + + ShapeBufferizeBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + ShapeBufferizeBase(const ShapeBufferizeBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("shape-bufferize"); + } + ::llvm::StringRef getArgument() const override { return "shape-bufferize"; } + + ::llvm::StringRef getDescription() const override { return "Bufferize the shape dialect."; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("ShapeBufferize"); + } + ::llvm::StringRef getName() const override { return "ShapeBufferize"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ShapeBufferizeBase) + +protected: +}; + +template +class ShapeToShapeLoweringBase : public ::mlir::OperationPass { +public: + using Base = ShapeToShapeLoweringBase; + + ShapeToShapeLoweringBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + ShapeToShapeLoweringBase(const ShapeToShapeLoweringBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("shape-to-shape-lowering"); + } + ::llvm::StringRef getArgument() const override { return "shape-to-shape-lowering"; } + + ::llvm::StringRef getDescription() const override { return "Legalize Shape dialect to be convertible to Arith"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("ShapeToShapeLowering"); + } + ::llvm::StringRef getName() const override { return "ShapeToShapeLowering"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ShapeToShapeLoweringBase) + +protected: +}; +#undef GEN_PASS_CLASSES +#endif // GEN_PASS_CLASSES diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/Enums.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/Enums.h new file mode 100644 index 0000000000000000000000000000000000000000..2920ef79f461c6abf584d615af01d8ad0ff87b0c --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/Enums.h @@ -0,0 +1,451 @@ +//===- Enums.h - Enums for the SparseTensor dialect -------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Typedefs and enums shared between MLIR code for manipulating the +// IR, and the lightweight runtime support library for sparse tensor +// manipulations. That is, all the enums are used to define the API +// of the runtime library and hence are also needed when generating +// calls into the runtime library. Moveover, the `DimLevelType` enum +// is also used as the internal IR encoding of dimension level types, +// to avoid code duplication (e.g., for the predicates). +// +// This file also defines x-macros +// so that we can generate variations of the public functions for each +// supported primary- and/or overhead-type. +// +// Because this file defines a library which is a dependency of the +// runtime library itself, this file must not depend on any MLIR internals +// (e.g., operators, attributes, ArrayRefs, etc) lest the runtime library +// inherit those dependencies. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_SPARSETENSOR_IR_ENUMS_H +#define MLIR_DIALECT_SPARSETENSOR_IR_ENUMS_H + +// NOTE: Client code will need to include "mlir/ExecutionEngine/Float16bits.h" +// if they want to use the `MLIR_SPARSETENSOR_FOREVERY_V` macro. + +#include +#include +#include + +namespace mlir { +namespace sparse_tensor { + +/// This type is used in the public API at all places where MLIR expects +/// values with the built-in type "index". For now, we simply assume that +/// type is 64-bit, but targets with different "index" bitwidths should +/// link with an alternatively built runtime support library. +using index_type = uint64_t; + +/// Encoding of overhead types (both position overhead and coordinate +/// overhead), for "overloading" @newSparseTensor. +enum class OverheadType : uint32_t { + kIndex = 0, + kU64 = 1, + kU32 = 2, + kU16 = 3, + kU8 = 4 +}; + +// This x-macro calls its argument on every overhead type which has +// fixed-width. It excludes `index_type` because that type is often +// handled specially (e.g., by translating it into the architecture-dependent +// equivalent fixed-width overhead type). +#define MLIR_SPARSETENSOR_FOREVERY_FIXED_O(DO) \ + DO(64, uint64_t) \ + DO(32, uint32_t) \ + DO(16, uint16_t) \ + DO(8, uint8_t) + +// This x-macro calls its argument on every overhead type, including +// `index_type`. +#define MLIR_SPARSETENSOR_FOREVERY_O(DO) \ + MLIR_SPARSETENSOR_FOREVERY_FIXED_O(DO) \ + DO(0, index_type) + +// These are not just shorthands but indicate the particular +// implementation used (e.g., as opposed to C99's `complex double`, +// or MLIR's `ComplexType`). +using complex64 = std::complex; +using complex32 = std::complex; + +/// Encoding of the elemental type, for "overloading" @newSparseTensor. +enum class PrimaryType : uint32_t { + kF64 = 1, + kF32 = 2, + kF16 = 3, + kBF16 = 4, + kI64 = 5, + kI32 = 6, + kI16 = 7, + kI8 = 8, + kC64 = 9, + kC32 = 10 +}; + +// This x-macro includes all `V` types. +#define MLIR_SPARSETENSOR_FOREVERY_V(DO) \ + DO(F64, double) \ + DO(F32, float) \ + DO(F16, f16) \ + DO(BF16, bf16) \ + DO(I64, int64_t) \ + DO(I32, int32_t) \ + DO(I16, int16_t) \ + DO(I8, int8_t) \ + DO(C64, complex64) \ + DO(C32, complex32) + +// This x-macro includes all `V` types and supports variadic arguments. +#define MLIR_SPARSETENSOR_FOREVERY_V_VAR(DO, ...) \ + DO(F64, double, __VA_ARGS__) \ + DO(F32, float, __VA_ARGS__) \ + DO(F16, f16, __VA_ARGS__) \ + DO(BF16, bf16, __VA_ARGS__) \ + DO(I64, int64_t, __VA_ARGS__) \ + DO(I32, int32_t, __VA_ARGS__) \ + DO(I16, int16_t, __VA_ARGS__) \ + DO(I8, int8_t, __VA_ARGS__) \ + DO(C64, complex64, __VA_ARGS__) \ + DO(C32, complex32, __VA_ARGS__) + +// This x-macro calls its argument on every pair of overhead and `V` types. +#define MLIR_SPARSETENSOR_FOREVERY_V_O(DO) \ + MLIR_SPARSETENSOR_FOREVERY_V_VAR(DO, 64, uint64_t) \ + MLIR_SPARSETENSOR_FOREVERY_V_VAR(DO, 32, uint32_t) \ + MLIR_SPARSETENSOR_FOREVERY_V_VAR(DO, 16, uint16_t) \ + MLIR_SPARSETENSOR_FOREVERY_V_VAR(DO, 8, uint8_t) \ + MLIR_SPARSETENSOR_FOREVERY_V_VAR(DO, 0, index_type) + +constexpr bool isFloatingPrimaryType(PrimaryType valTy) { + return PrimaryType::kF64 <= valTy && valTy <= PrimaryType::kBF16; +} + +constexpr bool isIntegralPrimaryType(PrimaryType valTy) { + return PrimaryType::kI64 <= valTy && valTy <= PrimaryType::kI8; +} + +constexpr bool isRealPrimaryType(PrimaryType valTy) { + return PrimaryType::kF64 <= valTy && valTy <= PrimaryType::kI8; +} + +constexpr bool isComplexPrimaryType(PrimaryType valTy) { + return PrimaryType::kC64 <= valTy && valTy <= PrimaryType::kC32; +} + +/// The actions performed by @newSparseTensor. +enum class Action : uint32_t { + kEmpty = 0, + // newSparseTensor no longer handles `kFromFile=1`, so we leave this + // number reserved to help catch any code that still needs updating. + kFromCOO = 2, + kSparseToSparse = 3, + kEmptyCOO = 4, + kToCOO = 5, + kToIterator = 6, + kPack = 7, +}; + +/// This enum defines all the sparse representations supportable by +/// the SparseTensor dialect. We use a lightweight encoding to encode +/// both the "format" per se (dense, compressed, singleton) as well as +/// the "properties" (ordered, unique). The encoding is chosen for +/// performance of the runtime library, and thus may change in future +/// versions; consequently, client code should use the predicate functions +/// defined below, rather than relying on knowledge about the particular +/// binary encoding. +/// +/// The `Undef` "format" is a special value used internally for cases +/// where we need to store an undefined or indeterminate `DimLevelType`. +/// It should not be used externally, since it does not indicate an +/// actual/representable format. +/// +// TODO: We should generalize TwoOutOfFour to N out of M and use property to +// encode the value of N and M. +// TODO: Update DimLevelType to use lower 8 bits for storage formats and the +// higher 4 bits to store level properties. Consider LooseCompressed and +// TwoOutOfFour as properties instead of formats. +enum class DimLevelType : uint8_t { + Undef = 0, // 0b00000_00 + Dense = 4, // 0b00001_00 + Compressed = 8, // 0b00010_00 + CompressedNu = 9, // 0b00010_01 + CompressedNo = 10, // 0b00010_10 + CompressedNuNo = 11, // 0b00010_11 + Singleton = 16, // 0b00100_00 + SingletonNu = 17, // 0b00100_01 + SingletonNo = 18, // 0b00100_10 + SingletonNuNo = 19, // 0b00100_11 + LooseCompressed = 32, // 0b01000_00 + LooseCompressedNu = 33, // 0b01000_01 + LooseCompressedNo = 34, // 0b01000_10 + LooseCompressedNuNo = 35, // 0b01000_11 + TwoOutOfFour = 64, // 0b10000_00 +}; + +/// This enum defines all supported storage format without the level properties. +enum class LevelFormat : uint8_t { + Dense = 4, // 0b00001_00 + Compressed = 8, // 0b00010_00 + Singleton = 16, // 0b00100_00 + LooseCompressed = 32, // 0b01000_00 + TwoOutOfFour = 64, // 0b10000_00 +}; + +/// This enum defines all the nondefault properties for storage formats. +enum class LevelNondefaultProperty : uint8_t { + Nonunique = 1, // 0b00000_01 + Nonordered = 2, // 0b00000_10 +}; + +/// Returns string representation of the given dimension level type. +constexpr const char *toMLIRString(DimLevelType dlt) { + switch (dlt) { + case DimLevelType::Undef: + return "undef"; + case DimLevelType::Dense: + return "dense"; + case DimLevelType::Compressed: + return "compressed"; + case DimLevelType::CompressedNu: + return "compressed(nonunique)"; + case DimLevelType::CompressedNo: + return "compressed(nonordered)"; + case DimLevelType::CompressedNuNo: + return "compressed(nonunique, nonordered)"; + case DimLevelType::Singleton: + return "singleton"; + case DimLevelType::SingletonNu: + return "singleton(nonunique)"; + case DimLevelType::SingletonNo: + return "singleton(nonordered)"; + case DimLevelType::SingletonNuNo: + return "singleton(nonunique, nonordered)"; + case DimLevelType::LooseCompressed: + return "loose_compressed"; + case DimLevelType::LooseCompressedNu: + return "loose_compressed(nonunique)"; + case DimLevelType::LooseCompressedNo: + return "loose_compressed(nonordered)"; + case DimLevelType::LooseCompressedNuNo: + return "loose_compressed(nonunique, nonordered)"; + case DimLevelType::TwoOutOfFour: + return "block2_4"; + } + return ""; +} + +/// Check that the `DimLevelType` contains a valid (possibly undefined) value. +constexpr bool isValidDLT(DimLevelType dlt) { + const uint8_t formatBits = static_cast(dlt) >> 2; + const uint8_t propertyBits = static_cast(dlt) & 3; + // If undefined or dense, then must be unique and ordered. + // Otherwise, the format must be one of the known ones. + return (formatBits <= 1 || formatBits == 16) + ? (propertyBits == 0) + : (formatBits == 2 || formatBits == 4 || formatBits == 8); +} + +/// Check if the `DimLevelType` is the special undefined value. +constexpr bool isUndefDLT(DimLevelType dlt) { + return dlt == DimLevelType::Undef; +} + +/// Check if the `DimLevelType` is dense. +constexpr bool isDenseDLT(DimLevelType dlt) { + return dlt == DimLevelType::Dense; +} + +/// Check if the `DimLevelType` is 2:4 +constexpr bool isTwoOutOfFourDLT(DimLevelType dlt) { + return dlt == DimLevelType::TwoOutOfFour; +} + +// We use the idiom `(dlt & ~3) == format` in order to only return true +// for valid DLTs. Whereas the `dlt & format` idiom is a bit faster but +// can return false-positives on invalid DLTs. + +/// Check if the `DimLevelType` is compressed (regardless of properties). +constexpr bool isCompressedDLT(DimLevelType dlt) { + return (static_cast(dlt) & ~3) == + static_cast(DimLevelType::Compressed); +} + +/// Check if the `DimLevelType` is compressed (regardless of properties). +constexpr bool isLooseCompressedDLT(DimLevelType dlt) { + return (static_cast(dlt) & ~3) == + static_cast(DimLevelType::LooseCompressed); +} + +/// Check if the `DimLevelType` is singleton (regardless of properties). +constexpr bool isSingletonDLT(DimLevelType dlt) { + return (static_cast(dlt) & ~3) == + static_cast(DimLevelType::Singleton); +} + +/// Check if the `DimLevelType` is ordered (regardless of storage format). +constexpr bool isOrderedDLT(DimLevelType dlt) { + return !(static_cast(dlt) & 2); +} + +/// Check if the `DimLevelType` is unique (regardless of storage format). +constexpr bool isUniqueDLT(DimLevelType dlt) { + return !(static_cast(dlt) & 1); +} + +/// Convert a DimLevelType to its corresponding LevelFormat. +/// Returns std::nullopt when input dlt is Undef. +constexpr std::optional getLevelFormat(DimLevelType dlt) { + if (dlt == DimLevelType::Undef) + return std::nullopt; + return static_cast(static_cast(dlt) & ~3); +} + +/// Convert a LevelFormat to its corresponding DimLevelType with the given +/// properties. Returns std::nullopt when the properties are not applicable for +/// the input level format. +/// TODO: factor out a new LevelProperties type so we can add new properties +/// without changing this function's signature +constexpr std::optional +buildLevelType(LevelFormat lf, bool ordered, bool unique) { + auto dlt = static_cast(static_cast(lf) | + (ordered ? 0 : 2) | (unique ? 0 : 1)); + return isValidDLT(dlt) ? std::optional(dlt) : std::nullopt; +} + +/// Ensure the above conversion works as intended. +static_assert( + (getLevelFormat(DimLevelType::Undef) == std::nullopt && + *getLevelFormat(DimLevelType::Dense) == LevelFormat::Dense && + *getLevelFormat(DimLevelType::Compressed) == LevelFormat::Compressed && + *getLevelFormat(DimLevelType::CompressedNu) == LevelFormat::Compressed && + *getLevelFormat(DimLevelType::CompressedNo) == LevelFormat::Compressed && + *getLevelFormat(DimLevelType::CompressedNuNo) == LevelFormat::Compressed && + *getLevelFormat(DimLevelType::Singleton) == LevelFormat::Singleton && + *getLevelFormat(DimLevelType::SingletonNu) == LevelFormat::Singleton && + *getLevelFormat(DimLevelType::SingletonNo) == LevelFormat::Singleton && + *getLevelFormat(DimLevelType::SingletonNuNo) == LevelFormat::Singleton), + "getLevelFormat conversion is broken"); + +static_assert( + (buildLevelType(LevelFormat::Dense, false, true) == std::nullopt && + buildLevelType(LevelFormat::Dense, true, false) == std::nullopt && + buildLevelType(LevelFormat::Dense, false, false) == std::nullopt && + *buildLevelType(LevelFormat::Dense, true, true) == DimLevelType::Dense && + buildLevelType(LevelFormat::TwoOutOfFour, false, true) == std::nullopt && + buildLevelType(LevelFormat::TwoOutOfFour, true, false) == std::nullopt && + buildLevelType(LevelFormat::TwoOutOfFour, false, false) == std::nullopt && + *buildLevelType(LevelFormat::TwoOutOfFour, true, true) == + DimLevelType::TwoOutOfFour && + *buildLevelType(LevelFormat::Compressed, true, true) == + DimLevelType::Compressed && + *buildLevelType(LevelFormat::Compressed, true, false) == + DimLevelType::CompressedNu && + *buildLevelType(LevelFormat::Compressed, false, true) == + DimLevelType::CompressedNo && + *buildLevelType(LevelFormat::Compressed, false, false) == + DimLevelType::CompressedNuNo && + *buildLevelType(LevelFormat::Singleton, true, true) == + DimLevelType::Singleton && + *buildLevelType(LevelFormat::Singleton, true, false) == + DimLevelType::SingletonNu && + *buildLevelType(LevelFormat::Singleton, false, true) == + DimLevelType::SingletonNo && + *buildLevelType(LevelFormat::Singleton, false, false) == + DimLevelType::SingletonNuNo), + "buildLevelType conversion is broken"); + +// Ensure the above predicates work as intended. +static_assert((isValidDLT(DimLevelType::Undef) && + isValidDLT(DimLevelType::Dense) && + isValidDLT(DimLevelType::Compressed) && + isValidDLT(DimLevelType::CompressedNu) && + isValidDLT(DimLevelType::CompressedNo) && + isValidDLT(DimLevelType::CompressedNuNo) && + isValidDLT(DimLevelType::Singleton) && + isValidDLT(DimLevelType::SingletonNu) && + isValidDLT(DimLevelType::SingletonNo) && + isValidDLT(DimLevelType::SingletonNuNo) && + isValidDLT(DimLevelType::LooseCompressed) && + isValidDLT(DimLevelType::LooseCompressedNu) && + isValidDLT(DimLevelType::LooseCompressedNo) && + isValidDLT(DimLevelType::LooseCompressedNuNo) && + isValidDLT(DimLevelType::TwoOutOfFour)), + "isValidDLT definition is broken"); + +static_assert((!isCompressedDLT(DimLevelType::Dense) && + isCompressedDLT(DimLevelType::Compressed) && + isCompressedDLT(DimLevelType::CompressedNu) && + isCompressedDLT(DimLevelType::CompressedNo) && + isCompressedDLT(DimLevelType::CompressedNuNo) && + !isCompressedDLT(DimLevelType::Singleton) && + !isCompressedDLT(DimLevelType::SingletonNu) && + !isCompressedDLT(DimLevelType::SingletonNo) && + !isCompressedDLT(DimLevelType::SingletonNuNo)), + "isCompressedDLT definition is broken"); + +static_assert((!isLooseCompressedDLT(DimLevelType::Dense) && + isLooseCompressedDLT(DimLevelType::LooseCompressed) && + isLooseCompressedDLT(DimLevelType::LooseCompressedNu) && + isLooseCompressedDLT(DimLevelType::LooseCompressedNo) && + isLooseCompressedDLT(DimLevelType::LooseCompressedNuNo) && + !isLooseCompressedDLT(DimLevelType::Singleton) && + !isLooseCompressedDLT(DimLevelType::SingletonNu) && + !isLooseCompressedDLT(DimLevelType::SingletonNo) && + !isLooseCompressedDLT(DimLevelType::SingletonNuNo)), + "isLooseCompressedDLT definition is broken"); + +static_assert((!isSingletonDLT(DimLevelType::Dense) && + !isSingletonDLT(DimLevelType::Compressed) && + !isSingletonDLT(DimLevelType::CompressedNu) && + !isSingletonDLT(DimLevelType::CompressedNo) && + !isSingletonDLT(DimLevelType::CompressedNuNo) && + isSingletonDLT(DimLevelType::Singleton) && + isSingletonDLT(DimLevelType::SingletonNu) && + isSingletonDLT(DimLevelType::SingletonNo) && + isSingletonDLT(DimLevelType::SingletonNuNo)), + "isSingletonDLT definition is broken"); + +static_assert((isOrderedDLT(DimLevelType::Dense) && + isOrderedDLT(DimLevelType::TwoOutOfFour) && + isOrderedDLT(DimLevelType::Compressed) && + isOrderedDLT(DimLevelType::CompressedNu) && + !isOrderedDLT(DimLevelType::CompressedNo) && + !isOrderedDLT(DimLevelType::CompressedNuNo) && + isOrderedDLT(DimLevelType::Singleton) && + isOrderedDLT(DimLevelType::SingletonNu) && + !isOrderedDLT(DimLevelType::SingletonNo) && + !isOrderedDLT(DimLevelType::SingletonNuNo) && + isOrderedDLT(DimLevelType::LooseCompressed) && + isOrderedDLT(DimLevelType::LooseCompressedNu) && + !isOrderedDLT(DimLevelType::LooseCompressedNo) && + !isOrderedDLT(DimLevelType::LooseCompressedNuNo)), + "isOrderedDLT definition is broken"); + +static_assert((isUniqueDLT(DimLevelType::Dense) && + isUniqueDLT(DimLevelType::TwoOutOfFour) && + isUniqueDLT(DimLevelType::Compressed) && + !isUniqueDLT(DimLevelType::CompressedNu) && + isUniqueDLT(DimLevelType::CompressedNo) && + !isUniqueDLT(DimLevelType::CompressedNuNo) && + isUniqueDLT(DimLevelType::Singleton) && + !isUniqueDLT(DimLevelType::SingletonNu) && + isUniqueDLT(DimLevelType::SingletonNo) && + !isUniqueDLT(DimLevelType::SingletonNuNo) && + isUniqueDLT(DimLevelType::LooseCompressed) && + !isUniqueDLT(DimLevelType::LooseCompressedNu) && + isUniqueDLT(DimLevelType::LooseCompressedNo) && + !isUniqueDLT(DimLevelType::LooseCompressedNuNo)), + "isUniqueDLT definition is broken"); + +} // namespace sparse_tensor +} // namespace mlir + +#endif // MLIR_DIALECT_SPARSETENSOR_IR_ENUMS_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensor.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensor.h new file mode 100644 index 0000000000000000000000000000000000000000..3eb9ce010cb006f39dce326d19751aa3c28030d0 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensor.h @@ -0,0 +1,197 @@ +//===- SparseTensor.h - Sparse tensor dialect -------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_SPARSETENSOR_IR_SPARSETENSOR_H_ +#define MLIR_DIALECT_SPARSETENSOR_IR_SPARSETENSOR_H_ + +#include "mlir/Bytecode/BytecodeOpInterface.h" +#include "mlir/Dialect/SparseTensor/IR/Enums.h" +#include "mlir/IR/BuiltinTypes.h" +#include "mlir/IR/Dialect.h" +#include "mlir/IR/OpDefinition.h" +#include "mlir/IR/OpImplementation.h" +#include "mlir/IR/TensorEncoding.h" +#include "mlir/Interfaces/InferTypeOpInterface.h" +#include "mlir/Interfaces/SideEffectInterfaces.h" + +//===----------------------------------------------------------------------===// +// +// Type aliases to help code be more self-documenting. Unfortunately +// these are not type-checked, so they only provide documentation rather +// than doing anything to prevent mixups. +// +// We must include these here (rather than in "SparseTensorType.h") +// because they are used by methods declared in the tablegen files. +// +//===----------------------------------------------------------------------===// + +namespace mlir { +namespace sparse_tensor { + +/// The type of dimension identifiers, and dimension-ranks. We use the +/// same type for both identifiers and ranks because the latter are used +/// mainly for ordering-comparisons against the former (just like how the +/// one-past-the-end iterators are used). +using Dimension = uint64_t; + +/// The type of level identifiers, and level-ranks. We use the same +/// type for both identifiers and ranks because the latter are used +/// mainly for ordering-comparisons against the former (just like how +/// the one-past-the-end iterators are used). +using Level = uint64_t; + +/// The type for individual components of a compile-time shape. We avoid +/// calling this "size" because we use the term "sizes" to indicate the +/// actual run-time sizes, whereas this type also allows the value +/// `ShapedType::kDynamic`. +using DynSize = int64_t; + +/// The type for individual components of a compile-time shape which +/// are known not to be `ShapedType::kDynamic`. +using StaticSize = int64_t; + +} // namespace sparse_tensor +} // namespace mlir + +//===----------------------------------------------------------------------===// +// TableGen-defined classes +//===----------------------------------------------------------------------===// + +// We must include Enums.h.inc before AttrDefs.h.inc due to dependency between +// StorageSpecifierKindAttr and StorageSpeciferKind Enum. + +#define GET_ATTRDEF_CLASSES +#include "mlir/Dialect/SparseTensor/IR/SparseTensorAttrEnums.h.inc" + +#define GET_ATTRDEF_CLASSES +#include "mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.h.inc" + +#define GET_TYPEDEF_CLASSES +#include "mlir/Dialect/SparseTensor/IR/SparseTensorTypes.h.inc" + +#define GET_OP_CLASSES +#include "mlir/Dialect/SparseTensor/IR/SparseTensorOps.h.inc" + +#include "mlir/Dialect/SparseTensor/IR/SparseTensorOpsDialect.h.inc" + +//===----------------------------------------------------------------------===// +// Additional convenience methods. +//===----------------------------------------------------------------------===// + +namespace mlir { +namespace sparse_tensor { + +// NOTE: `Value::getType` doesn't check for null before trying to +// dereference things. Therefore we check, because an assertion-failure +// is easier to debug than a segfault. Presumably other `T::getType` +// methods are similarly susceptible. + +/// Convenience method to abbreviate casting `getType()`. +template +inline RankedTensorType getRankedTensorType(T &&t) { + assert(static_cast(std::forward(t)) && + "getRankedTensorType got null argument"); + return cast(std::forward(t).getType()); +} + +/// Convenience method to abbreviate casting `getType()`. +template +inline MemRefType getMemRefType(T &&t) { + assert(static_cast(std::forward(t)) && + "getMemRefType got null argument"); + return cast(std::forward(t).getType()); +} + +/// Convenience method to get a sparse encoding attribute from a type. +/// Returns null-attribute for any type without an encoding. +SparseTensorEncodingAttr getSparseTensorEncoding(Type type); + +/// Convenience method to query whether a given DLT needs both position and +/// coordinates array or only coordinates array. +constexpr inline bool isDLTWithPos(DimLevelType dlt) { + return isLooseCompressedDLT(dlt) || isCompressedDLT(dlt); +} +constexpr inline bool isDLTWithCrd(DimLevelType dlt) { + return isSingletonDLT(dlt) || isLooseCompressedDLT(dlt) || + isCompressedDLT(dlt); +} + +/// Returns true iff the given sparse tensor encoding attribute has a trailing +/// COO region starting at the given level. +bool isCOOType(SparseTensorEncodingAttr enc, Level startLvl, bool isUnique); + +/// Returns true iff the given type is a COO type where the last level +/// is unique. +bool isUniqueCOOType(Type tp); + +/// Returns the starting level for a trailing COO region that spans +/// at least two levels. If no such COO region is found, then returns +/// the level-rank. +Level getCOOStart(SparseTensorEncodingAttr enc); + +/// Helpers to setup a COO type. +RankedTensorType getCOOFromTypeWithOrdering(RankedTensorType src, + AffineMap ordering, bool ordered); + +RankedTensorType getCOOFromType(RankedTensorType src, bool ordered); + +/// Returns true iff MLIR operand has any sparse operand. +inline bool hasAnySparseOperand(Operation *op) { + return llvm::any_of(op->getOperands().getTypes(), [](Type t) { + return getSparseTensorEncoding(t) != nullptr; + }); +} + +/// Returns true iff MLIR operand has any sparse result. +inline bool hasAnySparseResult(Operation *op) { + return llvm::any_of(op->getResults().getTypes(), [](Type t) { + return getSparseTensorEncoding(t) != nullptr; + }); +} + +/// Returns true iff MLIR operand has any sparse operand or result. +inline bool hasAnySparseOperandOrResult(Operation *op) { + return hasAnySparseOperand(op) || hasAnySparseResult(op); +} + +// +// Reordering. +// + +// This CPP guard is to disable deprecation warnings for the LLVM +// build-bot, while making it easy to re-enable it for local development. +#if 0 +#define DEPRECATED \ + LLVM_DEPRECATED("The toOrigDim/toStoredDim functions are deprecated " \ + "because they only work for permutations; therefore any " \ + "code using them cannot support non-permutations.", \ + "") +#else +#define DEPRECATED +#endif + +/// [deprecated] Convenience method to translate the given level to the +/// corresponding dimension. Requires: `0 <= l < lvlRank`. +DEPRECATED Dimension toOrigDim(SparseTensorEncodingAttr enc, Level l); +DEPRECATED Dimension toOrigDim(RankedTensorType type, Level l); + +/// [deprecated] Convenience method to translate the given dimension to +/// the corresponding level. Requires: `0 <= d < dimRank`. +DEPRECATED Level toStoredDim(SparseTensorEncodingAttr enc, Dimension d); +DEPRECATED Level toStoredDim(RankedTensorType type, Dimension d); + +#undef DEPRECATED + +namespace detail { +Type getIntegerOrIndexType(MLIRContext *ctx, unsigned bitwidth); +} // namespace detail + +} // namespace sparse_tensor +} // namespace mlir + +#endif // MLIR_DIALECT_SPARSETENSOR_IR_SPARSETENSOR_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.cpp.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..da1939c7cb9cfa235d5231ce3e072835f20b11ae --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.cpp.inc @@ -0,0 +1,386 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* AttrDef Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifdef GET_ATTRDEF_LIST +#undef GET_ATTRDEF_LIST + +::mlir::sparse_tensor::SparseTensorDimSliceAttr, +::mlir::sparse_tensor::SparseTensorEncodingAttr, +::mlir::sparse_tensor::SparseTensorSortKindAttr, +::mlir::sparse_tensor::StorageSpecifierKindAttr + +#endif // GET_ATTRDEF_LIST + +#ifdef GET_ATTRDEF_CLASSES +#undef GET_ATTRDEF_CLASSES + +static ::mlir::OptionalParseResult generatedAttributeParser(::mlir::AsmParser &parser, ::llvm::StringRef *mnemonic, ::mlir::Type type, ::mlir::Attribute &value) { + return ::mlir::AsmParser::KeywordSwitch<::mlir::OptionalParseResult>(parser) + .Case(::mlir::sparse_tensor::SparseTensorDimSliceAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::sparse_tensor::SparseTensorDimSliceAttr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::sparse_tensor::SparseTensorEncodingAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::sparse_tensor::SparseTensorEncodingAttr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::sparse_tensor::SparseTensorSortKindAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::sparse_tensor::SparseTensorSortKindAttr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::sparse_tensor::StorageSpecifierKindAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::sparse_tensor::StorageSpecifierKindAttr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Default([&](llvm::StringRef keyword, llvm::SMLoc) { + *mnemonic = keyword; + return std::nullopt; + }); +} + +static ::mlir::LogicalResult generatedAttributePrinter(::mlir::Attribute def, ::mlir::AsmPrinter &printer) { + return ::llvm::TypeSwitch<::mlir::Attribute, ::mlir::LogicalResult>(def) .Case<::mlir::sparse_tensor::SparseTensorDimSliceAttr>([&](auto t) { + printer << ::mlir::sparse_tensor::SparseTensorDimSliceAttr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::sparse_tensor::SparseTensorEncodingAttr>([&](auto t) { + printer << ::mlir::sparse_tensor::SparseTensorEncodingAttr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::sparse_tensor::SparseTensorSortKindAttr>([&](auto t) { + printer << ::mlir::sparse_tensor::SparseTensorSortKindAttr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::sparse_tensor::StorageSpecifierKindAttr>([&](auto t) { + printer << ::mlir::sparse_tensor::StorageSpecifierKindAttr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Default([](auto) { return ::mlir::failure(); }); +} + +namespace mlir { +namespace sparse_tensor { +namespace detail { +struct SparseTensorDimSliceAttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple; + SparseTensorDimSliceAttrStorage(int64_t offset, int64_t size, int64_t stride) : offset(std::move(offset)), size(std::move(size)), stride(std::move(stride)) {} + + KeyTy getAsKey() const { + return KeyTy(offset, size, stride); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (offset == std::get<0>(tblgenKey)) && (size == std::get<1>(tblgenKey)) && (stride == std::get<2>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey), std::get<2>(tblgenKey)); + } + + static SparseTensorDimSliceAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto offset = std::move(std::get<0>(tblgenKey)); + auto size = std::move(std::get<1>(tblgenKey)); + auto stride = std::move(std::get<2>(tblgenKey)); + return new (allocator.allocate()) SparseTensorDimSliceAttrStorage(std::move(offset), std::move(size), std::move(stride)); + } + + int64_t offset; + int64_t size; + int64_t stride; +}; +} // namespace detail +SparseTensorDimSliceAttr SparseTensorDimSliceAttr::get(::mlir::MLIRContext *context, int64_t offset, int64_t size, int64_t stride) { + return Base::get(context, std::move(offset), std::move(size), std::move(stride)); +} + +SparseTensorDimSliceAttr SparseTensorDimSliceAttr::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, int64_t offset, int64_t size, int64_t stride) { + return Base::getChecked(emitError, context, offset, size, stride); +} + +SparseTensorDimSliceAttr SparseTensorDimSliceAttr::get(::mlir::MLIRContext *context) { + return Base::get(context, 0, kDynamic, 1); +} + +SparseTensorDimSliceAttr SparseTensorDimSliceAttr::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context) { + return Base::getChecked(emitError, context, 0, kDynamic, 1); +} + +int64_t SparseTensorDimSliceAttr::getOffset() const { + return getImpl()->offset; +} + +int64_t SparseTensorDimSliceAttr::getSize() const { + return getImpl()->size; +} + +int64_t SparseTensorDimSliceAttr::getStride() const { + return getImpl()->stride; +} + +} // namespace sparse_tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::SparseTensorDimSliceAttr) +namespace mlir { +namespace sparse_tensor { +namespace detail { +struct SparseTensorEncodingAttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::llvm::ArrayRef<::mlir::sparse_tensor::DimLevelType>, AffineMap, AffineMap, unsigned, unsigned, ::llvm::ArrayRef<::mlir::sparse_tensor::SparseTensorDimSliceAttr>>; + SparseTensorEncodingAttrStorage(::llvm::ArrayRef<::mlir::sparse_tensor::DimLevelType> lvlTypes, AffineMap dimToLvl, AffineMap lvlToDim, unsigned posWidth, unsigned crdWidth, ::llvm::ArrayRef<::mlir::sparse_tensor::SparseTensorDimSliceAttr> dimSlices) : lvlTypes(std::move(lvlTypes)), dimToLvl(std::move(dimToLvl)), lvlToDim(std::move(lvlToDim)), posWidth(std::move(posWidth)), crdWidth(std::move(crdWidth)), dimSlices(std::move(dimSlices)) {} + + KeyTy getAsKey() const { + return KeyTy(lvlTypes, dimToLvl, lvlToDim, posWidth, crdWidth, dimSlices); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (lvlTypes == std::get<0>(tblgenKey)) && (dimToLvl == std::get<1>(tblgenKey)) && (lvlToDim == std::get<2>(tblgenKey)) && (posWidth == std::get<3>(tblgenKey)) && (crdWidth == std::get<4>(tblgenKey)) && (dimSlices == std::get<5>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey), std::get<2>(tblgenKey), std::get<3>(tblgenKey), std::get<4>(tblgenKey), std::get<5>(tblgenKey)); + } + + static SparseTensorEncodingAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto lvlTypes = std::move(std::get<0>(tblgenKey)); + auto dimToLvl = std::move(std::get<1>(tblgenKey)); + auto lvlToDim = std::move(std::get<2>(tblgenKey)); + auto posWidth = std::move(std::get<3>(tblgenKey)); + auto crdWidth = std::move(std::get<4>(tblgenKey)); + auto dimSlices = std::move(std::get<5>(tblgenKey)); + lvlTypes = allocator.copyInto(lvlTypes); + dimSlices = allocator.copyInto(dimSlices); + return new (allocator.allocate()) SparseTensorEncodingAttrStorage(std::move(lvlTypes), std::move(dimToLvl), std::move(lvlToDim), std::move(posWidth), std::move(crdWidth), std::move(dimSlices)); + } + + ::llvm::ArrayRef<::mlir::sparse_tensor::DimLevelType> lvlTypes; + AffineMap dimToLvl; + AffineMap lvlToDim; + unsigned posWidth; + unsigned crdWidth; + ::llvm::ArrayRef<::mlir::sparse_tensor::SparseTensorDimSliceAttr> dimSlices; +}; +} // namespace detail +SparseTensorEncodingAttr SparseTensorEncodingAttr::get(::mlir::MLIRContext *context, ::llvm::ArrayRef<::mlir::sparse_tensor::DimLevelType> lvlTypes, AffineMap dimToLvl, AffineMap lvlToDim, unsigned posWidth, unsigned crdWidth, ::llvm::ArrayRef<::mlir::sparse_tensor::SparseTensorDimSliceAttr> dimSlices) { + return Base::get(context, std::move(lvlTypes), std::move(dimToLvl), std::move(lvlToDim), std::move(posWidth), std::move(crdWidth), std::move(dimSlices)); +} + +SparseTensorEncodingAttr SparseTensorEncodingAttr::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, ::llvm::ArrayRef<::mlir::sparse_tensor::DimLevelType> lvlTypes, AffineMap dimToLvl, AffineMap lvlToDim, unsigned posWidth, unsigned crdWidth, ::llvm::ArrayRef<::mlir::sparse_tensor::SparseTensorDimSliceAttr> dimSlices) { + return Base::getChecked(emitError, context, lvlTypes, dimToLvl, lvlToDim, posWidth, crdWidth, dimSlices); +} + +SparseTensorEncodingAttr SparseTensorEncodingAttr::get(::mlir::MLIRContext *context, ArrayRef<::mlir::sparse_tensor::DimLevelType> lvlTypes, AffineMap dimToLvl, AffineMap lvlToDim, unsigned posWidth, unsigned crdWidth) { + return Base::get(context, lvlTypes, dimToLvl, lvlToDim, posWidth, crdWidth, + ArrayRef<::mlir::sparse_tensor::SparseTensorDimSliceAttr>{}); +} + +SparseTensorEncodingAttr SparseTensorEncodingAttr::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, ArrayRef<::mlir::sparse_tensor::DimLevelType> lvlTypes, AffineMap dimToLvl, AffineMap lvlToDim, unsigned posWidth, unsigned crdWidth) { + return Base::getChecked(emitError, context, lvlTypes, dimToLvl, lvlToDim, posWidth, crdWidth, + ArrayRef<::mlir::sparse_tensor::SparseTensorDimSliceAttr>{}); +} + +::llvm::ArrayRef<::mlir::sparse_tensor::DimLevelType> SparseTensorEncodingAttr::getLvlTypes() const { + return getImpl()->lvlTypes; +} + +AffineMap SparseTensorEncodingAttr::getDimToLvl() const { + return getImpl()->dimToLvl; +} + +AffineMap SparseTensorEncodingAttr::getLvlToDim() const { + return getImpl()->lvlToDim; +} + +unsigned SparseTensorEncodingAttr::getPosWidth() const { + return getImpl()->posWidth; +} + +unsigned SparseTensorEncodingAttr::getCrdWidth() const { + return getImpl()->crdWidth; +} + +::llvm::ArrayRef<::mlir::sparse_tensor::SparseTensorDimSliceAttr> SparseTensorEncodingAttr::getDimSlices() const { + return getImpl()->dimSlices; +} + +} // namespace sparse_tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::SparseTensorEncodingAttr) +namespace mlir { +namespace sparse_tensor { +namespace detail { +struct SparseTensorSortKindAttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::mlir::sparse_tensor::SparseTensorSortKind>; + SparseTensorSortKindAttrStorage(::mlir::sparse_tensor::SparseTensorSortKind value) : value(std::move(value)) {} + + KeyTy getAsKey() const { + return KeyTy(value); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (value == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static SparseTensorSortKindAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto value = std::move(std::get<0>(tblgenKey)); + return new (allocator.allocate()) SparseTensorSortKindAttrStorage(std::move(value)); + } + + ::mlir::sparse_tensor::SparseTensorSortKind value; +}; +} // namespace detail +SparseTensorSortKindAttr SparseTensorSortKindAttr::get(::mlir::MLIRContext *context, ::mlir::sparse_tensor::SparseTensorSortKind value) { + return Base::get(context, std::move(value)); +} + +::mlir::Attribute SparseTensorSortKindAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::mlir::sparse_tensor::SparseTensorSortKind> _result_value; + + // Parse variable 'value' + _result_value = [&]() -> ::mlir::FailureOr<::mlir::sparse_tensor::SparseTensorSortKind> { + auto loc = odsParser.getCurrentLocation(); + ::llvm::StringRef enumKeyword; + if (::mlir::failed(odsParser.parseKeyword(&enumKeyword))) + return ::mlir::failure(); + auto maybeEnum = ::mlir::sparse_tensor::symbolizeSparseTensorSortKind(enumKeyword); + if (maybeEnum) + return *maybeEnum; + return {(::mlir::LogicalResult)(odsParser.emitError(loc) << "expected " << "::mlir::sparse_tensor::SparseTensorSortKind" << " to be one of: " << "hybrid_quick_sort" << ", " << "insertion_sort_stable" << ", " << "quick_sort" << ", " << "heap_sort")}; + }(); + if (::mlir::failed(_result_value)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse SparseTensorSortKindAttr parameter 'value' which is to be a `::mlir::sparse_tensor::SparseTensorSortKind`"); + return {}; + } + assert(::mlir::succeeded(_result_value)); + return SparseTensorSortKindAttr::get(odsParser.getContext(), + ::mlir::sparse_tensor::SparseTensorSortKind((*_result_value))); +} + +void SparseTensorSortKindAttr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << ' '; + odsPrinter << stringifySparseTensorSortKind(getValue()); +} + +::mlir::sparse_tensor::SparseTensorSortKind SparseTensorSortKindAttr::getValue() const { + return getImpl()->value; +} + +} // namespace sparse_tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::SparseTensorSortKindAttr) +namespace mlir { +namespace sparse_tensor { +namespace detail { +struct StorageSpecifierKindAttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::mlir::sparse_tensor::StorageSpecifierKind>; + StorageSpecifierKindAttrStorage(::mlir::sparse_tensor::StorageSpecifierKind value) : value(std::move(value)) {} + + KeyTy getAsKey() const { + return KeyTy(value); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (value == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static StorageSpecifierKindAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto value = std::move(std::get<0>(tblgenKey)); + return new (allocator.allocate()) StorageSpecifierKindAttrStorage(std::move(value)); + } + + ::mlir::sparse_tensor::StorageSpecifierKind value; +}; +} // namespace detail +StorageSpecifierKindAttr StorageSpecifierKindAttr::get(::mlir::MLIRContext *context, ::mlir::sparse_tensor::StorageSpecifierKind value) { + return Base::get(context, std::move(value)); +} + +::mlir::Attribute StorageSpecifierKindAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::mlir::sparse_tensor::StorageSpecifierKind> _result_value; + + // Parse variable 'value' + _result_value = [&]() -> ::mlir::FailureOr<::mlir::sparse_tensor::StorageSpecifierKind> { + auto loc = odsParser.getCurrentLocation(); + ::llvm::StringRef enumKeyword; + if (::mlir::failed(odsParser.parseKeyword(&enumKeyword))) + return ::mlir::failure(); + auto maybeEnum = ::mlir::sparse_tensor::symbolizeStorageSpecifierKind(enumKeyword); + if (maybeEnum) + return *maybeEnum; + return {(::mlir::LogicalResult)(odsParser.emitError(loc) << "expected " << "::mlir::sparse_tensor::StorageSpecifierKind" << " to be one of: " << "lvl_sz" << ", " << "pos_mem_sz" << ", " << "crd_mem_sz" << ", " << "val_mem_sz" << ", " << "dim_offset" << ", " << "dim_stride")}; + }(); + if (::mlir::failed(_result_value)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse SparseTensorStorageSpecifierKindAttr parameter 'value' which is to be a `::mlir::sparse_tensor::StorageSpecifierKind`"); + return {}; + } + assert(::mlir::succeeded(_result_value)); + return StorageSpecifierKindAttr::get(odsParser.getContext(), + ::mlir::sparse_tensor::StorageSpecifierKind((*_result_value))); +} + +void StorageSpecifierKindAttr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << ' '; + odsPrinter << stringifyStorageSpecifierKind(getValue()); +} + +::mlir::sparse_tensor::StorageSpecifierKind StorageSpecifierKindAttr::getValue() const { + return getImpl()->value; +} + +} // namespace sparse_tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::StorageSpecifierKindAttr) +namespace mlir { +namespace sparse_tensor { + +/// Parse an attribute registered to this dialect. +::mlir::Attribute SparseTensorDialect::parseAttribute(::mlir::DialectAsmParser &parser, + ::mlir::Type type) const { + ::llvm::SMLoc typeLoc = parser.getCurrentLocation(); + ::llvm::StringRef attrTag; + { + ::mlir::Attribute attr; + auto parseResult = generatedAttributeParser(parser, &attrTag, type, attr); + if (parseResult.has_value()) + return attr; + } + + parser.emitError(typeLoc) << "unknown attribute `" + << attrTag << "` in dialect `" << getNamespace() << "`"; + return {}; +} +/// Print an attribute registered to this dialect. +void SparseTensorDialect::printAttribute(::mlir::Attribute attr, + ::mlir::DialectAsmPrinter &printer) const { + if (::mlir::succeeded(generatedAttributePrinter(attr, printer))) + return; + +} +} // namespace sparse_tensor +} // namespace mlir + +#endif // GET_ATTRDEF_CLASSES + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..72aafe4bc217538f0bbb1c8f009734817d381581 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.h.inc @@ -0,0 +1,238 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* AttrDef Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifdef GET_ATTRDEF_CLASSES +#undef GET_ATTRDEF_CLASSES + + +namespace mlir { +class AsmParser; +class AsmPrinter; +} // namespace mlir +namespace mlir { +namespace sparse_tensor { +class SparseTensorDimSliceAttr; +class SparseTensorEncodingAttr; +class SparseTensorSortKindAttr; +class StorageSpecifierKindAttr; +namespace detail { +struct SparseTensorDimSliceAttrStorage; +} // namespace detail +class SparseTensorDimSliceAttr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + void print(llvm::raw_ostream &os) const; + + /// Special value for dynamic offset/size/stride. + static constexpr int64_t kDynamic = -1; + static constexpr bool isDynamic(int64_t v) { return v == kDynamic; } + static std::optional getStatic(int64_t v); + static std::string getStaticString(int64_t v); + + std::optional getStaticOffset() const; + std::optional getStaticStride() const; + std::optional getStaticSize() const; + bool isCompletelyDynamic() const; + using Base::getChecked; + static SparseTensorDimSliceAttr get(::mlir::MLIRContext *context, int64_t offset, int64_t size, int64_t stride); + static SparseTensorDimSliceAttr getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, int64_t offset, int64_t size, int64_t stride); + static SparseTensorDimSliceAttr get(::mlir::MLIRContext *context); + static SparseTensorDimSliceAttr getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context); + static ::mlir::LogicalResult verify(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, int64_t offset, int64_t size, int64_t stride); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"slice"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + int64_t getOffset() const; + int64_t getSize() const; + int64_t getStride() const; +}; +namespace detail { +struct SparseTensorEncodingAttrStorage; +} // namespace detail +class SparseTensorEncodingAttr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + // + // Factory methods. + // + + /// Constructs a new encoding with the given dimToLvl mapping, + /// and all other fields inherited from `this`. + SparseTensorEncodingAttr withDimToLvl(AffineMap dimToLvl) const; + SparseTensorEncodingAttr withDimToLvl(SparseTensorEncodingAttr enc) const; + + /// Constructs a new encoding with dimToLvl reset to the default/identity, + /// and all other fields inherited from `this`. + SparseTensorEncodingAttr withoutDimToLvl() const; + + /// Constructs a new encoding with the given pointer and index + /// bitwidths, and all other fields inherited from `this`. + SparseTensorEncodingAttr withBitWidths(unsigned posWidth, unsigned crdWidth) const; + + /// Constructs a new encoding with the pointer and index bitwidths + /// reset to the default, and all other fields inherited from `this`. + SparseTensorEncodingAttr withoutBitWidths() const; + + /// Constructs a new encoding with the given dimSlices, and all + /// other fields inherited from `this`. + SparseTensorEncodingAttr withDimSlices(ArrayRef<::mlir::sparse_tensor::SparseTensorDimSliceAttr> dimSlices) const; + + /// Constructs a new encoding with the dimSlices reset to the default, + /// and all other fields inherited from `this`. + SparseTensorEncodingAttr withoutDimSlices() const; + + // + // Rank methods. + // + + /// Returns the expected number of tensor dimensions. Asserts that + /// the encoding is non-null (since no fixed result is valid for every + /// dense-tensor). + ::mlir::sparse_tensor::Dimension getDimRank() const; + + /// Returns the number of storage levels. Asserts that the encoding + /// is non-null (since no fixed result is valid for every dense-tensor). + ::mlir::sparse_tensor::Level getLvlRank() const; + + // + // lvlTypes methods. + // + + /// Safely looks up the level-type for the requested level. (Returns + /// `DimLevelType::Dense` for the null encoding, since dense-tensors + /// are always all-dense.) + ::mlir::sparse_tensor::DimLevelType getLvlType(::mlir::sparse_tensor::Level l) const; + + bool isDenseLvl(::mlir::sparse_tensor::Level l) const { return isDenseDLT(getLvlType(l)); } + bool isTwoOutOfFourLvl(::mlir::sparse_tensor::Level l) const { return isTwoOutOfFourDLT(getLvlType(l)); } + bool isCompressedLvl(::mlir::sparse_tensor::Level l) const { return isCompressedDLT(getLvlType(l)); } + bool isLooseCompressedLvl(::mlir::sparse_tensor::Level l) const { return isLooseCompressedDLT(getLvlType(l)); } + bool isSingletonLvl(::mlir::sparse_tensor::Level l) const { return isSingletonDLT(getLvlType(l)); } + bool isOrderedLvl(::mlir::sparse_tensor::Level l) const { return isOrderedDLT(getLvlType(l)); } + bool isUniqueLvl(::mlir::sparse_tensor::Level l) const { return isUniqueDLT(getLvlType(l)); } + + /// Returns true if every level is dense. Also returns true for + /// the null encoding (since dense-tensors are always all-dense). + bool isAllDense() const; + + /// Returns true if every level is ordered. Also returns true for + /// the null encoding (since dense-tensors are always all-ordered). + bool isAllOrdered() const; + + // + // dimToLvl methods. + // + + /// Returns true if the dimToLvl mapping is the identity. + /// Also returns true for the null encoding (since dense-tensors + /// always have the identity mapping). + bool isIdentity() const; + + /// Returns true if the dimToLvl mapping is a permutation. + /// Also returns true for the null encoding (since dense-tensors + /// always have the identity mapping). + bool isPermutation() const; + + // + // posWidth/crdWidth methods. + // + + /// Returns the type for position storage based on posWidth. + /// Asserts that the encoding is non-null (since there's nowhere + /// to get the `MLIRContext` from). + Type getPosType() const; + + /// Returns the type for coordinate storage based on crdWidth. + /// Asserts that the encoding is non-null (since there's nowhere + /// to get the `MLIRContext` from). + Type getCrdType() const; + + // + // dimSlices methods. + // + + bool isSlice() const; + + ::mlir::sparse_tensor::SparseTensorDimSliceAttr getDimSlice(::mlir::sparse_tensor::Dimension dim) const; + + std::optional getStaticDimSliceOffset(::mlir::sparse_tensor::Dimension dim) const; + std::optional getStaticDimSliceSize(::mlir::sparse_tensor::Dimension dim) const; + std::optional getStaticDimSliceStride(::mlir::sparse_tensor::Dimension dim) const; + std::optional getStaticLvlSliceOffset(::mlir::sparse_tensor::Level lvl) const; + std::optional getStaticLvlSliceSize(::mlir::sparse_tensor::Level lvl) const; + std::optional getStaticLvlSliceStride(::mlir::sparse_tensor::Level lvl) const; + + // + // Printing methods. + // + + void printSymbols(AffineMap &map, AsmPrinter &printer) const; + void printDimensions(AffineMap &map, AsmPrinter &printer, ArrayRef<::mlir::sparse_tensor::SparseTensorDimSliceAttr> dimSlices) const; + void printLevels(AffineMap &map, AsmPrinter &printer, ArrayRef<::mlir::sparse_tensor::DimLevelType> lvlTypes) const; + using Base::getChecked; + static SparseTensorEncodingAttr get(::mlir::MLIRContext *context, ::llvm::ArrayRef<::mlir::sparse_tensor::DimLevelType> lvlTypes, AffineMap dimToLvl, AffineMap lvlToDim, unsigned posWidth, unsigned crdWidth, ::llvm::ArrayRef<::mlir::sparse_tensor::SparseTensorDimSliceAttr> dimSlices); + static SparseTensorEncodingAttr getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, ::llvm::ArrayRef<::mlir::sparse_tensor::DimLevelType> lvlTypes, AffineMap dimToLvl, AffineMap lvlToDim, unsigned posWidth, unsigned crdWidth, ::llvm::ArrayRef<::mlir::sparse_tensor::SparseTensorDimSliceAttr> dimSlices); + static SparseTensorEncodingAttr get(::mlir::MLIRContext *context, ArrayRef<::mlir::sparse_tensor::DimLevelType> lvlTypes, AffineMap dimToLvl, AffineMap lvlToDim, unsigned posWidth, unsigned crdWidth); + static SparseTensorEncodingAttr getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, ArrayRef<::mlir::sparse_tensor::DimLevelType> lvlTypes, AffineMap dimToLvl, AffineMap lvlToDim, unsigned posWidth, unsigned crdWidth); + static ::mlir::LogicalResult verify(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::llvm::ArrayRef<::mlir::sparse_tensor::DimLevelType> lvlTypes, AffineMap dimToLvl, AffineMap lvlToDim, unsigned posWidth, unsigned crdWidth, ::llvm::ArrayRef<::mlir::sparse_tensor::SparseTensorDimSliceAttr> dimSlices); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"encoding"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::llvm::ArrayRef<::mlir::sparse_tensor::DimLevelType> getLvlTypes() const; + AffineMap getDimToLvl() const; + AffineMap getLvlToDim() const; + unsigned getPosWidth() const; + unsigned getCrdWidth() const; + ::llvm::ArrayRef<::mlir::sparse_tensor::SparseTensorDimSliceAttr> getDimSlices() const; + ::mlir::LogicalResult verifyEncoding(ArrayRef shape, Type elementType, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) const; +}; +namespace detail { +struct SparseTensorSortKindAttrStorage; +} // namespace detail +class SparseTensorSortKindAttr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + static SparseTensorSortKindAttr get(::mlir::MLIRContext *context, ::mlir::sparse_tensor::SparseTensorSortKind value); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"SparseTensorSortAlgorithm"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::mlir::sparse_tensor::SparseTensorSortKind getValue() const; +}; +namespace detail { +struct StorageSpecifierKindAttrStorage; +} // namespace detail +class StorageSpecifierKindAttr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + static StorageSpecifierKindAttr get(::mlir::MLIRContext *context, ::mlir::sparse_tensor::StorageSpecifierKind value); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"kind"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::mlir::sparse_tensor::StorageSpecifierKind getValue() const; +}; +} // namespace sparse_tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::SparseTensorDimSliceAttr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::SparseTensorEncodingAttr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::SparseTensorSortKindAttr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::StorageSpecifierKindAttr) + +#endif // GET_ATTRDEF_CLASSES + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrEnums.cpp.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrEnums.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..b6ab90d794d5f9d631561a4a09ba1529452f2609 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrEnums.cpp.inc @@ -0,0 +1,81 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Enum Utility Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: SparseTensorAttrDefs.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace sparse_tensor { +::llvm::StringRef stringifySparseTensorSortKind(SparseTensorSortKind val) { + switch (val) { + case SparseTensorSortKind::HybridQuickSort: return "hybrid_quick_sort"; + case SparseTensorSortKind::InsertionSortStable: return "insertion_sort_stable"; + case SparseTensorSortKind::QuickSort: return "quick_sort"; + case SparseTensorSortKind::HeapSort: return "heap_sort"; + } + return ""; +} + +::std::optional symbolizeSparseTensorSortKind(::llvm::StringRef str) { + return ::llvm::StringSwitch<::std::optional>(str) + .Case("hybrid_quick_sort", SparseTensorSortKind::HybridQuickSort) + .Case("insertion_sort_stable", SparseTensorSortKind::InsertionSortStable) + .Case("quick_sort", SparseTensorSortKind::QuickSort) + .Case("heap_sort", SparseTensorSortKind::HeapSort) + .Default(::std::nullopt); +} +::std::optional symbolizeSparseTensorSortKind(uint32_t value) { + switch (value) { + case 0: return SparseTensorSortKind::HybridQuickSort; + case 1: return SparseTensorSortKind::InsertionSortStable; + case 2: return SparseTensorSortKind::QuickSort; + case 3: return SparseTensorSortKind::HeapSort; + default: return ::std::nullopt; + } +} + +} // namespace sparse_tensor +} // namespace mlir + +namespace mlir { +namespace sparse_tensor { +::llvm::StringRef stringifyStorageSpecifierKind(StorageSpecifierKind val) { + switch (val) { + case StorageSpecifierKind::LvlSize: return "lvl_sz"; + case StorageSpecifierKind::PosMemSize: return "pos_mem_sz"; + case StorageSpecifierKind::CrdMemSize: return "crd_mem_sz"; + case StorageSpecifierKind::ValMemSize: return "val_mem_sz"; + case StorageSpecifierKind::DimOffset: return "dim_offset"; + case StorageSpecifierKind::DimStride: return "dim_stride"; + } + return ""; +} + +::std::optional symbolizeStorageSpecifierKind(::llvm::StringRef str) { + return ::llvm::StringSwitch<::std::optional>(str) + .Case("lvl_sz", StorageSpecifierKind::LvlSize) + .Case("pos_mem_sz", StorageSpecifierKind::PosMemSize) + .Case("crd_mem_sz", StorageSpecifierKind::CrdMemSize) + .Case("val_mem_sz", StorageSpecifierKind::ValMemSize) + .Case("dim_offset", StorageSpecifierKind::DimOffset) + .Case("dim_stride", StorageSpecifierKind::DimStride) + .Default(::std::nullopt); +} +::std::optional symbolizeStorageSpecifierKind(uint32_t value) { + switch (value) { + case 0: return StorageSpecifierKind::LvlSize; + case 1: return StorageSpecifierKind::PosMemSize; + case 2: return StorageSpecifierKind::CrdMemSize; + case 3: return StorageSpecifierKind::ValMemSize; + case 4: return StorageSpecifierKind::DimOffset; + case 5: return StorageSpecifierKind::DimStride; + default: return ::std::nullopt; + } +} + +} // namespace sparse_tensor +} // namespace mlir + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrEnums.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrEnums.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..89568237fb0b40c150d34441efac854918e89e53 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrEnums.h.inc @@ -0,0 +1,177 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Enum Utility Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: SparseTensorAttrDefs.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace sparse_tensor { +// sparse tensor sort algorithm +enum class SparseTensorSortKind : uint32_t { + HybridQuickSort = 0, + InsertionSortStable = 1, + QuickSort = 2, + HeapSort = 3, +}; + +::std::optional symbolizeSparseTensorSortKind(uint32_t); +::llvm::StringRef stringifySparseTensorSortKind(SparseTensorSortKind); +::std::optional symbolizeSparseTensorSortKind(::llvm::StringRef); +inline constexpr unsigned getMaxEnumValForSparseTensorSortKind() { + return 3; +} + + +inline ::llvm::StringRef stringifyEnum(SparseTensorSortKind enumValue) { + return stringifySparseTensorSortKind(enumValue); +} + +template +::std::optional symbolizeEnum(::llvm::StringRef); + +template <> +inline ::std::optional symbolizeEnum(::llvm::StringRef str) { + return symbolizeSparseTensorSortKind(str); +} +} // namespace sparse_tensor +} // namespace mlir + +namespace mlir { +template +struct FieldParser; + +template<> +struct FieldParser<::mlir::sparse_tensor::SparseTensorSortKind, ::mlir::sparse_tensor::SparseTensorSortKind> { + template + static FailureOr<::mlir::sparse_tensor::SparseTensorSortKind> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return parser.emitError(loc, "expected keyword for sparse tensor sort algorithm"); + + // Symbolize the keyword. + if (::std::optional<::mlir::sparse_tensor::SparseTensorSortKind> attr = ::mlir::sparse_tensor::symbolizeEnum<::mlir::sparse_tensor::SparseTensorSortKind>(enumKeyword)) + return *attr; + return parser.emitError(loc, "invalid sparse tensor sort algorithm specification: ") << enumKeyword; + } +}; +} // namespace mlir + +namespace llvm { +inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::sparse_tensor::SparseTensorSortKind value) { + auto valueStr = stringifyEnum(value); + return p << valueStr; +} +} // namespace llvm + +namespace llvm { +template<> struct DenseMapInfo<::mlir::sparse_tensor::SparseTensorSortKind> { + using StorageInfo = ::llvm::DenseMapInfo; + + static inline ::mlir::sparse_tensor::SparseTensorSortKind getEmptyKey() { + return static_cast<::mlir::sparse_tensor::SparseTensorSortKind>(StorageInfo::getEmptyKey()); + } + + static inline ::mlir::sparse_tensor::SparseTensorSortKind getTombstoneKey() { + return static_cast<::mlir::sparse_tensor::SparseTensorSortKind>(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const ::mlir::sparse_tensor::SparseTensorSortKind &val) { + return StorageInfo::getHashValue(static_cast(val)); + } + + static bool isEqual(const ::mlir::sparse_tensor::SparseTensorSortKind &lhs, const ::mlir::sparse_tensor::SparseTensorSortKind &rhs) { + return lhs == rhs; + } +}; +} + +namespace mlir { +namespace sparse_tensor { +// sparse tensor storage specifier kind +enum class StorageSpecifierKind : uint32_t { + LvlSize = 0, + PosMemSize = 1, + CrdMemSize = 2, + ValMemSize = 3, + DimOffset = 4, + DimStride = 5, +}; + +::std::optional symbolizeStorageSpecifierKind(uint32_t); +::llvm::StringRef stringifyStorageSpecifierKind(StorageSpecifierKind); +::std::optional symbolizeStorageSpecifierKind(::llvm::StringRef); +inline constexpr unsigned getMaxEnumValForStorageSpecifierKind() { + return 5; +} + + +inline ::llvm::StringRef stringifyEnum(StorageSpecifierKind enumValue) { + return stringifyStorageSpecifierKind(enumValue); +} + +template +::std::optional symbolizeEnum(::llvm::StringRef); + +template <> +inline ::std::optional symbolizeEnum(::llvm::StringRef str) { + return symbolizeStorageSpecifierKind(str); +} +} // namespace sparse_tensor +} // namespace mlir + +namespace mlir { +template +struct FieldParser; + +template<> +struct FieldParser<::mlir::sparse_tensor::StorageSpecifierKind, ::mlir::sparse_tensor::StorageSpecifierKind> { + template + static FailureOr<::mlir::sparse_tensor::StorageSpecifierKind> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return parser.emitError(loc, "expected keyword for sparse tensor storage specifier kind"); + + // Symbolize the keyword. + if (::std::optional<::mlir::sparse_tensor::StorageSpecifierKind> attr = ::mlir::sparse_tensor::symbolizeEnum<::mlir::sparse_tensor::StorageSpecifierKind>(enumKeyword)) + return *attr; + return parser.emitError(loc, "invalid sparse tensor storage specifier kind specification: ") << enumKeyword; + } +}; +} // namespace mlir + +namespace llvm { +inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::sparse_tensor::StorageSpecifierKind value) { + auto valueStr = stringifyEnum(value); + return p << valueStr; +} +} // namespace llvm + +namespace llvm { +template<> struct DenseMapInfo<::mlir::sparse_tensor::StorageSpecifierKind> { + using StorageInfo = ::llvm::DenseMapInfo; + + static inline ::mlir::sparse_tensor::StorageSpecifierKind getEmptyKey() { + return static_cast<::mlir::sparse_tensor::StorageSpecifierKind>(StorageInfo::getEmptyKey()); + } + + static inline ::mlir::sparse_tensor::StorageSpecifierKind getTombstoneKey() { + return static_cast<::mlir::sparse_tensor::StorageSpecifierKind>(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const ::mlir::sparse_tensor::StorageSpecifierKind &val) { + return StorageInfo::getHashValue(static_cast(val)); + } + + static bool isEqual(const ::mlir::sparse_tensor::StorageSpecifierKind &lhs, const ::mlir::sparse_tensor::StorageSpecifierKind &rhs) { + return lhs == rhs; + } +}; +} + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.cpp.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..88697d7d143b672daee00b01c3b63e8aba94e485 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.cpp.inc @@ -0,0 +1,9805 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Op Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: SparseTensorOps.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifdef GET_OP_LIST +#undef GET_OP_LIST + +::mlir::sparse_tensor::AssembleOp, +::mlir::sparse_tensor::BinaryOp, +::mlir::sparse_tensor::CompressOp, +::mlir::sparse_tensor::ConcatenateOp, +::mlir::sparse_tensor::ConvertOp, +::mlir::sparse_tensor::DisassembleOp, +::mlir::sparse_tensor::ExpandOp, +::mlir::sparse_tensor::ForeachOp, +::mlir::sparse_tensor::GetStorageSpecifierOp, +::mlir::sparse_tensor::InsertOp, +::mlir::sparse_tensor::LoadOp, +::mlir::sparse_tensor::NewOp, +::mlir::sparse_tensor::NumberOfEntriesOp, +::mlir::sparse_tensor::OutOp, +::mlir::sparse_tensor::PushBackOp, +::mlir::sparse_tensor::ReduceOp, +::mlir::sparse_tensor::SelectOp, +::mlir::sparse_tensor::SetStorageSpecifierOp, +::mlir::sparse_tensor::SortOp, +::mlir::sparse_tensor::StorageSpecifierInitOp, +::mlir::sparse_tensor::ToCoordinatesBufferOp, +::mlir::sparse_tensor::ToCoordinatesOp, +::mlir::sparse_tensor::ToPositionsOp, +::mlir::sparse_tensor::ToSliceOffsetOp, +::mlir::sparse_tensor::ToSliceStrideOp, +::mlir::sparse_tensor::ToValuesOp, +::mlir::sparse_tensor::UnaryOp, +::mlir::sparse_tensor::YieldOp +#endif // GET_OP_LIST + +#ifdef GET_OP_CLASSES +#undef GET_OP_CLASSES + + +//===----------------------------------------------------------------------===// +// Local Utility Method Definitions +//===----------------------------------------------------------------------===// + +namespace mlir { +namespace sparse_tensor { + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_SparseTensorOps0( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::TensorType>(type))) && ([](::mlir::Type elementType) { return (true); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be tensor of any type values, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_SparseTensorOps1( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::TensorType>(type))) && ([](::mlir::Type elementType) { return (elementType.isSignlessIntOrIndex()); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be tensor of signless integer or index values, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_SparseTensorOps2( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::TensorType>(type))) && ((!!::mlir::sparse_tensor::getSparseTensorEncoding(type)))) && ([](::mlir::Type elementType) { return (true); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be sparse tensor of any type values, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_SparseTensorOps3( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((true))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be any type, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_SparseTensorOps4( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((((::llvm::isa<::mlir::MemRefType>(type))) && ([](::mlir::Type elementType) { return (true); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && (( isStrided(::llvm::cast<::mlir::MemRefType>(type)) ))) && ((((::llvm::isa<::mlir::MemRefType>(type))) && ([](::mlir::Type elementType) { return (true); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank() + == 1)))))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be strided memref of any type values of rank 1, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_SparseTensorOps5( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::MemRefType>(type))) && ([](::mlir::Type elementType) { return (elementType.isSignlessInteger(1)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank() + == 1))))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be 1D memref of 1-bit signless integer values, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_SparseTensorOps6( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::MemRefType>(type))) && ([](::mlir::Type elementType) { return (::llvm::isa<::mlir::IndexType>(elementType)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank() + == 1))))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be 1D memref of index values, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_SparseTensorOps7( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((::llvm::isa<::mlir::IndexType>(type)))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be index, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_SparseTensorOps8( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return (true); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be ranked tensor of any type values, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_SparseTensorOps9( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((((::llvm::isa<::mlir::RankedTensorType>(type))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank() + == 0)))) && ([](::mlir::Type elementType) { return (elementType.isSignlessIntOrIndex()); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((type.isSignlessIntOrIndex())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be 0D tensor of signless integer or index values or signless integer or index, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_SparseTensorOps10( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((::llvm::isa<::mlir::sparse_tensor::StorageSpecifierType>(type)))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be metadata, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_SparseTensorOps11( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::MemRefType>(type))) && ([](::mlir::Type elementType) { return (true); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank() + == 1))))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be 1D memref of any type values, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_SparseTensorOps12( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::MemRefType>(type))) && ([](::mlir::Type elementType) { return ((::llvm::isa<::mlir::IntegerType>(elementType))) || ((::llvm::isa<::mlir::IndexType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank() + == 1))))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be 1D memref of integer or index values, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_SparseTensorOps13( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::TensorType>(type))) && ((!!::mlir::sparse_tensor::getSparseTensorEncoding(type) && ::mlir::sparse_tensor::getSparseTensorEncoding(type).isSlice()))) && ([](::mlir::Type elementType) { return (true); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be sparse tensor slice of any type values, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_SparseTensorOps0( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::UnitAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: unit attribute"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_SparseTensorOps0( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_SparseTensorOps0(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_SparseTensorOps1( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !(((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::isa<::mlir::IndexType>(::llvm::cast<::mlir::IntegerAttr>(attr).getType()))))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: dimension attribute"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_SparseTensorOps1( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_SparseTensorOps1(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_SparseTensorOps2( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::AffineMapAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: AffineMap attribute"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_SparseTensorOps2( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_SparseTensorOps2(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_SparseTensorOps3( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::sparse_tensor::StorageSpecifierKindAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: sparse tensor storage specifier kind"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_SparseTensorOps3( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_SparseTensorOps3(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_SparseTensorOps4( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !(((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::isa<::mlir::IndexType>(::llvm::cast<::mlir::IntegerAttr>(attr).getType()))))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: level attribute"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_SparseTensorOps4( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_SparseTensorOps4(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_SparseTensorOps5( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !(((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::isa<::mlir::IndexType>(::llvm::cast<::mlir::IntegerAttr>(attr).getType()))))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: index attribute"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_SparseTensorOps5( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_SparseTensorOps5(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_SparseTensorOps6( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::sparse_tensor::SparseTensorSortKindAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: sparse tensor sort algorithm"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_SparseTensorOps6( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_SparseTensorOps6(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_region_constraint_SparseTensorOps0( + ::mlir::Operation *op, ::mlir::Region ®ion, ::llvm::StringRef regionName, + unsigned regionIndex) { + if (!((true))) { + return op->emitOpError("region #") << regionIndex + << (regionName.empty() ? " " : " ('" + regionName + "') ") + << "failed to verify constraint: any region"; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_region_constraint_SparseTensorOps1( + ::mlir::Operation *op, ::mlir::Region ®ion, ::llvm::StringRef regionName, + unsigned regionIndex) { + if (!((::llvm::hasNItems(region, 1)))) { + return op->emitOpError("region #") << regionIndex + << (regionName.empty() ? " " : " ('" + regionName + "') ") + << "failed to verify constraint: region with 1 blocks"; + } + return ::mlir::success(); +} +} // namespace sparse_tensor +} // namespace mlir +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::AssembleOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +AssembleOpGenericAdaptorBase::AssembleOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("sparse_tensor.assemble", odsAttrs.getContext()); +} + +AssembleOpGenericAdaptorBase::AssembleOpGenericAdaptorBase(AssembleOp op) : AssembleOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair AssembleOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr AssembleOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +AssembleOpAdaptor::AssembleOpAdaptor(AssembleOp op) : AssembleOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult AssembleOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair AssembleOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range AssembleOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::TensorType> AssembleOp::getValues() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); +} + +::mlir::Operation::operand_range AssembleOp::getLevels() { + return getODSOperands(1); +} + +::mlir::OpOperand &AssembleOp::getValuesMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange AssembleOp::getLevelsMutable() { + auto range = getODSOperandIndexAndLength(1); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair AssembleOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range AssembleOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::TensorType> AssembleOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); +} + +void AssembleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value values, ::mlir::ValueRange levels) { + odsState.addOperands(values); + odsState.addOperands(levels); + odsState.addTypes(result); +} + +void AssembleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value values, ::mlir::ValueRange levels) { + odsState.addOperands(values); + odsState.addOperands(levels); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void AssembleOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult AssembleOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult AssembleOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult AssembleOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand valuesRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> valuesOperands(valuesRawOperands); ::llvm::SMLoc valuesOperandsLoc; + (void)valuesOperandsLoc; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> levelsOperands; + ::llvm::SMLoc levelsOperandsLoc; + (void)levelsOperandsLoc; + ::mlir::Type valuesRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> valuesTypes(valuesRawTypes); + ::llvm::SmallVector<::mlir::Type, 1> levelsTypes; + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + valuesOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(valuesRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + levelsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(levelsOperands)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + valuesRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + if (parser.parseTypeList(levelsTypes)) + return ::mlir::failure(); + if (parser.parseKeyword("to")) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(valuesOperands, valuesTypes, valuesOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(levelsOperands, levelsTypes, levelsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void AssembleOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getValues(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getLevels(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getValues().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getLevels().getTypes(); + _odsPrinter << ' ' << "to"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void AssembleOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace sparse_tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::AssembleOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::BinaryOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BinaryOpGenericAdaptorBase::BinaryOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("sparse_tensor.binary", odsAttrs.getContext()); +} + +BinaryOpGenericAdaptorBase::BinaryOpGenericAdaptorBase(BinaryOp op) : BinaryOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair BinaryOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr BinaryOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::UnitAttr BinaryOpGenericAdaptorBase::getLeftIdentityAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().left_identity); + if (!attr) + attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); + return attr; +} + +bool BinaryOpGenericAdaptorBase::getLeftIdentity() { + auto attr = getLeftIdentityAttr(); + if (!attr) + return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; + return attr != nullptr; +} + +::mlir::UnitAttr BinaryOpGenericAdaptorBase::getRightIdentityAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().right_identity); + if (!attr) + attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); + return attr; +} + +bool BinaryOpGenericAdaptorBase::getRightIdentity() { + auto attr = getRightIdentityAttr(); + if (!attr) + return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; + return attr != nullptr; +} + +::mlir::Region &BinaryOpGenericAdaptorBase::getOverlapRegion() { + return *odsRegions[0]; +} + +::mlir::Region &BinaryOpGenericAdaptorBase::getLeftRegion() { + return *odsRegions[1]; +} + +::mlir::Region &BinaryOpGenericAdaptorBase::getRightRegion() { + return *odsRegions[2]; +} + +::mlir::RegionRange BinaryOpGenericAdaptorBase::getRegions() { + return odsRegions; +} + +} // namespace detail +BinaryOpAdaptor::BinaryOpAdaptor(BinaryOp op) : BinaryOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult BinaryOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_left_identity = getProperties().left_identity; (void)tblgen_left_identity; + auto tblgen_right_identity = getProperties().right_identity; (void)tblgen_right_identity; + + if (tblgen_left_identity && !((::llvm::isa<::mlir::UnitAttr>(tblgen_left_identity)))) + return emitError(loc, "'sparse_tensor.binary' op ""attribute 'left_identity' failed to satisfy constraint: unit attribute"); + + if (tblgen_right_identity && !((::llvm::isa<::mlir::UnitAttr>(tblgen_right_identity)))) + return emitError(loc, "'sparse_tensor.binary' op ""attribute 'right_identity' failed to satisfy constraint: unit attribute"); + return ::mlir::success(); +} + +std::pair BinaryOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range BinaryOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value BinaryOp::getX() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin()); +} + +::mlir::Value BinaryOp::getY() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(1).begin()); +} + +::mlir::OpOperand &BinaryOp::getXMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &BinaryOp::getYMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +std::pair BinaryOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range BinaryOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value BinaryOp::getOutput() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +::mlir::Region &BinaryOp::getOverlapRegion() { + return (*this)->getRegion(0); +} + +::mlir::Region &BinaryOp::getLeftRegion() { + return (*this)->getRegion(1); +} + +::mlir::Region &BinaryOp::getRightRegion() { + return (*this)->getRegion(2); +} + +::mlir::LogicalResult BinaryOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.left_identity; + auto attr = dict.get("left_identity"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for left_identity in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `left_identity` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.right_identity; + auto attr = dict.get("right_identity"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for right_identity in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `right_identity` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute BinaryOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.left_identity; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("left_identity", + propStorage)); + } + + { + const auto &propStorage = prop.right_identity; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("right_identity", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code BinaryOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.left_identity.getAsOpaquePointer()), + llvm::hash_value(prop.right_identity.getAsOpaquePointer())); +} + +std::optional BinaryOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "left_identity") + return prop.left_identity; + + if (name == "right_identity") + return prop.right_identity; + return std::nullopt; +} + +void BinaryOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "left_identity") { + prop.left_identity = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "right_identity") { + prop.right_identity = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void BinaryOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.left_identity) attrs.append("left_identity", prop.left_identity); + + if (prop.right_identity) attrs.append("right_identity", prop.right_identity); +} + +::mlir::LogicalResult BinaryOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getLeftIdentityAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_SparseTensorOps0(attr, "left_identity", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getRightIdentityAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_SparseTensorOps0(attr, "right_identity", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult BinaryOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.left_identity))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.right_identity))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BinaryOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.left_identity); + + writer.writeOptionalAttribute(prop.right_identity); +} + +::mlir::UnitAttr BinaryOp::getLeftIdentityAttr() { + return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().left_identity); +} + +bool BinaryOp::getLeftIdentity() { + auto attr = getLeftIdentityAttr(); + if (!attr) + return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; + return attr != nullptr; +} + +::mlir::UnitAttr BinaryOp::getRightIdentityAttr() { + return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().right_identity); +} + +bool BinaryOp::getRightIdentity() { + auto attr = getRightIdentityAttr(); + if (!attr) + return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; + return attr != nullptr; +} + +void BinaryOp::setLeftIdentityAttr(::mlir::UnitAttr attr) { + (*this)->setAttr(getLeftIdentityAttrName(), attr); +} + +void BinaryOp::setLeftIdentity(bool attrValue) { + if (attrValue) + return (*this)->setAttr(getLeftIdentityAttrName(), ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr)); + (*this)->removeAttr(getLeftIdentityAttrName()); +} + +void BinaryOp::setRightIdentityAttr(::mlir::UnitAttr attr) { + (*this)->setAttr(getRightIdentityAttrName(), attr); +} + +void BinaryOp::setRightIdentity(bool attrValue) { + if (attrValue) + return (*this)->setAttr(getRightIdentityAttrName(), ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr)); + (*this)->removeAttr(getRightIdentityAttrName()); +} + +::mlir::Attribute BinaryOp::removeLeftIdentityAttr() { + auto &attr = getProperties().left_identity; + attr = {}; + return attr; +} + +::mlir::Attribute BinaryOp::removeRightIdentityAttr() { + auto &attr = getProperties().right_identity; + attr = {}; + return attr; +} + +void BinaryOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value x, ::mlir::Value y, /*optional*/::mlir::UnitAttr left_identity, /*optional*/::mlir::UnitAttr right_identity) { + odsState.addOperands(x); + odsState.addOperands(y); + if (left_identity) { + odsState.getOrAddProperties().left_identity = left_identity; + } + if (right_identity) { + odsState.getOrAddProperties().right_identity = right_identity; + } + (void)odsState.addRegion(); + (void)odsState.addRegion(); + (void)odsState.addRegion(); + odsState.addTypes(output); +} + +void BinaryOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value x, ::mlir::Value y, /*optional*/::mlir::UnitAttr left_identity, /*optional*/::mlir::UnitAttr right_identity) { + odsState.addOperands(x); + odsState.addOperands(y); + if (left_identity) { + odsState.getOrAddProperties().left_identity = left_identity; + } + if (right_identity) { + odsState.getOrAddProperties().right_identity = right_identity; + } + (void)odsState.addRegion(); + (void)odsState.addRegion(); + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BinaryOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value x, ::mlir::Value y, /*optional*/bool left_identity, /*optional*/bool right_identity) { + odsState.addOperands(x); + odsState.addOperands(y); + if (left_identity) { + odsState.getOrAddProperties().left_identity = ((left_identity) ? odsBuilder.getUnitAttr() : nullptr); + } + if (right_identity) { + odsState.getOrAddProperties().right_identity = ((right_identity) ? odsBuilder.getUnitAttr() : nullptr); + } + (void)odsState.addRegion(); + (void)odsState.addRegion(); + (void)odsState.addRegion(); + odsState.addTypes(output); +} + +void BinaryOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value x, ::mlir::Value y, /*optional*/bool left_identity, /*optional*/bool right_identity) { + odsState.addOperands(x); + odsState.addOperands(y); + if (left_identity) { + odsState.getOrAddProperties().left_identity = ((left_identity) ? odsBuilder.getUnitAttr() : nullptr); + } + if (right_identity) { + odsState.getOrAddProperties().right_identity = ((right_identity) ? odsBuilder.getUnitAttr() : nullptr); + } + (void)odsState.addRegion(); + (void)odsState.addRegion(); + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BinaryOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 3; ++i) + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult BinaryOp::verifyInvariantsImpl() { + auto tblgen_left_identity = getProperties().left_identity; (void)tblgen_left_identity; + auto tblgen_right_identity = getProperties().right_identity; (void)tblgen_right_identity; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_SparseTensorOps0(*this, tblgen_left_identity, "left_identity"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_SparseTensorOps0(*this, tblgen_right_identity, "right_identity"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_SparseTensorOps0(*this, region, "overlapRegion", index++))) + return ::mlir::failure(); + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(1))) + if (::mlir::failed(__mlir_ods_local_region_constraint_SparseTensorOps0(*this, region, "leftRegion", index++))) + return ::mlir::failure(); + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(2))) + if (::mlir::failed(__mlir_ods_local_region_constraint_SparseTensorOps0(*this, region, "rightRegion", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult BinaryOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult BinaryOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand xRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> xOperands(xRawOperands); ::llvm::SMLoc xOperandsLoc; + (void)xOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand yRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> yOperands(yRawOperands); ::llvm::SMLoc yOperandsLoc; + (void)yOperandsLoc; + ::mlir::Type xRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> xTypes(xRawTypes); + ::mlir::Type yRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> yTypes(yRawTypes); + ::mlir::Type outputRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> outputTypes(outputRawTypes); + std::unique_ptr<::mlir::Region> overlapRegionRegion = std::make_unique<::mlir::Region>(); + std::unique_ptr<::mlir::Region> leftRegionRegion = std::make_unique<::mlir::Region>(); + std::unique_ptr<::mlir::Region> rightRegionRegion = std::make_unique<::mlir::Region>(); + + xOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(xRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + yOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(yRawOperands[0])) + return ::mlir::failure(); + if (parser.parseColon()) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + xRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + yRawTypes[0] = type; + } + if (parser.parseKeyword("to")) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + outputRawTypes[0] = type; + } + if (parser.parseKeyword("overlap")) + return ::mlir::failure(); + if (parser.parseEqual()) + return ::mlir::failure(); + + if (parser.parseRegion(*overlapRegionRegion)) + return ::mlir::failure(); + if (parser.parseKeyword("left")) + return ::mlir::failure(); + if (parser.parseEqual()) + return ::mlir::failure(); + if (::mlir::succeeded(parser.parseOptionalKeyword("identity"))) { + result.getOrAddProperties().left_identity = parser.getBuilder().getUnitAttr(); } else { + + if (parser.parseRegion(*leftRegionRegion)) + return ::mlir::failure(); + } + if (parser.parseKeyword("right")) + return ::mlir::failure(); + if (parser.parseEqual()) + return ::mlir::failure(); + if (::mlir::succeeded(parser.parseOptionalKeyword("identity"))) { + result.getOrAddProperties().right_identity = parser.getBuilder().getUnitAttr(); } else { + + if (parser.parseRegion(*rightRegionRegion)) + return ::mlir::failure(); + } + result.addRegion(std::move(overlapRegionRegion)); + result.addRegion(std::move(leftRegionRegion)); + result.addRegion(std::move(rightRegionRegion)); + result.addTypes(outputTypes); + if (parser.resolveOperands(xOperands, xTypes, xOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(yOperands, yTypes, yOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BinaryOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getX(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getY(); + _odsPrinter << ' ' << ":"; + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("left_identity"); + elidedAttrs.push_back("right_identity"); + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getLeftIdentityAttr(); + if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) + elidedAttrs.push_back("left_identity"); + } + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getRightIdentityAttr(); + if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) + elidedAttrs.push_back("right_identity"); + } + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' '; + { + auto type = getX().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getY().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "to"; + _odsPrinter << ' '; + { + auto type = getOutput().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter.printNewline(); + _odsPrinter << ' ' << "overlap"; + _odsPrinter << ' ' << "="; + _odsPrinter << ' '; + _odsPrinter.printRegion(getOverlapRegion()); + _odsPrinter.printNewline(); + _odsPrinter << ' ' << "left"; + _odsPrinter << ' ' << "="; + if (getLeftIdentityAttr()) { + _odsPrinter << ' ' << "identity"; + } else { + _odsPrinter << ' '; + _odsPrinter.printRegion(getLeftRegion()); + } + _odsPrinter.printNewline(); + _odsPrinter << ' ' << "right"; + _odsPrinter << ' ' << "="; + if (getRightIdentityAttr()) { + _odsPrinter << ' ' << "identity"; + } else { + _odsPrinter << ' '; + _odsPrinter.printRegion(getRightRegion()); + } +} + +void BinaryOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace sparse_tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::BinaryOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::CompressOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CompressOpGenericAdaptorBase::CompressOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("sparse_tensor.compress", odsAttrs.getContext()); +} + +CompressOpGenericAdaptorBase::CompressOpGenericAdaptorBase(CompressOp op) : CompressOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair CompressOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, false, false, false, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 5) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr CompressOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +CompressOpAdaptor::CompressOpAdaptor(CompressOp op) : CompressOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult CompressOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair CompressOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, false, false, false, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 5) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range CompressOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value CompressOp::getValues() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::MemRefType> CompressOp::getFilled() { + return ::llvm::cast<::mlir::TypedValue<::mlir::MemRefType>>(*getODSOperands(1).begin()); +} + +::mlir::TypedValue<::mlir::MemRefType> CompressOp::getAdded() { + return ::llvm::cast<::mlir::TypedValue<::mlir::MemRefType>>(*getODSOperands(2).begin()); +} + +::mlir::TypedValue<::mlir::IndexType> CompressOp::getCount() { + return ::llvm::cast<::mlir::TypedValue<::mlir::IndexType>>(*getODSOperands(3).begin()); +} + +::mlir::TypedValue<::mlir::TensorType> CompressOp::getTensor() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(4).begin()); +} + +::mlir::Operation::operand_range CompressOp::getLvlCoords() { + return getODSOperands(5); +} + +::mlir::OpOperand &CompressOp::getValuesMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &CompressOp::getFilledMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &CompressOp::getAddedMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &CompressOp::getCountMutable() { + auto range = getODSOperandIndexAndLength(3); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &CompressOp::getTensorMutable() { + auto range = getODSOperandIndexAndLength(4); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange CompressOp::getLvlCoordsMutable() { + auto range = getODSOperandIndexAndLength(5); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair CompressOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range CompressOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::TensorType> CompressOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); +} + +void CompressOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value values, ::mlir::Value filled, ::mlir::Value added, ::mlir::Value count, ::mlir::Value tensor, ::mlir::ValueRange lvlCoords) { + odsState.addOperands(values); + odsState.addOperands(filled); + odsState.addOperands(added); + odsState.addOperands(count); + odsState.addOperands(tensor); + odsState.addOperands(lvlCoords); + odsState.addTypes(result); +} + +void CompressOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value values, ::mlir::Value filled, ::mlir::Value added, ::mlir::Value count, ::mlir::Value tensor, ::mlir::ValueRange lvlCoords) { + odsState.addOperands(values); + odsState.addOperands(filled); + odsState.addOperands(added); + odsState.addOperands(count); + odsState.addOperands(tensor); + odsState.addOperands(lvlCoords); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CompressOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void CompressOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value values, ::mlir::Value filled, ::mlir::Value added, ::mlir::Value count, ::mlir::Value tensor, ::mlir::ValueRange lvlCoords) { + odsState.addOperands(values); + odsState.addOperands(filled); + odsState.addOperands(added); + odsState.addOperands(count); + odsState.addOperands(tensor); + odsState.addOperands(lvlCoords); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void CompressOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 5u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void CompressOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 5u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(CompressOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult CompressOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps4(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps5(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup3 = getODSOperands(3); + + for (auto v : valueGroup3) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps7(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup4 = getODSOperands(4); + + for (auto v : valueGroup4) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup5 = getODSOperands(5); + + for (auto v : valueGroup5) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps7(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((((*this->getODSOperands(4).begin()).getType()) == ((*this->getODSResults(0).begin()).getType()) && ((*this->getODSResults(0).begin()).getType()) == ((*this->getODSOperands(4).begin()).getType())))) + return emitOpError("failed to verify that all of {tensor, result} have same type"); + return ::mlir::success(); +} + +::mlir::LogicalResult CompressOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::LogicalResult CompressOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = operands[4].getType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult CompressOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand valuesRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> valuesOperands(valuesRawOperands); ::llvm::SMLoc valuesOperandsLoc; + (void)valuesOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand filledRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> filledOperands(filledRawOperands); ::llvm::SMLoc filledOperandsLoc; + (void)filledOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand addedRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> addedOperands(addedRawOperands); ::llvm::SMLoc addedOperandsLoc; + (void)addedOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand countRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> countOperands(countRawOperands); ::llvm::SMLoc countOperandsLoc; + (void)countOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand tensorRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> tensorOperands(tensorRawOperands); ::llvm::SMLoc tensorOperandsLoc; + (void)tensorOperandsLoc; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> lvlCoordsOperands; + ::llvm::SMLoc lvlCoordsOperandsLoc; + (void)lvlCoordsOperandsLoc; + ::mlir::Type valuesRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> valuesTypes(valuesRawTypes); + ::mlir::Type filledRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> filledTypes(filledRawTypes); + ::mlir::Type addedRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> addedTypes(addedRawTypes); + ::mlir::Type tensorRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> tensorTypes(tensorRawTypes); + + valuesOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(valuesRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + filledOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(filledRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + addedOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(addedRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + countOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(countRawOperands[0])) + return ::mlir::failure(); + if (parser.parseKeyword("into")) + return ::mlir::failure(); + + tensorOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(tensorRawOperands[0])) + return ::mlir::failure(); + if (parser.parseLSquare()) + return ::mlir::failure(); + + lvlCoordsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(lvlCoordsOperands)) + return ::mlir::failure(); + if (parser.parseRSquare()) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + valuesRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::MemRefType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + filledRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::MemRefType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + addedRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + tensorRawTypes[0] = type; + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + result.addTypes(tensorTypes[0]); + if (parser.resolveOperands(valuesOperands, valuesTypes, valuesOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(filledOperands, filledTypes, filledOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(addedOperands, addedTypes, addedOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(countOperands, odsBuildableType0, countOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(tensorOperands, tensorTypes, tensorOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(lvlCoordsOperands, odsBuildableType0, lvlCoordsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CompressOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getValues(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getFilled(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getAdded(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getCount(); + _odsPrinter << ' ' << "into"; + _odsPrinter << ' '; + _odsPrinter << getTensor(); + _odsPrinter << "["; + _odsPrinter << getLvlCoords(); + _odsPrinter << "]"; + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getValues().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getFilled().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::MemRefType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getAdded().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::MemRefType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getTensor().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +} // namespace sparse_tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::CompressOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::ConcatenateOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ConcatenateOpGenericAdaptorBase::ConcatenateOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("sparse_tensor.concatenate", odsAttrs.getContext()); +} + +ConcatenateOpGenericAdaptorBase::ConcatenateOpGenericAdaptorBase(ConcatenateOp op) : ConcatenateOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ConcatenateOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr ConcatenateOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::IntegerAttr ConcatenateOpGenericAdaptorBase::getDimensionAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().dimension); + return attr; +} + +::mlir::sparse_tensor::Dimension ConcatenateOpGenericAdaptorBase::getDimension() { + auto attr = getDimensionAttr(); + return attr.getValue().getZExtValue(); +} + +} // namespace detail +ConcatenateOpAdaptor::ConcatenateOpAdaptor(ConcatenateOp op) : ConcatenateOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ConcatenateOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_dimension = getProperties().dimension; (void)tblgen_dimension; + if (!tblgen_dimension) return emitError(loc, "'sparse_tensor.concatenate' op ""requires attribute 'dimension'"); + + if (tblgen_dimension && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_dimension))) && ((::llvm::isa<::mlir::IndexType>(::llvm::cast<::mlir::IntegerAttr>(tblgen_dimension).getType()))))) + return emitError(loc, "'sparse_tensor.concatenate' op ""attribute 'dimension' failed to satisfy constraint: dimension attribute"); + return ::mlir::success(); +} + +std::pair ConcatenateOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range ConcatenateOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::operand_range ConcatenateOp::getInputs() { + return getODSOperands(0); +} + +::mlir::MutableOperandRange ConcatenateOp::getInputsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair ConcatenateOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ConcatenateOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::RankedTensorType> ConcatenateOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult ConcatenateOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.dimension; + auto attr = dict.get("dimension"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for dimension in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `dimension` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ConcatenateOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.dimension; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("dimension", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ConcatenateOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.dimension.getAsOpaquePointer())); +} + +std::optional ConcatenateOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "dimension") + return prop.dimension; + return std::nullopt; +} + +void ConcatenateOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "dimension") { + prop.dimension = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ConcatenateOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.dimension) attrs.append("dimension", prop.dimension); +} + +::mlir::LogicalResult ConcatenateOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getDimensionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_SparseTensorOps1(attr, "dimension", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ConcatenateOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.dimension))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ConcatenateOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.dimension); +} + +::mlir::IntegerAttr ConcatenateOp::getDimensionAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().dimension); +} + +::mlir::sparse_tensor::Dimension ConcatenateOp::getDimension() { + auto attr = getDimensionAttr(); + return attr.getValue().getZExtValue(); +} + +void ConcatenateOp::setDimensionAttr(::mlir::IntegerAttr attr) { + (*this)->setAttr(getDimensionAttrName(), attr); +} + +void ConcatenateOp::setDimension(::mlir::sparse_tensor::Dimension attrValue) { + (*this)->setAttr(getDimensionAttrName(), ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIndexType(), attrValue)); +} + +void ConcatenateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange inputs, ::mlir::IntegerAttr dimension) { + odsState.addOperands(inputs); + odsState.getOrAddProperties().dimension = dimension; + odsState.addTypes(result); +} + +void ConcatenateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange inputs, ::mlir::IntegerAttr dimension) { + odsState.addOperands(inputs); + odsState.getOrAddProperties().dimension = dimension; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ConcatenateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange inputs, ::mlir::sparse_tensor::Dimension dimension) { + odsState.addOperands(inputs); + odsState.getOrAddProperties().dimension = odsBuilder.getIntegerAttr(odsBuilder.getIndexType(), dimension); + odsState.addTypes(result); +} + +void ConcatenateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange inputs, ::mlir::sparse_tensor::Dimension dimension) { + odsState.addOperands(inputs); + odsState.getOrAddProperties().dimension = odsBuilder.getIntegerAttr(odsBuilder.getIndexType(), dimension); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ConcatenateOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ConcatenateOp::verifyInvariantsImpl() { + auto tblgen_dimension = getProperties().dimension; (void)tblgen_dimension; + if (!tblgen_dimension) return emitOpError("requires attribute 'dimension'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_SparseTensorOps1(*this, tblgen_dimension, "dimension"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps8(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ConcatenateOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult ConcatenateOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> inputsOperands; + ::llvm::SMLoc inputsOperandsLoc; + (void)inputsOperandsLoc; + ::llvm::SmallVector<::mlir::Type, 1> inputsTypes; + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + inputsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(inputsOperands)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + if (parser.parseTypeList(inputsTypes)) + return ::mlir::failure(); + if (parser.parseKeyword("to")) + return ::mlir::failure(); + + { + ::mlir::RankedTensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(inputsOperands, inputsTypes, inputsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ConcatenateOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getInputs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter << getInputs().getTypes(); + _odsPrinter << ' ' << "to"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::RankedTensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void ConcatenateOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace sparse_tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::ConcatenateOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::ConvertOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ConvertOpGenericAdaptorBase::ConvertOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("sparse_tensor.convert", odsAttrs.getContext()); +} + +ConvertOpGenericAdaptorBase::ConvertOpGenericAdaptorBase(ConvertOp op) : ConvertOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ConvertOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ConvertOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +ConvertOpAdaptor::ConvertOpAdaptor(ConvertOp op) : ConvertOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ConvertOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair ConvertOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ConvertOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::TensorType> ConvertOp::getSource() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &ConvertOp::getSourceMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair ConvertOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ConvertOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::TensorType> ConvertOp::getDest() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); +} + +void ConvertOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dest, ::mlir::Value source) { + odsState.addOperands(source); + odsState.addTypes(dest); +} + +void ConvertOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source) { + odsState.addOperands(source); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ConvertOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ConvertOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps0(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ConvertOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult ConvertOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(sourceRawOperands); ::llvm::SMLoc sourceOperandsLoc; + (void)sourceOperandsLoc; + ::mlir::Type sourceRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> sourceTypes(sourceRawTypes); + ::mlir::Type destRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> destTypes(destRawTypes); + + sourceOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(sourceRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + sourceRawTypes[0] = type; + } + if (parser.parseKeyword("to")) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + destRawTypes[0] = type; + } + result.addTypes(destTypes); + if (parser.resolveOperands(sourceOperands, sourceTypes, sourceOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ConvertOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getSource(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getSource().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "to"; + _odsPrinter << ' '; + { + auto type = getDest().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void ConvertOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace sparse_tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::ConvertOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::DisassembleOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +DisassembleOpGenericAdaptorBase::DisassembleOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("sparse_tensor.disassemble", odsAttrs.getContext()); +} + +DisassembleOpGenericAdaptorBase::DisassembleOpGenericAdaptorBase(DisassembleOp op) : DisassembleOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair DisassembleOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 2) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr DisassembleOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +DisassembleOpAdaptor::DisassembleOpAdaptor(DisassembleOp op) : DisassembleOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult DisassembleOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +void DisassembleOp::getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn) { + auto resultGroup0 = getODSResults(0); + if (!resultGroup0.empty()) + setNameFn(*resultGroup0.begin(), "ret_values"); + auto resultGroup1 = getODSResults(1); + if (!resultGroup1.empty()) + setNameFn(*resultGroup1.begin(), "ret_levels"); + auto resultGroup2 = getODSResults(2); + if (!resultGroup2.empty()) + setNameFn(*resultGroup2.begin(), "val_len"); + auto resultGroup3 = getODSResults(3); + if (!resultGroup3.empty()) + setNameFn(*resultGroup3.begin(), "lvl_lens"); +} + +std::pair DisassembleOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 2) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range DisassembleOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::TensorType> DisassembleOp::getTensor() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::TensorType> DisassembleOp::getOutValues() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(1).begin()); +} + +::mlir::Operation::operand_range DisassembleOp::getOutLevels() { + return getODSOperands(2); +} + +::mlir::OpOperand &DisassembleOp::getTensorMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &DisassembleOp::getOutValuesMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange DisassembleOp::getOutLevelsMutable() { + auto range = getODSOperandIndexAndLength(2); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair DisassembleOp::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {false, true, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 2) / 2; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::result_range DisassembleOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::TensorType> DisassembleOp::getRetValues() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); +} + +::mlir::Operation::result_range DisassembleOp::getRetLevels() { + return getODSResults(1); +} + +::mlir::Value DisassembleOp::getValLen() { + return ::llvm::cast<::mlir::Value>(*getODSResults(2).begin()); +} + +::mlir::Operation::result_range DisassembleOp::getLvlLens() { + return getODSResults(3); +} + +void DisassembleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type ret_values, ::mlir::TypeRange ret_levels, ::mlir::Type val_len, ::mlir::TypeRange lvl_lens, ::mlir::Value tensor, ::mlir::Value out_values, ::mlir::ValueRange out_levels) { + odsState.addOperands(tensor); + odsState.addOperands(out_values); + odsState.addOperands(out_levels); + odsState.addTypes(ret_values); + odsState.addTypes(ret_levels); + odsState.addTypes(val_len); + odsState.addTypes(lvl_lens); +} + +void DisassembleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tensor, ::mlir::Value out_values, ::mlir::ValueRange out_levels) { + odsState.addOperands(tensor); + odsState.addOperands(out_values); + odsState.addOperands(out_levels); + assert(resultTypes.size() >= 2u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DisassembleOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() >= 2u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult DisassembleOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps0(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSResults(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSResults(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps9(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + auto valueGroup3 = getODSResults(3); + + for (auto v : valueGroup3) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps9(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult DisassembleOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult DisassembleOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand tensorRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> tensorOperands(tensorRawOperands); ::llvm::SMLoc tensorOperandsLoc; + (void)tensorOperandsLoc; + ::mlir::Type tensorRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> tensorTypes(tensorRawTypes); + ::mlir::OpAsmParser::UnresolvedOperand out_valuesRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> out_valuesOperands(out_valuesRawOperands); ::llvm::SMLoc out_valuesOperandsLoc; + (void)out_valuesOperandsLoc; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> out_levelsOperands; + ::llvm::SMLoc out_levelsOperandsLoc; + (void)out_levelsOperandsLoc; + ::mlir::Type out_valuesRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> out_valuesTypes(out_valuesRawTypes); + ::llvm::SmallVector<::mlir::Type, 1> out_levelsTypes; + ::mlir::Type ret_valuesRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> ret_valuesTypes(ret_valuesRawTypes); + ::llvm::SmallVector<::mlir::Type, 1> ret_levelsTypes; + ::mlir::Type val_lenRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> val_lenTypes(val_lenRawTypes); + ::llvm::SmallVector<::mlir::Type, 1> lvl_lensTypes; + + tensorOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(tensorRawOperands[0])) + return ::mlir::failure(); + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + tensorRawTypes[0] = type; + } + if (parser.parseKeyword("outs")) + return ::mlir::failure(); + if (parser.parseLParen()) + return ::mlir::failure(); + + out_valuesOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(out_valuesRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + out_levelsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(out_levelsOperands)) + return ::mlir::failure(); + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + out_valuesRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + if (parser.parseTypeList(out_levelsTypes)) + return ::mlir::failure(); + if (parser.parseRParen()) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + ret_valuesRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + if (parser.parseLParen()) + return ::mlir::failure(); + + if (parser.parseTypeList(ret_levelsTypes)) + return ::mlir::failure(); + if (parser.parseRParen()) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + val_lenRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + if (parser.parseLParen()) + return ::mlir::failure(); + + if (parser.parseTypeList(lvl_lensTypes)) + return ::mlir::failure(); + if (parser.parseRParen()) + return ::mlir::failure(); + result.addTypes(ret_valuesTypes); + result.addTypes(ret_levelsTypes); + result.addTypes(val_lenTypes); + result.addTypes(lvl_lensTypes); + if (parser.resolveOperands(tensorOperands, tensorTypes, tensorOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(out_valuesOperands, out_valuesTypes, out_valuesOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(out_levelsOperands, out_levelsTypes, out_levelsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void DisassembleOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getTensor(); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getTensor().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "outs"; + _odsPrinter << "("; + _odsPrinter << getOutValues(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getOutLevels(); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getOutValues().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getOutLevels().getTypes(); + _odsPrinter << ")"; + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getRetValues().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' ' << "("; + _odsPrinter << getRetLevels().getTypes(); + _odsPrinter << ")"; + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getValLen().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' ' << "("; + _odsPrinter << getLvlLens().getTypes(); + _odsPrinter << ")"; +} + +void DisassembleOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace sparse_tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::DisassembleOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::ExpandOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ExpandOpGenericAdaptorBase::ExpandOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("sparse_tensor.expand", odsAttrs.getContext()); +} + +ExpandOpGenericAdaptorBase::ExpandOpGenericAdaptorBase(ExpandOp op) : ExpandOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ExpandOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ExpandOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +ExpandOpAdaptor::ExpandOpAdaptor(ExpandOp op) : ExpandOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ExpandOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +void ExpandOp::getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn) { + auto resultGroup0 = getODSResults(0); + if (!resultGroup0.empty()) + setNameFn(*resultGroup0.begin(), "values"); + auto resultGroup1 = getODSResults(1); + if (!resultGroup1.empty()) + setNameFn(*resultGroup1.begin(), "filled"); + auto resultGroup2 = getODSResults(2); + if (!resultGroup2.empty()) + setNameFn(*resultGroup2.begin(), "added"); + auto resultGroup3 = getODSResults(3); + if (!resultGroup3.empty()) + setNameFn(*resultGroup3.begin(), "count"); +} + +std::pair ExpandOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ExpandOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::TensorType> ExpandOp::getTensor() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &ExpandOp::getTensorMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair ExpandOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ExpandOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value ExpandOp::getValues() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +::mlir::TypedValue<::mlir::MemRefType> ExpandOp::getFilled() { + return ::llvm::cast<::mlir::TypedValue<::mlir::MemRefType>>(*getODSResults(1).begin()); +} + +::mlir::TypedValue<::mlir::MemRefType> ExpandOp::getAdded() { + return ::llvm::cast<::mlir::TypedValue<::mlir::MemRefType>>(*getODSResults(2).begin()); +} + +::mlir::TypedValue<::mlir::IndexType> ExpandOp::getCount() { + return ::llvm::cast<::mlir::TypedValue<::mlir::IndexType>>(*getODSResults(3).begin()); +} + +void ExpandOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type values, ::mlir::Type filled, ::mlir::Type added, ::mlir::Type count, ::mlir::Value tensor) { + odsState.addOperands(tensor); + odsState.addTypes(values); + odsState.addTypes(filled); + odsState.addTypes(added); + odsState.addTypes(count); +} + +void ExpandOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tensor) { + odsState.addOperands(tensor); + assert(resultTypes.size() == 4u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ExpandOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 4u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ExpandOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps4(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSResults(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps5(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSResults(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps6(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + auto valueGroup3 = getODSResults(3); + + for (auto v : valueGroup3) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps7(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ExpandOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult ExpandOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand tensorRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> tensorOperands(tensorRawOperands); ::llvm::SMLoc tensorOperandsLoc; + (void)tensorOperandsLoc; + ::mlir::Type tensorRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> tensorTypes(tensorRawTypes); + ::mlir::Type valuesRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> valuesTypes(valuesRawTypes); + ::mlir::Type filledRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> filledTypes(filledRawTypes); + ::mlir::Type addedRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> addedTypes(addedRawTypes); + + tensorOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(tensorRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + tensorRawTypes[0] = type; + } + if (parser.parseKeyword("to")) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + valuesRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::MemRefType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + filledRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::MemRefType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + addedRawTypes[0] = type; + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + result.addTypes(valuesTypes); + result.addTypes(filledTypes); + result.addTypes(addedTypes); + result.addTypes(odsBuildableType0); + if (parser.resolveOperands(tensorOperands, tensorTypes, tensorOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ExpandOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getTensor(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getTensor().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "to"; + _odsPrinter << ' '; + { + auto type = getValues().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getFilled().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::MemRefType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getAdded().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::MemRefType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +} // namespace sparse_tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::ExpandOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::ForeachOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ForeachOpGenericAdaptorBase::ForeachOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("sparse_tensor.foreach", odsAttrs.getContext()); +} + +ForeachOpGenericAdaptorBase::ForeachOpGenericAdaptorBase(ForeachOp op) : ForeachOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ForeachOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr ForeachOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::AffineMapAttr ForeachOpGenericAdaptorBase::getOrderAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::AffineMapAttr>(getProperties().order); + return attr; +} + +::std::optional< ::mlir::AffineMap > ForeachOpGenericAdaptorBase::getOrder() { + auto attr = getOrderAttr(); + return attr ? ::std::optional< ::mlir::AffineMap >(attr.getValue()) : (::std::nullopt); +} + +::mlir::Region &ForeachOpGenericAdaptorBase::getRegion() { + return *odsRegions[0]; +} + +::mlir::RegionRange ForeachOpGenericAdaptorBase::getRegions() { + return odsRegions; +} + +} // namespace detail +ForeachOpAdaptor::ForeachOpAdaptor(ForeachOp op) : ForeachOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ForeachOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_order = getProperties().order; (void)tblgen_order; + + if (tblgen_order && !((::llvm::isa<::mlir::AffineMapAttr>(tblgen_order)))) + return emitError(loc, "'sparse_tensor.foreach' op ""attribute 'order' failed to satisfy constraint: AffineMap attribute"); + return ::mlir::success(); +} + +std::pair ForeachOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range ForeachOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::TensorType> ForeachOp::getTensor() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); +} + +::mlir::Operation::operand_range ForeachOp::getInitArgs() { + return getODSOperands(1); +} + +::mlir::OpOperand &ForeachOp::getTensorMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange ForeachOp::getInitArgsMutable() { + auto range = getODSOperandIndexAndLength(1); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair ForeachOp::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::result_range ForeachOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::result_range ForeachOp::getResults() { + return getODSResults(0); +} + +::mlir::Region &ForeachOp::getRegion() { + return (*this)->getRegion(0); +} + +::mlir::LogicalResult ForeachOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.order; + auto attr = dict.get("order"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for order in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `order` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ForeachOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.order; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("order", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ForeachOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.order.getAsOpaquePointer())); +} + +std::optional ForeachOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "order") + return prop.order; + return std::nullopt; +} + +void ForeachOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "order") { + prop.order = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ForeachOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.order) attrs.append("order", prop.order); +} + +::mlir::LogicalResult ForeachOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getOrderAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_SparseTensorOps2(attr, "order", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ForeachOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.order))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ForeachOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.order); +} + +::mlir::AffineMapAttr ForeachOp::getOrderAttr() { + return ::llvm::dyn_cast_or_null<::mlir::AffineMapAttr>(getProperties().order); +} + +::std::optional< ::mlir::AffineMap > ForeachOp::getOrder() { + auto attr = getOrderAttr(); + return attr ? ::std::optional< ::mlir::AffineMap >(attr.getValue()) : (::std::nullopt); +} + +void ForeachOp::setOrderAttr(::mlir::AffineMapAttr attr) { + (*this)->setAttr(getOrderAttrName(), attr); +} + +void ForeachOp::setOrder(::std::optional<::mlir::AffineMap> attrValue) { + if (attrValue) + return (*this)->setAttr(getOrderAttrName(), ::mlir::AffineMapAttr::get(*attrValue)); + (*this)->removeAttr(getOrderAttrName()); +} + +::mlir::Attribute ForeachOp::removeOrderAttr() { + auto &attr = getProperties().order; + attr = {}; + return attr; +} + +void ForeachOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value tensor, AffineMapAttr order, function_ref bodyBuilder) { + build(odsBuilder, odsState, tensor, ValueRange(), order, bodyBuilder); + +} + +void ForeachOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value tensor, function_ref bodyBuilder) { + build(odsBuilder, odsState, tensor, ValueRange(), nullptr, bodyBuilder); + +} + +void ForeachOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value tensor, ValueRange iterArgs, function_ref bodyBuilder) { + build(odsBuilder, odsState, tensor, iterArgs, nullptr, bodyBuilder); + +} + +void ForeachOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::Value tensor, ::mlir::ValueRange initArgs, /*optional*/::mlir::AffineMapAttr order) { + odsState.addOperands(tensor); + odsState.addOperands(initArgs); + if (order) { + odsState.getOrAddProperties().order = order; + } + (void)odsState.addRegion(); + odsState.addTypes(results); +} + +void ForeachOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ForeachOp::verifyInvariantsImpl() { + auto tblgen_order = getProperties().order; (void)tblgen_order; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_SparseTensorOps2(*this, tblgen_order, "order"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_SparseTensorOps1(*this, region, "region", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ForeachOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult ForeachOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand tensorRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> tensorOperands(tensorRawOperands); ::llvm::SMLoc tensorOperandsLoc; + (void)tensorOperandsLoc; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> initArgsOperands; + ::llvm::SMLoc initArgsOperandsLoc; + (void)initArgsOperandsLoc; + ::mlir::Type tensorRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> tensorTypes(tensorRawTypes); + ::llvm::SmallVector<::mlir::Type, 1> initArgsTypes; + ::llvm::SmallVector<::mlir::Type, 1> resultsTypes; + std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>(); + if (parser.parseKeyword("in")) + return ::mlir::failure(); + + tensorOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(tensorRawOperands[0])) + return ::mlir::failure(); + if (::mlir::succeeded(parser.parseOptionalKeyword("init"))) { + if (parser.parseLParen()) + return ::mlir::failure(); + + initArgsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(initArgsOperands)) + return ::mlir::failure(); + if (parser.parseRParen()) + return ::mlir::failure(); + } + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + tensorRawTypes[0] = type; + } + if (::mlir::succeeded(parser.parseOptionalComma())) { + + if (parser.parseTypeList(initArgsTypes)) + return ::mlir::failure(); + } + if (::mlir::succeeded(parser.parseOptionalArrow())) { + + if (parser.parseTypeList(resultsTypes)) + return ::mlir::failure(); + } + if (parser.parseKeyword("do")) + return ::mlir::failure(); + + if (parser.parseRegion(*regionRegion)) + return ::mlir::failure(); + + ensureTerminator(*regionRegion, parser.getBuilder(), result.location); + result.addRegion(std::move(regionRegion)); + result.addTypes(resultsTypes); + if (parser.resolveOperands(tensorOperands, tensorTypes, tensorOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(initArgsOperands, initArgsTypes, initArgsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ForeachOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' ' << "in"; + _odsPrinter << ' '; + _odsPrinter << getTensor(); + if (!getInitArgs().empty()) { + _odsPrinter << ' ' << "init"; + _odsPrinter << "("; + _odsPrinter << getInitArgs(); + _odsPrinter << ")"; + } + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getTensor().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + if (!getInitArgs().empty()) { + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getInitArgs().getTypes(); + } + if (!getResults().empty()) { + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + _odsPrinter << getResults().getTypes(); + } + _odsPrinter << ' ' << "do"; + _odsPrinter << ' '; + + { + bool printTerminator = true; + if (auto *term = getRegion().empty() ? nullptr : getRegion().begin()->getTerminator()) { + printTerminator = !term->getAttrDictionary().empty() || + term->getNumOperands() != 0 || + term->getNumResults() != 0; + } + _odsPrinter.printRegion(getRegion(), /*printEntryBlockArgs=*/true, + /*printBlockTerminators=*/printTerminator); + } +} + +} // namespace sparse_tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::ForeachOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::GetStorageSpecifierOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +GetStorageSpecifierOpGenericAdaptorBase::GetStorageSpecifierOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("sparse_tensor.storage_specifier.get", odsAttrs.getContext()); +} + +GetStorageSpecifierOpGenericAdaptorBase::GetStorageSpecifierOpGenericAdaptorBase(GetStorageSpecifierOp op) : GetStorageSpecifierOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair GetStorageSpecifierOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr GetStorageSpecifierOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::sparse_tensor::StorageSpecifierKindAttr GetStorageSpecifierOpGenericAdaptorBase::getSpecifierKindAttr() { + auto attr = ::llvm::cast<::mlir::sparse_tensor::StorageSpecifierKindAttr>(getProperties().specifierKind); + return attr; +} + +::mlir::sparse_tensor::StorageSpecifierKind GetStorageSpecifierOpGenericAdaptorBase::getSpecifierKind() { + auto attr = getSpecifierKindAttr(); + return attr.getValue(); +} + +::mlir::IntegerAttr GetStorageSpecifierOpGenericAdaptorBase::getLevelAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::IntegerAttr>(getProperties().level); + return attr; +} + +::std::optional<::mlir::sparse_tensor::Level> GetStorageSpecifierOpGenericAdaptorBase::getLevel() { + auto attr = getLevelAttr(); + return attr ? ::std::optional<::mlir::sparse_tensor::Level>(attr.getValue().getZExtValue()) : (::std::nullopt); +} + +} // namespace detail +GetStorageSpecifierOpAdaptor::GetStorageSpecifierOpAdaptor(GetStorageSpecifierOp op) : GetStorageSpecifierOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult GetStorageSpecifierOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_level = getProperties().level; (void)tblgen_level; + auto tblgen_specifierKind = getProperties().specifierKind; (void)tblgen_specifierKind; + if (!tblgen_specifierKind) return emitError(loc, "'sparse_tensor.storage_specifier.get' op ""requires attribute 'specifierKind'"); + + if (tblgen_specifierKind && !((::llvm::isa<::mlir::sparse_tensor::StorageSpecifierKindAttr>(tblgen_specifierKind)))) + return emitError(loc, "'sparse_tensor.storage_specifier.get' op ""attribute 'specifierKind' failed to satisfy constraint: sparse tensor storage specifier kind"); + + if (tblgen_level && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_level))) && ((::llvm::isa<::mlir::IndexType>(::llvm::cast<::mlir::IntegerAttr>(tblgen_level).getType()))))) + return emitError(loc, "'sparse_tensor.storage_specifier.get' op ""attribute 'level' failed to satisfy constraint: level attribute"); + return ::mlir::success(); +} + +std::pair GetStorageSpecifierOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range GetStorageSpecifierOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::sparse_tensor::StorageSpecifierType> GetStorageSpecifierOp::getSpecifier() { + return ::llvm::cast<::mlir::TypedValue<::mlir::sparse_tensor::StorageSpecifierType>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &GetStorageSpecifierOp::getSpecifierMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair GetStorageSpecifierOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range GetStorageSpecifierOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::IndexType> GetStorageSpecifierOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::IndexType>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult GetStorageSpecifierOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.level; + auto attr = dict.get("level"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for level in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `level` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.specifierKind; + auto attr = dict.get("specifierKind"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for specifierKind in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `specifierKind` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute GetStorageSpecifierOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.level; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("level", + propStorage)); + } + + { + const auto &propStorage = prop.specifierKind; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("specifierKind", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code GetStorageSpecifierOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.level.getAsOpaquePointer()), + llvm::hash_value(prop.specifierKind.getAsOpaquePointer())); +} + +std::optional GetStorageSpecifierOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "level") + return prop.level; + + if (name == "specifierKind") + return prop.specifierKind; + return std::nullopt; +} + +void GetStorageSpecifierOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "level") { + prop.level = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "specifierKind") { + prop.specifierKind = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void GetStorageSpecifierOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.level) attrs.append("level", prop.level); + + if (prop.specifierKind) attrs.append("specifierKind", prop.specifierKind); +} + +::mlir::LogicalResult GetStorageSpecifierOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getLevelAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_SparseTensorOps4(attr, "level", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getSpecifierKindAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_SparseTensorOps3(attr, "specifierKind", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult GetStorageSpecifierOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.level))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.specifierKind))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void GetStorageSpecifierOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.level); + writer.writeAttribute(prop.specifierKind); +} + +::mlir::sparse_tensor::StorageSpecifierKindAttr GetStorageSpecifierOp::getSpecifierKindAttr() { + return ::llvm::cast<::mlir::sparse_tensor::StorageSpecifierKindAttr>(getProperties().specifierKind); +} + +::mlir::sparse_tensor::StorageSpecifierKind GetStorageSpecifierOp::getSpecifierKind() { + auto attr = getSpecifierKindAttr(); + return attr.getValue(); +} + +::mlir::IntegerAttr GetStorageSpecifierOp::getLevelAttr() { + return ::llvm::dyn_cast_or_null<::mlir::IntegerAttr>(getProperties().level); +} + +::std::optional<::mlir::sparse_tensor::Level> GetStorageSpecifierOp::getLevel() { + auto attr = getLevelAttr(); + return attr ? ::std::optional<::mlir::sparse_tensor::Level>(attr.getValue().getZExtValue()) : (::std::nullopt); +} + +void GetStorageSpecifierOp::setSpecifierKindAttr(::mlir::sparse_tensor::StorageSpecifierKindAttr attr) { + (*this)->setAttr(getSpecifierKindAttrName(), attr); +} + +void GetStorageSpecifierOp::setSpecifierKind(::mlir::sparse_tensor::StorageSpecifierKind attrValue) { + (*this)->setAttr(getSpecifierKindAttrName(), ::mlir::sparse_tensor::StorageSpecifierKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue)); +} + +void GetStorageSpecifierOp::setLevelAttr(::mlir::IntegerAttr attr) { + (*this)->setAttr(getLevelAttrName(), attr); +} + +void GetStorageSpecifierOp::setLevel(::std::optional<::mlir::sparse_tensor::Level> attrValue) { + if (attrValue) + return (*this)->setAttr(getLevelAttrName(), ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIndexType(), *attrValue)); + (*this)->removeAttr(getLevelAttrName()); +} + +::mlir::Attribute GetStorageSpecifierOp::removeLevelAttr() { + auto &attr = getProperties().level; + attr = {}; + return attr; +} + +void GetStorageSpecifierOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value specifier, ::mlir::sparse_tensor::StorageSpecifierKindAttr specifierKind, /*optional*/::mlir::IntegerAttr level) { + odsState.addOperands(specifier); + odsState.getOrAddProperties().specifierKind = specifierKind; + if (level) { + odsState.getOrAddProperties().level = level; + } + odsState.addTypes(result); +} + +void GetStorageSpecifierOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value specifier, ::mlir::sparse_tensor::StorageSpecifierKindAttr specifierKind, /*optional*/::mlir::IntegerAttr level) { + odsState.addOperands(specifier); + odsState.getOrAddProperties().specifierKind = specifierKind; + if (level) { + odsState.getOrAddProperties().level = level; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(GetStorageSpecifierOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void GetStorageSpecifierOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value specifier, ::mlir::sparse_tensor::StorageSpecifierKindAttr specifierKind, /*optional*/::mlir::IntegerAttr level) { + odsState.addOperands(specifier); + odsState.getOrAddProperties().specifierKind = specifierKind; + if (level) { + odsState.getOrAddProperties().level = level; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void GetStorageSpecifierOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value specifier, ::mlir::sparse_tensor::StorageSpecifierKind specifierKind, /*optional*/::mlir::IntegerAttr level) { + odsState.addOperands(specifier); + odsState.getOrAddProperties().specifierKind = ::mlir::sparse_tensor::StorageSpecifierKindAttr::get(odsBuilder.getContext(), specifierKind); + if (level) { + odsState.getOrAddProperties().level = level; + } + odsState.addTypes(result); +} + +void GetStorageSpecifierOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value specifier, ::mlir::sparse_tensor::StorageSpecifierKind specifierKind, /*optional*/::mlir::IntegerAttr level) { + odsState.addOperands(specifier); + odsState.getOrAddProperties().specifierKind = ::mlir::sparse_tensor::StorageSpecifierKindAttr::get(odsBuilder.getContext(), specifierKind); + if (level) { + odsState.getOrAddProperties().level = level; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(GetStorageSpecifierOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void GetStorageSpecifierOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value specifier, ::mlir::sparse_tensor::StorageSpecifierKind specifierKind, /*optional*/::mlir::IntegerAttr level) { + odsState.addOperands(specifier); + odsState.getOrAddProperties().specifierKind = ::mlir::sparse_tensor::StorageSpecifierKindAttr::get(odsBuilder.getContext(), specifierKind); + if (level) { + odsState.getOrAddProperties().level = level; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void GetStorageSpecifierOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void GetStorageSpecifierOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(GetStorageSpecifierOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult GetStorageSpecifierOp::verifyInvariantsImpl() { + auto tblgen_level = getProperties().level; (void)tblgen_level; + auto tblgen_specifierKind = getProperties().specifierKind; (void)tblgen_specifierKind; + if (!tblgen_specifierKind) return emitOpError("requires attribute 'specifierKind'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_SparseTensorOps3(*this, tblgen_specifierKind, "specifierKind"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_SparseTensorOps4(*this, tblgen_level, "level"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps10(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps7(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult GetStorageSpecifierOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::LogicalResult GetStorageSpecifierOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = odsBuilder.getIndexType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult GetStorageSpecifierOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand specifierRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> specifierOperands(specifierRawOperands); ::llvm::SMLoc specifierOperandsLoc; + (void)specifierOperandsLoc; + ::mlir::sparse_tensor::StorageSpecifierKindAttr specifierKindAttr; + ::mlir::IntegerAttr levelAttr; + ::mlir::Type specifierRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> specifierTypes(specifierRawTypes); + + specifierOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(specifierRawOperands[0])) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(specifierKindAttr, ::mlir::Type{})) { + return ::mlir::failure(); + } + if (specifierKindAttr) result.getOrAddProperties().specifierKind = specifierKindAttr; + if (::mlir::succeeded(parser.parseOptionalKeyword("at"))) { + + if (parser.parseCustomAttributeWithFallback(levelAttr, parser.getBuilder().getIndexType())) { + return ::mlir::failure(); + } + if (levelAttr) result.getOrAddProperties().level = levelAttr; + } + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + if (parser.parseType(specifierRawTypes[0])) + return ::mlir::failure(); + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + result.addTypes(odsBuildableType0); + if (parser.resolveOperands(specifierOperands, specifierTypes, specifierOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void GetStorageSpecifierOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getSpecifier(); + _odsPrinter << ' '; +_odsPrinter.printStrippedAttrOrType(getSpecifierKindAttr()); + if (getLevelAttr()) { + _odsPrinter << ' ' << "at"; + _odsPrinter << ' '; + _odsPrinter.printAttributeWithoutType(getLevelAttr()); + } + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("specifierKind"); + elidedAttrs.push_back("level"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter << getSpecifier().getType(); +} + +void GetStorageSpecifierOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace sparse_tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::GetStorageSpecifierOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::InsertOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +InsertOpGenericAdaptorBase::InsertOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("sparse_tensor.insert", odsAttrs.getContext()); +} + +InsertOpGenericAdaptorBase::InsertOpGenericAdaptorBase(InsertOp op) : InsertOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair InsertOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 2) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr InsertOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +InsertOpAdaptor::InsertOpAdaptor(InsertOp op) : InsertOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult InsertOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair InsertOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 2) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range InsertOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value InsertOp::getValue() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::TensorType> InsertOp::getTensor() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(1).begin()); +} + +::mlir::Operation::operand_range InsertOp::getLvlCoords() { + return getODSOperands(2); +} + +::mlir::OpOperand &InsertOp::getValueMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &InsertOp::getTensorMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange InsertOp::getLvlCoordsMutable() { + auto range = getODSOperandIndexAndLength(2); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair InsertOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range InsertOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::TensorType> InsertOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); +} + +void InsertOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value value, ::mlir::Value tensor, ::mlir::ValueRange lvlCoords) { + odsState.addOperands(value); + odsState.addOperands(tensor); + odsState.addOperands(lvlCoords); + odsState.addTypes(result); +} + +void InsertOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value value, ::mlir::Value tensor, ::mlir::ValueRange lvlCoords) { + odsState.addOperands(value); + odsState.addOperands(tensor); + odsState.addOperands(lvlCoords); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(InsertOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void InsertOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value value, ::mlir::Value tensor, ::mlir::ValueRange lvlCoords) { + odsState.addOperands(value); + odsState.addOperands(tensor); + odsState.addOperands(lvlCoords); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void InsertOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void InsertOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(InsertOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult InsertOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps7(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((std::equal_to<>()(::llvm::cast((*this->getODSOperands(1).begin()).getType()).getElementType(), (*this->getODSOperands(0).begin()).getType())))) + return emitOpError("failed to verify that value type matches element type of tensor"); + if (!((((*this->getODSOperands(1).begin()).getType()) == ((*this->getODSResults(0).begin()).getType()) && ((*this->getODSResults(0).begin()).getType()) == ((*this->getODSOperands(1).begin()).getType())))) + return emitOpError("failed to verify that all of {tensor, result} have same type"); + return ::mlir::success(); +} + +::mlir::LogicalResult InsertOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::LogicalResult InsertOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = operands[1].getType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult InsertOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand valueRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> valueOperands(valueRawOperands); ::llvm::SMLoc valueOperandsLoc; + (void)valueOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand tensorRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> tensorOperands(tensorRawOperands); ::llvm::SMLoc tensorOperandsLoc; + (void)tensorOperandsLoc; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> lvlCoordsOperands; + ::llvm::SMLoc lvlCoordsOperandsLoc; + (void)lvlCoordsOperandsLoc; + ::mlir::Type tensorRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> tensorTypes(tensorRawTypes); + + valueOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(valueRawOperands[0])) + return ::mlir::failure(); + if (parser.parseKeyword("into")) + return ::mlir::failure(); + + tensorOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(tensorRawOperands[0])) + return ::mlir::failure(); + if (parser.parseLSquare()) + return ::mlir::failure(); + + lvlCoordsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(lvlCoordsOperands)) + return ::mlir::failure(); + if (parser.parseRSquare()) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + tensorRawTypes[0] = type; + } + for (::mlir::Type type : tensorTypes) { + (void)type; + if (!((((::llvm::isa<::mlir::TensorType>(type))) && ((!!::mlir::sparse_tensor::getSparseTensorEncoding(type)))) && ([](::mlir::Type elementType) { return (true); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return parser.emitError(parser.getNameLoc()) << "'tensor' must be sparse tensor of any type values, but got " << type; + } + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + result.addTypes(tensorTypes[0]); + if (parser.resolveOperands(valueOperands, ::llvm::cast(tensorTypes[0]).getElementType(), valueOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(tensorOperands, tensorTypes, tensorOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(lvlCoordsOperands, odsBuildableType0, lvlCoordsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void InsertOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getValue(); + _odsPrinter << ' ' << "into"; + _odsPrinter << ' '; + _odsPrinter << getTensor(); + _odsPrinter << "["; + _odsPrinter << getLvlCoords(); + _odsPrinter << "]"; + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getTensor().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +} // namespace sparse_tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::InsertOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::LoadOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +LoadOpGenericAdaptorBase::LoadOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("sparse_tensor.load", odsAttrs.getContext()); +} + +LoadOpGenericAdaptorBase::LoadOpGenericAdaptorBase(LoadOp op) : LoadOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair LoadOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr LoadOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::UnitAttr LoadOpGenericAdaptorBase::getHasInsertsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().hasInserts); + if (!attr) + attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); + return attr; +} + +bool LoadOpGenericAdaptorBase::getHasInserts() { + auto attr = getHasInsertsAttr(); + if (!attr) + return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; + return attr != nullptr; +} + +} // namespace detail +LoadOpAdaptor::LoadOpAdaptor(LoadOp op) : LoadOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult LoadOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_hasInserts = getProperties().hasInserts; (void)tblgen_hasInserts; + + if (tblgen_hasInserts && !((::llvm::isa<::mlir::UnitAttr>(tblgen_hasInserts)))) + return emitError(loc, "'sparse_tensor.load' op ""attribute 'hasInserts' failed to satisfy constraint: unit attribute"); + return ::mlir::success(); +} + +std::pair LoadOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range LoadOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::TensorType> LoadOp::getTensor() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &LoadOp::getTensorMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair LoadOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range LoadOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::TensorType> LoadOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult LoadOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.hasInserts; + auto attr = dict.get("hasInserts"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for hasInserts in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `hasInserts` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute LoadOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.hasInserts; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("hasInserts", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code LoadOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.hasInserts.getAsOpaquePointer())); +} + +std::optional LoadOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "hasInserts") + return prop.hasInserts; + return std::nullopt; +} + +void LoadOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "hasInserts") { + prop.hasInserts = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void LoadOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.hasInserts) attrs.append("hasInserts", prop.hasInserts); +} + +::mlir::LogicalResult LoadOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getHasInsertsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_SparseTensorOps0(attr, "hasInserts", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult LoadOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.hasInserts))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void LoadOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.hasInserts); +} + +::mlir::UnitAttr LoadOp::getHasInsertsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().hasInserts); +} + +bool LoadOp::getHasInserts() { + auto attr = getHasInsertsAttr(); + if (!attr) + return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; + return attr != nullptr; +} + +void LoadOp::setHasInsertsAttr(::mlir::UnitAttr attr) { + (*this)->setAttr(getHasInsertsAttrName(), attr); +} + +void LoadOp::setHasInserts(bool attrValue) { + if (attrValue) + return (*this)->setAttr(getHasInsertsAttrName(), ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr)); + (*this)->removeAttr(getHasInsertsAttrName()); +} + +::mlir::Attribute LoadOp::removeHasInsertsAttr() { + auto &attr = getProperties().hasInserts; + attr = {}; + return attr; +} + +void LoadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value tensor, /*optional*/::mlir::UnitAttr hasInserts) { + odsState.addOperands(tensor); + if (hasInserts) { + odsState.getOrAddProperties().hasInserts = hasInserts; + } + odsState.addTypes(result); +} + +void LoadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value tensor, /*optional*/::mlir::UnitAttr hasInserts) { + odsState.addOperands(tensor); + if (hasInserts) { + odsState.getOrAddProperties().hasInserts = hasInserts; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(LoadOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void LoadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tensor, /*optional*/::mlir::UnitAttr hasInserts) { + odsState.addOperands(tensor); + if (hasInserts) { + odsState.getOrAddProperties().hasInserts = hasInserts; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void LoadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value tensor, /*optional*/bool hasInserts) { + odsState.addOperands(tensor); + if (hasInserts) { + odsState.getOrAddProperties().hasInserts = ((hasInserts) ? odsBuilder.getUnitAttr() : nullptr); + } + odsState.addTypes(result); +} + +void LoadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value tensor, /*optional*/bool hasInserts) { + odsState.addOperands(tensor); + if (hasInserts) { + odsState.getOrAddProperties().hasInserts = ((hasInserts) ? odsBuilder.getUnitAttr() : nullptr); + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(LoadOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void LoadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tensor, /*optional*/bool hasInserts) { + odsState.addOperands(tensor); + if (hasInserts) { + odsState.getOrAddProperties().hasInserts = ((hasInserts) ? odsBuilder.getUnitAttr() : nullptr); + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void LoadOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void LoadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(LoadOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult LoadOp::verifyInvariantsImpl() { + auto tblgen_hasInserts = getProperties().hasInserts; (void)tblgen_hasInserts; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_SparseTensorOps0(*this, tblgen_hasInserts, "hasInserts"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps0(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult LoadOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::LogicalResult LoadOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = operands[0].getType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult LoadOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand tensorRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> tensorOperands(tensorRawOperands); ::llvm::SMLoc tensorOperandsLoc; + (void)tensorOperandsLoc; + ::mlir::Type tensorRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> tensorTypes(tensorRawTypes); + + tensorOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(tensorRawOperands[0])) + return ::mlir::failure(); + if (::mlir::succeeded(parser.parseOptionalKeyword("hasInserts"))) { + result.getOrAddProperties().hasInserts = parser.getBuilder().getUnitAttr(); } + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + tensorRawTypes[0] = type; + } + result.addTypes(tensorTypes[0]); + if (parser.resolveOperands(tensorOperands, tensorTypes, tensorOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void LoadOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getTensor(); + if (getHasInsertsAttr()) { + _odsPrinter << ' ' << "hasInserts"; + } + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("hasInserts"); + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getHasInsertsAttr(); + if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) + elidedAttrs.push_back("hasInserts"); + } + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getTensor().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +} // namespace sparse_tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::LoadOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::NewOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +NewOpGenericAdaptorBase::NewOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("sparse_tensor.new", odsAttrs.getContext()); +} + +NewOpGenericAdaptorBase::NewOpGenericAdaptorBase(NewOp op) : NewOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair NewOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr NewOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +NewOpAdaptor::NewOpAdaptor(NewOp op) : NewOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult NewOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair NewOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range NewOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value NewOp::getSource() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &NewOp::getSourceMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair NewOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range NewOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::TensorType> NewOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); +} + +void NewOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source) { + odsState.addOperands(source); + odsState.addTypes(result); +} + +void NewOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source) { + odsState.addOperands(source); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void NewOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult NewOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult NewOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult NewOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(sourceRawOperands); ::llvm::SMLoc sourceOperandsLoc; + (void)sourceOperandsLoc; + ::mlir::Type sourceRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> sourceTypes(sourceRawTypes); + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + sourceOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(sourceRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + sourceRawTypes[0] = type; + } + if (parser.parseKeyword("to")) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(sourceOperands, sourceTypes, sourceOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void NewOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getSource(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getSource().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "to"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void NewOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace sparse_tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::NewOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::NumberOfEntriesOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +NumberOfEntriesOpGenericAdaptorBase::NumberOfEntriesOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("sparse_tensor.number_of_entries", odsAttrs.getContext()); +} + +NumberOfEntriesOpGenericAdaptorBase::NumberOfEntriesOpGenericAdaptorBase(NumberOfEntriesOp op) : NumberOfEntriesOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair NumberOfEntriesOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr NumberOfEntriesOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +NumberOfEntriesOpAdaptor::NumberOfEntriesOpAdaptor(NumberOfEntriesOp op) : NumberOfEntriesOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult NumberOfEntriesOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair NumberOfEntriesOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range NumberOfEntriesOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::TensorType> NumberOfEntriesOp::getTensor() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &NumberOfEntriesOp::getTensorMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair NumberOfEntriesOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range NumberOfEntriesOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::IndexType> NumberOfEntriesOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::IndexType>>(*getODSResults(0).begin()); +} + +void NumberOfEntriesOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value tensor) { + odsState.addOperands(tensor); + odsState.addTypes(result); +} + +void NumberOfEntriesOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value tensor) { + odsState.addOperands(tensor); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(NumberOfEntriesOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void NumberOfEntriesOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tensor) { + odsState.addOperands(tensor); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void NumberOfEntriesOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void NumberOfEntriesOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(NumberOfEntriesOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult NumberOfEntriesOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps7(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult NumberOfEntriesOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::LogicalResult NumberOfEntriesOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = odsBuilder.getIndexType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult NumberOfEntriesOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand tensorRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> tensorOperands(tensorRawOperands); ::llvm::SMLoc tensorOperandsLoc; + (void)tensorOperandsLoc; + ::mlir::Type tensorRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> tensorTypes(tensorRawTypes); + + tensorOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(tensorRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + tensorRawTypes[0] = type; + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + result.addTypes(odsBuildableType0); + if (parser.resolveOperands(tensorOperands, tensorTypes, tensorOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void NumberOfEntriesOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getTensor(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getTensor().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void NumberOfEntriesOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace sparse_tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::NumberOfEntriesOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::OutOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +OutOpGenericAdaptorBase::OutOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("sparse_tensor.out", odsAttrs.getContext()); +} + +OutOpGenericAdaptorBase::OutOpGenericAdaptorBase(OutOp op) : OutOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair OutOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr OutOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +OutOpAdaptor::OutOpAdaptor(OutOp op) : OutOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult OutOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair OutOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range OutOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::TensorType> OutOp::getTensor() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); +} + +::mlir::Value OutOp::getDest() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(1).begin()); +} + +::mlir::OpOperand &OutOp::getTensorMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &OutOp::getDestMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +std::pair OutOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range OutOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +void OutOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value tensor, ::mlir::Value dest) { + odsState.addOperands(tensor); + odsState.addOperands(dest); +} + +void OutOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tensor, ::mlir::Value dest) { + odsState.addOperands(tensor); + odsState.addOperands(dest); + assert(resultTypes.size() == 0u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void OutOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult OutOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult OutOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult OutOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand tensorRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> tensorOperands(tensorRawOperands); ::llvm::SMLoc tensorOperandsLoc; + (void)tensorOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand destRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> destOperands(destRawOperands); ::llvm::SMLoc destOperandsLoc; + (void)destOperandsLoc; + ::mlir::Type tensorRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> tensorTypes(tensorRawTypes); + ::mlir::Type destRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> destTypes(destRawTypes); + + tensorOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(tensorRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + destOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(destRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + tensorRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + destRawTypes[0] = type; + } + if (parser.resolveOperands(tensorOperands, tensorTypes, tensorOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(destOperands, destTypes, destOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void OutOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getTensor(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getDest(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getTensor().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getDest().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +} // namespace sparse_tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::OutOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::PushBackOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +PushBackOpGenericAdaptorBase::PushBackOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("sparse_tensor.push_back", odsAttrs.getContext()); +} + +PushBackOpGenericAdaptorBase::PushBackOpGenericAdaptorBase(PushBackOp op) : PushBackOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair PushBackOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, false, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 3) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr PushBackOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::UnitAttr PushBackOpGenericAdaptorBase::getInboundsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().inbounds); + if (!attr) + attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); + return attr; +} + +bool PushBackOpGenericAdaptorBase::getInbounds() { + auto attr = getInboundsAttr(); + if (!attr) + return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; + return attr != nullptr; +} + +} // namespace detail +PushBackOpAdaptor::PushBackOpAdaptor(PushBackOp op) : PushBackOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult PushBackOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_inbounds = getProperties().inbounds; (void)tblgen_inbounds; + + if (tblgen_inbounds && !((::llvm::isa<::mlir::UnitAttr>(tblgen_inbounds)))) + return emitError(loc, "'sparse_tensor.push_back' op ""attribute 'inbounds' failed to satisfy constraint: unit attribute"); + return ::mlir::success(); +} + +void PushBackOp::getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn) { + auto resultGroup0 = getODSResults(0); + if (!resultGroup0.empty()) + setNameFn(*resultGroup0.begin(), "outBuffer"); + auto resultGroup1 = getODSResults(1); + if (!resultGroup1.empty()) + setNameFn(*resultGroup1.begin(), "newSize"); +} + +std::pair PushBackOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, false, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 3) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range PushBackOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::IndexType> PushBackOp::getCurSize() { + return ::llvm::cast<::mlir::TypedValue<::mlir::IndexType>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::MemRefType> PushBackOp::getInBuffer() { + return ::llvm::cast<::mlir::TypedValue<::mlir::MemRefType>>(*getODSOperands(1).begin()); +} + +::mlir::Value PushBackOp::getValue() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(2).begin()); +} + +::mlir::TypedValue<::mlir::IndexType> PushBackOp::getN() { + auto operands = getODSOperands(3); + return operands.empty() ? ::mlir::TypedValue<::mlir::IndexType>{} : ::llvm::cast<::mlir::TypedValue<::mlir::IndexType>>(*operands.begin()); +} + +::mlir::OpOperand &PushBackOp::getCurSizeMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &PushBackOp::getInBufferMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &PushBackOp::getValueMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange PushBackOp::getNMutable() { + auto range = getODSOperandIndexAndLength(3); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair PushBackOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range PushBackOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::MemRefType> PushBackOp::getOutBuffer() { + return ::llvm::cast<::mlir::TypedValue<::mlir::MemRefType>>(*getODSResults(0).begin()); +} + +::mlir::TypedValue<::mlir::IndexType> PushBackOp::getNewSize() { + return ::llvm::cast<::mlir::TypedValue<::mlir::IndexType>>(*getODSResults(1).begin()); +} + +::mlir::LogicalResult PushBackOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.inbounds; + auto attr = dict.get("inbounds"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for inbounds in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `inbounds` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute PushBackOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.inbounds; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("inbounds", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code PushBackOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.inbounds.getAsOpaquePointer())); +} + +std::optional PushBackOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "inbounds") + return prop.inbounds; + return std::nullopt; +} + +void PushBackOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "inbounds") { + prop.inbounds = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void PushBackOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.inbounds) attrs.append("inbounds", prop.inbounds); +} + +::mlir::LogicalResult PushBackOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getInboundsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_SparseTensorOps0(attr, "inbounds", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult PushBackOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.inbounds))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void PushBackOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.inbounds); +} + +::mlir::UnitAttr PushBackOp::getInboundsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().inbounds); +} + +bool PushBackOp::getInbounds() { + auto attr = getInboundsAttr(); + if (!attr) + return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; + return attr != nullptr; +} + +void PushBackOp::setInboundsAttr(::mlir::UnitAttr attr) { + (*this)->setAttr(getInboundsAttrName(), attr); +} + +void PushBackOp::setInbounds(bool attrValue) { + if (attrValue) + return (*this)->setAttr(getInboundsAttrName(), ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr)); + (*this)->removeAttr(getInboundsAttrName()); +} + +::mlir::Attribute PushBackOp::removeInboundsAttr() { + auto &attr = getProperties().inbounds; + attr = {}; + return attr; +} + +void PushBackOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type outBuffer, ::mlir::Type newSize, ::mlir::Value curSize, ::mlir::Value inBuffer, ::mlir::Value value, /*optional*/::mlir::Value n, /*optional*/::mlir::UnitAttr inbounds) { + odsState.addOperands(curSize); + odsState.addOperands(inBuffer); + odsState.addOperands(value); + if (n) + odsState.addOperands(n); + if (inbounds) { + odsState.getOrAddProperties().inbounds = inbounds; + } + odsState.addTypes(outBuffer); + odsState.addTypes(newSize); +} + +void PushBackOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value curSize, ::mlir::Value inBuffer, ::mlir::Value value, /*optional*/::mlir::Value n, /*optional*/::mlir::UnitAttr inbounds) { + odsState.addOperands(curSize); + odsState.addOperands(inBuffer); + odsState.addOperands(value); + if (n) + odsState.addOperands(n); + if (inbounds) { + odsState.getOrAddProperties().inbounds = inbounds; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(PushBackOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void PushBackOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value curSize, ::mlir::Value inBuffer, ::mlir::Value value, /*optional*/::mlir::Value n, /*optional*/::mlir::UnitAttr inbounds) { + odsState.addOperands(curSize); + odsState.addOperands(inBuffer); + odsState.addOperands(value); + if (n) + odsState.addOperands(n); + if (inbounds) { + odsState.getOrAddProperties().inbounds = inbounds; + } + assert(resultTypes.size() == 2u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void PushBackOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type outBuffer, ::mlir::Type newSize, ::mlir::Value curSize, ::mlir::Value inBuffer, ::mlir::Value value, /*optional*/::mlir::Value n, /*optional*/bool inbounds) { + odsState.addOperands(curSize); + odsState.addOperands(inBuffer); + odsState.addOperands(value); + if (n) + odsState.addOperands(n); + if (inbounds) { + odsState.getOrAddProperties().inbounds = ((inbounds) ? odsBuilder.getUnitAttr() : nullptr); + } + odsState.addTypes(outBuffer); + odsState.addTypes(newSize); +} + +void PushBackOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value curSize, ::mlir::Value inBuffer, ::mlir::Value value, /*optional*/::mlir::Value n, /*optional*/bool inbounds) { + odsState.addOperands(curSize); + odsState.addOperands(inBuffer); + odsState.addOperands(value); + if (n) + odsState.addOperands(n); + if (inbounds) { + odsState.getOrAddProperties().inbounds = ((inbounds) ? odsBuilder.getUnitAttr() : nullptr); + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(PushBackOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void PushBackOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value curSize, ::mlir::Value inBuffer, ::mlir::Value value, /*optional*/::mlir::Value n, /*optional*/bool inbounds) { + odsState.addOperands(curSize); + odsState.addOperands(inBuffer); + odsState.addOperands(value); + if (n) + odsState.addOperands(n); + if (inbounds) { + odsState.getOrAddProperties().inbounds = ((inbounds) ? odsBuilder.getUnitAttr() : nullptr); + } + assert(resultTypes.size() == 2u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void PushBackOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 2u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void PushBackOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(PushBackOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 2u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult PushBackOp::verifyInvariantsImpl() { + auto tblgen_inbounds = getProperties().inbounds; (void)tblgen_inbounds; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_SparseTensorOps0(*this, tblgen_inbounds, "inbounds"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps7(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps11(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup3 = getODSOperands(3); + + if (valueGroup3.size() > 1) { + return emitOpError("operand group starting at #") << index + << " requires 0 or 1 element, but found " << valueGroup3.size(); + } + + for (auto v : valueGroup3) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps7(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps11(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSResults(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps7(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((std::equal_to<>()(::llvm::cast((*this->getODSOperands(1).begin()).getType()).getElementType(), (*this->getODSOperands(2).begin()).getType())))) + return emitOpError("failed to verify that value type matches element type of inBuffer"); + if (!((((*this->getODSOperands(1).begin()).getType()) == ((*this->getODSResults(0).begin()).getType()) && ((*this->getODSResults(0).begin()).getType()) == ((*this->getODSOperands(1).begin()).getType())))) + return emitOpError("failed to verify that all of {inBuffer, outBuffer} have same type"); + return ::mlir::success(); +} + +::mlir::LogicalResult PushBackOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::LogicalResult PushBackOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(2); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = operands[1].getType(); + ::mlir::Type odsInferredType1 = odsBuilder.getIndexType(); + inferredReturnTypes[0] = odsInferredType0; + inferredReturnTypes[1] = odsInferredType1; + return ::mlir::success(); +} + +::mlir::ParseResult PushBackOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand curSizeRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> curSizeOperands(curSizeRawOperands); ::llvm::SMLoc curSizeOperandsLoc; + (void)curSizeOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand inBufferRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> inBufferOperands(inBufferRawOperands); ::llvm::SMLoc inBufferOperandsLoc; + (void)inBufferOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand valueRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> valueOperands(valueRawOperands); ::llvm::SMLoc valueOperandsLoc; + (void)valueOperandsLoc; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> nOperands; + ::llvm::SMLoc nOperandsLoc; + (void)nOperandsLoc; + ::mlir::Type curSizeRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> curSizeTypes(curSizeRawTypes); + ::mlir::Type inBufferRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> inBufferTypes(inBufferRawTypes); + ::mlir::Type valueRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> valueTypes(valueRawTypes); + ::llvm::SmallVector<::mlir::Type, 1> nTypes; + if (::mlir::succeeded(parser.parseOptionalKeyword("inbounds"))) { + result.getOrAddProperties().inbounds = parser.getBuilder().getUnitAttr(); } + + curSizeOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(curSizeRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + inBufferOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(inBufferRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + valueOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(valueRawOperands[0])) + return ::mlir::failure(); + if (::mlir::succeeded(parser.parseOptionalComma())) { + + { + nOperandsLoc = parser.getCurrentLocation(); + ::mlir::OpAsmParser::UnresolvedOperand operand; + ::mlir::OptionalParseResult parseResult = + parser.parseOptionalOperand(operand); + if (parseResult.has_value()) { + if (failed(*parseResult)) + return ::mlir::failure(); + nOperands.push_back(operand); + } + } + } + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::IndexType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + curSizeRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::MemRefType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + inBufferRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + valueRawTypes[0] = type; + } + if (::mlir::succeeded(parser.parseOptionalComma())) { + + { + ::mlir::Type optionalType; + ::mlir::OptionalParseResult parseResult = + parser.parseOptionalType(optionalType); + if (parseResult.has_value()) { + if (failed(*parseResult)) + return ::mlir::failure(); + nTypes.push_back(optionalType); + } + } + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + result.addTypes(inBufferTypes[0]); + result.addTypes(odsBuildableType0); + if (parser.resolveOperands(curSizeOperands, curSizeTypes, curSizeOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(inBufferOperands, inBufferTypes, inBufferOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(valueOperands, valueTypes, valueOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(nOperands, nTypes, nOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void PushBackOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + if (getInboundsAttr()) { + _odsPrinter << ' ' << "inbounds"; + } + _odsPrinter << ' '; + _odsPrinter << getCurSize(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getInBuffer(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getValue(); + if (getN()) { + _odsPrinter << ","; + _odsPrinter << ' '; + if (::mlir::Value value = getN()) + _odsPrinter << value; + } + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("inbounds"); + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getInboundsAttr(); + if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) + elidedAttrs.push_back("inbounds"); + } + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getCurSize().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::IndexType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getInBuffer().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::MemRefType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getValue().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + if (getN()) { + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << (getN() ? ::llvm::ArrayRef<::mlir::Type>(getN().getType()) : ::llvm::ArrayRef<::mlir::Type>()); + } +} + +} // namespace sparse_tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::PushBackOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::ReduceOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ReduceOpGenericAdaptorBase::ReduceOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("sparse_tensor.reduce", odsAttrs.getContext()); +} + +ReduceOpGenericAdaptorBase::ReduceOpGenericAdaptorBase(ReduceOp op) : ReduceOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ReduceOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ReduceOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::Region &ReduceOpGenericAdaptorBase::getRegion() { + return *odsRegions[0]; +} + +::mlir::RegionRange ReduceOpGenericAdaptorBase::getRegions() { + return odsRegions; +} + +} // namespace detail +ReduceOpAdaptor::ReduceOpAdaptor(ReduceOp op) : ReduceOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ReduceOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair ReduceOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ReduceOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value ReduceOp::getX() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin()); +} + +::mlir::Value ReduceOp::getY() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(1).begin()); +} + +::mlir::Value ReduceOp::getIdentity() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(2).begin()); +} + +::mlir::OpOperand &ReduceOp::getXMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &ReduceOp::getYMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &ReduceOp::getIdentityMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); +} + +std::pair ReduceOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ReduceOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value ReduceOp::getOutput() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +::mlir::Region &ReduceOp::getRegion() { + return (*this)->getRegion(0); +} + +void ReduceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value x, ::mlir::Value y, ::mlir::Value identity) { + odsState.addOperands(x); + odsState.addOperands(y); + odsState.addOperands(identity); + (void)odsState.addRegion(); + odsState.addTypes(output); +} + +void ReduceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value x, ::mlir::Value y, ::mlir::Value identity) { + odsState.addOperands(x); + odsState.addOperands(y); + odsState.addOperands(identity); + (void)odsState.addRegion(); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ReduceOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void ReduceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value x, ::mlir::Value y, ::mlir::Value identity) { + odsState.addOperands(x); + odsState.addOperands(y); + odsState.addOperands(identity); + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ReduceOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ReduceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ReduceOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult ReduceOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_SparseTensorOps1(*this, region, "region", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ReduceOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::LogicalResult ReduceOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = operands[0].getType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult ReduceOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand xRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> xOperands(xRawOperands); ::llvm::SMLoc xOperandsLoc; + (void)xOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand yRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> yOperands(yRawOperands); ::llvm::SMLoc yOperandsLoc; + (void)yOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand identityRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> identityOperands(identityRawOperands); ::llvm::SMLoc identityOperandsLoc; + (void)identityOperandsLoc; + ::mlir::Type outputRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> outputTypes(outputRawTypes); + std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>(); + + xOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(xRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + yOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(yRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + identityOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(identityRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + outputRawTypes[0] = type; + } + + if (parser.parseRegion(*regionRegion)) + return ::mlir::failure(); + result.addRegion(std::move(regionRegion)); + result.addTypes(outputTypes); + if (parser.resolveOperands(xOperands, outputTypes[0], xOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(yOperands, outputTypes[0], yOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(identityOperands, outputTypes[0], identityOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ReduceOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getX(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getY(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getIdentity(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getOutput().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' '; + _odsPrinter.printRegion(getRegion()); +} + +void ReduceOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace sparse_tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::ReduceOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::SelectOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +SelectOpGenericAdaptorBase::SelectOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("sparse_tensor.select", odsAttrs.getContext()); +} + +SelectOpGenericAdaptorBase::SelectOpGenericAdaptorBase(SelectOp op) : SelectOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair SelectOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr SelectOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::Region &SelectOpGenericAdaptorBase::getRegion() { + return *odsRegions[0]; +} + +::mlir::RegionRange SelectOpGenericAdaptorBase::getRegions() { + return odsRegions; +} + +} // namespace detail +SelectOpAdaptor::SelectOpAdaptor(SelectOp op) : SelectOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult SelectOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair SelectOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range SelectOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value SelectOp::getX() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &SelectOp::getXMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair SelectOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range SelectOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value SelectOp::getOutput() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +::mlir::Region &SelectOp::getRegion() { + return (*this)->getRegion(0); +} + +void SelectOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value x) { + odsState.addOperands(x); + (void)odsState.addRegion(); + odsState.addTypes(output); +} + +void SelectOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value x) { + odsState.addOperands(x); + (void)odsState.addRegion(); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SelectOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void SelectOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value x) { + odsState.addOperands(x); + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SelectOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void SelectOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SelectOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult SelectOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_SparseTensorOps1(*this, region, "region", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult SelectOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::LogicalResult SelectOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = operands[0].getType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult SelectOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand xRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> xOperands(xRawOperands); ::llvm::SMLoc xOperandsLoc; + (void)xOperandsLoc; + ::mlir::Type xRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> xTypes(xRawTypes); + std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>(); + + xOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(xRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + xRawTypes[0] = type; + } + + if (parser.parseRegion(*regionRegion)) + return ::mlir::failure(); + result.addRegion(std::move(regionRegion)); + result.addTypes(xTypes[0]); + if (parser.resolveOperands(xOperands, xTypes, xOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SelectOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getX(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getX().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' '; + _odsPrinter.printRegion(getRegion()); +} + +void SelectOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace sparse_tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::SelectOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::SetStorageSpecifierOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +SetStorageSpecifierOpGenericAdaptorBase::SetStorageSpecifierOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("sparse_tensor.storage_specifier.set", odsAttrs.getContext()); +} + +SetStorageSpecifierOpGenericAdaptorBase::SetStorageSpecifierOpGenericAdaptorBase(SetStorageSpecifierOp op) : SetStorageSpecifierOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair SetStorageSpecifierOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr SetStorageSpecifierOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::sparse_tensor::StorageSpecifierKindAttr SetStorageSpecifierOpGenericAdaptorBase::getSpecifierKindAttr() { + auto attr = ::llvm::cast<::mlir::sparse_tensor::StorageSpecifierKindAttr>(getProperties().specifierKind); + return attr; +} + +::mlir::sparse_tensor::StorageSpecifierKind SetStorageSpecifierOpGenericAdaptorBase::getSpecifierKind() { + auto attr = getSpecifierKindAttr(); + return attr.getValue(); +} + +::mlir::IntegerAttr SetStorageSpecifierOpGenericAdaptorBase::getLevelAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::IntegerAttr>(getProperties().level); + return attr; +} + +::std::optional<::mlir::sparse_tensor::Level> SetStorageSpecifierOpGenericAdaptorBase::getLevel() { + auto attr = getLevelAttr(); + return attr ? ::std::optional<::mlir::sparse_tensor::Level>(attr.getValue().getZExtValue()) : (::std::nullopt); +} + +} // namespace detail +SetStorageSpecifierOpAdaptor::SetStorageSpecifierOpAdaptor(SetStorageSpecifierOp op) : SetStorageSpecifierOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult SetStorageSpecifierOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_level = getProperties().level; (void)tblgen_level; + auto tblgen_specifierKind = getProperties().specifierKind; (void)tblgen_specifierKind; + if (!tblgen_specifierKind) return emitError(loc, "'sparse_tensor.storage_specifier.set' op ""requires attribute 'specifierKind'"); + + if (tblgen_specifierKind && !((::llvm::isa<::mlir::sparse_tensor::StorageSpecifierKindAttr>(tblgen_specifierKind)))) + return emitError(loc, "'sparse_tensor.storage_specifier.set' op ""attribute 'specifierKind' failed to satisfy constraint: sparse tensor storage specifier kind"); + + if (tblgen_level && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_level))) && ((::llvm::isa<::mlir::IndexType>(::llvm::cast<::mlir::IntegerAttr>(tblgen_level).getType()))))) + return emitError(loc, "'sparse_tensor.storage_specifier.set' op ""attribute 'level' failed to satisfy constraint: level attribute"); + return ::mlir::success(); +} + +std::pair SetStorageSpecifierOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range SetStorageSpecifierOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::sparse_tensor::StorageSpecifierType> SetStorageSpecifierOp::getSpecifier() { + return ::llvm::cast<::mlir::TypedValue<::mlir::sparse_tensor::StorageSpecifierType>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::IndexType> SetStorageSpecifierOp::getValue() { + return ::llvm::cast<::mlir::TypedValue<::mlir::IndexType>>(*getODSOperands(1).begin()); +} + +::mlir::OpOperand &SetStorageSpecifierOp::getSpecifierMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &SetStorageSpecifierOp::getValueMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +std::pair SetStorageSpecifierOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range SetStorageSpecifierOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::sparse_tensor::StorageSpecifierType> SetStorageSpecifierOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::sparse_tensor::StorageSpecifierType>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult SetStorageSpecifierOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.level; + auto attr = dict.get("level"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for level in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `level` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.specifierKind; + auto attr = dict.get("specifierKind"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for specifierKind in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `specifierKind` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute SetStorageSpecifierOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.level; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("level", + propStorage)); + } + + { + const auto &propStorage = prop.specifierKind; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("specifierKind", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code SetStorageSpecifierOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.level.getAsOpaquePointer()), + llvm::hash_value(prop.specifierKind.getAsOpaquePointer())); +} + +std::optional SetStorageSpecifierOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "level") + return prop.level; + + if (name == "specifierKind") + return prop.specifierKind; + return std::nullopt; +} + +void SetStorageSpecifierOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "level") { + prop.level = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "specifierKind") { + prop.specifierKind = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void SetStorageSpecifierOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.level) attrs.append("level", prop.level); + + if (prop.specifierKind) attrs.append("specifierKind", prop.specifierKind); +} + +::mlir::LogicalResult SetStorageSpecifierOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getLevelAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_SparseTensorOps4(attr, "level", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getSpecifierKindAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_SparseTensorOps3(attr, "specifierKind", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult SetStorageSpecifierOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.level))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.specifierKind))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SetStorageSpecifierOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.level); + writer.writeAttribute(prop.specifierKind); +} + +::mlir::sparse_tensor::StorageSpecifierKindAttr SetStorageSpecifierOp::getSpecifierKindAttr() { + return ::llvm::cast<::mlir::sparse_tensor::StorageSpecifierKindAttr>(getProperties().specifierKind); +} + +::mlir::sparse_tensor::StorageSpecifierKind SetStorageSpecifierOp::getSpecifierKind() { + auto attr = getSpecifierKindAttr(); + return attr.getValue(); +} + +::mlir::IntegerAttr SetStorageSpecifierOp::getLevelAttr() { + return ::llvm::dyn_cast_or_null<::mlir::IntegerAttr>(getProperties().level); +} + +::std::optional<::mlir::sparse_tensor::Level> SetStorageSpecifierOp::getLevel() { + auto attr = getLevelAttr(); + return attr ? ::std::optional<::mlir::sparse_tensor::Level>(attr.getValue().getZExtValue()) : (::std::nullopt); +} + +void SetStorageSpecifierOp::setSpecifierKindAttr(::mlir::sparse_tensor::StorageSpecifierKindAttr attr) { + (*this)->setAttr(getSpecifierKindAttrName(), attr); +} + +void SetStorageSpecifierOp::setSpecifierKind(::mlir::sparse_tensor::StorageSpecifierKind attrValue) { + (*this)->setAttr(getSpecifierKindAttrName(), ::mlir::sparse_tensor::StorageSpecifierKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue)); +} + +void SetStorageSpecifierOp::setLevelAttr(::mlir::IntegerAttr attr) { + (*this)->setAttr(getLevelAttrName(), attr); +} + +void SetStorageSpecifierOp::setLevel(::std::optional<::mlir::sparse_tensor::Level> attrValue) { + if (attrValue) + return (*this)->setAttr(getLevelAttrName(), ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIndexType(), *attrValue)); + (*this)->removeAttr(getLevelAttrName()); +} + +::mlir::Attribute SetStorageSpecifierOp::removeLevelAttr() { + auto &attr = getProperties().level; + attr = {}; + return attr; +} + +void SetStorageSpecifierOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value specifier, ::mlir::sparse_tensor::StorageSpecifierKindAttr specifierKind, /*optional*/::mlir::IntegerAttr level, ::mlir::Value value) { + odsState.addOperands(specifier); + odsState.addOperands(value); + odsState.getOrAddProperties().specifierKind = specifierKind; + if (level) { + odsState.getOrAddProperties().level = level; + } + odsState.addTypes(result); +} + +void SetStorageSpecifierOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value specifier, ::mlir::sparse_tensor::StorageSpecifierKindAttr specifierKind, /*optional*/::mlir::IntegerAttr level, ::mlir::Value value) { + odsState.addOperands(specifier); + odsState.addOperands(value); + odsState.getOrAddProperties().specifierKind = specifierKind; + if (level) { + odsState.getOrAddProperties().level = level; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SetStorageSpecifierOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void SetStorageSpecifierOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value specifier, ::mlir::sparse_tensor::StorageSpecifierKindAttr specifierKind, /*optional*/::mlir::IntegerAttr level, ::mlir::Value value) { + odsState.addOperands(specifier); + odsState.addOperands(value); + odsState.getOrAddProperties().specifierKind = specifierKind; + if (level) { + odsState.getOrAddProperties().level = level; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SetStorageSpecifierOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value specifier, ::mlir::sparse_tensor::StorageSpecifierKind specifierKind, /*optional*/::mlir::IntegerAttr level, ::mlir::Value value) { + odsState.addOperands(specifier); + odsState.addOperands(value); + odsState.getOrAddProperties().specifierKind = ::mlir::sparse_tensor::StorageSpecifierKindAttr::get(odsBuilder.getContext(), specifierKind); + if (level) { + odsState.getOrAddProperties().level = level; + } + odsState.addTypes(result); +} + +void SetStorageSpecifierOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value specifier, ::mlir::sparse_tensor::StorageSpecifierKind specifierKind, /*optional*/::mlir::IntegerAttr level, ::mlir::Value value) { + odsState.addOperands(specifier); + odsState.addOperands(value); + odsState.getOrAddProperties().specifierKind = ::mlir::sparse_tensor::StorageSpecifierKindAttr::get(odsBuilder.getContext(), specifierKind); + if (level) { + odsState.getOrAddProperties().level = level; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SetStorageSpecifierOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void SetStorageSpecifierOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value specifier, ::mlir::sparse_tensor::StorageSpecifierKind specifierKind, /*optional*/::mlir::IntegerAttr level, ::mlir::Value value) { + odsState.addOperands(specifier); + odsState.addOperands(value); + odsState.getOrAddProperties().specifierKind = ::mlir::sparse_tensor::StorageSpecifierKindAttr::get(odsBuilder.getContext(), specifierKind); + if (level) { + odsState.getOrAddProperties().level = level; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SetStorageSpecifierOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void SetStorageSpecifierOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(SetStorageSpecifierOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult SetStorageSpecifierOp::verifyInvariantsImpl() { + auto tblgen_level = getProperties().level; (void)tblgen_level; + auto tblgen_specifierKind = getProperties().specifierKind; (void)tblgen_specifierKind; + if (!tblgen_specifierKind) return emitOpError("requires attribute 'specifierKind'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_SparseTensorOps3(*this, tblgen_specifierKind, "specifierKind"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_SparseTensorOps4(*this, tblgen_level, "level"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps10(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps7(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps10(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((((*this->getODSResults(0).begin()).getType()) == ((*this->getODSOperands(0).begin()).getType()) && ((*this->getODSOperands(0).begin()).getType()) == ((*this->getODSResults(0).begin()).getType())))) + return emitOpError("failed to verify that all of {result, specifier} have same type"); + return ::mlir::success(); +} + +::mlir::LogicalResult SetStorageSpecifierOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::LogicalResult SetStorageSpecifierOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = operands[0].getType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult SetStorageSpecifierOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand specifierRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> specifierOperands(specifierRawOperands); ::llvm::SMLoc specifierOperandsLoc; + (void)specifierOperandsLoc; + ::mlir::sparse_tensor::StorageSpecifierKindAttr specifierKindAttr; + ::mlir::IntegerAttr levelAttr; + ::mlir::OpAsmParser::UnresolvedOperand valueRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> valueOperands(valueRawOperands); ::llvm::SMLoc valueOperandsLoc; + (void)valueOperandsLoc; + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + specifierOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(specifierRawOperands[0])) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(specifierKindAttr, ::mlir::Type{})) { + return ::mlir::failure(); + } + if (specifierKindAttr) result.getOrAddProperties().specifierKind = specifierKindAttr; + if (::mlir::succeeded(parser.parseOptionalKeyword("at"))) { + + if (parser.parseCustomAttributeWithFallback(levelAttr, parser.getBuilder().getIndexType())) { + return ::mlir::failure(); + } + if (levelAttr) result.getOrAddProperties().level = levelAttr; + } + if (parser.parseKeyword("with")) + return ::mlir::failure(); + + valueOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(valueRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + if (parser.parseType(resultRawTypes[0])) + return ::mlir::failure(); + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + result.addTypes(resultTypes); + if (parser.resolveOperands(specifierOperands, resultTypes[0], specifierOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(valueOperands, odsBuildableType0, valueOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SetStorageSpecifierOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getSpecifier(); + _odsPrinter << ' '; +_odsPrinter.printStrippedAttrOrType(getSpecifierKindAttr()); + if (getLevelAttr()) { + _odsPrinter << ' ' << "at"; + _odsPrinter << ' '; + _odsPrinter.printAttributeWithoutType(getLevelAttr()); + } + _odsPrinter << ' ' << "with"; + _odsPrinter << ' '; + _odsPrinter << getValue(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("specifierKind"); + elidedAttrs.push_back("level"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter << getResult().getType(); +} + +void SetStorageSpecifierOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace sparse_tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::SetStorageSpecifierOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::SortOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +SortOpGenericAdaptorBase::SortOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("sparse_tensor.sort", odsAttrs.getContext()); +} + +SortOpGenericAdaptorBase::SortOpGenericAdaptorBase(SortOp op) : SortOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair SortOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 2) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr SortOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::AffineMapAttr SortOpGenericAdaptorBase::getPermMapAttr() { + auto attr = ::llvm::cast<::mlir::AffineMapAttr>(getProperties().perm_map); + return attr; +} + +::mlir::AffineMap SortOpGenericAdaptorBase::getPermMap() { + auto attr = getPermMapAttr(); + return attr.getValue(); +} + +::mlir::IntegerAttr SortOpGenericAdaptorBase::getNyAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::IntegerAttr>(getProperties().ny); + return attr; +} + +::std::optional< ::llvm::APInt > SortOpGenericAdaptorBase::getNy() { + auto attr = getNyAttr(); + return attr ? ::std::optional< ::llvm::APInt >(attr.getValue()) : (::std::nullopt); +} + +::mlir::sparse_tensor::SparseTensorSortKindAttr SortOpGenericAdaptorBase::getAlgorithmAttr() { + auto attr = ::llvm::cast<::mlir::sparse_tensor::SparseTensorSortKindAttr>(getProperties().algorithm); + return attr; +} + +::mlir::sparse_tensor::SparseTensorSortKind SortOpGenericAdaptorBase::getAlgorithm() { + auto attr = getAlgorithmAttr(); + return attr.getValue(); +} + +} // namespace detail +SortOpAdaptor::SortOpAdaptor(SortOp op) : SortOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult SortOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_algorithm = getProperties().algorithm; (void)tblgen_algorithm; + if (!tblgen_algorithm) return emitError(loc, "'sparse_tensor.sort' op ""requires attribute 'algorithm'"); + auto tblgen_ny = getProperties().ny; (void)tblgen_ny; + auto tblgen_perm_map = getProperties().perm_map; (void)tblgen_perm_map; + if (!tblgen_perm_map) return emitError(loc, "'sparse_tensor.sort' op ""requires attribute 'perm_map'"); + + if (tblgen_perm_map && !((::llvm::isa<::mlir::AffineMapAttr>(tblgen_perm_map)))) + return emitError(loc, "'sparse_tensor.sort' op ""attribute 'perm_map' failed to satisfy constraint: AffineMap attribute"); + + if (tblgen_ny && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_ny))) && ((::llvm::isa<::mlir::IndexType>(::llvm::cast<::mlir::IntegerAttr>(tblgen_ny).getType()))))) + return emitError(loc, "'sparse_tensor.sort' op ""attribute 'ny' failed to satisfy constraint: index attribute"); + + if (tblgen_algorithm && !((::llvm::isa<::mlir::sparse_tensor::SparseTensorSortKindAttr>(tblgen_algorithm)))) + return emitError(loc, "'sparse_tensor.sort' op ""attribute 'algorithm' failed to satisfy constraint: sparse tensor sort algorithm"); + return ::mlir::success(); +} + +std::pair SortOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 2) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range SortOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::IndexType> SortOp::getN() { + return ::llvm::cast<::mlir::TypedValue<::mlir::IndexType>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::MemRefType> SortOp::getXy() { + return ::llvm::cast<::mlir::TypedValue<::mlir::MemRefType>>(*getODSOperands(1).begin()); +} + +::mlir::Operation::operand_range SortOp::getYs() { + return getODSOperands(2); +} + +::mlir::OpOperand &SortOp::getNMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &SortOp::getXyMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange SortOp::getYsMutable() { + auto range = getODSOperandIndexAndLength(2); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair SortOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range SortOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::LogicalResult SortOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.algorithm; + auto attr = dict.get("algorithm"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for algorithm in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `algorithm` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.ny; + auto attr = dict.get("ny"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for ny in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `ny` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.perm_map; + auto attr = dict.get("perm_map"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for perm_map in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `perm_map` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute SortOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.algorithm; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("algorithm", + propStorage)); + } + + { + const auto &propStorage = prop.ny; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("ny", + propStorage)); + } + + { + const auto &propStorage = prop.perm_map; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("perm_map", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code SortOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.algorithm.getAsOpaquePointer()), + llvm::hash_value(prop.ny.getAsOpaquePointer()), + llvm::hash_value(prop.perm_map.getAsOpaquePointer())); +} + +std::optional SortOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "algorithm") + return prop.algorithm; + + if (name == "ny") + return prop.ny; + + if (name == "perm_map") + return prop.perm_map; + return std::nullopt; +} + +void SortOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "algorithm") { + prop.algorithm = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "ny") { + prop.ny = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "perm_map") { + prop.perm_map = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void SortOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.algorithm) attrs.append("algorithm", prop.algorithm); + + if (prop.ny) attrs.append("ny", prop.ny); + + if (prop.perm_map) attrs.append("perm_map", prop.perm_map); +} + +::mlir::LogicalResult SortOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getAlgorithmAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_SparseTensorOps6(attr, "algorithm", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getNyAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_SparseTensorOps5(attr, "ny", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getPermMapAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_SparseTensorOps2(attr, "perm_map", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult SortOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.algorithm))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.ny))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.perm_map))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SortOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.algorithm); + + writer.writeOptionalAttribute(prop.ny); + writer.writeAttribute(prop.perm_map); +} + +::mlir::AffineMapAttr SortOp::getPermMapAttr() { + return ::llvm::cast<::mlir::AffineMapAttr>(getProperties().perm_map); +} + +::mlir::AffineMap SortOp::getPermMap() { + auto attr = getPermMapAttr(); + return attr.getValue(); +} + +::mlir::IntegerAttr SortOp::getNyAttr() { + return ::llvm::dyn_cast_or_null<::mlir::IntegerAttr>(getProperties().ny); +} + +::std::optional< ::llvm::APInt > SortOp::getNy() { + auto attr = getNyAttr(); + return attr ? ::std::optional< ::llvm::APInt >(attr.getValue()) : (::std::nullopt); +} + +::mlir::sparse_tensor::SparseTensorSortKindAttr SortOp::getAlgorithmAttr() { + return ::llvm::cast<::mlir::sparse_tensor::SparseTensorSortKindAttr>(getProperties().algorithm); +} + +::mlir::sparse_tensor::SparseTensorSortKind SortOp::getAlgorithm() { + auto attr = getAlgorithmAttr(); + return attr.getValue(); +} + +void SortOp::setPermMapAttr(::mlir::AffineMapAttr attr) { + (*this)->setAttr(getPermMapAttrName(), attr); +} + +void SortOp::setPermMap(::mlir::AffineMap attrValue) { + (*this)->setAttr(getPermMapAttrName(), ::mlir::AffineMapAttr::get(attrValue)); +} + +void SortOp::setNyAttr(::mlir::IntegerAttr attr) { + (*this)->setAttr(getNyAttrName(), attr); +} + +void SortOp::setNy(::std::optional<::llvm::APInt> attrValue) { + if (attrValue) + return (*this)->setAttr(getNyAttrName(), ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIndexType(), *attrValue)); + (*this)->removeAttr(getNyAttrName()); +} + +void SortOp::setAlgorithmAttr(::mlir::sparse_tensor::SparseTensorSortKindAttr attr) { + (*this)->setAttr(getAlgorithmAttrName(), attr); +} + +void SortOp::setAlgorithm(::mlir::sparse_tensor::SparseTensorSortKind attrValue) { + (*this)->setAttr(getAlgorithmAttrName(), ::mlir::sparse_tensor::SparseTensorSortKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue)); +} + +::mlir::Attribute SortOp::removeNyAttr() { + auto &attr = getProperties().ny; + attr = {}; + return attr; +} + +void SortOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value n, ::mlir::Value xy, ::mlir::ValueRange ys, ::mlir::AffineMapAttr perm_map, /*optional*/::mlir::IntegerAttr ny, ::mlir::sparse_tensor::SparseTensorSortKindAttr algorithm) { + odsState.addOperands(n); + odsState.addOperands(xy); + odsState.addOperands(ys); + odsState.getOrAddProperties().perm_map = perm_map; + if (ny) { + odsState.getOrAddProperties().ny = ny; + } + odsState.getOrAddProperties().algorithm = algorithm; +} + +void SortOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value n, ::mlir::Value xy, ::mlir::ValueRange ys, ::mlir::AffineMapAttr perm_map, /*optional*/::mlir::IntegerAttr ny, ::mlir::sparse_tensor::SparseTensorSortKindAttr algorithm) { + odsState.addOperands(n); + odsState.addOperands(xy); + odsState.addOperands(ys); + odsState.getOrAddProperties().perm_map = perm_map; + if (ny) { + odsState.getOrAddProperties().ny = ny; + } + odsState.getOrAddProperties().algorithm = algorithm; + assert(resultTypes.size() == 0u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SortOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value n, ::mlir::Value xy, ::mlir::ValueRange ys, ::mlir::AffineMap perm_map, /*optional*/::mlir::IntegerAttr ny, ::mlir::sparse_tensor::SparseTensorSortKind algorithm) { + odsState.addOperands(n); + odsState.addOperands(xy); + odsState.addOperands(ys); + odsState.getOrAddProperties().perm_map = ::mlir::AffineMapAttr::get(perm_map); + if (ny) { + odsState.getOrAddProperties().ny = ny; + } + odsState.getOrAddProperties().algorithm = ::mlir::sparse_tensor::SparseTensorSortKindAttr::get(odsBuilder.getContext(), algorithm); +} + +void SortOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value n, ::mlir::Value xy, ::mlir::ValueRange ys, ::mlir::AffineMap perm_map, /*optional*/::mlir::IntegerAttr ny, ::mlir::sparse_tensor::SparseTensorSortKind algorithm) { + odsState.addOperands(n); + odsState.addOperands(xy); + odsState.addOperands(ys); + odsState.getOrAddProperties().perm_map = ::mlir::AffineMapAttr::get(perm_map); + if (ny) { + odsState.getOrAddProperties().ny = ny; + } + odsState.getOrAddProperties().algorithm = ::mlir::sparse_tensor::SparseTensorSortKindAttr::get(odsBuilder.getContext(), algorithm); + assert(resultTypes.size() == 0u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SortOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult SortOp::verifyInvariantsImpl() { + auto tblgen_algorithm = getProperties().algorithm; (void)tblgen_algorithm; + if (!tblgen_algorithm) return emitOpError("requires attribute 'algorithm'"); + auto tblgen_ny = getProperties().ny; (void)tblgen_ny; + auto tblgen_perm_map = getProperties().perm_map; (void)tblgen_perm_map; + if (!tblgen_perm_map) return emitOpError("requires attribute 'perm_map'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_SparseTensorOps2(*this, tblgen_perm_map, "perm_map"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_SparseTensorOps5(*this, tblgen_ny, "ny"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_SparseTensorOps6(*this, tblgen_algorithm, "algorithm"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps7(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps12(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps11(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult SortOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult SortOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::sparse_tensor::SparseTensorSortKindAttr algorithmAttr; + ::mlir::OpAsmParser::UnresolvedOperand nRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> nOperands(nRawOperands); ::llvm::SMLoc nOperandsLoc; + (void)nOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand xyRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> xyOperands(xyRawOperands); ::llvm::SMLoc xyOperandsLoc; + (void)xyOperandsLoc; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> ysOperands; + ::llvm::SMLoc ysOperandsLoc; + (void)ysOperandsLoc; + ::mlir::Type xyRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> xyTypes(xyRawTypes); + ::llvm::SmallVector<::mlir::Type, 1> ysTypes; + + if (parser.parseCustomAttributeWithFallback(algorithmAttr, ::mlir::Type{})) { + return ::mlir::failure(); + } + if (algorithmAttr) result.getOrAddProperties().algorithm = algorithmAttr; + + nOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(nRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + xyOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(xyRawOperands[0])) + return ::mlir::failure(); + if (::mlir::succeeded(parser.parseOptionalKeyword("jointly"))) { + + ysOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(ysOperands)) + return ::mlir::failure(); + } + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::MemRefType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + xyRawTypes[0] = type; + } + if (::mlir::succeeded(parser.parseOptionalKeyword("jointly"))) { + + if (parser.parseTypeList(ysTypes)) + return ::mlir::failure(); + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + if (parser.resolveOperands(nOperands, odsBuildableType0, nOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(xyOperands, xyTypes, xyOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(ysOperands, ysTypes, ysOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SortOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; +_odsPrinter.printStrippedAttrOrType(getAlgorithmAttr()); + _odsPrinter << ' '; + _odsPrinter << getN(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getXy(); + if (!getYs().empty()) { + _odsPrinter << ' ' << "jointly"; + _odsPrinter << ' '; + _odsPrinter << getYs(); + } + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("algorithm"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getXy().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::MemRefType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + if (!getYs().empty()) { + _odsPrinter << ' ' << "jointly"; + _odsPrinter << ' '; + _odsPrinter << getYs().getTypes(); + } +} + +} // namespace sparse_tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::SortOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::StorageSpecifierInitOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +StorageSpecifierInitOpGenericAdaptorBase::StorageSpecifierInitOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("sparse_tensor.storage_specifier.init", odsAttrs.getContext()); +} + +StorageSpecifierInitOpGenericAdaptorBase::StorageSpecifierInitOpGenericAdaptorBase(StorageSpecifierInitOp op) : StorageSpecifierInitOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair StorageSpecifierInitOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr StorageSpecifierInitOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +StorageSpecifierInitOpAdaptor::StorageSpecifierInitOpAdaptor(StorageSpecifierInitOp op) : StorageSpecifierInitOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult StorageSpecifierInitOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair StorageSpecifierInitOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range StorageSpecifierInitOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::sparse_tensor::StorageSpecifierType> StorageSpecifierInitOp::getSource() { + auto operands = getODSOperands(0); + return operands.empty() ? ::mlir::TypedValue<::mlir::sparse_tensor::StorageSpecifierType>{} : ::llvm::cast<::mlir::TypedValue<::mlir::sparse_tensor::StorageSpecifierType>>(*operands.begin()); +} + +::mlir::MutableOperandRange StorageSpecifierInitOp::getSourceMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair StorageSpecifierInitOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range StorageSpecifierInitOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::sparse_tensor::StorageSpecifierType> StorageSpecifierInitOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::sparse_tensor::StorageSpecifierType>>(*getODSResults(0).begin()); +} + +void StorageSpecifierInitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type result) { + build(odsBuilder, odsState, result, Value()); + +} + +void StorageSpecifierInitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, /*optional*/::mlir::Value source) { + if (source) + odsState.addOperands(source); + odsState.addTypes(result); +} + +void StorageSpecifierInitOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value source) { + if (source) + odsState.addOperands(source); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void StorageSpecifierInitOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult StorageSpecifierInitOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + if (valueGroup0.size() > 1) { + return emitOpError("operand group starting at #") << index + << " requires 0 or 1 element, but found " << valueGroup0.size(); + } + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps10(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps10(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult StorageSpecifierInitOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult StorageSpecifierInitOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> sourceOperands; + ::llvm::SMLoc sourceOperandsLoc; + (void)sourceOperandsLoc; + ::llvm::SmallVector<::mlir::Type, 1> sourceTypes; + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (::mlir::succeeded(parser.parseOptionalKeyword("with"))) { + + { + sourceOperandsLoc = parser.getCurrentLocation(); + ::mlir::OpAsmParser::UnresolvedOperand operand; + ::mlir::OptionalParseResult parseResult = + parser.parseOptionalOperand(operand); + if (parseResult.has_value()) { + if (failed(*parseResult)) + return ::mlir::failure(); + sourceOperands.push_back(operand); + } + } + } + if (parser.parseColon()) + return ::mlir::failure(); + if (::mlir::succeeded(parser.parseOptionalKeyword("from"))) { + + { + ::mlir::Type optionalType; + ::mlir::OptionalParseResult parseResult = + parser.parseOptionalType(optionalType); + if (parseResult.has_value()) { + if (failed(*parseResult)) + return ::mlir::failure(); + sourceTypes.push_back(optionalType); + } + } + if (parser.parseKeyword("to")) + return ::mlir::failure(); + } + + if (parser.parseType(resultRawTypes[0])) + return ::mlir::failure(); + result.addTypes(resultTypes); + if (parser.resolveOperands(sourceOperands, sourceTypes, sourceOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void StorageSpecifierInitOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + if (getSource()) { + _odsPrinter << ' ' << "with"; + _odsPrinter << ' '; + if (::mlir::Value value = getSource()) + _odsPrinter << value; + } + _odsPrinter << ' ' << ":"; + if (getSource()) { + _odsPrinter << ' ' << "from"; + _odsPrinter << ' '; + _odsPrinter << (getSource() ? ::llvm::ArrayRef<::mlir::Type>(getSource().getType()) : ::llvm::ArrayRef<::mlir::Type>()); + _odsPrinter << ' ' << "to"; + } + _odsPrinter << ' '; + _odsPrinter << getResult().getType(); +} + +void StorageSpecifierInitOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace sparse_tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::StorageSpecifierInitOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::ToCoordinatesBufferOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ToCoordinatesBufferOpGenericAdaptorBase::ToCoordinatesBufferOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("sparse_tensor.coordinates_buffer", odsAttrs.getContext()); +} + +ToCoordinatesBufferOpGenericAdaptorBase::ToCoordinatesBufferOpGenericAdaptorBase(ToCoordinatesBufferOp op) : ToCoordinatesBufferOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ToCoordinatesBufferOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ToCoordinatesBufferOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +ToCoordinatesBufferOpAdaptor::ToCoordinatesBufferOpAdaptor(ToCoordinatesBufferOp op) : ToCoordinatesBufferOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ToCoordinatesBufferOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair ToCoordinatesBufferOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ToCoordinatesBufferOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::TensorType> ToCoordinatesBufferOp::getTensor() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &ToCoordinatesBufferOp::getTensorMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair ToCoordinatesBufferOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ToCoordinatesBufferOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value ToCoordinatesBufferOp::getResult() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +void ToCoordinatesBufferOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value tensor) { + odsState.addOperands(tensor); + odsState.addTypes(result); +} + +void ToCoordinatesBufferOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tensor) { + odsState.addOperands(tensor); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ToCoordinatesBufferOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ToCoordinatesBufferOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps4(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ToCoordinatesBufferOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult ToCoordinatesBufferOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand tensorRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> tensorOperands(tensorRawOperands); ::llvm::SMLoc tensorOperandsLoc; + (void)tensorOperandsLoc; + ::mlir::Type tensorRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> tensorTypes(tensorRawTypes); + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + tensorOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(tensorRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + tensorRawTypes[0] = type; + } + if (parser.parseKeyword("to")) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(tensorOperands, tensorTypes, tensorOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ToCoordinatesBufferOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getTensor(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getTensor().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "to"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void ToCoordinatesBufferOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace sparse_tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::ToCoordinatesBufferOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::ToCoordinatesOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ToCoordinatesOpGenericAdaptorBase::ToCoordinatesOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("sparse_tensor.coordinates", odsAttrs.getContext()); +} + +ToCoordinatesOpGenericAdaptorBase::ToCoordinatesOpGenericAdaptorBase(ToCoordinatesOp op) : ToCoordinatesOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ToCoordinatesOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ToCoordinatesOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::IntegerAttr ToCoordinatesOpGenericAdaptorBase::getLevelAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().level); + return attr; +} + +::mlir::sparse_tensor::Level ToCoordinatesOpGenericAdaptorBase::getLevel() { + auto attr = getLevelAttr(); + return attr.getValue().getZExtValue(); +} + +} // namespace detail +ToCoordinatesOpAdaptor::ToCoordinatesOpAdaptor(ToCoordinatesOp op) : ToCoordinatesOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ToCoordinatesOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_level = getProperties().level; (void)tblgen_level; + if (!tblgen_level) return emitError(loc, "'sparse_tensor.coordinates' op ""requires attribute 'level'"); + + if (tblgen_level && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_level))) && ((::llvm::isa<::mlir::IndexType>(::llvm::cast<::mlir::IntegerAttr>(tblgen_level).getType()))))) + return emitError(loc, "'sparse_tensor.coordinates' op ""attribute 'level' failed to satisfy constraint: level attribute"); + return ::mlir::success(); +} + +std::pair ToCoordinatesOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ToCoordinatesOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::TensorType> ToCoordinatesOp::getTensor() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &ToCoordinatesOp::getTensorMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair ToCoordinatesOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ToCoordinatesOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value ToCoordinatesOp::getResult() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult ToCoordinatesOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.level; + auto attr = dict.get("level"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for level in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `level` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ToCoordinatesOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.level; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("level", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ToCoordinatesOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.level.getAsOpaquePointer())); +} + +std::optional ToCoordinatesOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "level") + return prop.level; + return std::nullopt; +} + +void ToCoordinatesOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "level") { + prop.level = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ToCoordinatesOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.level) attrs.append("level", prop.level); +} + +::mlir::LogicalResult ToCoordinatesOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getLevelAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_SparseTensorOps4(attr, "level", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ToCoordinatesOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.level))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ToCoordinatesOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.level); +} + +::mlir::IntegerAttr ToCoordinatesOp::getLevelAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().level); +} + +::mlir::sparse_tensor::Level ToCoordinatesOp::getLevel() { + auto attr = getLevelAttr(); + return attr.getValue().getZExtValue(); +} + +void ToCoordinatesOp::setLevelAttr(::mlir::IntegerAttr attr) { + (*this)->setAttr(getLevelAttrName(), attr); +} + +void ToCoordinatesOp::setLevel(::mlir::sparse_tensor::Level attrValue) { + (*this)->setAttr(getLevelAttrName(), ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIndexType(), attrValue)); +} + +void ToCoordinatesOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value tensor, ::mlir::IntegerAttr level) { + odsState.addOperands(tensor); + odsState.getOrAddProperties().level = level; + odsState.addTypes(result); +} + +void ToCoordinatesOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tensor, ::mlir::IntegerAttr level) { + odsState.addOperands(tensor); + odsState.getOrAddProperties().level = level; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ToCoordinatesOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value tensor, ::mlir::sparse_tensor::Level level) { + odsState.addOperands(tensor); + odsState.getOrAddProperties().level = odsBuilder.getIntegerAttr(odsBuilder.getIndexType(), level); + odsState.addTypes(result); +} + +void ToCoordinatesOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tensor, ::mlir::sparse_tensor::Level level) { + odsState.addOperands(tensor); + odsState.getOrAddProperties().level = odsBuilder.getIntegerAttr(odsBuilder.getIndexType(), level); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ToCoordinatesOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ToCoordinatesOp::verifyInvariantsImpl() { + auto tblgen_level = getProperties().level; (void)tblgen_level; + if (!tblgen_level) return emitOpError("requires attribute 'level'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_SparseTensorOps4(*this, tblgen_level, "level"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps4(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ToCoordinatesOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult ToCoordinatesOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand tensorRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> tensorOperands(tensorRawOperands); ::llvm::SMLoc tensorOperandsLoc; + (void)tensorOperandsLoc; + ::mlir::Type tensorRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> tensorTypes(tensorRawTypes); + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + tensorOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(tensorRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + tensorRawTypes[0] = type; + } + if (parser.parseKeyword("to")) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(tensorOperands, tensorTypes, tensorOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ToCoordinatesOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getTensor(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getTensor().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "to"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void ToCoordinatesOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace sparse_tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::ToCoordinatesOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::ToPositionsOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ToPositionsOpGenericAdaptorBase::ToPositionsOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("sparse_tensor.positions", odsAttrs.getContext()); +} + +ToPositionsOpGenericAdaptorBase::ToPositionsOpGenericAdaptorBase(ToPositionsOp op) : ToPositionsOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ToPositionsOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ToPositionsOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::IntegerAttr ToPositionsOpGenericAdaptorBase::getLevelAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().level); + return attr; +} + +::mlir::sparse_tensor::Level ToPositionsOpGenericAdaptorBase::getLevel() { + auto attr = getLevelAttr(); + return attr.getValue().getZExtValue(); +} + +} // namespace detail +ToPositionsOpAdaptor::ToPositionsOpAdaptor(ToPositionsOp op) : ToPositionsOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ToPositionsOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_level = getProperties().level; (void)tblgen_level; + if (!tblgen_level) return emitError(loc, "'sparse_tensor.positions' op ""requires attribute 'level'"); + + if (tblgen_level && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_level))) && ((::llvm::isa<::mlir::IndexType>(::llvm::cast<::mlir::IntegerAttr>(tblgen_level).getType()))))) + return emitError(loc, "'sparse_tensor.positions' op ""attribute 'level' failed to satisfy constraint: level attribute"); + return ::mlir::success(); +} + +std::pair ToPositionsOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ToPositionsOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::TensorType> ToPositionsOp::getTensor() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &ToPositionsOp::getTensorMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair ToPositionsOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ToPositionsOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value ToPositionsOp::getResult() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult ToPositionsOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.level; + auto attr = dict.get("level"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for level in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `level` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ToPositionsOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.level; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("level", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ToPositionsOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.level.getAsOpaquePointer())); +} + +std::optional ToPositionsOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "level") + return prop.level; + return std::nullopt; +} + +void ToPositionsOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "level") { + prop.level = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ToPositionsOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.level) attrs.append("level", prop.level); +} + +::mlir::LogicalResult ToPositionsOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getLevelAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_SparseTensorOps4(attr, "level", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ToPositionsOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.level))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ToPositionsOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.level); +} + +::mlir::IntegerAttr ToPositionsOp::getLevelAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().level); +} + +::mlir::sparse_tensor::Level ToPositionsOp::getLevel() { + auto attr = getLevelAttr(); + return attr.getValue().getZExtValue(); +} + +void ToPositionsOp::setLevelAttr(::mlir::IntegerAttr attr) { + (*this)->setAttr(getLevelAttrName(), attr); +} + +void ToPositionsOp::setLevel(::mlir::sparse_tensor::Level attrValue) { + (*this)->setAttr(getLevelAttrName(), ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIndexType(), attrValue)); +} + +void ToPositionsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value tensor, ::mlir::IntegerAttr level) { + odsState.addOperands(tensor); + odsState.getOrAddProperties().level = level; + odsState.addTypes(result); +} + +void ToPositionsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tensor, ::mlir::IntegerAttr level) { + odsState.addOperands(tensor); + odsState.getOrAddProperties().level = level; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ToPositionsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value tensor, ::mlir::sparse_tensor::Level level) { + odsState.addOperands(tensor); + odsState.getOrAddProperties().level = odsBuilder.getIntegerAttr(odsBuilder.getIndexType(), level); + odsState.addTypes(result); +} + +void ToPositionsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tensor, ::mlir::sparse_tensor::Level level) { + odsState.addOperands(tensor); + odsState.getOrAddProperties().level = odsBuilder.getIntegerAttr(odsBuilder.getIndexType(), level); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ToPositionsOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ToPositionsOp::verifyInvariantsImpl() { + auto tblgen_level = getProperties().level; (void)tblgen_level; + if (!tblgen_level) return emitOpError("requires attribute 'level'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_SparseTensorOps4(*this, tblgen_level, "level"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps4(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ToPositionsOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult ToPositionsOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand tensorRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> tensorOperands(tensorRawOperands); ::llvm::SMLoc tensorOperandsLoc; + (void)tensorOperandsLoc; + ::mlir::Type tensorRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> tensorTypes(tensorRawTypes); + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + tensorOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(tensorRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + tensorRawTypes[0] = type; + } + if (parser.parseKeyword("to")) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(tensorOperands, tensorTypes, tensorOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ToPositionsOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getTensor(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getTensor().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "to"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void ToPositionsOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace sparse_tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::ToPositionsOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::ToSliceOffsetOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ToSliceOffsetOpGenericAdaptorBase::ToSliceOffsetOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("sparse_tensor.slice.offset", odsAttrs.getContext()); +} + +ToSliceOffsetOpGenericAdaptorBase::ToSliceOffsetOpGenericAdaptorBase(ToSliceOffsetOp op) : ToSliceOffsetOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ToSliceOffsetOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ToSliceOffsetOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::IntegerAttr ToSliceOffsetOpGenericAdaptorBase::getDimAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().dim); + return attr; +} + +::llvm::APInt ToSliceOffsetOpGenericAdaptorBase::getDim() { + auto attr = getDimAttr(); + return attr.getValue(); +} + +} // namespace detail +ToSliceOffsetOpAdaptor::ToSliceOffsetOpAdaptor(ToSliceOffsetOp op) : ToSliceOffsetOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ToSliceOffsetOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_dim = getProperties().dim; (void)tblgen_dim; + if (!tblgen_dim) return emitError(loc, "'sparse_tensor.slice.offset' op ""requires attribute 'dim'"); + + if (tblgen_dim && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_dim))) && ((::llvm::isa<::mlir::IndexType>(::llvm::cast<::mlir::IntegerAttr>(tblgen_dim).getType()))))) + return emitError(loc, "'sparse_tensor.slice.offset' op ""attribute 'dim' failed to satisfy constraint: index attribute"); + return ::mlir::success(); +} + +std::pair ToSliceOffsetOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ToSliceOffsetOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::TensorType> ToSliceOffsetOp::getSlice() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &ToSliceOffsetOp::getSliceMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair ToSliceOffsetOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ToSliceOffsetOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::IndexType> ToSliceOffsetOp::getOffset() { + return ::llvm::cast<::mlir::TypedValue<::mlir::IndexType>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult ToSliceOffsetOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.dim; + auto attr = dict.get("dim"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for dim in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `dim` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ToSliceOffsetOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.dim; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("dim", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ToSliceOffsetOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.dim.getAsOpaquePointer())); +} + +std::optional ToSliceOffsetOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "dim") + return prop.dim; + return std::nullopt; +} + +void ToSliceOffsetOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "dim") { + prop.dim = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ToSliceOffsetOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.dim) attrs.append("dim", prop.dim); +} + +::mlir::LogicalResult ToSliceOffsetOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getDimAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_SparseTensorOps5(attr, "dim", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ToSliceOffsetOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.dim))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ToSliceOffsetOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.dim); +} + +::mlir::IntegerAttr ToSliceOffsetOp::getDimAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().dim); +} + +::llvm::APInt ToSliceOffsetOp::getDim() { + auto attr = getDimAttr(); + return attr.getValue(); +} + +void ToSliceOffsetOp::setDimAttr(::mlir::IntegerAttr attr) { + (*this)->setAttr(getDimAttrName(), attr); +} + +void ToSliceOffsetOp::setDim(::llvm::APInt attrValue) { + (*this)->setAttr(getDimAttrName(), ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIndexType(), attrValue)); +} + +void ToSliceOffsetOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type offset, ::mlir::Value slice, ::mlir::IntegerAttr dim) { + odsState.addOperands(slice); + odsState.getOrAddProperties().dim = dim; + odsState.addTypes(offset); +} + +void ToSliceOffsetOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value slice, ::mlir::IntegerAttr dim) { + odsState.addOperands(slice); + odsState.getOrAddProperties().dim = dim; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ToSliceOffsetOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void ToSliceOffsetOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value slice, ::mlir::IntegerAttr dim) { + odsState.addOperands(slice); + odsState.getOrAddProperties().dim = dim; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ToSliceOffsetOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type offset, ::mlir::Value slice, ::llvm::APInt dim) { + odsState.addOperands(slice); + odsState.getOrAddProperties().dim = odsBuilder.getIntegerAttr(odsBuilder.getIndexType(), dim); + odsState.addTypes(offset); +} + +void ToSliceOffsetOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value slice, ::llvm::APInt dim) { + odsState.addOperands(slice); + odsState.getOrAddProperties().dim = odsBuilder.getIntegerAttr(odsBuilder.getIndexType(), dim); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ToSliceOffsetOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void ToSliceOffsetOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value slice, ::llvm::APInt dim) { + odsState.addOperands(slice); + odsState.getOrAddProperties().dim = odsBuilder.getIntegerAttr(odsBuilder.getIndexType(), dim); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ToSliceOffsetOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ToSliceOffsetOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ToSliceOffsetOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult ToSliceOffsetOp::verifyInvariantsImpl() { + auto tblgen_dim = getProperties().dim; (void)tblgen_dim; + if (!tblgen_dim) return emitOpError("requires attribute 'dim'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_SparseTensorOps5(*this, tblgen_dim, "dim"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps13(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps7(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ToSliceOffsetOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::LogicalResult ToSliceOffsetOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = odsBuilder.getIndexType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult ToSliceOffsetOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand sliceRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sliceOperands(sliceRawOperands); ::llvm::SMLoc sliceOperandsLoc; + (void)sliceOperandsLoc; + ::mlir::IntegerAttr dimAttr; + ::mlir::Type sliceRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> sliceTypes(sliceRawTypes); + + sliceOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(sliceRawOperands[0])) + return ::mlir::failure(); + if (parser.parseKeyword("at")) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(dimAttr, parser.getBuilder().getIndexType())) { + return ::mlir::failure(); + } + if (dimAttr) result.getOrAddProperties().dim = dimAttr; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + sliceRawTypes[0] = type; + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + result.addTypes(odsBuildableType0); + if (parser.resolveOperands(sliceOperands, sliceTypes, sliceOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ToSliceOffsetOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getSlice(); + _odsPrinter << ' ' << "at"; + _odsPrinter << ' '; + _odsPrinter.printAttributeWithoutType(getDimAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("dim"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getSlice().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void ToSliceOffsetOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace sparse_tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::ToSliceOffsetOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::ToSliceStrideOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ToSliceStrideOpGenericAdaptorBase::ToSliceStrideOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("sparse_tensor.slice.stride", odsAttrs.getContext()); +} + +ToSliceStrideOpGenericAdaptorBase::ToSliceStrideOpGenericAdaptorBase(ToSliceStrideOp op) : ToSliceStrideOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ToSliceStrideOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ToSliceStrideOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::IntegerAttr ToSliceStrideOpGenericAdaptorBase::getDimAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().dim); + return attr; +} + +::llvm::APInt ToSliceStrideOpGenericAdaptorBase::getDim() { + auto attr = getDimAttr(); + return attr.getValue(); +} + +} // namespace detail +ToSliceStrideOpAdaptor::ToSliceStrideOpAdaptor(ToSliceStrideOp op) : ToSliceStrideOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ToSliceStrideOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_dim = getProperties().dim; (void)tblgen_dim; + if (!tblgen_dim) return emitError(loc, "'sparse_tensor.slice.stride' op ""requires attribute 'dim'"); + + if (tblgen_dim && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_dim))) && ((::llvm::isa<::mlir::IndexType>(::llvm::cast<::mlir::IntegerAttr>(tblgen_dim).getType()))))) + return emitError(loc, "'sparse_tensor.slice.stride' op ""attribute 'dim' failed to satisfy constraint: index attribute"); + return ::mlir::success(); +} + +std::pair ToSliceStrideOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ToSliceStrideOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::TensorType> ToSliceStrideOp::getSlice() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &ToSliceStrideOp::getSliceMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair ToSliceStrideOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ToSliceStrideOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::IndexType> ToSliceStrideOp::getStride() { + return ::llvm::cast<::mlir::TypedValue<::mlir::IndexType>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult ToSliceStrideOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.dim; + auto attr = dict.get("dim"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for dim in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `dim` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ToSliceStrideOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.dim; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("dim", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ToSliceStrideOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.dim.getAsOpaquePointer())); +} + +std::optional ToSliceStrideOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "dim") + return prop.dim; + return std::nullopt; +} + +void ToSliceStrideOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "dim") { + prop.dim = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ToSliceStrideOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.dim) attrs.append("dim", prop.dim); +} + +::mlir::LogicalResult ToSliceStrideOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getDimAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_SparseTensorOps5(attr, "dim", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ToSliceStrideOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.dim))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ToSliceStrideOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.dim); +} + +::mlir::IntegerAttr ToSliceStrideOp::getDimAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().dim); +} + +::llvm::APInt ToSliceStrideOp::getDim() { + auto attr = getDimAttr(); + return attr.getValue(); +} + +void ToSliceStrideOp::setDimAttr(::mlir::IntegerAttr attr) { + (*this)->setAttr(getDimAttrName(), attr); +} + +void ToSliceStrideOp::setDim(::llvm::APInt attrValue) { + (*this)->setAttr(getDimAttrName(), ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIndexType(), attrValue)); +} + +void ToSliceStrideOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type stride, ::mlir::Value slice, ::mlir::IntegerAttr dim) { + odsState.addOperands(slice); + odsState.getOrAddProperties().dim = dim; + odsState.addTypes(stride); +} + +void ToSliceStrideOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value slice, ::mlir::IntegerAttr dim) { + odsState.addOperands(slice); + odsState.getOrAddProperties().dim = dim; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ToSliceStrideOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void ToSliceStrideOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value slice, ::mlir::IntegerAttr dim) { + odsState.addOperands(slice); + odsState.getOrAddProperties().dim = dim; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ToSliceStrideOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type stride, ::mlir::Value slice, ::llvm::APInt dim) { + odsState.addOperands(slice); + odsState.getOrAddProperties().dim = odsBuilder.getIntegerAttr(odsBuilder.getIndexType(), dim); + odsState.addTypes(stride); +} + +void ToSliceStrideOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value slice, ::llvm::APInt dim) { + odsState.addOperands(slice); + odsState.getOrAddProperties().dim = odsBuilder.getIntegerAttr(odsBuilder.getIndexType(), dim); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ToSliceStrideOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void ToSliceStrideOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value slice, ::llvm::APInt dim) { + odsState.addOperands(slice); + odsState.getOrAddProperties().dim = odsBuilder.getIntegerAttr(odsBuilder.getIndexType(), dim); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ToSliceStrideOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ToSliceStrideOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ToSliceStrideOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult ToSliceStrideOp::verifyInvariantsImpl() { + auto tblgen_dim = getProperties().dim; (void)tblgen_dim; + if (!tblgen_dim) return emitOpError("requires attribute 'dim'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_SparseTensorOps5(*this, tblgen_dim, "dim"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps13(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps7(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ToSliceStrideOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::LogicalResult ToSliceStrideOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = odsBuilder.getIndexType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult ToSliceStrideOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand sliceRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sliceOperands(sliceRawOperands); ::llvm::SMLoc sliceOperandsLoc; + (void)sliceOperandsLoc; + ::mlir::IntegerAttr dimAttr; + ::mlir::Type sliceRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> sliceTypes(sliceRawTypes); + + sliceOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(sliceRawOperands[0])) + return ::mlir::failure(); + if (parser.parseKeyword("at")) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(dimAttr, parser.getBuilder().getIndexType())) { + return ::mlir::failure(); + } + if (dimAttr) result.getOrAddProperties().dim = dimAttr; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + sliceRawTypes[0] = type; + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + result.addTypes(odsBuildableType0); + if (parser.resolveOperands(sliceOperands, sliceTypes, sliceOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ToSliceStrideOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getSlice(); + _odsPrinter << ' ' << "at"; + _odsPrinter << ' '; + _odsPrinter.printAttributeWithoutType(getDimAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("dim"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getSlice().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void ToSliceStrideOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace sparse_tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::ToSliceStrideOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::ToValuesOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ToValuesOpGenericAdaptorBase::ToValuesOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("sparse_tensor.values", odsAttrs.getContext()); +} + +ToValuesOpGenericAdaptorBase::ToValuesOpGenericAdaptorBase(ToValuesOp op) : ToValuesOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ToValuesOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ToValuesOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +ToValuesOpAdaptor::ToValuesOpAdaptor(ToValuesOp op) : ToValuesOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ToValuesOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair ToValuesOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ToValuesOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::TensorType> ToValuesOp::getTensor() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &ToValuesOp::getTensorMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair ToValuesOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ToValuesOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value ToValuesOp::getResult() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +void ToValuesOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value tensor) { + odsState.addOperands(tensor); + odsState.addTypes(result); +} + +void ToValuesOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tensor) { + odsState.addOperands(tensor); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ToValuesOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ToValuesOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps4(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ToValuesOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult ToValuesOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand tensorRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> tensorOperands(tensorRawOperands); ::llvm::SMLoc tensorOperandsLoc; + (void)tensorOperandsLoc; + ::mlir::Type tensorRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> tensorTypes(tensorRawTypes); + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + tensorOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(tensorRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + tensorRawTypes[0] = type; + } + if (parser.parseKeyword("to")) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(tensorOperands, tensorTypes, tensorOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ToValuesOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getTensor(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getTensor().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "to"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void ToValuesOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace sparse_tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::ToValuesOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::UnaryOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +UnaryOpGenericAdaptorBase::UnaryOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("sparse_tensor.unary", odsAttrs.getContext()); +} + +UnaryOpGenericAdaptorBase::UnaryOpGenericAdaptorBase(UnaryOp op) : UnaryOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair UnaryOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr UnaryOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::Region &UnaryOpGenericAdaptorBase::getPresentRegion() { + return *odsRegions[0]; +} + +::mlir::Region &UnaryOpGenericAdaptorBase::getAbsentRegion() { + return *odsRegions[1]; +} + +::mlir::RegionRange UnaryOpGenericAdaptorBase::getRegions() { + return odsRegions; +} + +} // namespace detail +UnaryOpAdaptor::UnaryOpAdaptor(UnaryOp op) : UnaryOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult UnaryOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair UnaryOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range UnaryOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value UnaryOp::getX() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &UnaryOp::getXMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair UnaryOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range UnaryOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value UnaryOp::getOutput() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +::mlir::Region &UnaryOp::getPresentRegion() { + return (*this)->getRegion(0); +} + +::mlir::Region &UnaryOp::getAbsentRegion() { + return (*this)->getRegion(1); +} + +void UnaryOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value x) { + odsState.addOperands(x); + (void)odsState.addRegion(); + (void)odsState.addRegion(); + odsState.addTypes(output); +} + +void UnaryOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value x) { + odsState.addOperands(x); + (void)odsState.addRegion(); + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void UnaryOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 2; ++i) + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult UnaryOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_SparseTensorOps0(*this, region, "presentRegion", index++))) + return ::mlir::failure(); + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(1))) + if (::mlir::failed(__mlir_ods_local_region_constraint_SparseTensorOps0(*this, region, "absentRegion", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult UnaryOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult UnaryOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand xRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> xOperands(xRawOperands); ::llvm::SMLoc xOperandsLoc; + (void)xOperandsLoc; + ::mlir::Type xRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> xTypes(xRawTypes); + ::mlir::Type outputRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> outputTypes(outputRawTypes); + std::unique_ptr<::mlir::Region> presentRegionRegion = std::make_unique<::mlir::Region>(); + std::unique_ptr<::mlir::Region> absentRegionRegion = std::make_unique<::mlir::Region>(); + + xOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(xRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + xRawTypes[0] = type; + } + if (parser.parseKeyword("to")) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + outputRawTypes[0] = type; + } + if (parser.parseKeyword("present")) + return ::mlir::failure(); + if (parser.parseEqual()) + return ::mlir::failure(); + + if (parser.parseRegion(*presentRegionRegion)) + return ::mlir::failure(); + if (parser.parseKeyword("absent")) + return ::mlir::failure(); + if (parser.parseEqual()) + return ::mlir::failure(); + + if (parser.parseRegion(*absentRegionRegion)) + return ::mlir::failure(); + result.addRegion(std::move(presentRegionRegion)); + result.addRegion(std::move(absentRegionRegion)); + result.addTypes(outputTypes); + if (parser.resolveOperands(xOperands, xTypes, xOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void UnaryOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getX(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getX().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "to"; + _odsPrinter << ' '; + { + auto type = getOutput().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter.printNewline(); + _odsPrinter << ' ' << "present"; + _odsPrinter << ' ' << "="; + _odsPrinter << ' '; + _odsPrinter.printRegion(getPresentRegion()); + _odsPrinter.printNewline(); + _odsPrinter << ' ' << "absent"; + _odsPrinter << ' ' << "="; + _odsPrinter << ' '; + _odsPrinter.printRegion(getAbsentRegion()); +} + +void UnaryOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace sparse_tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::UnaryOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::YieldOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +YieldOpGenericAdaptorBase::YieldOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("sparse_tensor.yield", odsAttrs.getContext()); +} + +YieldOpGenericAdaptorBase::YieldOpGenericAdaptorBase(YieldOp op) : YieldOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair YieldOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr YieldOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +YieldOpAdaptor::YieldOpAdaptor(YieldOp op) : YieldOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult YieldOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair YieldOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range YieldOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value YieldOp::getResult() { + auto operands = getODSOperands(0); + return operands.empty() ? ::mlir::Value{} : ::llvm::cast<::mlir::Value>(*operands.begin()); +} + +::mlir::MutableOperandRange YieldOp::getResultMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair YieldOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range YieldOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +void YieldOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { + build(odsBuilder, odsState, Value()); + +} + +void YieldOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Value result) { + if (result) + odsState.addOperands(result); +} + +void YieldOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value result) { + if (result) + odsState.addOperands(result); + assert(resultTypes.size() == 0u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void YieldOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult YieldOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + if (valueGroup0.size() > 1) { + return emitOpError("operand group starting at #") << index + << " requires 0 or 1 element, but found " << valueGroup0.size(); + } + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_SparseTensorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult YieldOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult YieldOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> resultOperands; + ::llvm::SMLoc resultOperandsLoc; + (void)resultOperandsLoc; + ::llvm::SmallVector<::mlir::Type, 1> resultTypes; + + { + resultOperandsLoc = parser.getCurrentLocation(); + ::mlir::OpAsmParser::UnresolvedOperand operand; + ::mlir::OptionalParseResult parseResult = + parser.parseOptionalOperand(operand); + if (parseResult.has_value()) { + if (failed(*parseResult)) + return ::mlir::failure(); + resultOperands.push_back(operand); + } + } + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::Type optionalType; + ::mlir::OptionalParseResult parseResult = + parser.parseOptionalType(optionalType); + if (parseResult.has_value()) { + if (failed(*parseResult)) + return ::mlir::failure(); + resultTypes.push_back(optionalType); + } + } + if (parser.resolveOperands(resultOperands, resultTypes, resultOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void YieldOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + if (::mlir::Value value = getResult()) + _odsPrinter << value; + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter << (getResult() ? ::llvm::ArrayRef<::mlir::Type>(getResult().getType()) : ::llvm::ArrayRef<::mlir::Type>()); +} + +void YieldOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace sparse_tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::YieldOp) + + +#endif // GET_OP_CLASSES + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..4c7b77742eb0ba7cd77357769af129ce37e7bde5 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.h.inc @@ -0,0 +1,4069 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Op Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: SparseTensorOps.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#if defined(GET_OP_CLASSES) || defined(GET_OP_FWD_DEFINES) +#undef GET_OP_FWD_DEFINES +namespace mlir { +namespace sparse_tensor { +class AssembleOp; +} // namespace sparse_tensor +} // namespace mlir +namespace mlir { +namespace sparse_tensor { +class BinaryOp; +} // namespace sparse_tensor +} // namespace mlir +namespace mlir { +namespace sparse_tensor { +class CompressOp; +} // namespace sparse_tensor +} // namespace mlir +namespace mlir { +namespace sparse_tensor { +class ConcatenateOp; +} // namespace sparse_tensor +} // namespace mlir +namespace mlir { +namespace sparse_tensor { +class ConvertOp; +} // namespace sparse_tensor +} // namespace mlir +namespace mlir { +namespace sparse_tensor { +class DisassembleOp; +} // namespace sparse_tensor +} // namespace mlir +namespace mlir { +namespace sparse_tensor { +class ExpandOp; +} // namespace sparse_tensor +} // namespace mlir +namespace mlir { +namespace sparse_tensor { +class ForeachOp; +} // namespace sparse_tensor +} // namespace mlir +namespace mlir { +namespace sparse_tensor { +class GetStorageSpecifierOp; +} // namespace sparse_tensor +} // namespace mlir +namespace mlir { +namespace sparse_tensor { +class InsertOp; +} // namespace sparse_tensor +} // namespace mlir +namespace mlir { +namespace sparse_tensor { +class LoadOp; +} // namespace sparse_tensor +} // namespace mlir +namespace mlir { +namespace sparse_tensor { +class NewOp; +} // namespace sparse_tensor +} // namespace mlir +namespace mlir { +namespace sparse_tensor { +class NumberOfEntriesOp; +} // namespace sparse_tensor +} // namespace mlir +namespace mlir { +namespace sparse_tensor { +class OutOp; +} // namespace sparse_tensor +} // namespace mlir +namespace mlir { +namespace sparse_tensor { +class PushBackOp; +} // namespace sparse_tensor +} // namespace mlir +namespace mlir { +namespace sparse_tensor { +class ReduceOp; +} // namespace sparse_tensor +} // namespace mlir +namespace mlir { +namespace sparse_tensor { +class SelectOp; +} // namespace sparse_tensor +} // namespace mlir +namespace mlir { +namespace sparse_tensor { +class SetStorageSpecifierOp; +} // namespace sparse_tensor +} // namespace mlir +namespace mlir { +namespace sparse_tensor { +class SortOp; +} // namespace sparse_tensor +} // namespace mlir +namespace mlir { +namespace sparse_tensor { +class StorageSpecifierInitOp; +} // namespace sparse_tensor +} // namespace mlir +namespace mlir { +namespace sparse_tensor { +class ToCoordinatesBufferOp; +} // namespace sparse_tensor +} // namespace mlir +namespace mlir { +namespace sparse_tensor { +class ToCoordinatesOp; +} // namespace sparse_tensor +} // namespace mlir +namespace mlir { +namespace sparse_tensor { +class ToPositionsOp; +} // namespace sparse_tensor +} // namespace mlir +namespace mlir { +namespace sparse_tensor { +class ToSliceOffsetOp; +} // namespace sparse_tensor +} // namespace mlir +namespace mlir { +namespace sparse_tensor { +class ToSliceStrideOp; +} // namespace sparse_tensor +} // namespace mlir +namespace mlir { +namespace sparse_tensor { +class ToValuesOp; +} // namespace sparse_tensor +} // namespace mlir +namespace mlir { +namespace sparse_tensor { +class UnaryOp; +} // namespace sparse_tensor +} // namespace mlir +namespace mlir { +namespace sparse_tensor { +class YieldOp; +} // namespace sparse_tensor +} // namespace mlir +#endif + +#ifdef GET_OP_CLASSES +#undef GET_OP_CLASSES + + +//===----------------------------------------------------------------------===// +// Local Utility Method Definitions +//===----------------------------------------------------------------------===// + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::AssembleOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class AssembleOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + AssembleOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + AssembleOpGenericAdaptorBase(AssembleOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class AssembleOpGenericAdaptor : public detail::AssembleOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::AssembleOpGenericAdaptorBase; +public: + AssembleOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + AssembleOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : AssembleOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + AssembleOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getValues() { + return (*getODSOperands(0).begin()); + } + + RangeT getLevels() { + return getODSOperands(1); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class AssembleOpAdaptor : public AssembleOpGenericAdaptor<::mlir::ValueRange> { +public: + using AssembleOpGenericAdaptor::AssembleOpGenericAdaptor; + AssembleOpAdaptor(AssembleOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class AssembleOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<1>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = AssembleOpAdaptor; + template + using GenericAdaptor = AssembleOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("sparse_tensor.assemble"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::TensorType> getValues(); + ::mlir::Operation::operand_range getLevels(); + ::mlir::OpOperand &getValuesMutable(); + ::mlir::MutableOperandRange getLevelsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::TensorType> getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value values, ::mlir::ValueRange levels); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value values, ::mlir::ValueRange levels); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace sparse_tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::AssembleOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::BinaryOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BinaryOpGenericAdaptorBase { +public: + struct Properties { + using left_identityTy = ::mlir::UnitAttr; + left_identityTy left_identity; + + auto getLeftIdentity() { + auto &propStorage = this->left_identity; + return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(propStorage); + } + void setLeftIdentity(const ::mlir::UnitAttr &propValue) { + this->left_identity = propValue; + } + using right_identityTy = ::mlir::UnitAttr; + right_identityTy right_identity; + + auto getRightIdentity() { + auto &propStorage = this->right_identity; + return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(propStorage); + } + void setRightIdentity(const ::mlir::UnitAttr &propValue) { + this->right_identity = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.left_identity == this->left_identity && + rhs.right_identity == this->right_identity && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + BinaryOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + BinaryOpGenericAdaptorBase(BinaryOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::UnitAttr getLeftIdentityAttr(); + bool getLeftIdentity(); + ::mlir::UnitAttr getRightIdentityAttr(); + bool getRightIdentity(); + ::mlir::Region &getOverlapRegion(); + ::mlir::Region &getLeftRegion(); + ::mlir::Region &getRightRegion(); + ::mlir::RegionRange getRegions(); +}; +} // namespace detail +template +class BinaryOpGenericAdaptor : public detail::BinaryOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BinaryOpGenericAdaptorBase; +public: + BinaryOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BinaryOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BinaryOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + BinaryOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getX() { + return (*getODSOperands(0).begin()); + } + + ValueT getY() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BinaryOpAdaptor : public BinaryOpGenericAdaptor<::mlir::ValueRange> { +public: + using BinaryOpGenericAdaptor::BinaryOpGenericAdaptor; + BinaryOpAdaptor(BinaryOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class BinaryOp : public ::mlir::Op::Impl, ::mlir::OpTrait::OneResult, ::mlir::OpTrait::OneTypedResult<::mlir::Type>::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = BinaryOpAdaptor; + template + using GenericAdaptor = BinaryOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("left_identity"), ::llvm::StringRef("right_identity")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getLeftIdentityAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getLeftIdentityAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getRightIdentityAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getRightIdentityAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("sparse_tensor.binary"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getX(); + ::mlir::Value getY(); + ::mlir::OpOperand &getXMutable(); + ::mlir::OpOperand &getYMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getOutput(); + ::mlir::Region &getOverlapRegion(); + ::mlir::Region &getLeftRegion(); + ::mlir::Region &getRightRegion(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::UnitAttr getLeftIdentityAttr(); + bool getLeftIdentity(); + ::mlir::UnitAttr getRightIdentityAttr(); + bool getRightIdentity(); + void setLeftIdentityAttr(::mlir::UnitAttr attr); + void setLeftIdentity(bool attrValue); + void setRightIdentityAttr(::mlir::UnitAttr attr); + void setRightIdentity(bool attrValue); + ::mlir::Attribute removeLeftIdentityAttr(); + ::mlir::Attribute removeRightIdentityAttr(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value x, ::mlir::Value y, /*optional*/::mlir::UnitAttr left_identity, /*optional*/::mlir::UnitAttr right_identity); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value x, ::mlir::Value y, /*optional*/::mlir::UnitAttr left_identity, /*optional*/::mlir::UnitAttr right_identity); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value x, ::mlir::Value y, /*optional*/bool left_identity = false, /*optional*/bool right_identity = false); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value x, ::mlir::Value y, /*optional*/bool left_identity = false, /*optional*/bool right_identity = false); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace sparse_tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::BinaryOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::CompressOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CompressOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + CompressOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + CompressOpGenericAdaptorBase(CompressOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class CompressOpGenericAdaptor : public detail::CompressOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CompressOpGenericAdaptorBase; +public: + CompressOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CompressOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CompressOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + CompressOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getValues() { + return (*getODSOperands(0).begin()); + } + + ValueT getFilled() { + return (*getODSOperands(1).begin()); + } + + ValueT getAdded() { + return (*getODSOperands(2).begin()); + } + + ValueT getCount() { + return (*getODSOperands(3).begin()); + } + + ValueT getTensor() { + return (*getODSOperands(4).begin()); + } + + RangeT getLvlCoords() { + return getODSOperands(5); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class CompressOpAdaptor : public CompressOpGenericAdaptor<::mlir::ValueRange> { +public: + using CompressOpGenericAdaptor::CompressOpGenericAdaptor; + CompressOpAdaptor(CompressOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class CompressOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<5>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = CompressOpAdaptor; + template + using GenericAdaptor = CompressOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("sparse_tensor.compress"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getValues(); + ::mlir::TypedValue<::mlir::MemRefType> getFilled(); + ::mlir::TypedValue<::mlir::MemRefType> getAdded(); + ::mlir::TypedValue<::mlir::IndexType> getCount(); + ::mlir::TypedValue<::mlir::TensorType> getTensor(); + ::mlir::Operation::operand_range getLvlCoords(); + ::mlir::OpOperand &getValuesMutable(); + ::mlir::OpOperand &getFilledMutable(); + ::mlir::OpOperand &getAddedMutable(); + ::mlir::OpOperand &getCountMutable(); + ::mlir::OpOperand &getTensorMutable(); + ::mlir::MutableOperandRange getLvlCoordsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::TensorType> getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value values, ::mlir::Value filled, ::mlir::Value added, ::mlir::Value count, ::mlir::Value tensor, ::mlir::ValueRange lvlCoords); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value values, ::mlir::Value filled, ::mlir::Value added, ::mlir::Value count, ::mlir::Value tensor, ::mlir::ValueRange lvlCoords); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value values, ::mlir::Value filled, ::mlir::Value added, ::mlir::Value count, ::mlir::Value tensor, ::mlir::ValueRange lvlCoords); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +public: +}; +} // namespace sparse_tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::CompressOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::ConcatenateOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ConcatenateOpGenericAdaptorBase { +public: + struct Properties { + using dimensionTy = ::mlir::IntegerAttr; + dimensionTy dimension; + + auto getDimension() { + auto &propStorage = this->dimension; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setDimension(const ::mlir::IntegerAttr &propValue) { + this->dimension = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.dimension == this->dimension && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ConcatenateOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + ConcatenateOpGenericAdaptorBase(ConcatenateOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::IntegerAttr getDimensionAttr(); + ::mlir::sparse_tensor::Dimension getDimension(); +}; +} // namespace detail +template +class ConcatenateOpGenericAdaptor : public detail::ConcatenateOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ConcatenateOpGenericAdaptorBase; +public: + ConcatenateOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ConcatenateOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ConcatenateOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + ConcatenateOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getInputs() { + return getODSOperands(0); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ConcatenateOpAdaptor : public ConcatenateOpGenericAdaptor<::mlir::ValueRange> { +public: + using ConcatenateOpGenericAdaptor::ConcatenateOpGenericAdaptor; + ConcatenateOpAdaptor(ConcatenateOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ConcatenateOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ConcatenateOpAdaptor; + template + using GenericAdaptor = ConcatenateOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("dimension")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getDimensionAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getDimensionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("sparse_tensor.concatenate"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Operation::operand_range getInputs(); + ::mlir::MutableOperandRange getInputsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::RankedTensorType> getResult(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::IntegerAttr getDimensionAttr(); + ::mlir::sparse_tensor::Dimension getDimension(); + void setDimensionAttr(::mlir::IntegerAttr attr); + void setDimension(::mlir::sparse_tensor::Dimension attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange inputs, ::mlir::IntegerAttr dimension); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange inputs, ::mlir::IntegerAttr dimension); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange inputs, ::mlir::sparse_tensor::Dimension dimension); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange inputs, ::mlir::sparse_tensor::Dimension dimension); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace sparse_tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::ConcatenateOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::ConvertOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ConvertOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + ConvertOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + ConvertOpGenericAdaptorBase(ConvertOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class ConvertOpGenericAdaptor : public detail::ConvertOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ConvertOpGenericAdaptorBase; +public: + ConvertOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ConvertOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ConvertOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + ConvertOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSource() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ConvertOpAdaptor : public ConvertOpGenericAdaptor<::mlir::ValueRange> { +public: + using ConvertOpGenericAdaptor::ConvertOpGenericAdaptor; + ConvertOpAdaptor(ConvertOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ConvertOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ConvertOpAdaptor; + template + using GenericAdaptor = ConvertOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("sparse_tensor.convert"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::TensorType> getSource(); + ::mlir::OpOperand &getSourceMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::TensorType> getDest(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dest, ::mlir::Value source); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace sparse_tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::ConvertOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::DisassembleOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class DisassembleOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + DisassembleOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + DisassembleOpGenericAdaptorBase(DisassembleOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class DisassembleOpGenericAdaptor : public detail::DisassembleOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::DisassembleOpGenericAdaptorBase; +public: + DisassembleOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + DisassembleOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : DisassembleOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + DisassembleOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getTensor() { + return (*getODSOperands(0).begin()); + } + + ValueT getOutValues() { + return (*getODSOperands(1).begin()); + } + + RangeT getOutLevels() { + return getODSOperands(2); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class DisassembleOpAdaptor : public DisassembleOpGenericAdaptor<::mlir::ValueRange> { +public: + using DisassembleOpGenericAdaptor::DisassembleOpGenericAdaptor; + DisassembleOpAdaptor(DisassembleOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class DisassembleOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpAsmOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = DisassembleOpAdaptor; + template + using GenericAdaptor = DisassembleOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn); + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("sparse_tensor.disassemble"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::TensorType> getTensor(); + ::mlir::TypedValue<::mlir::TensorType> getOutValues(); + ::mlir::Operation::operand_range getOutLevels(); + ::mlir::OpOperand &getTensorMutable(); + ::mlir::OpOperand &getOutValuesMutable(); + ::mlir::MutableOperandRange getOutLevelsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::TensorType> getRetValues(); + ::mlir::Operation::result_range getRetLevels(); + ::mlir::Value getValLen(); + ::mlir::Operation::result_range getLvlLens(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type ret_values, ::mlir::TypeRange ret_levels, ::mlir::Type val_len, ::mlir::TypeRange lvl_lens, ::mlir::Value tensor, ::mlir::Value out_values, ::mlir::ValueRange out_levels); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tensor, ::mlir::Value out_values, ::mlir::ValueRange out_levels); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace sparse_tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::DisassembleOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::ExpandOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ExpandOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + ExpandOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + ExpandOpGenericAdaptorBase(ExpandOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class ExpandOpGenericAdaptor : public detail::ExpandOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ExpandOpGenericAdaptorBase; +public: + ExpandOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ExpandOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ExpandOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + ExpandOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getTensor() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ExpandOpAdaptor : public ExpandOpGenericAdaptor<::mlir::ValueRange> { +public: + using ExpandOpGenericAdaptor::ExpandOpGenericAdaptor; + ExpandOpAdaptor(ExpandOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ExpandOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::OpAsmOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ExpandOpAdaptor; + template + using GenericAdaptor = ExpandOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn); + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("sparse_tensor.expand"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::TensorType> getTensor(); + ::mlir::OpOperand &getTensorMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getValues(); + ::mlir::TypedValue<::mlir::MemRefType> getFilled(); + ::mlir::TypedValue<::mlir::MemRefType> getAdded(); + ::mlir::TypedValue<::mlir::IndexType> getCount(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type values, ::mlir::Type filled, ::mlir::Type added, ::mlir::Type count, ::mlir::Value tensor); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tensor); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +public: +}; +} // namespace sparse_tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::ExpandOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::ForeachOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ForeachOpGenericAdaptorBase { +public: + struct Properties { + using orderTy = ::mlir::AffineMapAttr; + orderTy order; + + auto getOrder() { + auto &propStorage = this->order; + return ::llvm::dyn_cast_or_null<::mlir::AffineMapAttr>(propStorage); + } + void setOrder(const ::mlir::AffineMapAttr &propValue) { + this->order = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.order == this->order && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ForeachOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + ForeachOpGenericAdaptorBase(ForeachOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::AffineMapAttr getOrderAttr(); + ::std::optional< ::mlir::AffineMap > getOrder(); + ::mlir::Region &getRegion(); + ::mlir::RegionRange getRegions(); +}; +} // namespace detail +template +class ForeachOpGenericAdaptor : public detail::ForeachOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ForeachOpGenericAdaptorBase; +public: + ForeachOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ForeachOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ForeachOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + ForeachOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getTensor() { + return (*getODSOperands(0).begin()); + } + + RangeT getInitArgs() { + return getODSOperands(1); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ForeachOpAdaptor : public ForeachOpGenericAdaptor<::mlir::ValueRange> { +public: + using ForeachOpGenericAdaptor::ForeachOpGenericAdaptor; + ForeachOpAdaptor(ForeachOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ForeachOp : public ::mlir::Op::Impl, ::mlir::OpTrait::SingleBlock, ::mlir::OpTrait::SingleBlockImplicitTerminator::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ForeachOpAdaptor; + template + using GenericAdaptor = ForeachOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("order")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getOrderAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getOrderAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("sparse_tensor.foreach"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::TensorType> getTensor(); + ::mlir::Operation::operand_range getInitArgs(); + ::mlir::OpOperand &getTensorMutable(); + ::mlir::MutableOperandRange getInitArgsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Operation::result_range getResults(); + ::mlir::Region &getRegion(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::AffineMapAttr getOrderAttr(); + ::std::optional< ::mlir::AffineMap > getOrder(); + void setOrderAttr(::mlir::AffineMapAttr attr); + void setOrder(::std::optional<::mlir::AffineMap> attrValue); + ::mlir::Attribute removeOrderAttr(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value tensor, ValueRange iterArgs, AffineMapAttr order, function_ref odsArg3); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value tensor, AffineMapAttr order, function_ref bodyBuilder); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value tensor, function_ref bodyBuilder); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value tensor, ValueRange iterArgs, function_ref bodyBuilder); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::Value tensor, ::mlir::ValueRange initArgs, /*optional*/::mlir::AffineMapAttr order); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace sparse_tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::ForeachOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::GetStorageSpecifierOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class GetStorageSpecifierOpGenericAdaptorBase { +public: + struct Properties { + using levelTy = ::mlir::IntegerAttr; + levelTy level; + + auto getLevel() { + auto &propStorage = this->level; + return ::llvm::dyn_cast_or_null<::mlir::IntegerAttr>(propStorage); + } + void setLevel(const ::mlir::IntegerAttr &propValue) { + this->level = propValue; + } + using specifierKindTy = ::mlir::sparse_tensor::StorageSpecifierKindAttr; + specifierKindTy specifierKind; + + auto getSpecifierKind() { + auto &propStorage = this->specifierKind; + return ::llvm::cast<::mlir::sparse_tensor::StorageSpecifierKindAttr>(propStorage); + } + void setSpecifierKind(const ::mlir::sparse_tensor::StorageSpecifierKindAttr &propValue) { + this->specifierKind = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.level == this->level && + rhs.specifierKind == this->specifierKind && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + GetStorageSpecifierOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + GetStorageSpecifierOpGenericAdaptorBase(GetStorageSpecifierOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::sparse_tensor::StorageSpecifierKindAttr getSpecifierKindAttr(); + ::mlir::sparse_tensor::StorageSpecifierKind getSpecifierKind(); + ::mlir::IntegerAttr getLevelAttr(); + ::std::optional<::mlir::sparse_tensor::Level> getLevel(); +}; +} // namespace detail +template +class GetStorageSpecifierOpGenericAdaptor : public detail::GetStorageSpecifierOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::GetStorageSpecifierOpGenericAdaptorBase; +public: + GetStorageSpecifierOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + GetStorageSpecifierOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : GetStorageSpecifierOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + GetStorageSpecifierOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSpecifier() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class GetStorageSpecifierOpAdaptor : public GetStorageSpecifierOpGenericAdaptor<::mlir::ValueRange> { +public: + using GetStorageSpecifierOpGenericAdaptor::GetStorageSpecifierOpGenericAdaptor; + GetStorageSpecifierOpAdaptor(GetStorageSpecifierOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class GetStorageSpecifierOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = GetStorageSpecifierOpAdaptor; + template + using GenericAdaptor = GetStorageSpecifierOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("level"), ::llvm::StringRef("specifierKind")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getLevelAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getLevelAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getSpecifierKindAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getSpecifierKindAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("sparse_tensor.storage_specifier.get"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::sparse_tensor::StorageSpecifierType> getSpecifier(); + ::mlir::OpOperand &getSpecifierMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::IndexType> getResult(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::sparse_tensor::StorageSpecifierKindAttr getSpecifierKindAttr(); + ::mlir::sparse_tensor::StorageSpecifierKind getSpecifierKind(); + ::mlir::IntegerAttr getLevelAttr(); + ::std::optional<::mlir::sparse_tensor::Level> getLevel(); + void setSpecifierKindAttr(::mlir::sparse_tensor::StorageSpecifierKindAttr attr); + void setSpecifierKind(::mlir::sparse_tensor::StorageSpecifierKind attrValue); + void setLevelAttr(::mlir::IntegerAttr attr); + void setLevel(::std::optional<::mlir::sparse_tensor::Level> attrValue); + ::mlir::Attribute removeLevelAttr(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value specifier, ::mlir::sparse_tensor::StorageSpecifierKindAttr specifierKind, /*optional*/::mlir::IntegerAttr level); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value specifier, ::mlir::sparse_tensor::StorageSpecifierKindAttr specifierKind, /*optional*/::mlir::IntegerAttr level); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value specifier, ::mlir::sparse_tensor::StorageSpecifierKindAttr specifierKind, /*optional*/::mlir::IntegerAttr level); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value specifier, ::mlir::sparse_tensor::StorageSpecifierKind specifierKind, /*optional*/::mlir::IntegerAttr level); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value specifier, ::mlir::sparse_tensor::StorageSpecifierKind specifierKind, /*optional*/::mlir::IntegerAttr level); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value specifier, ::mlir::sparse_tensor::StorageSpecifierKind specifierKind, /*optional*/::mlir::IntegerAttr level); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace sparse_tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::GetStorageSpecifierOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::InsertOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class InsertOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + InsertOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + InsertOpGenericAdaptorBase(InsertOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class InsertOpGenericAdaptor : public detail::InsertOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::InsertOpGenericAdaptorBase; +public: + InsertOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + InsertOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : InsertOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + InsertOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getValue() { + return (*getODSOperands(0).begin()); + } + + ValueT getTensor() { + return (*getODSOperands(1).begin()); + } + + RangeT getLvlCoords() { + return getODSOperands(2); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class InsertOpAdaptor : public InsertOpGenericAdaptor<::mlir::ValueRange> { +public: + using InsertOpGenericAdaptor::InsertOpGenericAdaptor; + InsertOpAdaptor(InsertOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class InsertOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = InsertOpAdaptor; + template + using GenericAdaptor = InsertOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("sparse_tensor.insert"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getValue(); + ::mlir::TypedValue<::mlir::TensorType> getTensor(); + ::mlir::Operation::operand_range getLvlCoords(); + ::mlir::OpOperand &getValueMutable(); + ::mlir::OpOperand &getTensorMutable(); + ::mlir::MutableOperandRange getLvlCoordsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::TensorType> getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value value, ::mlir::Value tensor, ::mlir::ValueRange lvlCoords); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value value, ::mlir::Value tensor, ::mlir::ValueRange lvlCoords); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value value, ::mlir::Value tensor, ::mlir::ValueRange lvlCoords); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +public: +}; +} // namespace sparse_tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::InsertOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::LoadOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class LoadOpGenericAdaptorBase { +public: + struct Properties { + using hasInsertsTy = ::mlir::UnitAttr; + hasInsertsTy hasInserts; + + auto getHasInserts() { + auto &propStorage = this->hasInserts; + return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(propStorage); + } + void setHasInserts(const ::mlir::UnitAttr &propValue) { + this->hasInserts = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.hasInserts == this->hasInserts && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + LoadOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + LoadOpGenericAdaptorBase(LoadOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::UnitAttr getHasInsertsAttr(); + bool getHasInserts(); +}; +} // namespace detail +template +class LoadOpGenericAdaptor : public detail::LoadOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::LoadOpGenericAdaptorBase; +public: + LoadOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + LoadOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : LoadOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + LoadOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getTensor() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class LoadOpAdaptor : public LoadOpGenericAdaptor<::mlir::ValueRange> { +public: + using LoadOpGenericAdaptor::LoadOpGenericAdaptor; + LoadOpAdaptor(LoadOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class LoadOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpTrait::SameOperandsAndResultType, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = LoadOpAdaptor; + template + using GenericAdaptor = LoadOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("hasInserts")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getHasInsertsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getHasInsertsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("sparse_tensor.load"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::TensorType> getTensor(); + ::mlir::OpOperand &getTensorMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::TensorType> getResult(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::UnitAttr getHasInsertsAttr(); + bool getHasInserts(); + void setHasInsertsAttr(::mlir::UnitAttr attr); + void setHasInserts(bool attrValue); + ::mlir::Attribute removeHasInsertsAttr(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value tensor, /*optional*/::mlir::UnitAttr hasInserts); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value tensor, /*optional*/::mlir::UnitAttr hasInserts); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tensor, /*optional*/::mlir::UnitAttr hasInserts); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value tensor, /*optional*/bool hasInserts = false); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value tensor, /*optional*/bool hasInserts = false); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tensor, /*optional*/bool hasInserts = false); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace sparse_tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::LoadOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::NewOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class NewOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + NewOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + NewOpGenericAdaptorBase(NewOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class NewOpGenericAdaptor : public detail::NewOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::NewOpGenericAdaptorBase; +public: + NewOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + NewOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : NewOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + NewOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSource() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class NewOpAdaptor : public NewOpGenericAdaptor<::mlir::ValueRange> { +public: + using NewOpGenericAdaptor::NewOpGenericAdaptor; + NewOpAdaptor(NewOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class NewOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = NewOpAdaptor; + template + using GenericAdaptor = NewOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("sparse_tensor.new"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getSource(); + ::mlir::OpOperand &getSourceMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::TensorType> getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace sparse_tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::NewOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::NumberOfEntriesOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class NumberOfEntriesOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + NumberOfEntriesOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + NumberOfEntriesOpGenericAdaptorBase(NumberOfEntriesOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class NumberOfEntriesOpGenericAdaptor : public detail::NumberOfEntriesOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::NumberOfEntriesOpGenericAdaptorBase; +public: + NumberOfEntriesOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + NumberOfEntriesOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : NumberOfEntriesOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + NumberOfEntriesOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getTensor() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class NumberOfEntriesOpAdaptor : public NumberOfEntriesOpGenericAdaptor<::mlir::ValueRange> { +public: + using NumberOfEntriesOpGenericAdaptor::NumberOfEntriesOpGenericAdaptor; + NumberOfEntriesOpAdaptor(NumberOfEntriesOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class NumberOfEntriesOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = NumberOfEntriesOpAdaptor; + template + using GenericAdaptor = NumberOfEntriesOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("sparse_tensor.number_of_entries"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::TensorType> getTensor(); + ::mlir::OpOperand &getTensorMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::IndexType> getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value tensor); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value tensor); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tensor); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace sparse_tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::NumberOfEntriesOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::OutOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class OutOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + OutOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + OutOpGenericAdaptorBase(OutOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class OutOpGenericAdaptor : public detail::OutOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::OutOpGenericAdaptorBase; +public: + OutOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + OutOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : OutOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + OutOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getTensor() { + return (*getODSOperands(0).begin()); + } + + ValueT getDest() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class OutOpAdaptor : public OutOpGenericAdaptor<::mlir::ValueRange> { +public: + using OutOpGenericAdaptor::OutOpGenericAdaptor; + OutOpAdaptor(OutOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class OutOp : public ::mlir::Op::Impl, ::mlir::OpTrait::OpInvariants> { +public: + using Op::Op; + using Op::print; + using Adaptor = OutOpAdaptor; + template + using GenericAdaptor = OutOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("sparse_tensor.out"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::TensorType> getTensor(); + ::mlir::Value getDest(); + ::mlir::OpOperand &getTensorMutable(); + ::mlir::OpOperand &getDestMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value tensor, ::mlir::Value dest); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tensor, ::mlir::Value dest); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +public: +}; +} // namespace sparse_tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::OutOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::PushBackOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class PushBackOpGenericAdaptorBase { +public: + struct Properties { + using inboundsTy = ::mlir::UnitAttr; + inboundsTy inbounds; + + auto getInbounds() { + auto &propStorage = this->inbounds; + return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(propStorage); + } + void setInbounds(const ::mlir::UnitAttr &propValue) { + this->inbounds = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.inbounds == this->inbounds && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + PushBackOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + PushBackOpGenericAdaptorBase(PushBackOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::UnitAttr getInboundsAttr(); + bool getInbounds(); +}; +} // namespace detail +template +class PushBackOpGenericAdaptor : public detail::PushBackOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::PushBackOpGenericAdaptorBase; +public: + PushBackOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + PushBackOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : PushBackOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + PushBackOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getCurSize() { + return (*getODSOperands(0).begin()); + } + + ValueT getInBuffer() { + return (*getODSOperands(1).begin()); + } + + ValueT getValue() { + return (*getODSOperands(2).begin()); + } + + ValueT getN() { + auto operands = getODSOperands(3); + return operands.empty() ? ValueT{} : (*operands.begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class PushBackOpAdaptor : public PushBackOpGenericAdaptor<::mlir::ValueRange> { +public: + using PushBackOpGenericAdaptor::PushBackOpGenericAdaptor; + PushBackOpAdaptor(PushBackOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class PushBackOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<3>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::OpAsmOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = PushBackOpAdaptor; + template + using GenericAdaptor = PushBackOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("inbounds")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getInboundsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getInboundsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn); + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("sparse_tensor.push_back"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::IndexType> getCurSize(); + ::mlir::TypedValue<::mlir::MemRefType> getInBuffer(); + ::mlir::Value getValue(); + ::mlir::TypedValue<::mlir::IndexType> getN(); + ::mlir::OpOperand &getCurSizeMutable(); + ::mlir::OpOperand &getInBufferMutable(); + ::mlir::OpOperand &getValueMutable(); + ::mlir::MutableOperandRange getNMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::MemRefType> getOutBuffer(); + ::mlir::TypedValue<::mlir::IndexType> getNewSize(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::UnitAttr getInboundsAttr(); + bool getInbounds(); + void setInboundsAttr(::mlir::UnitAttr attr); + void setInbounds(bool attrValue); + ::mlir::Attribute removeInboundsAttr(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value curSize, Value inBuffer, Value value); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type outBuffer, ::mlir::Type newSize, ::mlir::Value curSize, ::mlir::Value inBuffer, ::mlir::Value value, /*optional*/::mlir::Value n, /*optional*/::mlir::UnitAttr inbounds); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value curSize, ::mlir::Value inBuffer, ::mlir::Value value, /*optional*/::mlir::Value n, /*optional*/::mlir::UnitAttr inbounds); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value curSize, ::mlir::Value inBuffer, ::mlir::Value value, /*optional*/::mlir::Value n, /*optional*/::mlir::UnitAttr inbounds); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type outBuffer, ::mlir::Type newSize, ::mlir::Value curSize, ::mlir::Value inBuffer, ::mlir::Value value, /*optional*/::mlir::Value n, /*optional*/bool inbounds = false); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value curSize, ::mlir::Value inBuffer, ::mlir::Value value, /*optional*/::mlir::Value n, /*optional*/bool inbounds = false); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value curSize, ::mlir::Value inBuffer, ::mlir::Value value, /*optional*/::mlir::Value n, /*optional*/bool inbounds = false); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace sparse_tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::PushBackOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::ReduceOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ReduceOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + ReduceOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + ReduceOpGenericAdaptorBase(ReduceOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); + ::mlir::Region &getRegion(); + ::mlir::RegionRange getRegions(); +}; +} // namespace detail +template +class ReduceOpGenericAdaptor : public detail::ReduceOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ReduceOpGenericAdaptorBase; +public: + ReduceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ReduceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ReduceOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + ReduceOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getX() { + return (*getODSOperands(0).begin()); + } + + ValueT getY() { + return (*getODSOperands(1).begin()); + } + + ValueT getIdentity() { + return (*getODSOperands(2).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ReduceOpAdaptor : public ReduceOpGenericAdaptor<::mlir::ValueRange> { +public: + using ReduceOpGenericAdaptor::ReduceOpGenericAdaptor; + ReduceOpAdaptor(ReduceOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ReduceOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<3>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::SameOperandsAndResultType, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ReduceOpAdaptor; + template + using GenericAdaptor = ReduceOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("sparse_tensor.reduce"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getX(); + ::mlir::Value getY(); + ::mlir::Value getIdentity(); + ::mlir::OpOperand &getXMutable(); + ::mlir::OpOperand &getYMutable(); + ::mlir::OpOperand &getIdentityMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getOutput(); + ::mlir::Region &getRegion(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value x, ::mlir::Value y, ::mlir::Value identity); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value x, ::mlir::Value y, ::mlir::Value identity); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value x, ::mlir::Value y, ::mlir::Value identity); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace sparse_tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::ReduceOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::SelectOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class SelectOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + SelectOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + SelectOpGenericAdaptorBase(SelectOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); + ::mlir::Region &getRegion(); + ::mlir::RegionRange getRegions(); +}; +} // namespace detail +template +class SelectOpGenericAdaptor : public detail::SelectOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::SelectOpGenericAdaptorBase; +public: + SelectOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + SelectOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : SelectOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + SelectOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getX() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class SelectOpAdaptor : public SelectOpGenericAdaptor<::mlir::ValueRange> { +public: + using SelectOpGenericAdaptor::SelectOpGenericAdaptor; + SelectOpAdaptor(SelectOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class SelectOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::SameOperandsAndResultType, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = SelectOpAdaptor; + template + using GenericAdaptor = SelectOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("sparse_tensor.select"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getX(); + ::mlir::OpOperand &getXMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getOutput(); + ::mlir::Region &getRegion(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value x); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value x); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value x); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace sparse_tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::SelectOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::SetStorageSpecifierOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class SetStorageSpecifierOpGenericAdaptorBase { +public: + struct Properties { + using levelTy = ::mlir::IntegerAttr; + levelTy level; + + auto getLevel() { + auto &propStorage = this->level; + return ::llvm::dyn_cast_or_null<::mlir::IntegerAttr>(propStorage); + } + void setLevel(const ::mlir::IntegerAttr &propValue) { + this->level = propValue; + } + using specifierKindTy = ::mlir::sparse_tensor::StorageSpecifierKindAttr; + specifierKindTy specifierKind; + + auto getSpecifierKind() { + auto &propStorage = this->specifierKind; + return ::llvm::cast<::mlir::sparse_tensor::StorageSpecifierKindAttr>(propStorage); + } + void setSpecifierKind(const ::mlir::sparse_tensor::StorageSpecifierKindAttr &propValue) { + this->specifierKind = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.level == this->level && + rhs.specifierKind == this->specifierKind && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + SetStorageSpecifierOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + SetStorageSpecifierOpGenericAdaptorBase(SetStorageSpecifierOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::sparse_tensor::StorageSpecifierKindAttr getSpecifierKindAttr(); + ::mlir::sparse_tensor::StorageSpecifierKind getSpecifierKind(); + ::mlir::IntegerAttr getLevelAttr(); + ::std::optional<::mlir::sparse_tensor::Level> getLevel(); +}; +} // namespace detail +template +class SetStorageSpecifierOpGenericAdaptor : public detail::SetStorageSpecifierOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::SetStorageSpecifierOpGenericAdaptorBase; +public: + SetStorageSpecifierOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + SetStorageSpecifierOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : SetStorageSpecifierOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + SetStorageSpecifierOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSpecifier() { + return (*getODSOperands(0).begin()); + } + + ValueT getValue() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class SetStorageSpecifierOpAdaptor : public SetStorageSpecifierOpGenericAdaptor<::mlir::ValueRange> { +public: + using SetStorageSpecifierOpGenericAdaptor::SetStorageSpecifierOpGenericAdaptor; + SetStorageSpecifierOpAdaptor(SetStorageSpecifierOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class SetStorageSpecifierOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = SetStorageSpecifierOpAdaptor; + template + using GenericAdaptor = SetStorageSpecifierOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("level"), ::llvm::StringRef("specifierKind")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getLevelAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getLevelAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getSpecifierKindAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getSpecifierKindAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("sparse_tensor.storage_specifier.set"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::sparse_tensor::StorageSpecifierType> getSpecifier(); + ::mlir::TypedValue<::mlir::IndexType> getValue(); + ::mlir::OpOperand &getSpecifierMutable(); + ::mlir::OpOperand &getValueMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::sparse_tensor::StorageSpecifierType> getResult(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::sparse_tensor::StorageSpecifierKindAttr getSpecifierKindAttr(); + ::mlir::sparse_tensor::StorageSpecifierKind getSpecifierKind(); + ::mlir::IntegerAttr getLevelAttr(); + ::std::optional<::mlir::sparse_tensor::Level> getLevel(); + void setSpecifierKindAttr(::mlir::sparse_tensor::StorageSpecifierKindAttr attr); + void setSpecifierKind(::mlir::sparse_tensor::StorageSpecifierKind attrValue); + void setLevelAttr(::mlir::IntegerAttr attr); + void setLevel(::std::optional<::mlir::sparse_tensor::Level> attrValue); + ::mlir::Attribute removeLevelAttr(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value specifier, ::mlir::sparse_tensor::StorageSpecifierKindAttr specifierKind, /*optional*/::mlir::IntegerAttr level, ::mlir::Value value); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value specifier, ::mlir::sparse_tensor::StorageSpecifierKindAttr specifierKind, /*optional*/::mlir::IntegerAttr level, ::mlir::Value value); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value specifier, ::mlir::sparse_tensor::StorageSpecifierKindAttr specifierKind, /*optional*/::mlir::IntegerAttr level, ::mlir::Value value); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value specifier, ::mlir::sparse_tensor::StorageSpecifierKind specifierKind, /*optional*/::mlir::IntegerAttr level, ::mlir::Value value); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value specifier, ::mlir::sparse_tensor::StorageSpecifierKind specifierKind, /*optional*/::mlir::IntegerAttr level, ::mlir::Value value); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value specifier, ::mlir::sparse_tensor::StorageSpecifierKind specifierKind, /*optional*/::mlir::IntegerAttr level, ::mlir::Value value); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace sparse_tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::SetStorageSpecifierOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::SortOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class SortOpGenericAdaptorBase { +public: + struct Properties { + using algorithmTy = ::mlir::sparse_tensor::SparseTensorSortKindAttr; + algorithmTy algorithm; + + auto getAlgorithm() { + auto &propStorage = this->algorithm; + return ::llvm::cast<::mlir::sparse_tensor::SparseTensorSortKindAttr>(propStorage); + } + void setAlgorithm(const ::mlir::sparse_tensor::SparseTensorSortKindAttr &propValue) { + this->algorithm = propValue; + } + using nyTy = ::mlir::IntegerAttr; + nyTy ny; + + auto getNy() { + auto &propStorage = this->ny; + return ::llvm::dyn_cast_or_null<::mlir::IntegerAttr>(propStorage); + } + void setNy(const ::mlir::IntegerAttr &propValue) { + this->ny = propValue; + } + using perm_mapTy = ::mlir::AffineMapAttr; + perm_mapTy perm_map; + + auto getPermMap() { + auto &propStorage = this->perm_map; + return ::llvm::cast<::mlir::AffineMapAttr>(propStorage); + } + void setPermMap(const ::mlir::AffineMapAttr &propValue) { + this->perm_map = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.algorithm == this->algorithm && + rhs.ny == this->ny && + rhs.perm_map == this->perm_map && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + SortOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + SortOpGenericAdaptorBase(SortOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::AffineMapAttr getPermMapAttr(); + ::mlir::AffineMap getPermMap(); + ::mlir::IntegerAttr getNyAttr(); + ::std::optional< ::llvm::APInt > getNy(); + ::mlir::sparse_tensor::SparseTensorSortKindAttr getAlgorithmAttr(); + ::mlir::sparse_tensor::SparseTensorSortKind getAlgorithm(); +}; +} // namespace detail +template +class SortOpGenericAdaptor : public detail::SortOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::SortOpGenericAdaptorBase; +public: + SortOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + SortOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : SortOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + SortOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getN() { + return (*getODSOperands(0).begin()); + } + + ValueT getXy() { + return (*getODSOperands(1).begin()); + } + + RangeT getYs() { + return getODSOperands(2); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class SortOpAdaptor : public SortOpGenericAdaptor<::mlir::ValueRange> { +public: + using SortOpGenericAdaptor::SortOpGenericAdaptor; + SortOpAdaptor(SortOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class SortOp : public ::mlir::Op::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = SortOpAdaptor; + template + using GenericAdaptor = SortOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("algorithm"), ::llvm::StringRef("ny"), ::llvm::StringRef("perm_map")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getAlgorithmAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getAlgorithmAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getNyAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getNyAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getPermMapAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getPermMapAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("sparse_tensor.sort"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::IndexType> getN(); + ::mlir::TypedValue<::mlir::MemRefType> getXy(); + ::mlir::Operation::operand_range getYs(); + ::mlir::OpOperand &getNMutable(); + ::mlir::OpOperand &getXyMutable(); + ::mlir::MutableOperandRange getYsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::AffineMapAttr getPermMapAttr(); + ::mlir::AffineMap getPermMap(); + ::mlir::IntegerAttr getNyAttr(); + ::std::optional< ::llvm::APInt > getNy(); + ::mlir::sparse_tensor::SparseTensorSortKindAttr getAlgorithmAttr(); + ::mlir::sparse_tensor::SparseTensorSortKind getAlgorithm(); + void setPermMapAttr(::mlir::AffineMapAttr attr); + void setPermMap(::mlir::AffineMap attrValue); + void setNyAttr(::mlir::IntegerAttr attr); + void setNy(::std::optional<::llvm::APInt> attrValue); + void setAlgorithmAttr(::mlir::sparse_tensor::SparseTensorSortKindAttr attr); + void setAlgorithm(::mlir::sparse_tensor::SparseTensorSortKind attrValue); + ::mlir::Attribute removeNyAttr(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value n, ::mlir::Value xy, ::mlir::ValueRange ys, ::mlir::AffineMapAttr perm_map, /*optional*/::mlir::IntegerAttr ny, ::mlir::sparse_tensor::SparseTensorSortKindAttr algorithm); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value n, ::mlir::Value xy, ::mlir::ValueRange ys, ::mlir::AffineMapAttr perm_map, /*optional*/::mlir::IntegerAttr ny, ::mlir::sparse_tensor::SparseTensorSortKindAttr algorithm); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value n, ::mlir::Value xy, ::mlir::ValueRange ys, ::mlir::AffineMap perm_map, /*optional*/::mlir::IntegerAttr ny, ::mlir::sparse_tensor::SparseTensorSortKind algorithm); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value n, ::mlir::Value xy, ::mlir::ValueRange ys, ::mlir::AffineMap perm_map, /*optional*/::mlir::IntegerAttr ny, ::mlir::sparse_tensor::SparseTensorSortKind algorithm); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 3 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace sparse_tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::SortOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::StorageSpecifierInitOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class StorageSpecifierInitOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + StorageSpecifierInitOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + StorageSpecifierInitOpGenericAdaptorBase(StorageSpecifierInitOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class StorageSpecifierInitOpGenericAdaptor : public detail::StorageSpecifierInitOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::StorageSpecifierInitOpGenericAdaptorBase; +public: + StorageSpecifierInitOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + StorageSpecifierInitOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : StorageSpecifierInitOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + StorageSpecifierInitOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSource() { + auto operands = getODSOperands(0); + return operands.empty() ? ValueT{} : (*operands.begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class StorageSpecifierInitOpAdaptor : public StorageSpecifierInitOpGenericAdaptor<::mlir::ValueRange> { +public: + using StorageSpecifierInitOpGenericAdaptor::StorageSpecifierInitOpGenericAdaptor; + StorageSpecifierInitOpAdaptor(StorageSpecifierInitOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class StorageSpecifierInitOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = StorageSpecifierInitOpAdaptor; + template + using GenericAdaptor = StorageSpecifierInitOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("sparse_tensor.storage_specifier.init"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::sparse_tensor::StorageSpecifierType> getSource(); + ::mlir::MutableOperandRange getSourceMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::sparse_tensor::StorageSpecifierType> getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type result); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, /*optional*/::mlir::Value source); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value source); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace sparse_tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::StorageSpecifierInitOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::ToCoordinatesBufferOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ToCoordinatesBufferOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + ToCoordinatesBufferOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + ToCoordinatesBufferOpGenericAdaptorBase(ToCoordinatesBufferOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class ToCoordinatesBufferOpGenericAdaptor : public detail::ToCoordinatesBufferOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ToCoordinatesBufferOpGenericAdaptorBase; +public: + ToCoordinatesBufferOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ToCoordinatesBufferOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ToCoordinatesBufferOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + ToCoordinatesBufferOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getTensor() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ToCoordinatesBufferOpAdaptor : public ToCoordinatesBufferOpGenericAdaptor<::mlir::ValueRange> { +public: + using ToCoordinatesBufferOpGenericAdaptor::ToCoordinatesBufferOpGenericAdaptor; + ToCoordinatesBufferOpAdaptor(ToCoordinatesBufferOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ToCoordinatesBufferOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ToCoordinatesBufferOpAdaptor; + template + using GenericAdaptor = ToCoordinatesBufferOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("sparse_tensor.coordinates_buffer"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::TensorType> getTensor(); + ::mlir::OpOperand &getTensorMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value tensor); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tensor); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace sparse_tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::ToCoordinatesBufferOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::ToCoordinatesOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ToCoordinatesOpGenericAdaptorBase { +public: + struct Properties { + using levelTy = ::mlir::IntegerAttr; + levelTy level; + + auto getLevel() { + auto &propStorage = this->level; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setLevel(const ::mlir::IntegerAttr &propValue) { + this->level = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.level == this->level && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ToCoordinatesOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + ToCoordinatesOpGenericAdaptorBase(ToCoordinatesOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::IntegerAttr getLevelAttr(); + ::mlir::sparse_tensor::Level getLevel(); +}; +} // namespace detail +template +class ToCoordinatesOpGenericAdaptor : public detail::ToCoordinatesOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ToCoordinatesOpGenericAdaptorBase; +public: + ToCoordinatesOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ToCoordinatesOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ToCoordinatesOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + ToCoordinatesOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getTensor() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ToCoordinatesOpAdaptor : public ToCoordinatesOpGenericAdaptor<::mlir::ValueRange> { +public: + using ToCoordinatesOpGenericAdaptor::ToCoordinatesOpGenericAdaptor; + ToCoordinatesOpAdaptor(ToCoordinatesOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ToCoordinatesOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ToCoordinatesOpAdaptor; + template + using GenericAdaptor = ToCoordinatesOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("level")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getLevelAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getLevelAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("sparse_tensor.coordinates"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::TensorType> getTensor(); + ::mlir::OpOperand &getTensorMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getResult(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::IntegerAttr getLevelAttr(); + ::mlir::sparse_tensor::Level getLevel(); + void setLevelAttr(::mlir::IntegerAttr attr); + void setLevel(::mlir::sparse_tensor::Level attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value tensor, ::mlir::IntegerAttr level); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tensor, ::mlir::IntegerAttr level); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value tensor, ::mlir::sparse_tensor::Level level); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tensor, ::mlir::sparse_tensor::Level level); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace sparse_tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::ToCoordinatesOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::ToPositionsOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ToPositionsOpGenericAdaptorBase { +public: + struct Properties { + using levelTy = ::mlir::IntegerAttr; + levelTy level; + + auto getLevel() { + auto &propStorage = this->level; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setLevel(const ::mlir::IntegerAttr &propValue) { + this->level = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.level == this->level && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ToPositionsOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + ToPositionsOpGenericAdaptorBase(ToPositionsOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::IntegerAttr getLevelAttr(); + ::mlir::sparse_tensor::Level getLevel(); +}; +} // namespace detail +template +class ToPositionsOpGenericAdaptor : public detail::ToPositionsOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ToPositionsOpGenericAdaptorBase; +public: + ToPositionsOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ToPositionsOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ToPositionsOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + ToPositionsOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getTensor() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ToPositionsOpAdaptor : public ToPositionsOpGenericAdaptor<::mlir::ValueRange> { +public: + using ToPositionsOpGenericAdaptor::ToPositionsOpGenericAdaptor; + ToPositionsOpAdaptor(ToPositionsOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ToPositionsOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ToPositionsOpAdaptor; + template + using GenericAdaptor = ToPositionsOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("level")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getLevelAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getLevelAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("sparse_tensor.positions"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::TensorType> getTensor(); + ::mlir::OpOperand &getTensorMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getResult(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::IntegerAttr getLevelAttr(); + ::mlir::sparse_tensor::Level getLevel(); + void setLevelAttr(::mlir::IntegerAttr attr); + void setLevel(::mlir::sparse_tensor::Level attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value tensor, ::mlir::IntegerAttr level); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tensor, ::mlir::IntegerAttr level); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value tensor, ::mlir::sparse_tensor::Level level); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tensor, ::mlir::sparse_tensor::Level level); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace sparse_tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::ToPositionsOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::ToSliceOffsetOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ToSliceOffsetOpGenericAdaptorBase { +public: + struct Properties { + using dimTy = ::mlir::IntegerAttr; + dimTy dim; + + auto getDim() { + auto &propStorage = this->dim; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setDim(const ::mlir::IntegerAttr &propValue) { + this->dim = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.dim == this->dim && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ToSliceOffsetOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + ToSliceOffsetOpGenericAdaptorBase(ToSliceOffsetOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::IntegerAttr getDimAttr(); + ::llvm::APInt getDim(); +}; +} // namespace detail +template +class ToSliceOffsetOpGenericAdaptor : public detail::ToSliceOffsetOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ToSliceOffsetOpGenericAdaptorBase; +public: + ToSliceOffsetOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ToSliceOffsetOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ToSliceOffsetOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + ToSliceOffsetOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSlice() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ToSliceOffsetOpAdaptor : public ToSliceOffsetOpGenericAdaptor<::mlir::ValueRange> { +public: + using ToSliceOffsetOpGenericAdaptor::ToSliceOffsetOpGenericAdaptor; + ToSliceOffsetOpAdaptor(ToSliceOffsetOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ToSliceOffsetOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ToSliceOffsetOpAdaptor; + template + using GenericAdaptor = ToSliceOffsetOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("dim")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getDimAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getDimAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("sparse_tensor.slice.offset"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::TensorType> getSlice(); + ::mlir::OpOperand &getSliceMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::IndexType> getOffset(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::IntegerAttr getDimAttr(); + ::llvm::APInt getDim(); + void setDimAttr(::mlir::IntegerAttr attr); + void setDim(::llvm::APInt attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type offset, ::mlir::Value slice, ::mlir::IntegerAttr dim); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value slice, ::mlir::IntegerAttr dim); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value slice, ::mlir::IntegerAttr dim); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type offset, ::mlir::Value slice, ::llvm::APInt dim); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value slice, ::llvm::APInt dim); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value slice, ::llvm::APInt dim); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace sparse_tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::ToSliceOffsetOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::ToSliceStrideOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ToSliceStrideOpGenericAdaptorBase { +public: + struct Properties { + using dimTy = ::mlir::IntegerAttr; + dimTy dim; + + auto getDim() { + auto &propStorage = this->dim; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setDim(const ::mlir::IntegerAttr &propValue) { + this->dim = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.dim == this->dim && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ToSliceStrideOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + ToSliceStrideOpGenericAdaptorBase(ToSliceStrideOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::IntegerAttr getDimAttr(); + ::llvm::APInt getDim(); +}; +} // namespace detail +template +class ToSliceStrideOpGenericAdaptor : public detail::ToSliceStrideOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ToSliceStrideOpGenericAdaptorBase; +public: + ToSliceStrideOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ToSliceStrideOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ToSliceStrideOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + ToSliceStrideOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSlice() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ToSliceStrideOpAdaptor : public ToSliceStrideOpGenericAdaptor<::mlir::ValueRange> { +public: + using ToSliceStrideOpGenericAdaptor::ToSliceStrideOpGenericAdaptor; + ToSliceStrideOpAdaptor(ToSliceStrideOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ToSliceStrideOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ToSliceStrideOpAdaptor; + template + using GenericAdaptor = ToSliceStrideOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("dim")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getDimAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getDimAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("sparse_tensor.slice.stride"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::TensorType> getSlice(); + ::mlir::OpOperand &getSliceMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::IndexType> getStride(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::IntegerAttr getDimAttr(); + ::llvm::APInt getDim(); + void setDimAttr(::mlir::IntegerAttr attr); + void setDim(::llvm::APInt attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type stride, ::mlir::Value slice, ::mlir::IntegerAttr dim); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value slice, ::mlir::IntegerAttr dim); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value slice, ::mlir::IntegerAttr dim); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type stride, ::mlir::Value slice, ::llvm::APInt dim); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value slice, ::llvm::APInt dim); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value slice, ::llvm::APInt dim); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace sparse_tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::ToSliceStrideOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::ToValuesOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ToValuesOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + ToValuesOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + ToValuesOpGenericAdaptorBase(ToValuesOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class ToValuesOpGenericAdaptor : public detail::ToValuesOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ToValuesOpGenericAdaptorBase; +public: + ToValuesOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ToValuesOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ToValuesOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + ToValuesOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getTensor() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ToValuesOpAdaptor : public ToValuesOpGenericAdaptor<::mlir::ValueRange> { +public: + using ToValuesOpGenericAdaptor::ToValuesOpGenericAdaptor; + ToValuesOpAdaptor(ToValuesOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ToValuesOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ToValuesOpAdaptor; + template + using GenericAdaptor = ToValuesOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("sparse_tensor.values"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::TensorType> getTensor(); + ::mlir::OpOperand &getTensorMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value tensor); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tensor); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace sparse_tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::ToValuesOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::UnaryOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class UnaryOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + UnaryOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + UnaryOpGenericAdaptorBase(UnaryOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); + ::mlir::Region &getPresentRegion(); + ::mlir::Region &getAbsentRegion(); + ::mlir::RegionRange getRegions(); +}; +} // namespace detail +template +class UnaryOpGenericAdaptor : public detail::UnaryOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::UnaryOpGenericAdaptorBase; +public: + UnaryOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + UnaryOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : UnaryOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + UnaryOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getX() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class UnaryOpAdaptor : public UnaryOpGenericAdaptor<::mlir::ValueRange> { +public: + using UnaryOpGenericAdaptor::UnaryOpGenericAdaptor; + UnaryOpAdaptor(UnaryOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class UnaryOp : public ::mlir::Op::Impl, ::mlir::OpTrait::OneResult, ::mlir::OpTrait::OneTypedResult<::mlir::Type>::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = UnaryOpAdaptor; + template + using GenericAdaptor = UnaryOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("sparse_tensor.unary"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getX(); + ::mlir::OpOperand &getXMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getOutput(); + ::mlir::Region &getPresentRegion(); + ::mlir::Region &getAbsentRegion(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value x); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value x); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace sparse_tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::UnaryOp) + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::sparse_tensor::YieldOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class YieldOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + YieldOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + YieldOpGenericAdaptorBase(YieldOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class YieldOpGenericAdaptor : public detail::YieldOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::YieldOpGenericAdaptorBase; +public: + YieldOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + YieldOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : YieldOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + YieldOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getResult() { + auto operands = getODSOperands(0); + return operands.empty() ? ValueT{} : (*operands.begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class YieldOpAdaptor : public YieldOpGenericAdaptor<::mlir::ValueRange> { +public: + using YieldOpGenericAdaptor::YieldOpGenericAdaptor; + YieldOpAdaptor(YieldOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class YieldOp : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = YieldOpAdaptor; + template + using GenericAdaptor = YieldOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("sparse_tensor.yield"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getResult(); + ::mlir::MutableOperandRange getResultMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Value result); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value result); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace sparse_tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::YieldOp) + + +#endif // GET_OP_CLASSES + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOpsDialect.cpp.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOpsDialect.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..b02eb6a8ed4a85af83e89f991bd59202a80e6487 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOpsDialect.cpp.inc @@ -0,0 +1,23 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Dialect Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: SparseTensorOps.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::SparseTensorDialect) +namespace mlir { +namespace sparse_tensor { + +SparseTensorDialect::SparseTensorDialect(::mlir::MLIRContext *context) + : ::mlir::Dialect(getDialectNamespace(), context, ::mlir::TypeID::get()) { + + initialize(); +} + +SparseTensorDialect::~SparseTensorDialect() = default; + +} // namespace sparse_tensor +} // namespace mlir diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOpsDialect.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOpsDialect.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..5a86bd2edcfcd84506364dbc435234eb14710725 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOpsDialect.h.inc @@ -0,0 +1,41 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Dialect Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: SparseTensorOps.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace sparse_tensor { + +class SparseTensorDialect : public ::mlir::Dialect { + explicit SparseTensorDialect(::mlir::MLIRContext *context); + + void initialize(); + friend class ::mlir::MLIRContext; +public: + ~SparseTensorDialect() override; + static constexpr ::llvm::StringLiteral getDialectNamespace() { + return ::llvm::StringLiteral("sparse_tensor"); + } + + /// Parse an attribute registered to this dialect. + ::mlir::Attribute parseAttribute(::mlir::DialectAsmParser &parser, + ::mlir::Type type) const override; + + /// Print an attribute registered to this dialect. + void printAttribute(::mlir::Attribute attr, + ::mlir::DialectAsmPrinter &os) const override; + + /// Parse a type registered to this dialect. + ::mlir::Type parseType(::mlir::DialectAsmParser &parser) const override; + + /// Print a type registered to this dialect. + void printType(::mlir::Type type, + ::mlir::DialectAsmPrinter &os) const override; +}; +} // namespace sparse_tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::SparseTensorDialect) diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorStorageLayout.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorStorageLayout.h new file mode 100644 index 0000000000000000000000000000000000000000..b7ce44d877eb29c00d9a735980f7c55ab76381a0 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorStorageLayout.h @@ -0,0 +1,183 @@ +//===- SparseTensorStorageLayout.h ------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This header file defines utilities for the sparse memory layout. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_SPARSETENSOR_IR_SPARSETENSORSTORAGELAYOUT_H_ +#define MLIR_DIALECT_SPARSETENSOR_IR_SPARSETENSORSTORAGELAYOUT_H_ + +#include "mlir/Dialect/SparseTensor/IR/SparseTensor.h" +#include "mlir/Dialect/SparseTensor/IR/SparseTensorType.h" + +namespace mlir { +namespace sparse_tensor { + +///===----------------------------------------------------------------------===// +/// The sparse tensor storage scheme for a tensor is organized as a single +/// compound type with the following fields. Note that every memref with ? size +/// actually behaves as a "vector", i.e. the stored size is the capacity and the +/// used size resides in the storage_specifier struct. +/// +/// struct { +/// ; per-level l: +/// ; if dense: +/// +/// ; if compresed: +/// memref positions-l ; positions for sparse level l +/// memref coordinates-l ; coordinates for sparse level l +/// ; if singleton: +/// memref coordinates-l ; coordinates for singleton level l +/// +/// memref values ; values +/// +/// struct sparse_tensor.storage_specifier { +/// array lvlSizes ; sizes/cardinalities for each level +/// array memSizes; ; sizes/lengths for each data memref +/// } +/// }; +/// +/// In addition, for a "trailing COO region", defined as a compressed level +/// followed by one or more singleton levels, the default SOA storage that +/// is inherent to the TACO format is optimized into an AOS storage where +/// all coordinates of a stored element appear consecutively. In such cases, +/// a special operation (sparse_tensor.coordinates_buffer) must be used to +/// access the AOS coordinates array. In the code below, the method +/// `getCOOStart` is used to find the start of the "trailing COO region". +/// +/// If the sparse tensor is a slice (produced by `tensor.extract_slice` +/// operation), instead of allocating a new sparse tensor for it, it reuses the +/// same sets of MemRefs but attaching a additional set of slicing-metadata for +/// per-dimension slice offset and stride. +/// +/// Examples. +/// +/// #CSR storage of 2-dim matrix yields +/// memref ; positions-1 +/// memref ; coordinates-1 +/// memref ; values +/// struct<(array<2 x i64>, array<3 x i64>)>) ; lvl0, lvl1, 3xsizes +/// +/// #COO storage of 2-dim matrix yields +/// memref, ; positions-0, essentially +/// [0,sz] memref ; AOS coordinates storage +/// memref ; values +/// struct<(array<2 x i64>, array<3 x i64>)>) ; lvl0, lvl1, 3xsizes +/// +/// Slice on #COO storage of 2-dim matrix yields +/// ;; Inherited from the original sparse tensors +/// memref, ; positions-0, essentially +/// [0,sz] memref ; AOS coordinates storage +/// memref ; values +/// struct<(array<2 x i64>, array<3 x i64>, ; lvl0, lvl1, 3xsizes +/// ;; Extra slicing-metadata +/// array<2 x i64>, array<2 x i64>)>) ; dim offset, dim stride. +/// +///===----------------------------------------------------------------------===// + +enum class SparseTensorFieldKind : uint32_t { + StorageSpec = 0, + PosMemRef = static_cast(StorageSpecifierKind::PosMemSize), + CrdMemRef = static_cast(StorageSpecifierKind::CrdMemSize), + ValMemRef = static_cast(StorageSpecifierKind::ValMemSize) +}; + +inline StorageSpecifierKind toSpecifierKind(SparseTensorFieldKind kind) { + assert(kind != SparseTensorFieldKind::StorageSpec); + return static_cast(kind); +} + +inline SparseTensorFieldKind toFieldKind(StorageSpecifierKind kind) { + assert(kind != StorageSpecifierKind::LvlSize); + return static_cast(kind); +} + +/// The type of field indices. This alias is to help code be more +/// self-documenting; unfortunately it is not type-checked, so it only +/// provides documentation rather than doing anything to prevent mixups. +using FieldIndex = unsigned; + +/// Provides methods to access fields of a sparse tensor with the given +/// encoding. +class StorageLayout { +public: + // TODO: Functions/methods marked with [NUMFIELDS] should use + // `FieldIndex` for their return type, via the same reasoning for why + // `Dimension`/`Level` are used both for identifiers and ranks. + explicit StorageLayout(const SparseTensorType &stt) + : StorageLayout(stt.getEncoding()) {} + explicit StorageLayout(SparseTensorEncodingAttr enc) : enc(enc) { + assert(enc); + } + + /// For each field that will be allocated for the given sparse tensor + /// encoding, calls the callback with the corresponding field index, + /// field kind, level, and level-type (the last two are only for level + /// memrefs). The field index always starts with zero and increments + /// by one between each callback invocation. Ideally, all other methods + /// should rely on this function to query a sparse tensor fields instead + /// of relying on ad-hoc index computation. + void foreachField( + llvm::function_ref) + const; + + /// Gets the field index for required field. + FieldIndex getMemRefFieldIndex(SparseTensorFieldKind kind, + std::optional lvl) const { + return getFieldIndexAndStride(kind, lvl).first; + } + + /// Gets the total number of fields for the given sparse tensor encoding. + unsigned getNumFields() const; + + /// Gets the total number of data fields (coordinate arrays, position + /// arrays, and a value array) for the given sparse tensor encoding. + unsigned getNumDataFields() const; + + std::pair + getFieldIndexAndStride(SparseTensorFieldKind kind, + std::optional lvl) const; + +private: + const SparseTensorEncodingAttr enc; +}; + +// +// Wrapper functions to invoke StorageLayout-related method. +// + +// See note [NUMFIELDS]. +inline unsigned getNumFieldsFromEncoding(SparseTensorEncodingAttr enc) { + return StorageLayout(enc).getNumFields(); +} + +// See note [NUMFIELDS]. +inline unsigned getNumDataFieldsFromEncoding(SparseTensorEncodingAttr enc) { + return StorageLayout(enc).getNumDataFields(); +} + +inline void foreachFieldInSparseTensor( + SparseTensorEncodingAttr enc, + llvm::function_ref + callback) { + return StorageLayout(enc).foreachField(callback); +} + +void foreachFieldAndTypeInSparseTensor( + SparseTensorType, + llvm::function_ref); + +} // namespace sparse_tensor +} // namespace mlir + +#endif // MLIR_DIALECT_SPARSETENSOR_IR_SPARSETENSORSTORAGELAYOUT_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorType.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorType.h new file mode 100644 index 0000000000000000000000000000000000000000..b5dbc67781ce004826035acae2a63a23df57dc8d --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorType.h @@ -0,0 +1,325 @@ +//===- SparseTensorType.h - Wrapper around RankedTensorType -----*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This header defines the `SparseTensorType` wrapper class. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_SPARSETENSOR_IR_SPARSETENSORTYPE_H_ +#define MLIR_DIALECT_SPARSETENSOR_IR_SPARSETENSORTYPE_H_ + +#include "mlir/Dialect/SparseTensor/IR/SparseTensor.h" + +namespace mlir { +namespace sparse_tensor { + +//===----------------------------------------------------------------------===// +/// A wrapper around `RankedTensorType`, which has three goals: +/// +/// (1) To provide a uniform API for querying aspects of sparse-tensor +/// types; in particular, to make the "dimension" vs "level" distinction +/// overt (i.e., explicit everywhere). Thus, throughout the sparse-compiler +/// this class should be preferred over using `RankedTensorType` or +/// `ShapedType` directly, since the methods of the latter do not make +/// the "dimension" vs "level" distinction overt. +/// +/// (2) To provide a uniform abstraction over both sparse-tensor +/// types (i.e., `RankedTensorType` with `SparseTensorEncodingAttr`) +/// and dense-tensor types (i.e., `RankedTensorType` without an encoding). +/// That is, we want to manipulate dense-tensor types using the same API +/// that we use for manipulating sparse-tensor types; both to keep the +/// "dimension" vs "level" distinction overt, and to avoid needing to +/// handle certain cases specially in the sparse-compiler. +/// +/// (3) To provide uniform handling of "defaults". In particular +/// this means that dense-tensors should always return the same answers +/// as sparse-tensors with a default encoding. But it additionally means +/// that the answers should be normalized, so that there's no way to +/// distinguish between non-provided data (which is filled in by default) +/// vs explicitly-provided data which equals the defaults. +/// +class SparseTensorType { +public: + // We memoize `lvlRank`, `dimToLvl`, and `lvlToDim` to avoid repeating + // the conditionals throughout the rest of the class. + SparseTensorType(RankedTensorType rtp) + : rtp(rtp), enc(getSparseTensorEncoding(rtp)), + lvlRank(enc ? enc.getLvlRank() : getDimRank()), + dimToLvl(enc.isIdentity() ? AffineMap() : enc.getDimToLvl()), + lvlToDim(enc.isIdentity() ? AffineMap() : enc.getLvlToDim()) { + assert(rtp && "got null RankedTensorType"); + assert((!isIdentity() || getDimRank() == lvlRank) && "Rank mismatch"); + } + + SparseTensorType(ShapedType stp, SparseTensorEncodingAttr enc) + : SparseTensorType( + RankedTensorType::get(stp.getShape(), stp.getElementType(), enc)) {} + + // Copy-assignment would be implicitly deleted (because our fields + // are const), so we explicitly delete it for clarity. + SparseTensorType &operator=(const SparseTensorType &) = delete; + // So we must explicitly define the copy-ctor to silence -Wdeprecated-copy. + SparseTensorType(const SparseTensorType &) = default; + + // + // Factory methods. + // + + /// Constructs a new `SparseTensorType` with the same dimension-shape + /// and element type, but with the encoding replaced by the given encoding. + SparseTensorType withEncoding(SparseTensorEncodingAttr newEnc) const { + return SparseTensorType(rtp, newEnc); + } + + /// Constructs a new `SparseTensorType` with the same dimension-shape + /// and element type, but with the encoding replaced by + /// `getEncoding().withDimToLvl(dimToLvl)`. + SparseTensorType withDimToLvl(AffineMap dimToLvl) const { + return withEncoding(enc.withDimToLvl(dimToLvl)); + } + + SparseTensorType withDimToLvl(SparseTensorEncodingAttr dimToLvlEnc) const { + return withEncoding(enc.withDimToLvl(dimToLvlEnc)); + } + + SparseTensorType withDimToLvl(const SparseTensorType &dimToLvlSTT) const { + return withDimToLvl(dimToLvlSTT.getEncoding()); + } + + /// Constructs a new `SparseTensorType` with the same dimension-shape + /// and element type, but with the encoding replaced by + /// `getEncoding().withoutDimToLvl()`. + SparseTensorType withoutDimToLvl() const { + return withEncoding(enc.withoutDimToLvl()); + } + + /// Constructs a new `SparseTensorType` with the same dimension-shape + /// and element type, but with the encoding replaced by + /// `getEncoding().withBitWidths(posWidth, crdWidth)`. + SparseTensorType withBitWidths(unsigned posWidth, unsigned crdWidth) const { + return withEncoding(enc.withBitWidths(posWidth, crdWidth)); + } + + /// Constructs a new `SparseTensorType` with the same dimension-shape + /// and element type, but with the encoding replaced by + /// `getEncoding().withoutBitWidths()`. + SparseTensorType withoutBitWidths() const { + return withEncoding(enc.withoutBitWidths()); + } + + SparseTensorType + withDimSlices(ArrayRef dimSlices) const { + return withEncoding(enc.withDimSlices(dimSlices)); + } + + SparseTensorType withoutDimSlices() const { + return withEncoding(enc.withoutDimSlices()); + } + + // + // Other methods. + // + + /// Allow implicit conversion to `RankedTensorType`, `ShapedType`, + /// and `Type`. These are implicit to help alleviate the impedance + /// mismatch for code that has not been converted to use `SparseTensorType` + /// directly. Once more uses have been converted to `SparseTensorType`, + /// we may want to make these explicit instead. + /// + /// WARNING: This user-defined-conversion method causes overload + /// ambiguity whenever passing a `SparseTensorType` directly to a + /// function which is overloaded to accept either `Type` or `TypeRange`. + /// In particular, this includes `RewriterBase::replaceOpWithNewOp` + /// and `OpBuilder::create` whenever the `OpTy::build` is overloaded + /// thus. This happens because the `TypeRange(T&&)` ctor is implicit + /// as well, and there's no SFINAE we can add to this method that would + /// block subsequent application of that ctor. The only way to fix the + /// overload ambiguity is to avoid *implicit* conversion at the callsite: + /// e.g., by using `static_cast` to make the conversion explicit, by + /// assigning the `SparseTensorType` to a temporary variable of the + /// desired type, etc. + // + // NOTE: We implement this as a single templated user-defined-conversion + // function to avoid ambiguity problems when the desired result is `Type` + // (since both `RankedTensorType` and `ShapedType` can be implicitly + // converted to `Type`). + template >> + /*implicit*/ operator T() const { + return rtp; + } + + /// Explicitly convert to `RankedTensorType`. This method is + /// a convenience for resolving overload-ambiguity issues with + /// implicit conversion. + RankedTensorType getRankedTensorType() const { return rtp; } + + bool operator==(const SparseTensorType &other) const { + // All other fields are derived from `rtp` and therefore don't need + // to be checked. + return rtp == other.rtp; + } + + bool operator!=(const SparseTensorType &other) const { + return !(*this == other); + } + + MLIRContext *getContext() const { return rtp.getContext(); } + + Type getElementType() const { return rtp.getElementType(); } + + /// Returns the encoding (or the null-attribute for dense-tensors). + SparseTensorEncodingAttr getEncoding() const { return enc; } + + /// Returns true for tensors which have an encoding, and false for + /// those which do not. Therefore tensors with an all-dense encoding + /// return true. + bool hasEncoding() const { return static_cast(enc); } + + /// Returns true for tensors where every level is dense. + /// (This is always true for dense-tensors.) + bool isAllDense() const { return enc.isAllDense(); } + + /// Returns true for tensors where every level is ordered. + /// (This is always true for dense-tensors.) + bool isAllOrdered() const { return enc.isAllOrdered(); } + + /// Returns true if the dimToLvl mapping is the identity. + /// (This is always true for dense-tensors.) + bool isIdentity() const { return !dimToLvl; } + + /// Returns true if the dimToLvl mapping is a permutation. + /// (This is always true for dense-tensors.) + bool isPermutation() const { return enc.isPermutation(); } + + /// Returns the dimToLvl mapping (or the null-map for the identity). + /// If you intend to compare the results of this method for equality, + /// see `hasSameDimToLvl` instead. + AffineMap getDimToLvl() const { return dimToLvl; } + + /// Returns the lvlToDiml mapping (or the null-map for the identity). + AffineMap getLvlToDim() const { return lvlToDim; } + + /// Returns the dimToLvl mapping, where the identity map is expanded out + /// into a full `AffineMap`. This method is provided as a convenience, + /// but for most purposes other methods (`isIdentity`, `getDimToLvl`, + /// etc) will be more helpful. + AffineMap getExpandedDimToLvl() const { + return dimToLvl + ? dimToLvl + : AffineMap::getMultiDimIdentityMap(getDimRank(), getContext()); + } + + /// Returns true iff the two types have the same mapping. This method + /// takes care to handle identity maps properly, so it should be preferred + /// over using `getDimToLvl` followed by `AffineMap::operator==`. + bool hasSameDimToLvl(const SparseTensorType &other) const { + // If the maps are the identity, then we need to check the rank + // to be sure they're the same size identity. (And since identity + // means dimRank==lvlRank, we use lvlRank as a minor optimization.) + return isIdentity() ? (other.isIdentity() && lvlRank == other.lvlRank) + : (dimToLvl == other.dimToLvl); + } + + /// Returns the dimension-rank. + Dimension getDimRank() const { return rtp.getRank(); } + + /// Returns the level-rank. + Level getLvlRank() const { return lvlRank; } + + /// Returns the dimension-shape. + ArrayRef getDimShape() const { return rtp.getShape(); } + + /// Safely looks up the requested dimension-DynSize. If you intend + /// to check the result with `ShapedType::isDynamic`, then see the + /// `getStaticDimSize` method instead. + DynSize getDynamicDimSize(Dimension d) const { + assert(d < getDimRank() && "Dimension is out of bounds"); + return getDimShape()[d]; + } + + /// Safely looks up the requested dimension-size, mapping dynamic + /// sizes to `std::nullopt`. + std::optional getStaticDimSize(Dimension d) const { + const DynSize sh = getDynamicDimSize(d); + return ShapedType::isDynamic(sh) ? std::nullopt + : std::optional(sh); + } + + /// Returns true if no dimension has dynamic size. + bool hasStaticDimShape() const { return rtp.hasStaticShape(); } + + /// Returns true if any dimension has dynamic size. + bool hasDynamicDimShape() const { return !hasStaticDimShape(); } + + /// Returns true if the given dimension has dynamic size. If you + /// intend to call `getDynamicDimSize` based on the result, then see + /// the `getStaticDimSize` method instead. + bool isDynamicDim(Dimension d) const { + // We don't use `rtp.isDynamicDim(d)` because we want the + // OOB error message to be consistent with `getDynamicDimSize`. + return ShapedType::isDynamic(getDynamicDimSize(d)); + } + + /// Returns the number of dimensions which have dynamic sizes. + /// The return type is `int64_t` to maintain consistency with + /// `ShapedType::Trait::getNumDynamicDims`. + int64_t getNumDynamicDims() const { return rtp.getNumDynamicDims(); } + + DimLevelType getLvlType(Level l) const { + // This OOB check is for dense-tensors, since this class knows + // their lvlRank (whereas STEA::getLvlType will/can only check + // OOB for sparse-tensors). + assert(l < lvlRank && "Level out of bounds"); + return enc.getLvlType(l); + } + + // We can't just delegate these, since we want to use this class's + // `getLvlType` method instead of STEA's. + bool isDenseLvl(Level l) const { return isDenseDLT(getLvlType(l)); } + bool isCompressedLvl(Level l) const { return isCompressedDLT(getLvlType(l)); } + bool isSingletonLvl(Level l) const { return isSingletonDLT(getLvlType(l)); } + bool isOrderedLvl(Level l) const { return isOrderedDLT(getLvlType(l)); } + bool isUniqueLvl(Level l) const { return isUniqueDLT(getLvlType(l)); } + + /// Returns the coordinate-overhead bitwidth, defaulting to zero. + unsigned getCrdWidth() const { return enc ? enc.getCrdWidth() : 0; } + + /// Returns the position-overhead bitwidth, defaulting to zero. + unsigned getPosWidth() const { return enc ? enc.getPosWidth() : 0; } + + /// Returns the coordinate-overhead MLIR type, defaulting to `IndexType`. + Type getCrdType() const { + return detail::getIntegerOrIndexType(getContext(), getCrdWidth()); + } + + /// Returns the position-overhead MLIR type, defaulting to `IndexType`. + Type getPosType() const { + return detail::getIntegerOrIndexType(getContext(), getPosWidth()); + } + +private: + // These two must be const, to ensure coherence of the memoized fields. + const RankedTensorType rtp; + const SparseTensorEncodingAttr enc; + // Memoized to avoid frequent redundant conditionals. + const Level lvlRank; + const AffineMap dimToLvl; + const AffineMap lvlToDim; +}; + +/// Convenience method to abbreviate wrapping `getRankedTensorType`. +template +inline SparseTensorType getSparseTensorType(T t) { + return SparseTensorType(getRankedTensorType(t)); +} + +} // namespace sparse_tensor +} // namespace mlir + +#endif // MLIR_DIALECT_SPARSETENSOR_IR_SPARSETENSORTYPE_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorTypes.cpp.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorTypes.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..7c6cee7f569ee3d440794806e95e5397eae05a56 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorTypes.cpp.inc @@ -0,0 +1,141 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* TypeDef Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifdef GET_TYPEDEF_LIST +#undef GET_TYPEDEF_LIST + +::mlir::sparse_tensor::StorageSpecifierType + +#endif // GET_TYPEDEF_LIST + +#ifdef GET_TYPEDEF_CLASSES +#undef GET_TYPEDEF_CLASSES + +static ::mlir::OptionalParseResult generatedTypeParser(::mlir::AsmParser &parser, ::llvm::StringRef *mnemonic, ::mlir::Type &value) { + return ::mlir::AsmParser::KeywordSwitch<::mlir::OptionalParseResult>(parser) + .Case(::mlir::sparse_tensor::StorageSpecifierType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::sparse_tensor::StorageSpecifierType::parse(parser); + return ::mlir::success(!!value); + }) + .Default([&](llvm::StringRef keyword, llvm::SMLoc) { + *mnemonic = keyword; + return std::nullopt; + }); +} + +static ::mlir::LogicalResult generatedTypePrinter(::mlir::Type def, ::mlir::AsmPrinter &printer) { + return ::llvm::TypeSwitch<::mlir::Type, ::mlir::LogicalResult>(def) .Case<::mlir::sparse_tensor::StorageSpecifierType>([&](auto t) { + printer << ::mlir::sparse_tensor::StorageSpecifierType::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Default([](auto) { return ::mlir::failure(); }); +} + +namespace mlir { +namespace sparse_tensor { +namespace detail { +struct StorageSpecifierTypeStorage : public ::mlir::TypeStorage { + using KeyTy = std::tuple<::mlir::sparse_tensor::SparseTensorEncodingAttr>; + StorageSpecifierTypeStorage(::mlir::sparse_tensor::SparseTensorEncodingAttr encoding) : encoding(std::move(encoding)) {} + + KeyTy getAsKey() const { + return KeyTy(encoding); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (encoding == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static StorageSpecifierTypeStorage *construct(::mlir::TypeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto encoding = std::move(std::get<0>(tblgenKey)); + return new (allocator.allocate()) StorageSpecifierTypeStorage(std::move(encoding)); + } + + ::mlir::sparse_tensor::SparseTensorEncodingAttr encoding; +}; +} // namespace detail +StorageSpecifierType StorageSpecifierType::get(SparseTensorEncodingAttr encoding) { + return get(encoding.getContext(), encoding); +} + +StorageSpecifierType StorageSpecifierType::get(Type type) { + return get(getSparseTensorEncoding(type)); +} + +StorageSpecifierType StorageSpecifierType::get(Value tensor) { + return get(tensor.getType()); +} + +::mlir::Type StorageSpecifierType::parse(::mlir::AsmParser &odsParser) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::mlir::sparse_tensor::SparseTensorEncodingAttr> _result_encoding; + // Parse literal '<' + if (odsParser.parseLess()) return {}; + + // Parse variable 'encoding' + _result_encoding = ::mlir::FieldParser<::mlir::sparse_tensor::SparseTensorEncodingAttr>::parse(odsParser); + if (::mlir::failed(_result_encoding)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse SparseTensor_StorageSpecifier parameter 'encoding' which is to be a `::mlir::sparse_tensor::SparseTensorEncodingAttr`"); + return {}; + } + // Parse literal '>' + if (odsParser.parseGreater()) return {}; + assert(::mlir::succeeded(_result_encoding)); + return StorageSpecifierType::get(odsParser.getContext(), + ::mlir::sparse_tensor::SparseTensorEncodingAttr(::llvm::cast<::mlir::sparse_tensor::SparseTensorEncodingAttr>((*_result_encoding)))); +} + +void StorageSpecifierType::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << "<"; + odsPrinter << getEncoding(); + odsPrinter << ">"; +} + +::mlir::sparse_tensor::SparseTensorEncodingAttr StorageSpecifierType::getEncoding() const { + return getImpl()->encoding; +} + +} // namespace sparse_tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::StorageSpecifierType) +namespace mlir { +namespace sparse_tensor { + +/// Parse a type registered to this dialect. +::mlir::Type SparseTensorDialect::parseType(::mlir::DialectAsmParser &parser) const { + ::llvm::SMLoc typeLoc = parser.getCurrentLocation(); + ::llvm::StringRef mnemonic; + ::mlir::Type genType; + auto parseResult = generatedTypeParser(parser, &mnemonic, genType); + if (parseResult.has_value()) + return genType; + + parser.emitError(typeLoc) << "unknown type `" + << mnemonic << "` in dialect `" << getNamespace() << "`"; + return {}; +} +/// Print a type registered to this dialect. +void SparseTensorDialect::printType(::mlir::Type type, + ::mlir::DialectAsmPrinter &printer) const { + if (::mlir::succeeded(generatedTypePrinter(type, printer))) + return; + +} +} // namespace sparse_tensor +} // namespace mlir + +#endif // GET_TYPEDEF_CLASSES + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorTypes.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorTypes.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..b186f8167c6816611782cfdd3babdc70d70ae312 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorTypes.h.inc @@ -0,0 +1,43 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* TypeDef Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifdef GET_TYPEDEF_CLASSES +#undef GET_TYPEDEF_CLASSES + + +namespace mlir { +class AsmParser; +class AsmPrinter; +} // namespace mlir +namespace mlir { +namespace sparse_tensor { +class StorageSpecifierType; +namespace detail { +struct StorageSpecifierTypeStorage; +} // namespace detail +class StorageSpecifierType : public ::mlir::Type::TypeBase { +public: + using Base::Base; + static StorageSpecifierType get(::mlir::MLIRContext *context, SparseTensorEncodingAttr encoding); + static StorageSpecifierType get(SparseTensorEncodingAttr encoding); + static StorageSpecifierType get(Type type); + static StorageSpecifierType get(Value tensor); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"storage_specifier"}; + } + + static ::mlir::Type parse(::mlir::AsmParser &odsParser); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::mlir::sparse_tensor::SparseTensorEncodingAttr getEncoding() const; +}; +} // namespace sparse_tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::StorageSpecifierType) + +#endif // GET_TYPEDEF_CLASSES + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/Transforms/BufferizableOpInterfaceImpl.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/Transforms/BufferizableOpInterfaceImpl.h new file mode 100644 index 0000000000000000000000000000000000000000..81ff534c18478de1c117bb9d63c8fdec6fc9d8db --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/Transforms/BufferizableOpInterfaceImpl.h @@ -0,0 +1,20 @@ +//===- BufferizableOpInterfaceImpl.h - Impl. of BufferizableOpInterface ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_SPARSETENSOR_TRANSFORMS_BUFFERIZABLEOPINTERFACEIMPL_H_ +#define MLIR_DIALECT_SPARSETENSOR_TRANSFORMS_BUFFERIZABLEOPINTERFACEIMPL_H_ + +namespace mlir { +class DialectRegistry; + +namespace sparse_tensor { +void registerBufferizableOpInterfaceExternalModels(DialectRegistry ®istry); +} // namespace sparse_tensor +} // namespace mlir + +#endif // MLIR_DIALECT_SPARSETENSOR_TRANSFORMS_BUFFERIZABLEOPINTERFACEIMPL_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.capi.cpp.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.capi.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..157f1915088f257cab8a9d1988f470c4de48d860 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.capi.cpp.inc @@ -0,0 +1,96 @@ +/* Autogenerated by mlir-tblgen; don't manually edit. */ +//===----------------------------------------------------------------------===// +// SparseTensor Group Registration +//===----------------------------------------------------------------------===// + +void mlirRegisterSparseTensorPasses(void) { + registerSparseTensorPasses(); +} + +MlirPass mlirCreateSparseTensorPostSparsificationRewrite(void) { + return wrap(mlir::createPostSparsificationRewritePass().release()); +} +void mlirRegisterSparseTensorPostSparsificationRewrite(void) { + registerPostSparsificationRewrite(); +} + + +MlirPass mlirCreateSparseTensorPreSparsificationRewrite(void) { + return wrap(mlir::createPreSparsificationRewritePass().release()); +} +void mlirRegisterSparseTensorPreSparsificationRewrite(void) { + registerPreSparsificationRewrite(); +} + + +MlirPass mlirCreateSparseTensorSparseBufferRewrite(void) { + return wrap(mlir::createSparseBufferRewritePass().release()); +} +void mlirRegisterSparseTensorSparseBufferRewrite(void) { + registerSparseBufferRewrite(); +} + + +MlirPass mlirCreateSparseTensorSparseGPUCodegen(void) { + return wrap(mlir::createSparseGPUCodegenPass().release()); +} +void mlirRegisterSparseTensorSparseGPUCodegen(void) { + registerSparseGPUCodegen(); +} + + +MlirPass mlirCreateSparseTensorSparseTensorCodegen(void) { + return wrap(mlir::createSparseTensorCodegenPass().release()); +} +void mlirRegisterSparseTensorSparseTensorCodegen(void) { + registerSparseTensorCodegen(); +} + + +MlirPass mlirCreateSparseTensorSparseTensorConversionPass(void) { + return wrap(mlir::createSparseTensorConversionPass().release()); +} +void mlirRegisterSparseTensorSparseTensorConversionPass(void) { + registerSparseTensorConversionPass(); +} + + +MlirPass mlirCreateSparseTensorSparseVectorization(void) { + return wrap(mlir::createSparseVectorizationPass().release()); +} +void mlirRegisterSparseTensorSparseVectorization(void) { + registerSparseVectorization(); +} + + +MlirPass mlirCreateSparseTensorSparsificationAndBufferization(void) { + return wrap(mlir::createSparsificationAndBufferizationPass().release()); +} +void mlirRegisterSparseTensorSparsificationAndBufferization(void) { + registerSparsificationAndBufferization(); +} + + +MlirPass mlirCreateSparseTensorSparsificationPass(void) { + return wrap(mlir::createSparsificationPass().release()); +} +void mlirRegisterSparseTensorSparsificationPass(void) { + registerSparsificationPass(); +} + + +MlirPass mlirCreateSparseTensorStageSparseOperations(void) { + return wrap(mlir::createStageSparseOperationsPass().release()); +} +void mlirRegisterSparseTensorStageSparseOperations(void) { + registerStageSparseOperations(); +} + + +MlirPass mlirCreateSparseTensorStorageSpecifierToLLVM(void) { + return wrap(mlir::createStorageSpecifierToLLVMPass().release()); +} +void mlirRegisterSparseTensorStorageSpecifierToLLVM(void) { + registerStorageSpecifierToLLVM(); +} + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.capi.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.capi.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..336d775d3c6298bb6d31b586e389050f8ebd55a8 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.capi.h.inc @@ -0,0 +1,72 @@ + +/* Autogenerated by mlir-tblgen; don't manually edit. */ + +#include "mlir-c/Pass.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// Registration for the entire group +MLIR_CAPI_EXPORTED void mlirRegisterSparseTensorPasses(void); + + +/* Create SparseTensor Pass. */ +MLIR_CAPI_EXPORTED MlirPass mlirCreateSparseTensorPostSparsificationRewrite(void); +MLIR_CAPI_EXPORTED void mlirRegisterSparseTensorPostSparsificationRewrite(void); + + +/* Create SparseTensor Pass. */ +MLIR_CAPI_EXPORTED MlirPass mlirCreateSparseTensorPreSparsificationRewrite(void); +MLIR_CAPI_EXPORTED void mlirRegisterSparseTensorPreSparsificationRewrite(void); + + +/* Create SparseTensor Pass. */ +MLIR_CAPI_EXPORTED MlirPass mlirCreateSparseTensorSparseBufferRewrite(void); +MLIR_CAPI_EXPORTED void mlirRegisterSparseTensorSparseBufferRewrite(void); + + +/* Create SparseTensor Pass. */ +MLIR_CAPI_EXPORTED MlirPass mlirCreateSparseTensorSparseGPUCodegen(void); +MLIR_CAPI_EXPORTED void mlirRegisterSparseTensorSparseGPUCodegen(void); + + +/* Create SparseTensor Pass. */ +MLIR_CAPI_EXPORTED MlirPass mlirCreateSparseTensorSparseTensorCodegen(void); +MLIR_CAPI_EXPORTED void mlirRegisterSparseTensorSparseTensorCodegen(void); + + +/* Create SparseTensor Pass. */ +MLIR_CAPI_EXPORTED MlirPass mlirCreateSparseTensorSparseTensorConversionPass(void); +MLIR_CAPI_EXPORTED void mlirRegisterSparseTensorSparseTensorConversionPass(void); + + +/* Create SparseTensor Pass. */ +MLIR_CAPI_EXPORTED MlirPass mlirCreateSparseTensorSparseVectorization(void); +MLIR_CAPI_EXPORTED void mlirRegisterSparseTensorSparseVectorization(void); + + +/* Create SparseTensor Pass. */ +MLIR_CAPI_EXPORTED MlirPass mlirCreateSparseTensorSparsificationAndBufferization(void); +MLIR_CAPI_EXPORTED void mlirRegisterSparseTensorSparsificationAndBufferization(void); + + +/* Create SparseTensor Pass. */ +MLIR_CAPI_EXPORTED MlirPass mlirCreateSparseTensorSparsificationPass(void); +MLIR_CAPI_EXPORTED void mlirRegisterSparseTensorSparsificationPass(void); + + +/* Create SparseTensor Pass. */ +MLIR_CAPI_EXPORTED MlirPass mlirCreateSparseTensorStageSparseOperations(void); +MLIR_CAPI_EXPORTED void mlirRegisterSparseTensorStageSparseOperations(void); + + +/* Create SparseTensor Pass. */ +MLIR_CAPI_EXPORTED MlirPass mlirCreateSparseTensorStorageSpecifierToLLVM(void); +MLIR_CAPI_EXPORTED void mlirRegisterSparseTensorStorageSpecifierToLLVM(void); + + + +#ifdef __cplusplus +} +#endif diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.h new file mode 100644 index 0000000000000000000000000000000000000000..c537e92a51d53335bd6873f995cb914469e5d774 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.h @@ -0,0 +1,253 @@ +//===- Passes.h - Sparse tensor pass entry points ---------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This header file defines prototypes of all sparse tensor passes. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_SPARSETENSOR_TRANSFORMS_PASSES_H_ +#define MLIR_DIALECT_SPARSETENSOR_TRANSFORMS_PASSES_H_ + +#include "mlir/IR/PatternMatch.h" +#include "mlir/Pass/Pass.h" +#include "mlir/Transforms/DialectConversion.h" + +//===----------------------------------------------------------------------===// +// Include the generated pass header (which needs some early definitions). +//===----------------------------------------------------------------------===// + +namespace mlir { + +namespace bufferization { +struct OneShotBufferizationOptions; +} // namespace bufferization + +/// Defines a parallelization strategy. Any independent loop is a candidate +/// for parallelization. The loop is made parallel if (1) allowed by the +/// strategy (e.g., AnyStorageOuterLoop considers either a dense or sparse +/// outermost loop only), and (2) the generated code is an actual for-loop +/// (and not a co-iterating while-loop). +enum class SparseParallelizationStrategy { + kNone, + kDenseOuterLoop, + kAnyStorageOuterLoop, + kDenseAnyLoop, + kAnyStorageAnyLoop +}; + +/// Defines data movement strategy between host and device for GPU. +// TODO : Zero copy is disabled due to correctness bugs (tracker #64316) +enum class GPUDataTransferStrategy { kRegularDMA, kZeroCopy, kPinnedDMA }; + +#define GEN_PASS_DECL +#include "mlir/Dialect/SparseTensor/Transforms/Passes.h.inc" + +//===----------------------------------------------------------------------===// +// The PreSparsificationRewriting pass. +//===----------------------------------------------------------------------===// + +void populatePreSparsificationRewriting(RewritePatternSet &patterns); + +std::unique_ptr createPreSparsificationRewritePass(); + +//===----------------------------------------------------------------------===// +// The Sparsification pass. +//===----------------------------------------------------------------------===// + +/// Options for the Sparsification pass. +struct SparsificationOptions { + SparsificationOptions(SparseParallelizationStrategy p, + GPUDataTransferStrategy t, bool idxReduc, + bool gpuLibgen, bool enableRT) + : parallelizationStrategy(p), gpuDataTransferStrategy(t), + enableIndexReduction(idxReduc), enableGPULibgen(gpuLibgen), + enableRuntimeLibrary(enableRT) {} + SparsificationOptions() + : SparsificationOptions(SparseParallelizationStrategy::kNone, + GPUDataTransferStrategy::kRegularDMA, false, + false, true) {} + SparseParallelizationStrategy parallelizationStrategy; + GPUDataTransferStrategy gpuDataTransferStrategy; + bool enableIndexReduction; + bool enableGPULibgen; + bool enableRuntimeLibrary; +}; + +/// Sets up sparsification rewriting rules with the given options. +void populateSparsificationPatterns( + RewritePatternSet &patterns, + const SparsificationOptions &options = SparsificationOptions()); + +std::unique_ptr createSparsificationPass(); +std::unique_ptr +createSparsificationPass(const SparsificationOptions &options); + +//===----------------------------------------------------------------------===// +// The StageSparseOperations pass. +//===----------------------------------------------------------------------===// + +/// Sets up StageSparseOperation rewriting rules. +void populateStageSparseOperationsPatterns(RewritePatternSet &patterns); + +std::unique_ptr createStageSparseOperationsPass(); + +//===----------------------------------------------------------------------===// +// The PostSparsificationRewriting pass. +//===----------------------------------------------------------------------===// + +void populatePostSparsificationRewriting(RewritePatternSet &patterns, + bool enableRT, bool enableForeach, + bool enableConvert); + +std::unique_ptr createPostSparsificationRewritePass(); +std::unique_ptr +createPostSparsificationRewritePass(bool enableRT, bool enableForeach = true, + bool enableConvert = true); + +//===----------------------------------------------------------------------===// +// The SparseTensorConversion pass. +//===----------------------------------------------------------------------===// + +/// Sparse tensor type converter into an opaque pointer. +class SparseTensorTypeToPtrConverter : public TypeConverter { +public: + SparseTensorTypeToPtrConverter(); +}; + +/// Defines a strategy for implementing sparse-to-sparse conversion. +/// `kAuto` leaves it up to the compiler to automatically determine +/// the method used. `kViaCOO` converts the source tensor to COO and +/// then converts the COO to the target format. `kDirect` converts +/// directly via the algorithm in ; +/// however, beware that there are many formats not supported by this +/// conversion method. +enum class SparseToSparseConversionStrategy { kAuto, kViaCOO, kDirect }; + +/// Converts command-line sparse2sparse flag to the strategy enum. +SparseToSparseConversionStrategy sparseToSparseConversionStrategy(int32_t flag); + +/// SparseTensorConversion options. +struct SparseTensorConversionOptions { + SparseTensorConversionOptions(SparseToSparseConversionStrategy s2s) + : sparseToSparseStrategy(s2s) {} + SparseTensorConversionOptions() + : SparseTensorConversionOptions(SparseToSparseConversionStrategy::kAuto) { + } + SparseToSparseConversionStrategy sparseToSparseStrategy; +}; + +/// Sets up sparse tensor conversion rules. +void populateSparseTensorConversionPatterns( + TypeConverter &typeConverter, RewritePatternSet &patterns, + const SparseTensorConversionOptions &options = + SparseTensorConversionOptions()); + +std::unique_ptr createSparseTensorConversionPass(); +std::unique_ptr +createSparseTensorConversionPass(const SparseTensorConversionOptions &options); + +//===----------------------------------------------------------------------===// +// The SparseTensorCodegen pass. +//===----------------------------------------------------------------------===// + +/// Sparse tensor type converter into an actual buffer. +class SparseTensorTypeToBufferConverter : public TypeConverter { +public: + SparseTensorTypeToBufferConverter(); +}; + +/// Sets up sparse tensor codegen rules. +void populateSparseTensorCodegenPatterns(TypeConverter &typeConverter, + RewritePatternSet &patterns, + bool createSparseDeallocs, + bool enableBufferInitialization); + +std::unique_ptr createSparseTensorCodegenPass(); +std::unique_ptr +createSparseTensorCodegenPass(bool createSparseDeallocs, + bool enableBufferInitialization); + +//===----------------------------------------------------------------------===// +// The SparseBufferRewrite pass. +//===----------------------------------------------------------------------===// + +void populateSparseBufferRewriting(RewritePatternSet &patterns, + bool enableBufferInitialization); + +std::unique_ptr createSparseBufferRewritePass(); +std::unique_ptr +createSparseBufferRewritePass(bool enableBufferInitialization); + +//===----------------------------------------------------------------------===// +// The SparseVectorization pass. +//===----------------------------------------------------------------------===// + +void populateSparseVectorizationPatterns(RewritePatternSet &patterns, + unsigned vectorLength, + bool enableVLAVectorization, + bool enableSIMDIndex32); + +std::unique_ptr createSparseVectorizationPass(); +std::unique_ptr createSparseVectorizationPass(unsigned vectorLength, + bool enableVLAVectorization, + bool enableSIMDIndex32); + +//===----------------------------------------------------------------------===// +// The SparseGPU pass. +//===----------------------------------------------------------------------===// + +void populateSparseGPUCodegenPatterns(RewritePatternSet &patterns, + unsigned numThreads); + +void populateSparseGPULibgenPatterns(RewritePatternSet &patterns, bool enableRT, + GPUDataTransferStrategy gpuDataTransfer); + +std::unique_ptr createSparseGPUCodegenPass(); +std::unique_ptr createSparseGPUCodegenPass(unsigned numThreads); + +//===----------------------------------------------------------------------===// +// The SparseStorageSpecifierToLLVM pass. +//===----------------------------------------------------------------------===// + +class StorageSpecifierToLLVMTypeConverter : public TypeConverter { +public: + StorageSpecifierToLLVMTypeConverter(); +}; + +void populateStorageSpecifierToLLVMPatterns(TypeConverter &converter, + RewritePatternSet &patterns); +std::unique_ptr createStorageSpecifierToLLVMPass(); + +//===----------------------------------------------------------------------===// +// The mini-pipeline for sparsification and bufferization. +//===----------------------------------------------------------------------===// + +bufferization::OneShotBufferizationOptions +getBufferizationOptionsForSparsification(bool analysisOnly); + +std::unique_ptr createSparsificationAndBufferizationPass(); + +std::unique_ptr createSparsificationAndBufferizationPass( + const bufferization::OneShotBufferizationOptions &bufferizationOptions, + const SparsificationOptions &sparsificationOptions, + const SparseTensorConversionOptions &sparseTensorConversionOptions, + bool createSparseDeallocs, bool enableRuntimeLibrary, + bool enableBufferInitialization, unsigned vectorLength, + bool enableVLAVectorization, bool enableSIMDIndex32); + +//===----------------------------------------------------------------------===// +// Registration. +//===----------------------------------------------------------------------===// + +/// Generate the code for registering passes. +#define GEN_PASS_REGISTRATION +#include "mlir/Dialect/SparseTensor/Transforms/Passes.h.inc" + +} // namespace mlir + +#endif // MLIR_DIALECT_SPARSETENSOR_TRANSFORMS_PASSES_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..0bada302e0c3a2fb53118e8cdbae8dd175daade6 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.h.inc @@ -0,0 +1,1758 @@ +/* Autogenerated by mlir-tblgen; don't manually edit */ + +#ifdef GEN_PASS_DECL +// Generate declarations for all passes. +#define GEN_PASS_DECL_POSTSPARSIFICATIONREWRITE +#define GEN_PASS_DECL_PRESPARSIFICATIONREWRITE +#define GEN_PASS_DECL_SPARSEBUFFERREWRITE +#define GEN_PASS_DECL_SPARSEGPUCODEGEN +#define GEN_PASS_DECL_SPARSETENSORCODEGEN +#define GEN_PASS_DECL_SPARSETENSORCONVERSIONPASS +#define GEN_PASS_DECL_SPARSEVECTORIZATION +#define GEN_PASS_DECL_SPARSIFICATIONANDBUFFERIZATION +#define GEN_PASS_DECL_SPARSIFICATIONPASS +#define GEN_PASS_DECL_STAGESPARSEOPERATIONS +#define GEN_PASS_DECL_STORAGESPECIFIERTOLLVM +#undef GEN_PASS_DECL +#endif // GEN_PASS_DECL + +//===----------------------------------------------------------------------===// +// PostSparsificationRewrite +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_POSTSPARSIFICATIONREWRITE +struct PostSparsificationRewriteOptions { + bool enableRuntimeLibrary = true; + bool enableForeach = true; + bool enableConvert = true; +}; +#undef GEN_PASS_DECL_POSTSPARSIFICATIONREWRITE +#endif // GEN_PASS_DECL_POSTSPARSIFICATIONREWRITE +#ifdef GEN_PASS_DEF_POSTSPARSIFICATIONREWRITE +namespace impl { + +template +class PostSparsificationRewriteBase : public ::mlir::OperationPass { +public: + using Base = PostSparsificationRewriteBase; + + PostSparsificationRewriteBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + PostSparsificationRewriteBase(const PostSparsificationRewriteBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("post-sparsification-rewrite"); + } + ::llvm::StringRef getArgument() const override { return "post-sparsification-rewrite"; } + + ::llvm::StringRef getDescription() const override { return "Applies sparse tensor rewriting rules after sparsification"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("PostSparsificationRewrite"); + } + ::llvm::StringRef getName() const override { return "PostSparsificationRewrite"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(PostSparsificationRewriteBase) + + PostSparsificationRewriteBase(const PostSparsificationRewriteOptions &options) : PostSparsificationRewriteBase() { + enableRuntimeLibrary = options.enableRuntimeLibrary; + enableForeach = options.enableForeach; + enableConvert = options.enableConvert; + } +protected: + ::mlir::Pass::Option enableRuntimeLibrary{*this, "enable-runtime-library", ::llvm::cl::desc("Enable runtime library for manipulating sparse tensors"), ::llvm::cl::init(true)}; + ::mlir::Pass::Option enableForeach{*this, "enable-foreach", ::llvm::cl::desc("Enable rewriting rules for the foreach operator"), ::llvm::cl::init(true)}; + ::mlir::Pass::Option enableConvert{*this, "enable-convert", ::llvm::cl::desc("Enable rewriting rules for the convert operator"), ::llvm::cl::init(true)}; +private: +}; +} // namespace impl +#undef GEN_PASS_DEF_POSTSPARSIFICATIONREWRITE +#endif // GEN_PASS_DEF_POSTSPARSIFICATIONREWRITE + +//===----------------------------------------------------------------------===// +// PreSparsificationRewrite +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_PRESPARSIFICATIONREWRITE +#undef GEN_PASS_DECL_PRESPARSIFICATIONREWRITE +#endif // GEN_PASS_DECL_PRESPARSIFICATIONREWRITE +#ifdef GEN_PASS_DEF_PRESPARSIFICATIONREWRITE +namespace impl { + +template +class PreSparsificationRewriteBase : public ::mlir::OperationPass { +public: + using Base = PreSparsificationRewriteBase; + + PreSparsificationRewriteBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + PreSparsificationRewriteBase(const PreSparsificationRewriteBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("pre-sparsification-rewrite"); + } + ::llvm::StringRef getArgument() const override { return "pre-sparsification-rewrite"; } + + ::llvm::StringRef getDescription() const override { return "Applies sparse tensor rewriting rules prior to sparsification"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("PreSparsificationRewrite"); + } + ::llvm::StringRef getName() const override { return "PreSparsificationRewrite"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(PreSparsificationRewriteBase) + +protected: +private: +}; +} // namespace impl +#undef GEN_PASS_DEF_PRESPARSIFICATIONREWRITE +#endif // GEN_PASS_DEF_PRESPARSIFICATIONREWRITE + +//===----------------------------------------------------------------------===// +// SparseBufferRewrite +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_SPARSEBUFFERREWRITE +struct SparseBufferRewriteOptions { + bool enableBufferInitialization = false; +}; +#undef GEN_PASS_DECL_SPARSEBUFFERREWRITE +#endif // GEN_PASS_DECL_SPARSEBUFFERREWRITE +#ifdef GEN_PASS_DEF_SPARSEBUFFERREWRITE +namespace impl { + +template +class SparseBufferRewriteBase : public ::mlir::OperationPass { +public: + using Base = SparseBufferRewriteBase; + + SparseBufferRewriteBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + SparseBufferRewriteBase(const SparseBufferRewriteBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("sparse-buffer-rewrite"); + } + ::llvm::StringRef getArgument() const override { return "sparse-buffer-rewrite"; } + + ::llvm::StringRef getDescription() const override { return "Rewrite sparse primitives on buffers to actual code"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("SparseBufferRewrite"); + } + ::llvm::StringRef getName() const override { return "SparseBufferRewrite"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SparseBufferRewriteBase) + + SparseBufferRewriteBase(const SparseBufferRewriteOptions &options) : SparseBufferRewriteBase() { + enableBufferInitialization = options.enableBufferInitialization; + } +protected: + ::mlir::Pass::Option enableBufferInitialization{*this, "enable-buffer-initialization", ::llvm::cl::desc("Enable zero-initialization of the memory buffers"), ::llvm::cl::init(false)}; +private: +}; +} // namespace impl +#undef GEN_PASS_DEF_SPARSEBUFFERREWRITE +#endif // GEN_PASS_DEF_SPARSEBUFFERREWRITE + +//===----------------------------------------------------------------------===// +// SparseGPUCodegen +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_SPARSEGPUCODEGEN +struct SparseGPUCodegenOptions { + int32_t numThreads = 1024; +}; +#undef GEN_PASS_DECL_SPARSEGPUCODEGEN +#endif // GEN_PASS_DECL_SPARSEGPUCODEGEN +#ifdef GEN_PASS_DEF_SPARSEGPUCODEGEN +namespace impl { + +template +class SparseGPUCodegenBase : public ::mlir::OperationPass { +public: + using Base = SparseGPUCodegenBase; + + SparseGPUCodegenBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + SparseGPUCodegenBase(const SparseGPUCodegenBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("sparse-gpu-codegen"); + } + ::llvm::StringRef getArgument() const override { return "sparse-gpu-codegen"; } + + ::llvm::StringRef getDescription() const override { return "Generates GPU code during sparsification"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("SparseGPUCodegen"); + } + ::llvm::StringRef getName() const override { return "SparseGPUCodegen"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SparseGPUCodegenBase) + + SparseGPUCodegenBase(const SparseGPUCodegenOptions &options) : SparseGPUCodegenBase() { + numThreads = options.numThreads; + } +protected: + ::mlir::Pass::Option numThreads{*this, "num_threads", ::llvm::cl::desc("Sets the number of GPU threads"), ::llvm::cl::init(1024)}; +private: +}; +} // namespace impl +#undef GEN_PASS_DEF_SPARSEGPUCODEGEN +#endif // GEN_PASS_DEF_SPARSEGPUCODEGEN + +//===----------------------------------------------------------------------===// +// SparseTensorCodegen +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_SPARSETENSORCODEGEN +struct SparseTensorCodegenOptions { + bool enableBufferInitialization = false; + bool createSparseDeallocs = true; +}; +#undef GEN_PASS_DECL_SPARSETENSORCODEGEN +#endif // GEN_PASS_DECL_SPARSETENSORCODEGEN +#ifdef GEN_PASS_DEF_SPARSETENSORCODEGEN +namespace impl { + +template +class SparseTensorCodegenBase : public ::mlir::OperationPass { +public: + using Base = SparseTensorCodegenBase; + + SparseTensorCodegenBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + SparseTensorCodegenBase(const SparseTensorCodegenBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("sparse-tensor-codegen"); + } + ::llvm::StringRef getArgument() const override { return "sparse-tensor-codegen"; } + + ::llvm::StringRef getDescription() const override { return "Convert sparse tensors and primitives to actual code"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("SparseTensorCodegen"); + } + ::llvm::StringRef getName() const override { return "SparseTensorCodegen"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SparseTensorCodegenBase) + + SparseTensorCodegenBase(const SparseTensorCodegenOptions &options) : SparseTensorCodegenBase() { + enableBufferInitialization = options.enableBufferInitialization; + createSparseDeallocs = options.createSparseDeallocs; + } +protected: + ::mlir::Pass::Option enableBufferInitialization{*this, "enable-buffer-initialization", ::llvm::cl::desc("Enable zero-initialization of the memory buffers"), ::llvm::cl::init(false)}; + ::mlir::Pass::Option createSparseDeallocs{*this, "create-sparse-deallocs", ::llvm::cl::desc("Specify if the temporary buffers created by the sparse compiler should be deallocated. For compatibility with core bufferization passes. This option is only used when enable-runtime-library=false. See also create-deallocs for BufferizationOption."), ::llvm::cl::init(true)}; +private: +}; +} // namespace impl +#undef GEN_PASS_DEF_SPARSETENSORCODEGEN +#endif // GEN_PASS_DEF_SPARSETENSORCODEGEN + +//===----------------------------------------------------------------------===// +// SparseTensorConversionPass +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_SPARSETENSORCONVERSIONPASS +struct SparseTensorConversionPassOptions { + int32_t sparseToSparse = 0; +}; +#undef GEN_PASS_DECL_SPARSETENSORCONVERSIONPASS +#endif // GEN_PASS_DECL_SPARSETENSORCONVERSIONPASS +#ifdef GEN_PASS_DEF_SPARSETENSORCONVERSIONPASS +namespace impl { + +template +class SparseTensorConversionPassBase : public ::mlir::OperationPass { +public: + using Base = SparseTensorConversionPassBase; + + SparseTensorConversionPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + SparseTensorConversionPassBase(const SparseTensorConversionPassBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("sparse-tensor-conversion"); + } + ::llvm::StringRef getArgument() const override { return "sparse-tensor-conversion"; } + + ::llvm::StringRef getDescription() const override { return "Convert sparse tensors and primitives to library calls"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("SparseTensorConversionPass"); + } + ::llvm::StringRef getName() const override { return "SparseTensorConversionPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SparseTensorConversionPassBase) + + SparseTensorConversionPassBase(const SparseTensorConversionPassOptions &options) : SparseTensorConversionPassBase() { + sparseToSparse = options.sparseToSparse; + } +protected: + ::mlir::Pass::Option sparseToSparse{*this, "s2s-strategy", ::llvm::cl::desc("Set the strategy for sparse-to-sparse conversion"), ::llvm::cl::init(0)}; +private: +}; +} // namespace impl +#undef GEN_PASS_DEF_SPARSETENSORCONVERSIONPASS +#endif // GEN_PASS_DEF_SPARSETENSORCONVERSIONPASS + +//===----------------------------------------------------------------------===// +// SparseVectorization +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_SPARSEVECTORIZATION +struct SparseVectorizationOptions { + int32_t vectorLength = 0; + bool enableVLAVectorization = false; + bool enableSIMDIndex32 = false; +}; +#undef GEN_PASS_DECL_SPARSEVECTORIZATION +#endif // GEN_PASS_DECL_SPARSEVECTORIZATION +#ifdef GEN_PASS_DEF_SPARSEVECTORIZATION +namespace impl { + +template +class SparseVectorizationBase : public ::mlir::OperationPass { +public: + using Base = SparseVectorizationBase; + + SparseVectorizationBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + SparseVectorizationBase(const SparseVectorizationBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("sparse-vectorization"); + } + ::llvm::StringRef getArgument() const override { return "sparse-vectorization"; } + + ::llvm::StringRef getDescription() const override { return "Vectorizes loops after sparsification"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("SparseVectorization"); + } + ::llvm::StringRef getName() const override { return "SparseVectorization"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SparseVectorizationBase) + + SparseVectorizationBase(const SparseVectorizationOptions &options) : SparseVectorizationBase() { + vectorLength = options.vectorLength; + enableVLAVectorization = options.enableVLAVectorization; + enableSIMDIndex32 = options.enableSIMDIndex32; + } +protected: + ::mlir::Pass::Option vectorLength{*this, "vl", ::llvm::cl::desc("Set the vector length (use 0 to disable vectorization)"), ::llvm::cl::init(0)}; + ::mlir::Pass::Option enableVLAVectorization{*this, "enable-vla-vectorization", ::llvm::cl::desc("Enable vector length agnostic vectorization"), ::llvm::cl::init(false)}; + ::mlir::Pass::Option enableSIMDIndex32{*this, "enable-simd-index32", ::llvm::cl::desc("Enable i32 indexing into vectors (for efficient gather/scatter)"), ::llvm::cl::init(false)}; +private: +}; +} // namespace impl +#undef GEN_PASS_DEF_SPARSEVECTORIZATION +#endif // GEN_PASS_DEF_SPARSEVECTORIZATION + +//===----------------------------------------------------------------------===// +// SparsificationAndBufferization +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_SPARSIFICATIONANDBUFFERIZATION +#undef GEN_PASS_DECL_SPARSIFICATIONANDBUFFERIZATION +#endif // GEN_PASS_DECL_SPARSIFICATIONANDBUFFERIZATION +#ifdef GEN_PASS_DEF_SPARSIFICATIONANDBUFFERIZATION +namespace impl { + +template +class SparsificationAndBufferizationBase : public ::mlir::OperationPass { +public: + using Base = SparsificationAndBufferizationBase; + + SparsificationAndBufferizationBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + SparsificationAndBufferizationBase(const SparsificationAndBufferizationBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("sparsification-and-bufferization"); + } + ::llvm::StringRef getArgument() const override { return "sparsification-and-bufferization"; } + + ::llvm::StringRef getDescription() const override { return "Mini-pipeline that combines bufferization and sparsifiation"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("SparsificationAndBufferization"); + } + ::llvm::StringRef getName() const override { return "SparsificationAndBufferization"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SparsificationAndBufferizationBase) + +protected: +private: +}; +} // namespace impl +#undef GEN_PASS_DEF_SPARSIFICATIONANDBUFFERIZATION +#endif // GEN_PASS_DEF_SPARSIFICATIONANDBUFFERIZATION + +//===----------------------------------------------------------------------===// +// SparsificationPass +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_SPARSIFICATIONPASS +struct SparsificationPassOptions { + bool enableIndexReduction = false; + mlir::SparseParallelizationStrategy parallelization = mlir::SparseParallelizationStrategy::kNone; + mlir::GPUDataTransferStrategy gpuDataTransfer = mlir::GPUDataTransferStrategy::kRegularDMA; + bool enableGPULibgen = false; + bool enableRuntimeLibrary = true; +}; +#undef GEN_PASS_DECL_SPARSIFICATIONPASS +#endif // GEN_PASS_DECL_SPARSIFICATIONPASS +#ifdef GEN_PASS_DEF_SPARSIFICATIONPASS +namespace impl { + +template +class SparsificationPassBase : public ::mlir::OperationPass { +public: + using Base = SparsificationPassBase; + + SparsificationPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + SparsificationPassBase(const SparsificationPassBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("sparsification"); + } + ::llvm::StringRef getArgument() const override { return "sparsification"; } + + ::llvm::StringRef getDescription() const override { return "Automatically generate sparse tensor code from sparse tensor types"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("SparsificationPass"); + } + ::llvm::StringRef getName() const override { return "SparsificationPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SparsificationPassBase) + + SparsificationPassBase(const SparsificationPassOptions &options) : SparsificationPassBase() { + enableIndexReduction = options.enableIndexReduction; + parallelization = options.parallelization; + gpuDataTransfer = options.gpuDataTransfer; + enableGPULibgen = options.enableGPULibgen; + enableRuntimeLibrary = options.enableRuntimeLibrary; + } +protected: + ::mlir::Pass::Option enableIndexReduction{*this, "enable-index-reduction", ::llvm::cl::desc("Enable dependent index reduction based algorithm to handle non-trivial index expressions on sparse inputs (experimental features)"), ::llvm::cl::init(false)}; + ::mlir::Pass::Option parallelization{*this, "parallelization-strategy", ::llvm::cl::desc("Set the parallelization strategy"), ::llvm::cl::init(mlir::SparseParallelizationStrategy::kNone), llvm::cl::values( + clEnumValN(mlir::SparseParallelizationStrategy::kNone, "none", + "Turn off sparse parallelization."), + clEnumValN(mlir::SparseParallelizationStrategy::kDenseOuterLoop, + "dense-outer-loop", + "Enable dense outer loop sparse parallelization."), + clEnumValN(mlir::SparseParallelizationStrategy::kAnyStorageOuterLoop, + "any-storage-outer-loop", + "Enable sparse parallelization regardless of storage for the outer loop."), + clEnumValN(mlir::SparseParallelizationStrategy::kDenseAnyLoop, + "dense-any-loop", + "Enable dense parallelization for any loop."), + clEnumValN(mlir::SparseParallelizationStrategy::kAnyStorageAnyLoop, + "any-storage-any-loop", + "Enable sparse parallelization for any storage and loop."))}; + ::mlir::Pass::Option gpuDataTransfer{*this, "gpu-data-transfer-strategy", ::llvm::cl::desc("Set the data transfer strategy"), ::llvm::cl::init(mlir::GPUDataTransferStrategy::kRegularDMA), llvm::cl::values( + clEnumValN(mlir::GPUDataTransferStrategy::kRegularDMA, + "regular-dma", + "Default option: malloc on host without additional " + "options or care and then use DMA to copy the data"), + clEnumValN(mlir::GPUDataTransferStrategy::kPinnedDMA, "pinned-dma", + "Based on the default option, pin the host memory to " + "accelerate the data transfer"), + clEnumValN(mlir::GPUDataTransferStrategy::kZeroCopy, "zero-copy", + "Use zero-copy to perform the data transfer from the host " + "to the GPU"))}; + ::mlir::Pass::Option enableGPULibgen{*this, "enable-gpu-libgen", ::llvm::cl::desc("Enable GPU acceleration by means of direct library calls (like cuSPARSE)"), ::llvm::cl::init(false)}; + ::mlir::Pass::Option enableRuntimeLibrary{*this, "enable-runtime-library", ::llvm::cl::desc("Enable runtime library for manipulating sparse tensors"), ::llvm::cl::init(true)}; +private: +}; +} // namespace impl +#undef GEN_PASS_DEF_SPARSIFICATIONPASS +#endif // GEN_PASS_DEF_SPARSIFICATIONPASS + +//===----------------------------------------------------------------------===// +// StageSparseOperations +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_STAGESPARSEOPERATIONS +#undef GEN_PASS_DECL_STAGESPARSEOPERATIONS +#endif // GEN_PASS_DECL_STAGESPARSEOPERATIONS +#ifdef GEN_PASS_DEF_STAGESPARSEOPERATIONS +namespace impl { + +template +class StageSparseOperationsBase : public ::mlir::OperationPass { +public: + using Base = StageSparseOperationsBase; + + StageSparseOperationsBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StageSparseOperationsBase(const StageSparseOperationsBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("stage-sparse-ops"); + } + ::llvm::StringRef getArgument() const override { return "stage-sparse-ops"; } + + ::llvm::StringRef getDescription() const override { return "Decompose a complex sparse operation into multiple stages"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StageSparseOperations"); + } + ::llvm::StringRef getName() const override { return "StageSparseOperations"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StageSparseOperationsBase) + +protected: +private: +}; +} // namespace impl +#undef GEN_PASS_DEF_STAGESPARSEOPERATIONS +#endif // GEN_PASS_DEF_STAGESPARSEOPERATIONS + +//===----------------------------------------------------------------------===// +// StorageSpecifierToLLVM +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_STORAGESPECIFIERTOLLVM +#undef GEN_PASS_DECL_STORAGESPECIFIERTOLLVM +#endif // GEN_PASS_DECL_STORAGESPECIFIERTOLLVM +#ifdef GEN_PASS_DEF_STORAGESPECIFIERTOLLVM +namespace impl { + +template +class StorageSpecifierToLLVMBase : public ::mlir::OperationPass { +public: + using Base = StorageSpecifierToLLVMBase; + + StorageSpecifierToLLVMBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StorageSpecifierToLLVMBase(const StorageSpecifierToLLVMBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("sparse-storage-specifier-to-llvm"); + } + ::llvm::StringRef getArgument() const override { return "sparse-storage-specifier-to-llvm"; } + + ::llvm::StringRef getDescription() const override { return "Lower sparse storage specifer to llvm structure"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StorageSpecifierToLLVM"); + } + ::llvm::StringRef getName() const override { return "StorageSpecifierToLLVM"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + registry.insert(); + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StorageSpecifierToLLVMBase) + +protected: +private: +}; +} // namespace impl +#undef GEN_PASS_DEF_STORAGESPECIFIERTOLLVM +#endif // GEN_PASS_DEF_STORAGESPECIFIERTOLLVM +#ifdef GEN_PASS_REGISTRATION + +//===----------------------------------------------------------------------===// +// PostSparsificationRewrite Registration +//===----------------------------------------------------------------------===// + +inline void registerPostSparsificationRewrite() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createPostSparsificationRewritePass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerPostSparsificationRewritePass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createPostSparsificationRewritePass(); + }); +} + +//===----------------------------------------------------------------------===// +// PreSparsificationRewrite Registration +//===----------------------------------------------------------------------===// + +inline void registerPreSparsificationRewrite() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createPreSparsificationRewritePass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerPreSparsificationRewritePass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createPreSparsificationRewritePass(); + }); +} + +//===----------------------------------------------------------------------===// +// SparseBufferRewrite Registration +//===----------------------------------------------------------------------===// + +inline void registerSparseBufferRewrite() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createSparseBufferRewritePass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerSparseBufferRewritePass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createSparseBufferRewritePass(); + }); +} + +//===----------------------------------------------------------------------===// +// SparseGPUCodegen Registration +//===----------------------------------------------------------------------===// + +inline void registerSparseGPUCodegen() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createSparseGPUCodegenPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerSparseGPUCodegenPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createSparseGPUCodegenPass(); + }); +} + +//===----------------------------------------------------------------------===// +// SparseTensorCodegen Registration +//===----------------------------------------------------------------------===// + +inline void registerSparseTensorCodegen() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createSparseTensorCodegenPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerSparseTensorCodegenPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createSparseTensorCodegenPass(); + }); +} + +//===----------------------------------------------------------------------===// +// SparseTensorConversionPass Registration +//===----------------------------------------------------------------------===// + +inline void registerSparseTensorConversionPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createSparseTensorConversionPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerSparseTensorConversionPassPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createSparseTensorConversionPass(); + }); +} + +//===----------------------------------------------------------------------===// +// SparseVectorization Registration +//===----------------------------------------------------------------------===// + +inline void registerSparseVectorization() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createSparseVectorizationPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerSparseVectorizationPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createSparseVectorizationPass(); + }); +} + +//===----------------------------------------------------------------------===// +// SparsificationAndBufferization Registration +//===----------------------------------------------------------------------===// + +inline void registerSparsificationAndBufferization() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createSparsificationAndBufferizationPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerSparsificationAndBufferizationPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createSparsificationAndBufferizationPass(); + }); +} + +//===----------------------------------------------------------------------===// +// SparsificationPass Registration +//===----------------------------------------------------------------------===// + +inline void registerSparsificationPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createSparsificationPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerSparsificationPassPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createSparsificationPass(); + }); +} + +//===----------------------------------------------------------------------===// +// StageSparseOperations Registration +//===----------------------------------------------------------------------===// + +inline void registerStageSparseOperations() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createStageSparseOperationsPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerStageSparseOperationsPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createStageSparseOperationsPass(); + }); +} + +//===----------------------------------------------------------------------===// +// StorageSpecifierToLLVM Registration +//===----------------------------------------------------------------------===// + +inline void registerStorageSpecifierToLLVM() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createStorageSpecifierToLLVMPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerStorageSpecifierToLLVMPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::createStorageSpecifierToLLVMPass(); + }); +} + +//===----------------------------------------------------------------------===// +// SparseTensor Registration +//===----------------------------------------------------------------------===// + +inline void registerSparseTensorPasses() { + registerPostSparsificationRewrite(); + registerPreSparsificationRewrite(); + registerSparseBufferRewrite(); + registerSparseGPUCodegen(); + registerSparseTensorCodegen(); + registerSparseTensorConversionPass(); + registerSparseVectorization(); + registerSparsificationAndBufferization(); + registerSparsificationPass(); + registerStageSparseOperations(); + registerStorageSpecifierToLLVM(); +} +#undef GEN_PASS_REGISTRATION +#endif // GEN_PASS_REGISTRATION +// Deprecated. Please use the new per-pass macros. +#ifdef GEN_PASS_CLASSES + +template +class PostSparsificationRewriteBase : public ::mlir::OperationPass { +public: + using Base = PostSparsificationRewriteBase; + + PostSparsificationRewriteBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + PostSparsificationRewriteBase(const PostSparsificationRewriteBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("post-sparsification-rewrite"); + } + ::llvm::StringRef getArgument() const override { return "post-sparsification-rewrite"; } + + ::llvm::StringRef getDescription() const override { return "Applies sparse tensor rewriting rules after sparsification"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("PostSparsificationRewrite"); + } + ::llvm::StringRef getName() const override { return "PostSparsificationRewrite"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(PostSparsificationRewriteBase) + +protected: + ::mlir::Pass::Option enableRuntimeLibrary{*this, "enable-runtime-library", ::llvm::cl::desc("Enable runtime library for manipulating sparse tensors"), ::llvm::cl::init(true)}; + ::mlir::Pass::Option enableForeach{*this, "enable-foreach", ::llvm::cl::desc("Enable rewriting rules for the foreach operator"), ::llvm::cl::init(true)}; + ::mlir::Pass::Option enableConvert{*this, "enable-convert", ::llvm::cl::desc("Enable rewriting rules for the convert operator"), ::llvm::cl::init(true)}; +}; + +template +class PreSparsificationRewriteBase : public ::mlir::OperationPass { +public: + using Base = PreSparsificationRewriteBase; + + PreSparsificationRewriteBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + PreSparsificationRewriteBase(const PreSparsificationRewriteBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("pre-sparsification-rewrite"); + } + ::llvm::StringRef getArgument() const override { return "pre-sparsification-rewrite"; } + + ::llvm::StringRef getDescription() const override { return "Applies sparse tensor rewriting rules prior to sparsification"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("PreSparsificationRewrite"); + } + ::llvm::StringRef getName() const override { return "PreSparsificationRewrite"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(PreSparsificationRewriteBase) + +protected: +}; + +template +class SparseBufferRewriteBase : public ::mlir::OperationPass { +public: + using Base = SparseBufferRewriteBase; + + SparseBufferRewriteBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + SparseBufferRewriteBase(const SparseBufferRewriteBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("sparse-buffer-rewrite"); + } + ::llvm::StringRef getArgument() const override { return "sparse-buffer-rewrite"; } + + ::llvm::StringRef getDescription() const override { return "Rewrite sparse primitives on buffers to actual code"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("SparseBufferRewrite"); + } + ::llvm::StringRef getName() const override { return "SparseBufferRewrite"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SparseBufferRewriteBase) + +protected: + ::mlir::Pass::Option enableBufferInitialization{*this, "enable-buffer-initialization", ::llvm::cl::desc("Enable zero-initialization of the memory buffers"), ::llvm::cl::init(false)}; +}; + +template +class SparseGPUCodegenBase : public ::mlir::OperationPass { +public: + using Base = SparseGPUCodegenBase; + + SparseGPUCodegenBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + SparseGPUCodegenBase(const SparseGPUCodegenBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("sparse-gpu-codegen"); + } + ::llvm::StringRef getArgument() const override { return "sparse-gpu-codegen"; } + + ::llvm::StringRef getDescription() const override { return "Generates GPU code during sparsification"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("SparseGPUCodegen"); + } + ::llvm::StringRef getName() const override { return "SparseGPUCodegen"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SparseGPUCodegenBase) + +protected: + ::mlir::Pass::Option numThreads{*this, "num_threads", ::llvm::cl::desc("Sets the number of GPU threads"), ::llvm::cl::init(1024)}; +}; + +template +class SparseTensorCodegenBase : public ::mlir::OperationPass { +public: + using Base = SparseTensorCodegenBase; + + SparseTensorCodegenBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + SparseTensorCodegenBase(const SparseTensorCodegenBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("sparse-tensor-codegen"); + } + ::llvm::StringRef getArgument() const override { return "sparse-tensor-codegen"; } + + ::llvm::StringRef getDescription() const override { return "Convert sparse tensors and primitives to actual code"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("SparseTensorCodegen"); + } + ::llvm::StringRef getName() const override { return "SparseTensorCodegen"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SparseTensorCodegenBase) + +protected: + ::mlir::Pass::Option enableBufferInitialization{*this, "enable-buffer-initialization", ::llvm::cl::desc("Enable zero-initialization of the memory buffers"), ::llvm::cl::init(false)}; + ::mlir::Pass::Option createSparseDeallocs{*this, "create-sparse-deallocs", ::llvm::cl::desc("Specify if the temporary buffers created by the sparse compiler should be deallocated. For compatibility with core bufferization passes. This option is only used when enable-runtime-library=false. See also create-deallocs for BufferizationOption."), ::llvm::cl::init(true)}; +}; + +template +class SparseTensorConversionPassBase : public ::mlir::OperationPass { +public: + using Base = SparseTensorConversionPassBase; + + SparseTensorConversionPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + SparseTensorConversionPassBase(const SparseTensorConversionPassBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("sparse-tensor-conversion"); + } + ::llvm::StringRef getArgument() const override { return "sparse-tensor-conversion"; } + + ::llvm::StringRef getDescription() const override { return "Convert sparse tensors and primitives to library calls"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("SparseTensorConversionPass"); + } + ::llvm::StringRef getName() const override { return "SparseTensorConversionPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SparseTensorConversionPassBase) + +protected: + ::mlir::Pass::Option sparseToSparse{*this, "s2s-strategy", ::llvm::cl::desc("Set the strategy for sparse-to-sparse conversion"), ::llvm::cl::init(0)}; +}; + +template +class SparseVectorizationBase : public ::mlir::OperationPass { +public: + using Base = SparseVectorizationBase; + + SparseVectorizationBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + SparseVectorizationBase(const SparseVectorizationBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("sparse-vectorization"); + } + ::llvm::StringRef getArgument() const override { return "sparse-vectorization"; } + + ::llvm::StringRef getDescription() const override { return "Vectorizes loops after sparsification"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("SparseVectorization"); + } + ::llvm::StringRef getName() const override { return "SparseVectorization"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SparseVectorizationBase) + +protected: + ::mlir::Pass::Option vectorLength{*this, "vl", ::llvm::cl::desc("Set the vector length (use 0 to disable vectorization)"), ::llvm::cl::init(0)}; + ::mlir::Pass::Option enableVLAVectorization{*this, "enable-vla-vectorization", ::llvm::cl::desc("Enable vector length agnostic vectorization"), ::llvm::cl::init(false)}; + ::mlir::Pass::Option enableSIMDIndex32{*this, "enable-simd-index32", ::llvm::cl::desc("Enable i32 indexing into vectors (for efficient gather/scatter)"), ::llvm::cl::init(false)}; +}; + +template +class SparsificationAndBufferizationBase : public ::mlir::OperationPass { +public: + using Base = SparsificationAndBufferizationBase; + + SparsificationAndBufferizationBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + SparsificationAndBufferizationBase(const SparsificationAndBufferizationBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("sparsification-and-bufferization"); + } + ::llvm::StringRef getArgument() const override { return "sparsification-and-bufferization"; } + + ::llvm::StringRef getDescription() const override { return "Mini-pipeline that combines bufferization and sparsifiation"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("SparsificationAndBufferization"); + } + ::llvm::StringRef getName() const override { return "SparsificationAndBufferization"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SparsificationAndBufferizationBase) + +protected: +}; + +template +class SparsificationPassBase : public ::mlir::OperationPass { +public: + using Base = SparsificationPassBase; + + SparsificationPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + SparsificationPassBase(const SparsificationPassBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("sparsification"); + } + ::llvm::StringRef getArgument() const override { return "sparsification"; } + + ::llvm::StringRef getDescription() const override { return "Automatically generate sparse tensor code from sparse tensor types"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("SparsificationPass"); + } + ::llvm::StringRef getName() const override { return "SparsificationPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SparsificationPassBase) + +protected: + ::mlir::Pass::Option enableIndexReduction{*this, "enable-index-reduction", ::llvm::cl::desc("Enable dependent index reduction based algorithm to handle non-trivial index expressions on sparse inputs (experimental features)"), ::llvm::cl::init(false)}; + ::mlir::Pass::Option parallelization{*this, "parallelization-strategy", ::llvm::cl::desc("Set the parallelization strategy"), ::llvm::cl::init(mlir::SparseParallelizationStrategy::kNone), llvm::cl::values( + clEnumValN(mlir::SparseParallelizationStrategy::kNone, "none", + "Turn off sparse parallelization."), + clEnumValN(mlir::SparseParallelizationStrategy::kDenseOuterLoop, + "dense-outer-loop", + "Enable dense outer loop sparse parallelization."), + clEnumValN(mlir::SparseParallelizationStrategy::kAnyStorageOuterLoop, + "any-storage-outer-loop", + "Enable sparse parallelization regardless of storage for the outer loop."), + clEnumValN(mlir::SparseParallelizationStrategy::kDenseAnyLoop, + "dense-any-loop", + "Enable dense parallelization for any loop."), + clEnumValN(mlir::SparseParallelizationStrategy::kAnyStorageAnyLoop, + "any-storage-any-loop", + "Enable sparse parallelization for any storage and loop."))}; + ::mlir::Pass::Option gpuDataTransfer{*this, "gpu-data-transfer-strategy", ::llvm::cl::desc("Set the data transfer strategy"), ::llvm::cl::init(mlir::GPUDataTransferStrategy::kRegularDMA), llvm::cl::values( + clEnumValN(mlir::GPUDataTransferStrategy::kRegularDMA, + "regular-dma", + "Default option: malloc on host without additional " + "options or care and then use DMA to copy the data"), + clEnumValN(mlir::GPUDataTransferStrategy::kPinnedDMA, "pinned-dma", + "Based on the default option, pin the host memory to " + "accelerate the data transfer"), + clEnumValN(mlir::GPUDataTransferStrategy::kZeroCopy, "zero-copy", + "Use zero-copy to perform the data transfer from the host " + "to the GPU"))}; + ::mlir::Pass::Option enableGPULibgen{*this, "enable-gpu-libgen", ::llvm::cl::desc("Enable GPU acceleration by means of direct library calls (like cuSPARSE)"), ::llvm::cl::init(false)}; + ::mlir::Pass::Option enableRuntimeLibrary{*this, "enable-runtime-library", ::llvm::cl::desc("Enable runtime library for manipulating sparse tensors"), ::llvm::cl::init(true)}; +}; + +template +class StageSparseOperationsBase : public ::mlir::OperationPass { +public: + using Base = StageSparseOperationsBase; + + StageSparseOperationsBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StageSparseOperationsBase(const StageSparseOperationsBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("stage-sparse-ops"); + } + ::llvm::StringRef getArgument() const override { return "stage-sparse-ops"; } + + ::llvm::StringRef getDescription() const override { return "Decompose a complex sparse operation into multiple stages"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StageSparseOperations"); + } + ::llvm::StringRef getName() const override { return "StageSparseOperations"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StageSparseOperationsBase) + +protected: +}; + +template +class StorageSpecifierToLLVMBase : public ::mlir::OperationPass { +public: + using Base = StorageSpecifierToLLVMBase; + + StorageSpecifierToLLVMBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + StorageSpecifierToLLVMBase(const StorageSpecifierToLLVMBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("sparse-storage-specifier-to-llvm"); + } + ::llvm::StringRef getArgument() const override { return "sparse-storage-specifier-to-llvm"; } + + ::llvm::StringRef getDescription() const override { return "Lower sparse storage specifer to llvm structure"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("StorageSpecifierToLLVM"); + } + ::llvm::StringRef getName() const override { return "StorageSpecifierToLLVM"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + registry.insert(); + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StorageSpecifierToLLVMBase) + +protected: +}; +#undef GEN_PASS_CLASSES +#endif // GEN_PASS_CLASSES diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/Utils/Merger.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/Utils/Merger.h new file mode 100644 index 0000000000000000000000000000000000000000..5e75380067572871ec847e9368aa0a273bb562df --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/Utils/Merger.h @@ -0,0 +1,744 @@ +//===- Merger.h - Utilities for defining lattices ---------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This header file defines utilities for dealing with iteration lattices. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_SPARSETENSOR_UTILS_MERGER_H_ +#define MLIR_DIALECT_SPARSETENSOR_UTILS_MERGER_H_ + +#include "mlir/Dialect/Linalg/IR/Linalg.h" +#include "mlir/Dialect/SparseTensor/IR/Enums.h" +#include "mlir/Dialect/SparseTensor/IR/SparseTensor.h" +#include "mlir/IR/Value.h" +#include "llvm/ADT/BitVector.h" + +#include + +namespace mlir { +namespace sparse_tensor { + +namespace detail { +/// A constant serving as the canonically invalid identifier, +/// regardless of the identifier type. +static constexpr unsigned kInvalidId = -1u; +} // namespace detail + +/// Tensor identifiers, chosen to be the `BlockArgument::getArgNumber` +/// of the value passed to `Merger::buildTensorExp`. +using TensorId = unsigned; + +/// Loop identifiers. +using LoopId = unsigned; + +/// A compressed representation of `std::pair`. +/// The compression scheme is such that this also serves as an index +/// into the bitvector stored in `LatPoint` (since that bitvector is +/// just the implementation for a set of `TensorLoopId` values). +using TensorLoopId = unsigned; + +/// `TensorExp` identifiers. These are allocated by `Merger::addExp`, +/// and serve as unique identifiers for the corresponding `TensorExp` object. +using ExprId = unsigned; + +/// `LatPoint` identifiers. These are allocated by `Merger::addLat`, +/// and serve as unique identifiers for the corresponding `LatPoint` object. +using LatPointId = unsigned; + +/// `LatSet` identifiers. These are allocated by `Merger::addSet` (and +/// by other methods calling that one), and serve as unique identifiers +/// for the corresponding `SmallVector` object. +using LatSetId = unsigned; + +/// A pair of level and its corresponding DimLevelType of a tensor. +using LvlDLTPair = std::pair; + +/// A pair of loop id and its coefficients. E.g., for affine expression in the +/// affine map `2 * d0`, loop id = 0, coefficient = 2. +using LoopCoeffPair = std::pair; + +/// Tensor expression. Represents an MLIR expression in tensor index notation. +struct TensorExp final { + enum class Kind; + + /// Child subexpressions for non-leaf expressions. + struct Children final { + ExprId e0; + ExprId e1; + }; + + /// The `x` parameter has different types depending on the value of the + /// `k` parameter. The correspondences are: + /// * `kTensor` -> `TensorId` + /// * `kInvariant` -> `kInvalidId` + /// * `kLoopVar` -> `LoopId` + /// * else -> `ExprId` + /// + /// The `y`, `v`, and `op` parameters either must or must not be + /// `kInvalidId`/`nullptr`, depending on the value of the `k` parameter; + /// however, they have uniform C++ types regardless of the value of `k`. + TensorExp(Kind k, unsigned x, ExprId y, Value v, Operation *op, Attribute a); + + /// Tensor expression kind. + Kind kind; + + union { + /// `kTensor` expressions simply have a tensor identifier. + TensorId tensor; + + /// `kLoopVar` expressions simply have a loop identifier. + LoopId loop; + + /// All other expressions hold the `ExprId`s of their children. + Children children; + }; + + /// Direct link to IR for an invariant or the destination value (to + /// infer destination type) of a cast operation During code generation, + /// this field may be used to cache "hoisted" loop invariant tensor loads. + Value val; + + /// Code blocks used by semirings. For the case of kUnary, kBinary, kReduce, + /// and kSelect, this holds the original operation with all regions. For + /// kBinaryBranch, this holds the YieldOp for the left or right half + /// to be merged into a nested scf loop. + /// + /// Or the actual operation that we can not sparsify but having all dense + /// operands for kDenseOp. + Operation *op; + + /// An optional attribute that is required to determine the semantics of the + /// operations. E.g., CmpPredicateAttr for CmpI/CmpF operations. + Attribute attr; +}; + +/// Tensor expression kind. +/// +/// The `kLoopVar` leaf kind is for representing `linalg::IndexOp`. +/// That is, its argument is a `LoopId` identifying the loop-variable +/// in question, and its value will be the current iteration's value +/// of that loop-variable. See the `LoopId` documentation for more details. +/// +/// The `kSynZero` leaf kind is for representing a synthetic zero value, which +/// can be introduced when sparsifying operations like `arith::cmp` to generate +/// `arith::cmp %lhs, %syn_zero` when the rhs operand is absent. +// +// TODO: Modify this definition so that the numeric values already encode +// the `ExpArity` (while extending the notion of "arity" to include not +// just the number of `ExprId` children the node has, but also whether the +// node has a `Value` and/or `Operation*`). Doing this will avoid needing +// to enumerate all the kinds in `getExpArity` and in the `TensorExp` ctor, +// and should help clean up a few other places as well. +enum class TensorExp::Kind { + // Leaf. + kTensor = 0, + kSynZero, + kInvariant, + kLoopVar, + // Unary operations. + kAbsF, + kAbsC, + kAbsI, + kCeilF, + kFloorF, + kSqrtF, + kSqrtC, + kExpm1F, + kExpm1C, + kLog1pF, + kLog1pC, + kSinF, + kSinC, + kTanhF, + kTanhC, + kNegF, + kNegC, + kNegI, + kTruncF, + kExtF, + kCastFS, // signed + kCastFU, // unsigned + kCastSF, // signed + kCastUF, // unsigned + kCastS, // signed + kCastU, // unsigned + kCastIdx, + kTruncI, + kCIm, // complex.im + kCRe, // complex.re + kBitCast, + kBinaryBranch, // semiring unary branch created from a binary op + kUnary, // semiring unary op + kSelect, // custom selection criteria + // Binary operations. + kMulF, + kMulC, + kMulI, + kDivF, + kDivC, // complex + kDivS, // signed + kDivU, // unsigned + kAddF, + kAddC, + kAddI, + kSubF, + kSubC, + kSubI, + kAndI, + kOrI, + kXorI, + kCmpI, + kCmpF, + kShrS, // signed + kShrU, // unsigned + kShlI, + kBinary, // semiring binary op + kReduce, // semiring reduction op + kDenseOp, // special category of operations requiring all dense operands +}; + +/// Lattice point. Each lattice point consists of a formal conjunction +/// of `TensorLoopId`s, together with the identifier of the corresponding +/// tensor expression. The formal conjunction is represented as a set of +/// `TensorLoopId`, where that set is implemented as a `BitVector`. +struct LatPoint final { + /// Construct a lattice point with the empty set of `TensorLoopId`s. + LatPoint(unsigned size, ExprId e) : bits(size, false), exp(e) {} + + /// Construct a lattice point from the given set of `TensorLoopId`s. + LatPoint(const BitVector &bits, ExprId e) : bits(bits), exp(e) {} + + /// Conjunction of all `TensorLoopId`s involved in the tensor expression. + BitVector bits; + + /// Simplified conjunction of `TensorLoopId` as bitvector. This + /// represents a simplified condition under which this tensor expression + /// must execute. Pre-computed during codegen to avoid repeated eval. + BitVector simple; + + /// Identifier of the tensor expression. + ExprId exp; +}; + +/// A class to handle all iteration lattice operations. This class abstracts +/// away from some implementation details of storing iteration lattices and +/// tensor expressions. This allows for fine-tuning performance characteristics +/// independently from the basic algorithm if bottlenecks are identified. +class Merger { +public: + /// Constructs a merger for the given number of tensors, native loops, and + /// filter loops. The user supplies the number of tensors involved in the + /// kernel, with the last tensor in this set denoting the output tensor. + /// The merger adds an additional synthetic tensor at the end of this set + /// to represent all invariant expressions in the kernel. + /// + /// In addition to natives loops (which are specified by the GenericOp), + /// extra filter loops are needed in order to handle affine expressions on + /// sparse levels. E.g., (d0, d1, d2) => (d0 + d1, d2), a naive + /// implementation of the filter loop could be generated as + /// + /// for (const auto c0 : coordinates[0]) { + /// if (c0 == d0 + d1) { + /// generated_code; + /// } + /// } + /// + /// to filter out coordinates that are not equal to the affine expression. + /// + /// The maxLvlRank specifies the max level rank of all inputs/output tensors. + /// It is used to pre-allocate sufficient memory for internal storage. + // + // TODO: we want to make the filter loop more efficient in the future, + // e.g., by avoiding scanning the full list of stored coordinates (keeping + // the last position in ordered list) or even apply binary search to find + // the coordinate. + // + // TODO: would be cleaner to understand/document if the first argument + // gave the number of input tensors, instead of the current number of + // input+output tensors. + Merger(unsigned numInputOutputTensors, unsigned numNativeLoops, + unsigned numFilterLoops, unsigned maxLvlRank); + + // + // Constructing valid tensor and loop identifiers. + // + + /// Safely converts the argument to a tensor identifier. + constexpr TensorId makeTensorId(unsigned t) const { + assert(isValidTensorId(t)); + return t; + } + + /// Safely converts the argument to a loop identifier. + constexpr LoopId makeLoopId(unsigned i) const { + assert(isValidLoopId(i)); + return i; + } + + /// Safely converts the arguments to a pair of (tensor,loop) identifiers. + constexpr TensorLoopId makeTensorLoopId(unsigned t, unsigned i) const { + assert(isValidTensorId(t) && isValidLoopId(i)); + return numTensors * i + t; + } + + // + // Allocating new expressions, points, and sets. + // + + /// Constructs a new tensor expression, and returns its identifier. + ExprId addTensorExp(TensorId t); + /// Constructs a new loop-variable expression, and returns its identifier. + ExprId addLoopVarExp(LoopId i); + /// Constructs a new invariant expression, and returns its identifier. + ExprId addInvariantExp(Value v); + /// Constructs a new synthetic zero expression. + ExprId addSynZeroExp(); + /// Constructs a new unary or binary expression, and returns its identifier. + ExprId addExp(TensorExp::Kind k, ExprId e0, ExprId e1 = detail::kInvalidId, + Operation *op = nullptr, Attribute attr = nullptr); + /// Constructs a new sesquinary expression, and returns its identifier. + /// Currently no sesquinary `Kind` allows specifying the `op`, but we + /// allow it anyways because `mapSet` is designed to allow it. + ExprId addExp(TensorExp::Kind k, ExprId e, Value v, Operation *op = nullptr, + Attribute attr = nullptr); + + /// Constructs a new iteration lattice point, and returns its identifier. + LatPointId addLat(TensorId t, LoopId i, ExprId e); + LatPointId addLat(const BitVector &bits, ExprId e); + + /// Constructs a new (initially empty) set, and returns its identifier. + LatSetId addSet(); + + /// Computes a single conjunction of two lattice points by taking the "union" + /// of `LoopId` (effectively constructing a larger "intersection" of those + /// loops) with a newly constructed tensor (sub)expression of given kind. + /// Returns the identifier of the new lattice point. + LatPointId conjLat(ExprId e, LatPointId p0, LatPointId p1, + Operation *op = nullptr); + + /// Conjunctive merge of two lattice sets: `(s0 /\_op s1)`. + /// Returns the identifier of the new set. + LatSetId conjSet(ExprId e, LatSetId s0, LatSetId s1, Operation *op = nullptr); + + /// Disjunctive merge of two lattice sets: `(s0 /\_op s1, s0, s1)`. + /// Returns the identifier of the new set. + LatSetId disjSet(ExprId e, LatSetId s0, LatSetId s1, Operation *op = nullptr); + + /// Disjunctive merge of two lattice sets and also set one of the operand to + /// zero: `(s0 /\_op s1 (e0 op e1), s0 (0 op e0), s1 (e1 op 0))`. + /// Returns the identifier of the new set. + LatSetId disjSetWithZero(ExprId e, LatSetId s0, LatSetId s1); + + /// Disjunctive merge of two lattice sets with custom handling of the + /// overlap, left, and right regions. Any region may be left missing + /// in the output. Returns the identifier of the new set. + LatSetId combiSet(ExprId e, LatSetId s0, LatSetId s1, Operation *orig, + bool includeLeft, TensorExp::Kind ltrans, Operation *opleft, + bool includeRight, TensorExp::Kind rtrans, + Operation *opright); + + /// Maps the unary operator over the lattice set of the operand, i.e. each + /// lattice point on an expression E is simply copied over, but with OP E + /// as new expression. Returns the identifier of the new set. + LatSetId mapSet(TensorExp::Kind kind, LatSetId s, Value v = Value(), + Operation *op = nullptr); + + /// Maps the binary operator to the same operation but with one of its operand + /// set to zero, i.e. each lattice point on an expression E is simply copied + /// over, but with `OP 0 E` (if lhsZero == true) or `OP E 0` (if lhsZero == + /// false) as new expression. Returns the identifier of the new set. + LatSetId mapBinWithSynZeroSet(ExprId e, LatSetId s, bool lhsZero); + + /// Optimizes the iteration lattice points in the given set. This + /// method should be called right before code generation to avoid + /// generating redundant loops and conditions. + LatSetId optimizeSet(LatSetId s); + + /// Simplifies the conditions in a conjunction of a given lattice point + /// within the given set using just two basic rules: + /// (1) multiple dense conditions are reduced to single dense, and + /// (2) a *singleton* sparse/dense is reduced to sparse/random access. + BitVector simplifyCond(LatSetId s, LatPointId p); + + /// Returns true if p0 > p1. + bool latGT(LatPointId p0, LatPointId p1) const; + + /// Returns true if p0 and p1 only differ in dense. + bool onlyDenseDiff(LatPointId p0, LatPointId p1) const; + + /// Gets the tensor-identifier of the `TensorLoopId`. + constexpr TensorId tensor(TensorLoopId b) const { return b % numTensors; } + /// Gets the loop-identifier of the `TensorLoopId`. + constexpr LoopId loop(TensorLoopId b) const { return b / numTensors; } + + /// Gets the total number of tensors (including the output-tensor and + /// synthetic-tensor). + constexpr unsigned getNumTensors() const { return numTensors; } + + /// Gets the total number of loops (native loops + filter loops). + constexpr unsigned getNumLoops() const { return numLoops; } + /// Gets the number of native loops. + constexpr unsigned getNumNativeLoops() const { return numNativeLoops; } + /// Gets the number of filter loops. + constexpr unsigned getNumFilterLoops() const { + return numLoops - numNativeLoops; + } + /// Gets the identifier of the first filter-loop. + constexpr LoopId getStartingFilterLoopId() const { + return getNumNativeLoops(); + } + + /// Returns true if `b` is the `i`th loop of the output tensor. + constexpr bool isOutTensor(TensorLoopId b, LoopId i) const { + return b == makeTensorLoopId(outTensor, i); + } + + /// Gets the output tensor's identifier. + constexpr TensorId getOutTensorID() const { return outTensor; } + + /// Gets the synthetic tensor's identifier (used for all invariant + /// tensor expressions). + constexpr TensorId getSynTensorID() const { return syntheticTensor; } + + constexpr bool isFilterLoop(LoopId i) const { + assert(isValidLoopId(i)); + return i >= numNativeLoops; + } + + /// Returns true if the expression is `(kTensor t)`. + bool expIsTensor(ExprId e, TensorId t) const { + const auto &expr = exp(e); + return expr.kind == TensorExp::Kind::kTensor && expr.tensor == t; + } + + /// Returns true if the expression contains the tensor as an operand. + bool expContainsTensor(ExprId e, TensorId t) const; + + /// Returns true if the expression contains a negation on output tensor. + /// I.e., `- outTensor` or `exp - outputTensor` + /// NOTE: this is an trivial tests in that it does not handle recursive + /// negation, i.e., it returns true when the expression is `-(-tensor)`. + bool hasNegateOnOut(ExprId e) const; + + /// Returns true if given tensor iterates *only* in the given tensor + /// expression. For the output tensor, this defines a "simply dynamic" + /// operation [Bik96]. For instance: a(i) *= 2.0 or a(i) += a(i) for + /// sparse vector a. + bool isSingleCondition(TensorId t, ExprId e) const; + + /// Returns true if any `TensorLoopId` in the bitvector corresponds + /// to sparse level-type. + bool hasAnySparse(const BitVector &bits) const; + + /// Returns true if bits contains a dependent index reduction condition on + /// sparse levels. + bool hasSparseIdxReduction(const BitVector &bits) const; + + /// Gets the level-type of the `t`th tensor on `i`th loop. + DimLevelType getLvlType(TensorId t, LoopId i) const { + assert(isValidTensorId(t) && isValidLoopId(i)); + return lvlTypes[t][i]; + } + + /// Gets the level-type of the TensorLoopId. + DimLevelType getLvlType(TensorLoopId b) const { + return getLvlType(tensor(b), loop(b)); + } + + /// Gets the loop identifier for the `lvl`th level of the `t`th tensor. + std::optional getLoopId(TensorId t, Level lvl) const { + assert(isValidLevel(t, lvl)); + return lvlToLoop[t][lvl]; + } + + /// Gets the level number of the the `t`th tensor on `i`th loop. + std::optional getLvl(TensorId t, LoopId i) const { + assert(isValidTensorId(t) && isValidLoopId(i)); + return loopToLvl[t][i]; + } + std::optional getLvl(TensorLoopId b) const { + return getLvl(tensor(b), loop(b)); + } + + /// Sets the level number and level-type of the `t`th tensor on + /// `i`th loop. + void setLevelAndType(TensorId t, LoopId i, Level lvl, DimLevelType dlt) { + assert(isValidLevel(t, lvl) && isValidLoopId(i) && isValidDLT(dlt)); + lvlTypes[t][i] = dlt; + loopToLvl[t][i] = lvl; + lvlToLoop[t][lvl] = i; + // TODO: Maybe we should favor a constant loop bound when there are multiple + // choices. + loopBounds[i] = std::make_pair(t, lvl); + } + + using ForeachTensorLoopIdCallback = function_ref, DimLevelType, bool)>; + + /// Iterates over a set of `TensorLoopId`s, invoking the callback + /// for each `TensorLoopId` and passing it the corresponding tensor + /// identifier, level, and level-type, following with a boolean value + /// indicating whether it is a dependent index reduction loop condition. + void foreachTensorLoopId(LatPointId p, + ForeachTensorLoopIdCallback callback) const { + // TODO: the default ought to be simple=true; but we'll need to make + // sure to update all the tests to make sure they do the right thing. + foreachTensorLoopId(p, /*simple=*/false, callback); + } + void foreachTensorLoopId(LatPointId p, bool simple, + ForeachTensorLoopIdCallback callback) const { + const auto &point = lat(p); + const auto &bits = simple ? point.simple : point.bits; + for (const TensorLoopId b : bits.set_bits()) { + const TensorId t = tensor(b); + const auto optLvl = getLvl(b); + const auto lvlTp = getLvlType(b); + if (isLvlWithNonTrivialIdxExp(b)) { + // This must be an undefined level. + assert(!optLvl.has_value()); + // Slice the tid along the dependent level to iterate current loop. + callback(b, t, getLoopDependentLevel(b), lvlTp, + /*isIdxReduc=*/true); + } else { + callback(b, t, optLvl, lvlTp, /*isIdxReduc=*/false); + } + } + } + + /// Sets whether the output tensor is sparse or not. + void setHasSparseOut(bool s) { hasSparseOut = s; } + + /// Establishes the two-way map that i <-> . + void setLoopDependentTensorLevel(LoopId i, TensorId t, Level lvl, + DimLevelType dlt, unsigned coefficient) { + assert(isValidLoopId(i) && isValidLevel(t, lvl)); + assert(!loopToUnresolvedLvls[i][t].has_value()); // must be the first def + loopToUnresolvedLvls[i][t] = std::make_pair(lvl, dlt); + levelToDependentLoop[t][lvl].emplace_back(i, coefficient); + } + + /// Whether the loop has dependent slice. + bool hasDependentLvl(LoopId i, TensorId t) { + assert(isValidTensorId(t) && isValidLoopId(i)); + return loopToUnresolvedLvls[i][t].has_value(); + } + + /// Returns the list of loop indices which appear in the non-trivial index + /// expression on t_l, e.g., A[i+j] => {i, j} + std::vector &getDependentLoops(TensorId t, Level lvl) { + assert(isValidLevel(t, lvl)); + return levelToDependentLoop[t][lvl]; + } + + /// Returns the defining [tid, lvl] for the loop. + std::pair getLoopDefiningLvl(LoopId i) const { + assert(isValidLoopId(i)); + return loopBounds[i]; + } + + /// Checks whether the TensorLoopId represents a tensor level contains + /// non-trivial index expression. + bool isLvlWithNonTrivialIdxExp(TensorLoopId b) const { + const TensorId t = tensor(b); + const LoopId i = loop(b); + assert(isValidTensorId(t) && isValidLoopId(i)); + return loopToUnresolvedLvls[i][t].has_value(); + } + + /// Checks whether the TensorLoopId represents a sparse tensor level contains + /// non-trivial index expression. + bool isSparseLvlWithNonTrivialIdxExp(TensorLoopId b) const { + if (isLvlWithNonTrivialIdxExp(b)) { + auto dlt = getLoopDependentLevelType(b); + return isCompressedDLT(dlt) || isSingletonDLT(dlt); + } + return false; + } + + Level getLoopDependentLevel(TensorLoopId b) const { + assert(isLvlWithNonTrivialIdxExp(b)); + return loopToUnresolvedLvls[loop(b)][tensor(b)]->first; + } + + DimLevelType getLoopDependentLevelType(TensorLoopId b) const { + assert(isLvlWithNonTrivialIdxExp(b)); + return loopToUnresolvedLvls[loop(b)][tensor(b)]->second; + } + + /// Convenience getters to immediately access the stored nodes. + /// These methods return `const&` because the underlying objects must + /// not be mutated by client code. The only exception is for mutating + /// the value associated with an expression, for which there are + /// dedicated methods below. + /// + /// NOTE: It is inadvisable to keep the reference alive for a long + /// time (e.g., as in `TensorExpr &te = merger.exp(e)`), since insertions + /// into the merger can cause data movement which will invalidate the + /// underlying memory address. This isn't just a problem with the `&` + /// references, but also applies to the `ArrayRef`. In particular, + /// using `for (LatPointId p : merger.set(s))` will run into the same + /// dangling-reference problems if the loop body inserts new sets. + const TensorExp &exp(ExprId e) const { + assert(isValidExprId(e)); + return tensorExps[e]; + } + const LatPoint &lat(LatPointId p) const { + assert(isValidLatPointId(p)); + return latPoints[p]; + } + ArrayRef set(LatSetId s) const { + assert(isValidLatSetId(s)); + return latSets[s]; + } + + /// Checks whether the given expression has an associated value. + bool hasExprValue(ExprId e) const { return static_cast(exp(e).val); } + + /// Sets the expression to have the associated value. Asserts that + /// the new value is defined, and that the expression does not already + /// have a value. If you want to overwrite a previous associated value, + /// use `updateExprValue` instead. + void setExprValue(ExprId e, Value v) { + assert(isValidExprId(e)); + assert(v && "Got an undefined value"); + auto &val = tensorExps[e].val; + assert(!val && "Expression already has an associated value"); + val = v; + } + + /// Clears the value associated with the expression. Asserts that the + /// expression does indeed have an associated value before clearing it. + /// If you don't want to check for a previous associated value first, + /// then use `updateExprValue` instead. + void clearExprValue(ExprId e) { + assert(isValidExprId(e)); + auto &val = tensorExps[e].val; + assert(val && "Expression does not have an associated value to clear"); + val = Value(); + } + + /// Unilaterally updates the expression to have the associated value. + /// That is, unlike `setExprValue` and `clearExprValue`, this method + /// does not perform any checks on whether the expression had a + /// previously associated value nor whether the new value is defined. + // + // TODO: The unilateral update semantics are required by the + // current implementation of `CodegenEnv::genLoopBoundary`; however, + // that implementation seems a bit dubious. We would much rather have + // the semantics `{ clearExprValue(e); setExprValue(e, v); }` or + // `{ clearExprValue(e); if (v) setExprValue(e, v); }` since those + // provide better invariants. + void updateExprValue(ExprId e, Value v) { + assert(isValidExprId(e)); + tensorExps[e].val = v; + } + +#ifndef NDEBUG + /// Print methods (for debugging). + void dumpExp(ExprId e) const; + void dumpLat(LatPointId p) const; + void dumpSet(LatSetId s) const; + void dumpBits(const BitVector &bits) const; +#endif + + /// Builds the iteration lattices in a bottom-up traversal given the + /// remaining tensor (sub)expression and the next loop in the iteration + /// graph. Returns the identifier of the root set. + LatSetId buildLattices(ExprId e, LoopId i); + + /// Builds a tensor expression from the given Linalg operation. + /// On success, returns the identifier of the root expression. + std::optional buildTensorExpFromLinalg(linalg::GenericOp op); + + /// Rebuilds SSA format from a tensor expression. + Value buildExp(RewriterBase &rewriter, Location loc, ExprId e, Value v0, + Value v1) const; + +private: + /// Private helpers. + constexpr bool isValidTensorId(TensorId t) const { return t < numTensors; } + constexpr bool isValidLoopId(LoopId i) const { + return i != detail::kInvalidId && i < numLoops; + } + bool isValidLevel(TensorId t, Level lvl) const { + assert(levelToDependentLoop[t].size() == lvlToLoop[t].size()); + return isValidTensorId(t) && lvl < lvlToLoop[t].size(); + } + bool isValidExprId(ExprId e) const { + return e != detail::kInvalidId && e < tensorExps.size(); + } + bool isValidLatPointId(LatPointId p) const { + return p != detail::kInvalidId && p < latPoints.size(); + } + bool isValidLatSetId(LatSetId s) const { + return s != detail::kInvalidId && s < latSets.size(); + } + bool maybeZero(ExprId e) const; + bool isInvariant(ExprId e) const { + return exp(e).kind == TensorExp::Kind::kInvariant; + } + Type inferType(ExprId e, Value src) const; + + /// Traverses the SSA tree (possibly a DAG) to build a tensor expression. + /// The boolean value returned indicates whether the result of the current + /// operation being built depends on any value that is loaded from a sparse + /// tensor. + std::pair, bool> buildTensorExp(linalg::GenericOp op, + Value v); + + /// Merger data structures. + const TensorId outTensor; + const TensorId syntheticTensor; + const unsigned numTensors; + const unsigned numNativeLoops; + const unsigned numLoops; + bool hasSparseOut; + + // Below we use `std::vector` for things which have a priori fixed + // sizes, whereas we use `llvm::SmallVector` for things with variable + // size. Do beware that these two classes differ in the semantics of + // `operator[]`: `SmallVector` performs OOB checks, whereas `std::vector` + // does not. + + /// Map that converts pair to the corresponding + /// level-type. + std::vector> lvlTypes; + + /// Map that converts pair to the corresponding + /// level. + std::vector>> loopToLvl; + + /// Map that converts pair to the corresponding LoopId. + std::vector>> lvlToLoop; + + /// Map from a loop to its dependencies if any. + /// The dependencies of a loop is a set of (tensor, level) pairs. + /// It is currently only set for non-trivial index expressions. + /// E.g., A[i+j] => i and j will have dependencies {A0, dlt(A0)} to indicate + /// that i and j are used in the non-trivial index expression on A0. + std::vector>> loopToUnresolvedLvls; + + /// The inverse map of ldxToDependencies from tensor level -> dependent loop + /// E.g., A[2i+j], we have A0 => {(2, i), (1, j)}, to indicate that A0 uses + /// both {i, j} to compute its indices and the coefficients on the loop id are + /// 2 and 1 respectively. + std::vector>> levelToDependentLoop; + + /// Map from a loop to the [tid, lvl] pair that defines the loop boundary. + std::vector> loopBounds; + + llvm::SmallVector tensorExps; + llvm::SmallVector latPoints; + llvm::SmallVector> latSets; +}; + +} // namespace sparse_tensor +} // namespace mlir + +#endif // MLIR_DIALECT_SPARSETENSOR_UTILS_MERGER_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/IR/Tensor.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/IR/Tensor.h new file mode 100644 index 0000000000000000000000000000000000000000..06642adda42b38109f9ca87f30dac64b160d9532 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/IR/Tensor.h @@ -0,0 +1,172 @@ +//===- Tensor.h - Tensor dialect --------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_TENSOR_IR_TENSOR_H_ +#define MLIR_DIALECT_TENSOR_IR_TENSOR_H_ + +#include "mlir/Bytecode/BytecodeOpInterface.h" +#include "mlir/Dialect/Utils/ReshapeOpsUtils.h" +#include "mlir/IR/BuiltinTypes.h" +#include "mlir/IR/Dialect.h" +#include "mlir/IR/OpDefinition.h" +#include "mlir/IR/OpImplementation.h" +#include "mlir/Interfaces/CastInterfaces.h" +#include "mlir/Interfaces/ControlFlowInterfaces.h" +#include "mlir/Interfaces/DestinationStyleOpInterface.h" +#include "mlir/Interfaces/InferTypeOpInterface.h" +#include "mlir/Interfaces/ParallelCombiningOpInterface.h" +#include "mlir/Interfaces/ShapedOpInterfaces.h" +#include "mlir/Interfaces/SideEffectInterfaces.h" +#include "mlir/Interfaces/TilingInterface.h" +#include "mlir/Interfaces/ViewLikeInterface.h" + +//===----------------------------------------------------------------------===// +// Tensor Dialect Helpers +//===----------------------------------------------------------------------===// + +namespace mlir { + +/// Return the list of Range (i.e. offset, size, stride). Each Range +/// entry contains either the dynamic value or a ConstantIndexOp constructed +/// with `b` at location `loc`. +SmallVector getOrCreateRanges(OffsetSizeAndStrideOpInterface op, + OpBuilder &b, Location loc); + +} // namespace mlir + +//===----------------------------------------------------------------------===// +// Tensor Dialect +//===----------------------------------------------------------------------===// + +#include "mlir/Dialect/Tensor/IR/TensorOpsDialect.h.inc" + +//===----------------------------------------------------------------------===// +// Tensor Dialect Operations +//===----------------------------------------------------------------------===// + +#define GET_OP_CLASSES +#include "mlir/Dialect/Tensor/IR/TensorOps.h.inc" + +//===----------------------------------------------------------------------===// +// Tensor Dialect Helpers +//===----------------------------------------------------------------------===// + +namespace mlir { +namespace tensor { + +/// Returns true if `target` is a ranked tensor type that preserves static +/// information available in the `source` ranked tensor type. +bool preservesStaticInformation(Type source, Type target); + +/// Determines whether tensor::CastOp casts to a more dynamic version of the +/// source tensor. This is useful to fold a tensor.cast into a consuming op and +/// implement canonicalization patterns for ops in different dialects that may +/// consume the results of tensor.cast operations. Such foldable tensor.cast +/// operations are typically inserted as `extract_slice` ops and are +/// canonicalized, to preserve the type compatibility of their uses. +/// +/// Returns true when all conditions are met: +/// 1. source and result are ranked tensors with same element type and rank. +/// 2. the tensor type has more static information than the result +/// +/// Example: +/// ```mlir +/// %1 = tensor.cast %0 : tensor<8x16xf32> to tensor +/// %2 = consumer %1 ... : tensor ... +/// ``` +/// +/// folds into: +/// +/// ```mlir +/// %2 = consumer %0 ... : tensor<8x16xf32> ... +/// ``` +bool canFoldIntoConsumerOp(CastOp castOp); + +/// Determines whether the tensor::CastOp casts to a more static version of the +/// source tensor. This is useful to fold into a producing op and implement +/// canonicaliation patterns with the `tensor.cast` op as the root, but producer +/// being from different dialects. Returns true when all conditions are met: +/// 1. source and result and ranked tensors with same element type and rank. +/// 2. the result type has more static information than the source. +/// +/// Example: +/// ```mlir +/// %1 = producer ... : tensor +/// %2 = tensor.cast %1 : tensor to tensor<8x16xf32> +/// ``` +/// +/// can be canonicalized to : +/// +/// ```mlir +/// %2 = producer ... : tensor<8x16xf32> +/// ``` +/// Not all ops might be canonicalizable this way, but for those that can be, +/// this method provides a check that it is worth doing the canonicalization. +bool canFoldIntoProducerOp(CastOp castOp); + +/// Performs folding of any operand of `op` if it comes from a tensor::CastOp +/// that can be folded. +LogicalResult foldTensorCast(Operation *op); + +/// Return the dimension of the given tensor value. +OpFoldResult getMixedSize(OpBuilder &builder, Location loc, Value value, + int64_t dim); + +/// Return the dimensions of the given tensor value. +SmallVector getMixedSizes(OpBuilder &builder, Location loc, + Value value); + +/// Create a rank-reducing ExtractSliceOp @[0 .. 0] with strides [1 .. 1] and +/// appropriate sizes (i.e. `tensor.getSizes()`) to reduce the rank of `tensor` +/// to that of `targetType`. +Value createCanonicalRankReducingExtractSliceOp(OpBuilder &b, Location loc, + Value tensor, + RankedTensorType targetType); + +/// Create a rank-reducing InsertSliceOp @[0 .. 0] with strides [1 .. 1] and +/// appropriate sizes (i.e. `dest.getSizes()`). The result is a new tensor with +/// rank increased to that of `dest`, obtained by inserting `tensor` into `dest` +/// at the canonical [0 .. 0] position. +Value createCanonicalRankReducingInsertSliceOp(OpBuilder &b, Location loc, + Value tensor, Value dest); + +/// This is a helper function for DestinationStyleOpInterface. If there is a +/// destination operand for the given OpResult, return that operand. Otherwise, +/// return an empty tensor (`tensor.empty`) with the shape of the OpResult. +/// Dynamic dimensions are queried via ReifyRankedShapedTypeOpInterface. +FailureOr getOrCreateDestination(OpBuilder &b, Location loc, + OpResult opResult); + +/// This is a helper function for DestinationStyleOpInterface. Get or create +/// destinations for every tensor OpResult of the given op. +LogicalResult getOrCreateDestinations(OpBuilder &b, Location loc, Operation *op, + SmallVector &result); + +/// Tests if types are the same when ignoring encoding on ranked tensors. +bool isSameTypeWithoutEncoding(Type tp1, Type tp2); + +/// Function to control the folding of constant and extract slice. +using ControlConstantExtractSliceFusionFn = std::function; + +/// Patterns to fold the extract slice op with its constant operand. +void populateFoldConstantExtractSlicePatterns( + RewritePatternSet &patterns, + const ControlConstantExtractSliceFusionFn &controlFn = + [](ExtractSliceOp op) { + // Disable by default because the folding can generate a large + // constant tensor, which would affect the compile time and storage. + return false; + }); + +/// Patterns to simplify tensor.pack. +void populateSimplifyTensorPack(RewritePatternSet &patterns); + +} // namespace tensor +} // namespace mlir + +#endif // MLIR_DIALECT_TENSOR_IR_TENSOR_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/IR/TensorInferTypeOpInterfaceImpl.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/IR/TensorInferTypeOpInterfaceImpl.h new file mode 100644 index 0000000000000000000000000000000000000000..f806a5db45a98a3b1afd127c1058068572d1c1db --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/IR/TensorInferTypeOpInterfaceImpl.h @@ -0,0 +1,38 @@ +//===- TensorInferTypeOpInterfaceImpl.h - ---------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file implements InferTypeOp interface for TensorOps with ExternalModel. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_TENSOR_IR_TENSORINFERTYPEOPINTERFACEIMPL_H_ +#define MLIR_DIALECT_TENSOR_IR_TENSORINFERTYPEOPINTERFACEIMPL_H_ + +#include "mlir/IR/Dialect.h" + +namespace mlir { +namespace tensor { + +/// Registers external models for Infer Type interfaces for tensor ops. +/// Currently, it registers: +/// +/// * ReifyRankedShapedTypeOpInterface for `tensor.collapse_shape`. +/// * ReifyRankedShapedTypeOpInterface for `tensor.expand_shape`. +/// +/// Unfortunately, a "normal" internal registration is not possible at the +/// moment, because of the dependency of the interface implementation for these +/// ops on `affine.apply` and Affine dialect already depends on TensorOps. In +/// order to break the cyclic dependency (TensorOps->AffineOps->TensorOps) the +/// implementation is moved to a separate library. +void registerInferTypeOpInterfaceExternalModels( + mlir::DialectRegistry ®istry); + +} // namespace tensor +} // namespace mlir + +#endif // MLIR_DIALECT_TENSOR_IR_TENSORINFERTYPEOPINTERFACEIMPL_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/IR/TensorOps.cpp.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/IR/TensorOps.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..6bd0372108c64868b7f3b741e3f2d5d610209a40 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/IR/TensorOps.cpp.inc @@ -0,0 +1,8867 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Op Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: TensorOps.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifdef GET_OP_LIST +#undef GET_OP_LIST + +::mlir::tensor::BitcastOp, +::mlir::tensor::CastOp, +::mlir::tensor::CollapseShapeOp, +::mlir::tensor::DimOp, +::mlir::tensor::EmptyOp, +::mlir::tensor::ExpandShapeOp, +::mlir::tensor::ExtractOp, +::mlir::tensor::ExtractSliceOp, +::mlir::tensor::FromElementsOp, +::mlir::tensor::GatherOp, +::mlir::tensor::GenerateOp, +::mlir::tensor::InsertOp, +::mlir::tensor::InsertSliceOp, +::mlir::tensor::PackOp, +::mlir::tensor::PadOp, +::mlir::tensor::ParallelInsertSliceOp, +::mlir::tensor::RankOp, +::mlir::tensor::ReshapeOp, +::mlir::tensor::ScatterOp, +::mlir::tensor::SplatOp, +::mlir::tensor::UnPackOp, +::mlir::tensor::YieldOp +#endif // GET_OP_LIST + +#ifdef GET_OP_CLASSES +#undef GET_OP_CLASSES + + +//===----------------------------------------------------------------------===// +// Local Utility Method Definitions +//===----------------------------------------------------------------------===// + +namespace mlir { +namespace tensor { + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_TensorOps0( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::TensorType>(type))) && ([](::mlir::Type elementType) { return (true); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be tensor of any type values, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_TensorOps1( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return (true); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be ranked tensor of any type values, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_TensorOps2( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::UnrankedTensorType>(type))) && ([](::mlir::Type elementType) { return (true); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((((::llvm::isa<::mlir::TensorType>(type))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank() >= 1)))) && ([](::mlir::Type elementType) { return (true); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be non-0-ranked or unranked tensor, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_TensorOps3( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((::llvm::isa<::mlir::IndexType>(type)))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be index, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_TensorOps4( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((true))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be any type, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_TensorOps5( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::cast<::mlir::ShapedType>(type).hasStaticShape()))) && ([](::mlir::Type elementType) { return (true); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be statically shaped tensor of any type values, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_TensorOps6( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return (elementType.isSignlessIntOrIndex()); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be ranked tensor of signless integer or index values, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_TensorOps7( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::RankedTensorType>(type))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank() + == 1)))) && ([](::mlir::Type elementType) { return ((elementType.isSignlessInteger())) || ((::llvm::isa<::mlir::IndexType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be 1D tensor of signless integer or index values, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_TensorOps8( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((type.isSignlessInteger())) || ((::llvm::isa<::mlir::IndexType>(type))) || ((::llvm::isa<::mlir::FloatType>(type))))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be integer/index/float type, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_TensorOps0( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !(((::llvm::isa<::mlir::ArrayAttr>(attr))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(attr), [&](::mlir::Attribute attr) { return attr && (((::llvm::isa<::mlir::ArrayAttr>(attr))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(attr), [&](::mlir::Attribute attr) { return attr && (((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(64)))); }))); })))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: Array of 64-bit integer array attributes"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_TensorOps0( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_TensorOps0(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_TensorOps1( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: i64 dense array attribute"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_TensorOps1( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_TensorOps1(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_TensorOps2( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::UnitAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: unit attribute"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_TensorOps2( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_TensorOps2(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_region_constraint_TensorOps0( + ::mlir::Operation *op, ::mlir::Region ®ion, ::llvm::StringRef regionName, + unsigned regionIndex) { + if (!((::llvm::hasNItems(region, 1)))) { + return op->emitOpError("region #") << regionIndex + << (regionName.empty() ? " " : " ('" + regionName + "') ") + << "failed to verify constraint: region with 1 blocks"; + } + return ::mlir::success(); +} +} // namespace tensor +} // namespace mlir +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::BitcastOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BitcastOpGenericAdaptorBase::BitcastOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("tensor.bitcast", odsAttrs.getContext()); +} + +BitcastOpGenericAdaptorBase::BitcastOpGenericAdaptorBase(BitcastOp op) : BitcastOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair BitcastOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr BitcastOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +BitcastOpAdaptor::BitcastOpAdaptor(BitcastOp op) : BitcastOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult BitcastOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair BitcastOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range BitcastOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::TensorType> BitcastOp::getSource() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &BitcastOp::getSourceMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair BitcastOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range BitcastOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::TensorType> BitcastOp::getDest() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); +} + +void BitcastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dest, ::mlir::Value source) { + odsState.addOperands(source); + odsState.addTypes(dest); +} + +void BitcastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source) { + odsState.addOperands(source); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BitcastOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult BitcastOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps0(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult BitcastOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult BitcastOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(sourceRawOperands); ::llvm::SMLoc sourceOperandsLoc; + (void)sourceOperandsLoc; + ::mlir::Type sourceRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> sourceTypes(sourceRawTypes); + ::mlir::Type destRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> destTypes(destRawTypes); + + sourceOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(sourceRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + sourceRawTypes[0] = type; + } + if (parser.parseKeyword("to")) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + destRawTypes[0] = type; + } + result.addTypes(destTypes); + if (parser.resolveOperands(sourceOperands, sourceTypes, sourceOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BitcastOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getSource(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getSource().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "to"; + _odsPrinter << ' '; + { + auto type = getDest().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void BitcastOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::tensor::BitcastOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::CastOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CastOpGenericAdaptorBase::CastOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("tensor.cast", odsAttrs.getContext()); +} + +CastOpGenericAdaptorBase::CastOpGenericAdaptorBase(CastOp op) : CastOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair CastOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr CastOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +CastOpAdaptor::CastOpAdaptor(CastOp op) : CastOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult CastOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair CastOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range CastOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::TensorType> CastOp::getSource() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &CastOp::getSourceMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair CastOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range CastOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::TensorType> CastOp::getDest() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); +} + +void CastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dest, ::mlir::Value source) { + odsState.addOperands(source); + odsState.addTypes(dest); +} + +void CastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source) { + odsState.addOperands(source); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void CastOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult CastOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps0(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult CastOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult CastOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(sourceRawOperands); ::llvm::SMLoc sourceOperandsLoc; + (void)sourceOperandsLoc; + ::mlir::Type sourceRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> sourceTypes(sourceRawTypes); + ::mlir::Type destRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> destTypes(destRawTypes); + + sourceOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(sourceRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + sourceRawTypes[0] = type; + } + if (parser.parseKeyword("to")) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + destRawTypes[0] = type; + } + result.addTypes(destTypes); + if (parser.resolveOperands(sourceOperands, sourceTypes, sourceOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CastOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getSource(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getSource().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "to"; + _odsPrinter << ' '; + { + auto type = getDest().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void CastOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::tensor::CastOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::CollapseShapeOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CollapseShapeOpGenericAdaptorBase::CollapseShapeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("tensor.collapse_shape", odsAttrs.getContext()); +} + +CollapseShapeOpGenericAdaptorBase::CollapseShapeOpGenericAdaptorBase(CollapseShapeOp op) : CollapseShapeOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair CollapseShapeOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr CollapseShapeOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::ArrayAttr CollapseShapeOpGenericAdaptorBase::getReassociationAttr() { + auto attr = ::llvm::cast<::mlir::ArrayAttr>(getProperties().reassociation); + return attr; +} + +::mlir::ArrayAttr CollapseShapeOpGenericAdaptorBase::getReassociation() { + auto attr = getReassociationAttr(); + return attr; +} + +} // namespace detail +CollapseShapeOpAdaptor::CollapseShapeOpAdaptor(CollapseShapeOp op) : CollapseShapeOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult CollapseShapeOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_reassociation = getProperties().reassociation; (void)tblgen_reassociation; + if (!tblgen_reassociation) return emitError(loc, "'tensor.collapse_shape' op ""requires attribute 'reassociation'"); + + if (tblgen_reassociation && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_reassociation))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_reassociation), [&](::mlir::Attribute attr) { return attr && (((::llvm::isa<::mlir::ArrayAttr>(attr))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(attr), [&](::mlir::Attribute attr) { return attr && (((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(64)))); }))); })))) + return emitError(loc, "'tensor.collapse_shape' op ""attribute 'reassociation' failed to satisfy constraint: Array of 64-bit integer array attributes"); + return ::mlir::success(); +} + +std::pair CollapseShapeOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range CollapseShapeOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::RankedTensorType> CollapseShapeOp::getSrc() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &CollapseShapeOp::getSrcMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair CollapseShapeOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range CollapseShapeOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::RankedTensorType> CollapseShapeOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult CollapseShapeOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.reassociation; + auto attr = dict.get("reassociation"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for reassociation in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `reassociation` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute CollapseShapeOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.reassociation; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("reassociation", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code CollapseShapeOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.reassociation.getAsOpaquePointer())); +} + +std::optional CollapseShapeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "reassociation") + return prop.reassociation; + return std::nullopt; +} + +void CollapseShapeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "reassociation") { + prop.reassociation = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void CollapseShapeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.reassociation) attrs.append("reassociation", prop.reassociation); +} + +::mlir::LogicalResult CollapseShapeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getReassociationAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps0(attr, "reassociation", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult CollapseShapeOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.reassociation))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CollapseShapeOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.reassociation); +} + +::mlir::ArrayAttr CollapseShapeOp::getReassociationAttr() { + return ::llvm::cast<::mlir::ArrayAttr>(getProperties().reassociation); +} + +::mlir::ArrayAttr CollapseShapeOp::getReassociation() { + auto attr = getReassociationAttr(); + return attr; +} + +void CollapseShapeOp::setReassociationAttr(::mlir::ArrayAttr attr) { + (*this)->setAttr(getReassociationAttrName(), attr); +} + +void CollapseShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value src, ArrayRef reassociation, ArrayRef attrs) { + auto reassociationMaps = + convertReassociationMapsToIndices(odsBuilder, reassociation); + build(odsBuilder, odsState, src, reassociationMaps, attrs); + +} + +void CollapseShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType, Value src, ArrayRef reassociation, ArrayRef attrs) { + build(odsBuilder, odsState, resultType, src, attrs); + odsState.addAttribute("reassociation", + getReassociationIndicesAttribute(odsBuilder, reassociation)); + +} + +void CollapseShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType, Value src, ArrayRef reassociation, ArrayRef attrs) { + auto reassociationMaps = + convertReassociationMapsToIndices(odsBuilder, reassociation); + build(odsBuilder, odsState, resultType, src, reassociationMaps, attrs); + +} + +void CollapseShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value src, ::mlir::ArrayAttr reassociation) { + odsState.addOperands(src); + odsState.getOrAddProperties().reassociation = reassociation; + odsState.addTypes(result); +} + +void CollapseShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::ArrayAttr reassociation) { + odsState.addOperands(src); + odsState.getOrAddProperties().reassociation = reassociation; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void CollapseShapeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult CollapseShapeOp::verifyInvariantsImpl() { + auto tblgen_reassociation = getProperties().reassociation; (void)tblgen_reassociation; + if (!tblgen_reassociation) return emitOpError("requires attribute 'reassociation'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps0(*this, tblgen_reassociation, "reassociation"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult CollapseShapeOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult CollapseShapeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand srcRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcOperands(srcRawOperands); ::llvm::SMLoc srcOperandsLoc; + (void)srcOperandsLoc; + ::mlir::ArrayAttr reassociationAttr; + ::mlir::Type srcRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> srcTypes(srcRawTypes); + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + srcOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(srcRawOperands[0])) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(reassociationAttr, parser.getBuilder().getType<::mlir::NoneType>())) { + return ::mlir::failure(); + } + if (reassociationAttr) result.getOrAddProperties().reassociation = reassociationAttr; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::RankedTensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + srcRawTypes[0] = type; + } + if (parser.parseKeyword("into")) + return ::mlir::failure(); + + { + ::mlir::RankedTensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(srcOperands, srcTypes, srcOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CollapseShapeOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getSrc(); + _odsPrinter << ' '; + _odsPrinter.printAttributeWithoutType(getReassociationAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("reassociation"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getSrc().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::RankedTensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "into"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::RankedTensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void CollapseShapeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::tensor::CollapseShapeOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::DimOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +DimOpGenericAdaptorBase::DimOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("tensor.dim", odsAttrs.getContext()); +} + +DimOpGenericAdaptorBase::DimOpGenericAdaptorBase(DimOp op) : DimOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair DimOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr DimOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +DimOpAdaptor::DimOpAdaptor(DimOp op) : DimOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult DimOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair DimOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range DimOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::TensorType> DimOp::getSource() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::IndexType> DimOp::getIndex() { + return ::llvm::cast<::mlir::TypedValue<::mlir::IndexType>>(*getODSOperands(1).begin()); +} + +::mlir::OpOperand &DimOp::getSourceMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &DimOp::getIndexMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +std::pair DimOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range DimOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::IndexType> DimOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::IndexType>>(*getODSResults(0).begin()); +} + +void DimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::Value index) { + odsState.addOperands(source); + odsState.addOperands(index); + odsState.addTypes(result); +} + +void DimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value source, ::mlir::Value index) { + odsState.addOperands(source); + odsState.addOperands(index); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(DimOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void DimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value index) { + odsState.addOperands(source); + odsState.addOperands(index); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DimOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void DimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(DimOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult DimOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult DimOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::LogicalResult DimOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = odsBuilder.getIndexType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult DimOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(sourceRawOperands); ::llvm::SMLoc sourceOperandsLoc; + (void)sourceOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand indexRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> indexOperands(indexRawOperands); ::llvm::SMLoc indexOperandsLoc; + (void)indexOperandsLoc; + ::mlir::Type sourceRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> sourceTypes(sourceRawTypes); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + + sourceOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(sourceRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + indexOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(indexRawOperands[0])) + return ::mlir::failure(); + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + sourceRawTypes[0] = type; + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + result.addTypes(odsBuildableType0); + if (parser.resolveOperands(sourceOperands, sourceTypes, sourceOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(indexOperands, odsBuildableType0, indexOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void DimOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' '; + _odsPrinter << getSource(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getIndex(); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getSource().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void DimOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::tensor::DimOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::EmptyOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +EmptyOpGenericAdaptorBase::EmptyOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("tensor.empty", odsAttrs.getContext()); +} + +EmptyOpGenericAdaptorBase::EmptyOpGenericAdaptorBase(EmptyOp op) : EmptyOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair EmptyOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr EmptyOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +EmptyOpAdaptor::EmptyOpAdaptor(EmptyOp op) : EmptyOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult EmptyOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair EmptyOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range EmptyOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::operand_range EmptyOp::getDynamicSizes() { + return getODSOperands(0); +} + +::mlir::MutableOperandRange EmptyOp::getDynamicSizesMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair EmptyOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range EmptyOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::RankedTensorType> EmptyOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); +} + +void EmptyOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange dynamicSizes) { + odsState.addOperands(dynamicSizes); + odsState.addTypes(result); +} + +void EmptyOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult EmptyOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult EmptyOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult EmptyOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> dynamicSizesOperands; + ::llvm::SMLoc dynamicSizesOperandsLoc; + (void)dynamicSizesOperandsLoc; + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + if (parser.parseLParen()) + return ::mlir::failure(); + + dynamicSizesOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(dynamicSizesOperands)) + return ::mlir::failure(); + if (parser.parseRParen()) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::RankedTensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + result.addTypes(resultTypes); + if (parser.resolveOperands(dynamicSizesOperands, odsBuildableType0, dynamicSizesOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void EmptyOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << "("; + _odsPrinter << getDynamicSizes(); + _odsPrinter << ")"; + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::RankedTensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void EmptyOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::tensor::EmptyOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::ExpandShapeOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ExpandShapeOpGenericAdaptorBase::ExpandShapeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("tensor.expand_shape", odsAttrs.getContext()); +} + +ExpandShapeOpGenericAdaptorBase::ExpandShapeOpGenericAdaptorBase(ExpandShapeOp op) : ExpandShapeOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ExpandShapeOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ExpandShapeOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::ArrayAttr ExpandShapeOpGenericAdaptorBase::getReassociationAttr() { + auto attr = ::llvm::cast<::mlir::ArrayAttr>(getProperties().reassociation); + return attr; +} + +::mlir::ArrayAttr ExpandShapeOpGenericAdaptorBase::getReassociation() { + auto attr = getReassociationAttr(); + return attr; +} + +} // namespace detail +ExpandShapeOpAdaptor::ExpandShapeOpAdaptor(ExpandShapeOp op) : ExpandShapeOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ExpandShapeOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_reassociation = getProperties().reassociation; (void)tblgen_reassociation; + if (!tblgen_reassociation) return emitError(loc, "'tensor.expand_shape' op ""requires attribute 'reassociation'"); + + if (tblgen_reassociation && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_reassociation))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_reassociation), [&](::mlir::Attribute attr) { return attr && (((::llvm::isa<::mlir::ArrayAttr>(attr))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(attr), [&](::mlir::Attribute attr) { return attr && (((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(64)))); }))); })))) + return emitError(loc, "'tensor.expand_shape' op ""attribute 'reassociation' failed to satisfy constraint: Array of 64-bit integer array attributes"); + return ::mlir::success(); +} + +std::pair ExpandShapeOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ExpandShapeOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::RankedTensorType> ExpandShapeOp::getSrc() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &ExpandShapeOp::getSrcMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair ExpandShapeOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ExpandShapeOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::RankedTensorType> ExpandShapeOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult ExpandShapeOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.reassociation; + auto attr = dict.get("reassociation"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for reassociation in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `reassociation` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ExpandShapeOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.reassociation; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("reassociation", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ExpandShapeOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.reassociation.getAsOpaquePointer())); +} + +std::optional ExpandShapeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "reassociation") + return prop.reassociation; + return std::nullopt; +} + +void ExpandShapeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "reassociation") { + prop.reassociation = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ExpandShapeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.reassociation) attrs.append("reassociation", prop.reassociation); +} + +::mlir::LogicalResult ExpandShapeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getReassociationAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps0(attr, "reassociation", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ExpandShapeOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.reassociation))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ExpandShapeOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.reassociation); +} + +::mlir::ArrayAttr ExpandShapeOp::getReassociationAttr() { + return ::llvm::cast<::mlir::ArrayAttr>(getProperties().reassociation); +} + +::mlir::ArrayAttr ExpandShapeOp::getReassociation() { + auto attr = getReassociationAttr(); + return attr; +} + +void ExpandShapeOp::setReassociationAttr(::mlir::ArrayAttr attr) { + (*this)->setAttr(getReassociationAttrName(), attr); +} + +void ExpandShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType, Value src, ArrayRef reassociation, ArrayRef attrs) { + build(odsBuilder, odsState, resultType, src, attrs); + odsState.addAttribute("reassociation", + getReassociationIndicesAttribute(odsBuilder, reassociation)); + +} + +void ExpandShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType, Value src, ArrayRef reassociation, ArrayRef attrs) { + auto reassociationMaps = + convertReassociationMapsToIndices(odsBuilder, reassociation); + build(odsBuilder, odsState, resultType, src, reassociationMaps, attrs); + +} + +void ExpandShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value src, ::mlir::ArrayAttr reassociation) { + odsState.addOperands(src); + odsState.getOrAddProperties().reassociation = reassociation; + odsState.addTypes(result); +} + +void ExpandShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::ArrayAttr reassociation) { + odsState.addOperands(src); + odsState.getOrAddProperties().reassociation = reassociation; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ExpandShapeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ExpandShapeOp::verifyInvariantsImpl() { + auto tblgen_reassociation = getProperties().reassociation; (void)tblgen_reassociation; + if (!tblgen_reassociation) return emitOpError("requires attribute 'reassociation'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps0(*this, tblgen_reassociation, "reassociation"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ExpandShapeOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult ExpandShapeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand srcRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcOperands(srcRawOperands); ::llvm::SMLoc srcOperandsLoc; + (void)srcOperandsLoc; + ::mlir::ArrayAttr reassociationAttr; + ::mlir::Type srcRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> srcTypes(srcRawTypes); + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + srcOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(srcRawOperands[0])) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(reassociationAttr, parser.getBuilder().getType<::mlir::NoneType>())) { + return ::mlir::failure(); + } + if (reassociationAttr) result.getOrAddProperties().reassociation = reassociationAttr; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::RankedTensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + srcRawTypes[0] = type; + } + if (parser.parseKeyword("into")) + return ::mlir::failure(); + + { + ::mlir::RankedTensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(srcOperands, srcTypes, srcOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ExpandShapeOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getSrc(); + _odsPrinter << ' '; + _odsPrinter.printAttributeWithoutType(getReassociationAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("reassociation"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getSrc().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::RankedTensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "into"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::RankedTensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void ExpandShapeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::tensor::ExpandShapeOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::ExtractOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ExtractOpGenericAdaptorBase::ExtractOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("tensor.extract", odsAttrs.getContext()); +} + +ExtractOpGenericAdaptorBase::ExtractOpGenericAdaptorBase(ExtractOp op) : ExtractOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ExtractOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr ExtractOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +ExtractOpAdaptor::ExtractOpAdaptor(ExtractOp op) : ExtractOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ExtractOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair ExtractOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range ExtractOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::RankedTensorType> ExtractOp::getTensor() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); +} + +::mlir::Operation::operand_range ExtractOp::getIndices() { + return getODSOperands(1); +} + +::mlir::OpOperand &ExtractOp::getTensorMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange ExtractOp::getIndicesMutable() { + auto range = getODSOperandIndexAndLength(1); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair ExtractOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ExtractOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value ExtractOp::getResult() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +void ExtractOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value tensor, ::mlir::ValueRange indices) { + odsState.addOperands(tensor); + odsState.addOperands(indices); + odsState.addTypes(result); +} + +void ExtractOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value tensor, ::mlir::ValueRange indices) { + odsState.addOperands(tensor); + odsState.addOperands(indices); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ExtractOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void ExtractOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tensor, ::mlir::ValueRange indices) { + odsState.addOperands(tensor); + odsState.addOperands(indices); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ExtractOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ExtractOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ExtractOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult ExtractOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps4(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((std::equal_to<>()(::llvm::cast((*this->getODSOperands(0).begin()).getType()).getElementType(), (*this->getODSResults(0).begin()).getType())))) + return emitOpError("failed to verify that result type matches element type of tensor"); + return ::mlir::success(); +} + +::mlir::LogicalResult ExtractOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::LogicalResult ExtractOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = ::llvm::cast(operands[0].getType()).getElementType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult ExtractOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand tensorRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> tensorOperands(tensorRawOperands); ::llvm::SMLoc tensorOperandsLoc; + (void)tensorOperandsLoc; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> indicesOperands; + ::llvm::SMLoc indicesOperandsLoc; + (void)indicesOperandsLoc; + ::mlir::Type tensorRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> tensorTypes(tensorRawTypes); + + tensorOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(tensorRawOperands[0])) + return ::mlir::failure(); + if (parser.parseLSquare()) + return ::mlir::failure(); + + indicesOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(indicesOperands)) + return ::mlir::failure(); + if (parser.parseRSquare()) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::RankedTensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + tensorRawTypes[0] = type; + } + for (::mlir::Type type : tensorTypes) { + (void)type; + if (!(((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return (true); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return parser.emitError(parser.getNameLoc()) << "'tensor' must be ranked tensor of any type values, but got " << type; + } + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + result.addTypes(::llvm::cast(tensorTypes[0]).getElementType()); + if (parser.resolveOperands(tensorOperands, tensorTypes, tensorOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(indicesOperands, odsBuildableType0, indicesOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ExtractOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getTensor(); + _odsPrinter << "["; + _odsPrinter << getIndices(); + _odsPrinter << "]"; + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getTensor().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::RankedTensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void ExtractOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::tensor::ExtractOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::ExtractSliceOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ExtractSliceOpGenericAdaptorBase::ExtractSliceOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("tensor.extract_slice", odsAttrs.getContext()); +} + +ExtractSliceOpGenericAdaptorBase::ExtractSliceOpGenericAdaptorBase(ExtractSliceOp op) : ExtractSliceOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ExtractSliceOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; + + unsigned start = 0; + for (unsigned i = 0; i < index; ++i) + start += sizeAttr[i]; + return {start, sizeAttr[index]}; +} + +::mlir::DictionaryAttr ExtractSliceOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::DenseI64ArrayAttr ExtractSliceOpGenericAdaptorBase::getStaticOffsetsAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().static_offsets); + return attr; +} + +::llvm::ArrayRef ExtractSliceOpGenericAdaptorBase::getStaticOffsets() { + auto attr = getStaticOffsetsAttr(); + return attr; +} + +::mlir::DenseI64ArrayAttr ExtractSliceOpGenericAdaptorBase::getStaticSizesAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().static_sizes); + return attr; +} + +::llvm::ArrayRef ExtractSliceOpGenericAdaptorBase::getStaticSizes() { + auto attr = getStaticSizesAttr(); + return attr; +} + +::mlir::DenseI64ArrayAttr ExtractSliceOpGenericAdaptorBase::getStaticStridesAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().static_strides); + return attr; +} + +::llvm::ArrayRef ExtractSliceOpGenericAdaptorBase::getStaticStrides() { + auto attr = getStaticStridesAttr(); + return attr; +} + +} // namespace detail +ExtractSliceOpAdaptor::ExtractSliceOpAdaptor(ExtractSliceOp op) : ExtractSliceOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ExtractSliceOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_static_offsets = getProperties().static_offsets; (void)tblgen_static_offsets; + if (!tblgen_static_offsets) return emitError(loc, "'tensor.extract_slice' op ""requires attribute 'static_offsets'"); + auto tblgen_static_sizes = getProperties().static_sizes; (void)tblgen_static_sizes; + if (!tblgen_static_sizes) return emitError(loc, "'tensor.extract_slice' op ""requires attribute 'static_sizes'"); + auto tblgen_static_strides = getProperties().static_strides; (void)tblgen_static_strides; + if (!tblgen_static_strides) return emitError(loc, "'tensor.extract_slice' op ""requires attribute 'static_strides'"); + + if (tblgen_static_offsets && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_static_offsets)))) + return emitError(loc, "'tensor.extract_slice' op ""attribute 'static_offsets' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_static_sizes && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_static_sizes)))) + return emitError(loc, "'tensor.extract_slice' op ""attribute 'static_sizes' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_static_strides && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_static_strides)))) + return emitError(loc, "'tensor.extract_slice' op ""attribute 'static_strides' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +std::pair ExtractSliceOp::getODSOperandIndexAndLength(unsigned index) { + ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; + + unsigned start = 0; + for (unsigned i = 0; i < index; ++i) + start += sizeAttr[i]; + return {start, sizeAttr[index]}; +} + +::mlir::Operation::operand_range ExtractSliceOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::RankedTensorType> ExtractSliceOp::getSource() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); +} + +::mlir::Operation::operand_range ExtractSliceOp::getOffsets() { + return getODSOperands(1); +} + +::mlir::Operation::operand_range ExtractSliceOp::getSizes() { + return getODSOperands(2); +} + +::mlir::Operation::operand_range ExtractSliceOp::getStrides() { + return getODSOperands(3); +} + +::mlir::OpOperand &ExtractSliceOp::getSourceMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange ExtractSliceOp::getOffsetsMutable() { + auto range = getODSOperandIndexAndLength(1); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); + return mutableRange; +} + +::mlir::MutableOperandRange ExtractSliceOp::getSizesMutable() { + auto range = getODSOperandIndexAndLength(2); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); + return mutableRange; +} + +::mlir::MutableOperandRange ExtractSliceOp::getStridesMutable() { + auto range = getODSOperandIndexAndLength(3); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); + return mutableRange; +} + +std::pair ExtractSliceOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ExtractSliceOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::RankedTensorType> ExtractSliceOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult ExtractSliceOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.static_offsets; + auto attr = dict.get("static_offsets"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for static_offsets in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `static_offsets` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.static_sizes; + auto attr = dict.get("static_sizes"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for static_sizes in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `static_sizes` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.static_strides; + auto attr = dict.get("static_strides"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for static_strides in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `static_strides` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } +; + { + auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, + ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return convertFromAttribute(propStorage, propAttr, emitError);; + }; + auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; + if (!attr) { + emitError() << "expected key entry for operandSegmentSizes in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + if (::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute ExtractSliceOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.static_offsets; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("static_offsets", + propStorage)); + } + + { + const auto &propStorage = prop.static_sizes; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("static_sizes", + propStorage)); + } + + { + const auto &propStorage = prop.static_strides; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("static_strides", + propStorage)); + } + + { + const auto &propStorage = prop.operandSegmentSizes; + attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", + ::mlir::DenseI32ArrayAttr::get(ctx, propStorage))); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ExtractSliceOp::computePropertiesHash(const Properties &prop) { + auto hash_operandSegmentSizes = [] (const auto &propStorage) -> llvm::hash_code { + return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; + }; + return llvm::hash_combine( + llvm::hash_value(prop.static_offsets.getAsOpaquePointer()), + llvm::hash_value(prop.static_sizes.getAsOpaquePointer()), + llvm::hash_value(prop.static_strides.getAsOpaquePointer()), + hash_operandSegmentSizes(prop.operandSegmentSizes)); +} + +std::optional ExtractSliceOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "static_offsets") + return prop.static_offsets; + + if (name == "static_sizes") + return prop.static_sizes; + + if (name == "static_strides") + return prop.static_strides; + if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); + return std::nullopt; +} + +void ExtractSliceOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "static_offsets") { + prop.static_offsets = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "static_sizes") { + prop.static_sizes = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "static_strides") { + prop.static_strides = ::llvm::dyn_cast_or_null>(value); + return; + } + if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { + auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); + if (!arrAttr) return; + if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) + return; + llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); + return; + } +} + +void ExtractSliceOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.static_offsets) attrs.append("static_offsets", prop.static_offsets); + + if (prop.static_sizes) attrs.append("static_sizes", prop.static_sizes); + + if (prop.static_strides) attrs.append("static_strides", prop.static_strides); + attrs.append("operandSegmentSizes", ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes)); +} + +::mlir::LogicalResult ExtractSliceOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getStaticOffsetsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(attr, "static_offsets", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getStaticSizesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(attr, "static_sizes", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getStaticStridesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(attr, "static_strides", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ExtractSliceOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.static_offsets))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.static_sizes))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.static_strides))) + return ::mlir::failure(); + + { + auto &propStorage = prop.operandSegmentSizes; + auto readProp = [&]() { + +if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { + ::mlir::DenseI32ArrayAttr attr; + if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); + if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { + reader.emitError("size mismatch for operand/result_segment_size"); + return ::mlir::failure(); + } + ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); +} else { + return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); +} +; + return ::mlir::success(); + }; + if (::mlir::failed(readProp())) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +void ExtractSliceOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.static_offsets); + writer.writeAttribute(prop.static_sizes); + writer.writeAttribute(prop.static_strides); + + { + auto &propStorage = prop.operandSegmentSizes; + +if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) + writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(getContext(), propStorage)); +else + writer.writeSparseArray(::llvm::ArrayRef(propStorage)); +; + } +} + +::mlir::DenseI64ArrayAttr ExtractSliceOp::getStaticOffsetsAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().static_offsets); +} + +::llvm::ArrayRef ExtractSliceOp::getStaticOffsets() { + auto attr = getStaticOffsetsAttr(); + return attr; +} + +::mlir::DenseI64ArrayAttr ExtractSliceOp::getStaticSizesAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().static_sizes); +} + +::llvm::ArrayRef ExtractSliceOp::getStaticSizes() { + auto attr = getStaticSizesAttr(); + return attr; +} + +::mlir::DenseI64ArrayAttr ExtractSliceOp::getStaticStridesAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().static_strides); +} + +::llvm::ArrayRef ExtractSliceOp::getStaticStrides() { + auto attr = getStaticStridesAttr(); + return attr; +} + +void ExtractSliceOp::setStaticOffsetsAttr(::mlir::DenseI64ArrayAttr attr) { + (*this)->setAttr(getStaticOffsetsAttrName(), attr); +} + +void ExtractSliceOp::setStaticOffsets(::llvm::ArrayRef attrValue) { + (*this)->setAttr(getStaticOffsetsAttrName(), ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue)); +} + +void ExtractSliceOp::setStaticSizesAttr(::mlir::DenseI64ArrayAttr attr) { + (*this)->setAttr(getStaticSizesAttrName(), attr); +} + +void ExtractSliceOp::setStaticSizes(::llvm::ArrayRef attrValue) { + (*this)->setAttr(getStaticSizesAttrName(), ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue)); +} + +void ExtractSliceOp::setStaticStridesAttr(::mlir::DenseI64ArrayAttr attr) { + (*this)->setAttr(getStaticStridesAttrName(), attr); +} + +void ExtractSliceOp::setStaticStrides(::llvm::ArrayRef attrValue) { + (*this)->setAttr(getStaticStridesAttrName(), ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue)); +} + +void ExtractSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::mlir::DenseI64ArrayAttr static_offsets, ::mlir::DenseI64ArrayAttr static_sizes, ::mlir::DenseI64ArrayAttr static_strides) { + odsState.addOperands(source); + odsState.addOperands(offsets); + odsState.addOperands(sizes); + odsState.addOperands(strides); + ::llvm::copy(::llvm::ArrayRef({1, static_cast(offsets.size()), static_cast(sizes.size()), static_cast(strides.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + odsState.getOrAddProperties().static_offsets = static_offsets; + odsState.getOrAddProperties().static_sizes = static_sizes; + odsState.getOrAddProperties().static_strides = static_strides; + odsState.addTypes(result); +} + +void ExtractSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::mlir::DenseI64ArrayAttr static_offsets, ::mlir::DenseI64ArrayAttr static_sizes, ::mlir::DenseI64ArrayAttr static_strides) { + odsState.addOperands(source); + odsState.addOperands(offsets); + odsState.addOperands(sizes); + odsState.addOperands(strides); + ::llvm::copy(::llvm::ArrayRef({1, static_cast(offsets.size()), static_cast(sizes.size()), static_cast(strides.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + odsState.getOrAddProperties().static_offsets = static_offsets; + odsState.getOrAddProperties().static_sizes = static_sizes; + odsState.getOrAddProperties().static_strides = static_strides; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ExtractSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::llvm::ArrayRef static_offsets, ::llvm::ArrayRef static_sizes, ::llvm::ArrayRef static_strides) { + odsState.addOperands(source); + odsState.addOperands(offsets); + odsState.addOperands(sizes); + odsState.addOperands(strides); + ::llvm::copy(::llvm::ArrayRef({1, static_cast(offsets.size()), static_cast(sizes.size()), static_cast(strides.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + odsState.getOrAddProperties().static_offsets = odsBuilder.getDenseI64ArrayAttr(static_offsets); + odsState.getOrAddProperties().static_sizes = odsBuilder.getDenseI64ArrayAttr(static_sizes); + odsState.getOrAddProperties().static_strides = odsBuilder.getDenseI64ArrayAttr(static_strides); + odsState.addTypes(result); +} + +void ExtractSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::llvm::ArrayRef static_offsets, ::llvm::ArrayRef static_sizes, ::llvm::ArrayRef static_strides) { + odsState.addOperands(source); + odsState.addOperands(offsets); + odsState.addOperands(sizes); + odsState.addOperands(strides); + ::llvm::copy(::llvm::ArrayRef({1, static_cast(offsets.size()), static_cast(sizes.size()), static_cast(strides.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + odsState.getOrAddProperties().static_offsets = odsBuilder.getDenseI64ArrayAttr(static_offsets); + odsState.getOrAddProperties().static_sizes = odsBuilder.getDenseI64ArrayAttr(static_sizes); + odsState.getOrAddProperties().static_strides = odsBuilder.getDenseI64ArrayAttr(static_strides); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ExtractSliceOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ExtractSliceOp::verifyInvariantsImpl() { + auto tblgen_static_offsets = getProperties().static_offsets; (void)tblgen_static_offsets; + if (!tblgen_static_offsets) return emitOpError("requires attribute 'static_offsets'"); + auto tblgen_static_sizes = getProperties().static_sizes; (void)tblgen_static_sizes; + if (!tblgen_static_sizes) return emitOpError("requires attribute 'static_sizes'"); + auto tblgen_static_strides = getProperties().static_strides; (void)tblgen_static_strides; + if (!tblgen_static_strides) return emitOpError("requires attribute 'static_strides'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(*this, tblgen_static_offsets, "static_offsets"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(*this, tblgen_static_sizes, "static_sizes"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(*this, tblgen_static_strides, "static_strides"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup3 = getODSOperands(3); + + for (auto v : valueGroup3) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ExtractSliceOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult ExtractSliceOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(sourceRawOperands); ::llvm::SMLoc sourceOperandsLoc; + (void)sourceOperandsLoc; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> offsetsOperands; + ::llvm::SMLoc offsetsOperandsLoc; + (void)offsetsOperandsLoc; + ::mlir::DenseI64ArrayAttr static_offsetsAttr; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> sizesOperands; + ::llvm::SMLoc sizesOperandsLoc; + (void)sizesOperandsLoc; + ::mlir::DenseI64ArrayAttr static_sizesAttr; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> stridesOperands; + ::llvm::SMLoc stridesOperandsLoc; + (void)stridesOperandsLoc; + ::mlir::DenseI64ArrayAttr static_stridesAttr; + ::mlir::Type sourceRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> sourceTypes(sourceRawTypes); + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + sourceOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(sourceRawOperands[0])) + return ::mlir::failure(); + { + offsetsOperandsLoc = parser.getCurrentLocation(); + auto odsResult = parseDynamicIndexList(parser, offsetsOperands, static_offsetsAttr); + if (odsResult) return ::mlir::failure(); + result.getOrAddProperties().static_offsets = static_offsetsAttr; + } + { + sizesOperandsLoc = parser.getCurrentLocation(); + auto odsResult = parseDynamicIndexList(parser, sizesOperands, static_sizesAttr); + if (odsResult) return ::mlir::failure(); + result.getOrAddProperties().static_sizes = static_sizesAttr; + } + { + stridesOperandsLoc = parser.getCurrentLocation(); + auto odsResult = parseDynamicIndexList(parser, stridesOperands, static_stridesAttr); + if (odsResult) return ::mlir::failure(); + result.getOrAddProperties().static_strides = static_stridesAttr; + } + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::RankedTensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + sourceRawTypes[0] = type; + } + if (parser.parseKeyword("to")) + return ::mlir::failure(); + + { + ::mlir::RankedTensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } +::llvm::copy(::llvm::ArrayRef({1, static_cast(offsetsOperands.size()), static_cast(sizesOperands.size()), static_cast(stridesOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + result.addTypes(resultTypes); + if (parser.resolveOperands(sourceOperands, sourceTypes, sourceOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(offsetsOperands, odsBuildableType0, offsetsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(sizesOperands, odsBuildableType0, sizesOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(stridesOperands, odsBuildableType0, stridesOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ExtractSliceOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getSource(); + printDynamicIndexList(_odsPrinter, *this, getOffsets(), getStaticOffsetsAttr()); + _odsPrinter << ' '; + printDynamicIndexList(_odsPrinter, *this, getSizes(), getStaticSizesAttr()); + _odsPrinter << ' '; + printDynamicIndexList(_odsPrinter, *this, getStrides(), getStaticStridesAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("operandSegmentSizes"); + elidedAttrs.push_back("static_offsets"); + elidedAttrs.push_back("static_sizes"); + elidedAttrs.push_back("static_strides"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getSource().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::RankedTensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "to"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::RankedTensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void ExtractSliceOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::tensor::ExtractSliceOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::FromElementsOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +FromElementsOpGenericAdaptorBase::FromElementsOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("tensor.from_elements", odsAttrs.getContext()); +} + +FromElementsOpGenericAdaptorBase::FromElementsOpGenericAdaptorBase(FromElementsOp op) : FromElementsOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair FromElementsOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr FromElementsOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +FromElementsOpAdaptor::FromElementsOpAdaptor(FromElementsOp op) : FromElementsOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult FromElementsOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair FromElementsOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range FromElementsOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::operand_range FromElementsOp::getElements() { + return getODSOperands(0); +} + +::mlir::MutableOperandRange FromElementsOp::getElementsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair FromElementsOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range FromElementsOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::RankedTensorType> FromElementsOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); +} + +void FromElementsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange elements) { + odsState.addOperands(elements); + odsState.addTypes(result); +} + +void FromElementsOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult FromElementsOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps4(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps5(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((std::equal_to<>()(SmallVector(::llvm::cast((*this->getODSResults(0).begin()).getType()).getNumElements(), ::llvm::cast((*this->getODSResults(0).begin()).getType()).getElementType()), this->getODSOperands(0).getType())))) + return emitOpError("failed to verify that operand types match result element type"); + return ::mlir::success(); +} + +::mlir::LogicalResult FromElementsOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult FromElementsOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> elementsOperands; + ::llvm::SMLoc elementsOperandsLoc; + (void)elementsOperandsLoc; + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + elementsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(elementsOperands)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::RankedTensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + for (::mlir::Type type : resultTypes) { + (void)type; + if (!((((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::cast<::mlir::ShapedType>(type).hasStaticShape()))) && ([](::mlir::Type elementType) { return (true); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return parser.emitError(parser.getNameLoc()) << "'result' must be statically shaped tensor of any type values, but got " << type; + } + } + result.addTypes(resultTypes); + if (parser.resolveOperands(elementsOperands, SmallVector(::llvm::cast(resultTypes[0]).getNumElements(), ::llvm::cast(resultTypes[0]).getElementType()), elementsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void FromElementsOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getElements(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::RankedTensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void FromElementsOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::tensor::FromElementsOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::GatherOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +GatherOpGenericAdaptorBase::GatherOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("tensor.gather", odsAttrs.getContext()); +} + +GatherOpGenericAdaptorBase::GatherOpGenericAdaptorBase(GatherOp op) : GatherOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair GatherOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr GatherOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::DenseI64ArrayAttr GatherOpGenericAdaptorBase::getGatherDimsAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().gather_dims); + return attr; +} + +::llvm::ArrayRef GatherOpGenericAdaptorBase::getGatherDims() { + auto attr = getGatherDimsAttr(); + return attr; +} + +::mlir::UnitAttr GatherOpGenericAdaptorBase::getUniqueAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().unique); + if (!attr) + attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); + return attr; +} + +bool GatherOpGenericAdaptorBase::getUnique() { + auto attr = getUniqueAttr(); + if (!attr) + return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; + return attr != nullptr; +} + +} // namespace detail +GatherOpAdaptor::GatherOpAdaptor(GatherOp op) : GatherOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult GatherOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_gather_dims = getProperties().gather_dims; (void)tblgen_gather_dims; + if (!tblgen_gather_dims) return emitError(loc, "'tensor.gather' op ""requires attribute 'gather_dims'"); + auto tblgen_unique = getProperties().unique; (void)tblgen_unique; + + if (tblgen_gather_dims && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_gather_dims)))) + return emitError(loc, "'tensor.gather' op ""attribute 'gather_dims' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_unique && !((::llvm::isa<::mlir::UnitAttr>(tblgen_unique)))) + return emitError(loc, "'tensor.gather' op ""attribute 'unique' failed to satisfy constraint: unit attribute"); + return ::mlir::success(); +} + +std::pair GatherOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range GatherOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::RankedTensorType> GatherOp::getSource() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::RankedTensorType> GatherOp::getIndices() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); +} + +::mlir::OpOperand &GatherOp::getSourceMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &GatherOp::getIndicesMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +std::pair GatherOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range GatherOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::RankedTensorType> GatherOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult GatherOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.gather_dims; + auto attr = dict.get("gather_dims"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for gather_dims in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `gather_dims` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.unique; + auto attr = dict.get("unique"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for unique in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `unique` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute GatherOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.gather_dims; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("gather_dims", + propStorage)); + } + + { + const auto &propStorage = prop.unique; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("unique", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code GatherOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.gather_dims.getAsOpaquePointer()), + llvm::hash_value(prop.unique.getAsOpaquePointer())); +} + +std::optional GatherOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "gather_dims") + return prop.gather_dims; + + if (name == "unique") + return prop.unique; + return std::nullopt; +} + +void GatherOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "gather_dims") { + prop.gather_dims = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "unique") { + prop.unique = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void GatherOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.gather_dims) attrs.append("gather_dims", prop.gather_dims); + + if (prop.unique) attrs.append("unique", prop.unique); +} + +::mlir::LogicalResult GatherOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getGatherDimsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(attr, "gather_dims", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getUniqueAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps2(attr, "unique", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult GatherOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.gather_dims))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.unique))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void GatherOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.gather_dims); + + writer.writeOptionalAttribute(prop.unique); +} + +::mlir::DenseI64ArrayAttr GatherOp::getGatherDimsAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().gather_dims); +} + +::llvm::ArrayRef GatherOp::getGatherDims() { + auto attr = getGatherDimsAttr(); + return attr; +} + +::mlir::UnitAttr GatherOp::getUniqueAttr() { + return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().unique); +} + +bool GatherOp::getUnique() { + auto attr = getUniqueAttr(); + if (!attr) + return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; + return attr != nullptr; +} + +void GatherOp::setGatherDimsAttr(::mlir::DenseI64ArrayAttr attr) { + (*this)->setAttr(getGatherDimsAttrName(), attr); +} + +void GatherOp::setGatherDims(::llvm::ArrayRef attrValue) { + (*this)->setAttr(getGatherDimsAttrName(), ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue)); +} + +void GatherOp::setUniqueAttr(::mlir::UnitAttr attr) { + (*this)->setAttr(getUniqueAttrName(), attr); +} + +void GatherOp::setUnique(bool attrValue) { + if (attrValue) + return (*this)->setAttr(getUniqueAttrName(), ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr)); + (*this)->removeAttr(getUniqueAttrName()); +} + +::mlir::Attribute GatherOp::removeUniqueAttr() { + auto &attr = getProperties().unique; + attr = {}; + return attr; +} + +void GatherOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::Value indices, ::mlir::DenseI64ArrayAttr gather_dims, /*optional*/::mlir::UnitAttr unique) { + odsState.addOperands(source); + odsState.addOperands(indices); + odsState.getOrAddProperties().gather_dims = gather_dims; + if (unique) { + odsState.getOrAddProperties().unique = unique; + } + odsState.addTypes(result); +} + +void GatherOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value indices, ::mlir::DenseI64ArrayAttr gather_dims, /*optional*/::mlir::UnitAttr unique) { + odsState.addOperands(source); + odsState.addOperands(indices); + odsState.getOrAddProperties().gather_dims = gather_dims; + if (unique) { + odsState.getOrAddProperties().unique = unique; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void GatherOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::Value indices, ::llvm::ArrayRef gather_dims, /*optional*/bool unique) { + odsState.addOperands(source); + odsState.addOperands(indices); + odsState.getOrAddProperties().gather_dims = odsBuilder.getDenseI64ArrayAttr(gather_dims); + if (unique) { + odsState.getOrAddProperties().unique = ((unique) ? odsBuilder.getUnitAttr() : nullptr); + } + odsState.addTypes(result); +} + +void GatherOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value indices, ::llvm::ArrayRef gather_dims, /*optional*/bool unique) { + odsState.addOperands(source); + odsState.addOperands(indices); + odsState.getOrAddProperties().gather_dims = odsBuilder.getDenseI64ArrayAttr(gather_dims); + if (unique) { + odsState.getOrAddProperties().unique = ((unique) ? odsBuilder.getUnitAttr() : nullptr); + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void GatherOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult GatherOp::verifyInvariantsImpl() { + auto tblgen_gather_dims = getProperties().gather_dims; (void)tblgen_gather_dims; + if (!tblgen_gather_dims) return emitOpError("requires attribute 'gather_dims'"); + auto tblgen_unique = getProperties().unique; (void)tblgen_unique; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(*this, tblgen_gather_dims, "gather_dims"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps2(*this, tblgen_unique, "unique"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult GatherOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult GatherOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(sourceRawOperands); ::llvm::SMLoc sourceOperandsLoc; + (void)sourceOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand indicesRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> indicesOperands(indicesRawOperands); ::llvm::SMLoc indicesOperandsLoc; + (void)indicesOperandsLoc; + ::mlir::DenseI64ArrayAttr gather_dimsAttr; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + + sourceOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(sourceRawOperands[0])) + return ::mlir::failure(); + if (parser.parseLSquare()) + return ::mlir::failure(); + + indicesOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(indicesRawOperands[0])) + return ::mlir::failure(); + if (parser.parseRSquare()) + return ::mlir::failure(); + if (parser.parseKeyword("gather_dims")) + return ::mlir::failure(); + if (parser.parseLParen()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(gather_dimsAttr, ::mlir::Type{})) { + return ::mlir::failure(); + } + if (gather_dimsAttr) result.getOrAddProperties().gather_dims = gather_dimsAttr; + if (parser.parseRParen()) + return ::mlir::failure(); + if (::mlir::succeeded(parser.parseOptionalKeyword("unique"))) { + result.getOrAddProperties().unique = parser.getBuilder().getUnitAttr(); } + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(::llvm::concat(sourceOperands, indicesOperands), allOperandTypes, parser.getNameLoc(), result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void GatherOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getSource(); + _odsPrinter << "["; + _odsPrinter << getIndices(); + _odsPrinter << "]"; + _odsPrinter << ' ' << "gather_dims"; + _odsPrinter << "("; +_odsPrinter.printStrippedAttrOrType(getGatherDimsAttr()); + _odsPrinter << ")"; + if (getUniqueAttr()) { + _odsPrinter << ' ' << "unique"; + } + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("gather_dims"); + elidedAttrs.push_back("unique"); + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getUniqueAttr(); + if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) + elidedAttrs.push_back("unique"); + } + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +void GatherOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::tensor::GatherOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::GenerateOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +GenerateOpGenericAdaptorBase::GenerateOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("tensor.generate", odsAttrs.getContext()); +} + +GenerateOpGenericAdaptorBase::GenerateOpGenericAdaptorBase(GenerateOp op) : GenerateOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair GenerateOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr GenerateOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::Region &GenerateOpGenericAdaptorBase::getBody() { + return *odsRegions[0]; +} + +::mlir::RegionRange GenerateOpGenericAdaptorBase::getRegions() { + return odsRegions; +} + +} // namespace detail +GenerateOpAdaptor::GenerateOpAdaptor(GenerateOp op) : GenerateOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult GenerateOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair GenerateOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range GenerateOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::operand_range GenerateOp::getDynamicExtents() { + return getODSOperands(0); +} + +::mlir::MutableOperandRange GenerateOp::getDynamicExtentsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair GenerateOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range GenerateOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::RankedTensorType> GenerateOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); +} + +::mlir::Region &GenerateOp::getBody() { + return (*this)->getRegion(0); +} + +void GenerateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange dynamicExtents) { + odsState.addOperands(dynamicExtents); + (void)odsState.addRegion(); + odsState.addTypes(result); +} + +void GenerateOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult GenerateOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_TensorOps0(*this, region, "body", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult GenerateOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult GenerateOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> dynamicExtentsOperands; + ::llvm::SMLoc dynamicExtentsOperandsLoc; + (void)dynamicExtentsOperandsLoc; + std::unique_ptr<::mlir::Region> bodyRegion = std::make_unique<::mlir::Region>(); + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + dynamicExtentsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(dynamicExtentsOperands)) + return ::mlir::failure(); + + if (parser.parseRegion(*bodyRegion)) + return ::mlir::failure(); + + ensureTerminator(*bodyRegion, parser.getBuilder(), result.location); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::RankedTensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + result.addRegion(std::move(bodyRegion)); + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + result.addTypes(resultTypes); + if (parser.resolveOperands(dynamicExtentsOperands, odsBuildableType0, dynamicExtentsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void GenerateOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getDynamicExtents(); + _odsPrinter << ' '; + + { + bool printTerminator = true; + if (auto *term = getBody().empty() ? nullptr : getBody().begin()->getTerminator()) { + printTerminator = !term->getAttrDictionary().empty() || + term->getNumOperands() != 0 || + term->getNumResults() != 0; + } + _odsPrinter.printRegion(getBody(), /*printEntryBlockArgs=*/true, + /*printBlockTerminators=*/printTerminator); + } + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::RankedTensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +} // namespace tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::tensor::GenerateOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::InsertOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +InsertOpGenericAdaptorBase::InsertOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("tensor.insert", odsAttrs.getContext()); +} + +InsertOpGenericAdaptorBase::InsertOpGenericAdaptorBase(InsertOp op) : InsertOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair InsertOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 2) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr InsertOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +InsertOpAdaptor::InsertOpAdaptor(InsertOp op) : InsertOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult InsertOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair InsertOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 2) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range InsertOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value InsertOp::getScalar() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::RankedTensorType> InsertOp::getDest() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); +} + +::mlir::Operation::operand_range InsertOp::getIndices() { + return getODSOperands(2); +} + +::mlir::OpOperand &InsertOp::getScalarMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &InsertOp::getDestMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange InsertOp::getIndicesMutable() { + auto range = getODSOperandIndexAndLength(2); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair InsertOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range InsertOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::RankedTensorType> InsertOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); +} + +void InsertOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value scalar, ::mlir::Value dest, ::mlir::ValueRange indices) { + odsState.addOperands(scalar); + odsState.addOperands(dest); + odsState.addOperands(indices); + odsState.addTypes(result); +} + +void InsertOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value scalar, ::mlir::Value dest, ::mlir::ValueRange indices) { + odsState.addOperands(scalar); + odsState.addOperands(dest); + odsState.addOperands(indices); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(InsertOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void InsertOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value scalar, ::mlir::Value dest, ::mlir::ValueRange indices) { + odsState.addOperands(scalar); + odsState.addOperands(dest); + odsState.addOperands(indices); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void InsertOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void InsertOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(InsertOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult InsertOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps4(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((std::equal_to<>()((*this->getODSOperands(1).begin()).getType(), (*this->getODSResults(0).begin()).getType())))) + return emitOpError("failed to verify that result type matches type of dest"); + if (!((std::equal_to<>()(::llvm::cast((*this->getODSOperands(1).begin()).getType()).getElementType(), (*this->getODSOperands(0).begin()).getType())))) + return emitOpError("failed to verify that scalar type matches element type of dest"); + return ::mlir::success(); +} + +::mlir::LogicalResult InsertOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::LogicalResult InsertOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = operands[1].getType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult InsertOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand scalarRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> scalarOperands(scalarRawOperands); ::llvm::SMLoc scalarOperandsLoc; + (void)scalarOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand destRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> destOperands(destRawOperands); ::llvm::SMLoc destOperandsLoc; + (void)destOperandsLoc; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> indicesOperands; + ::llvm::SMLoc indicesOperandsLoc; + (void)indicesOperandsLoc; + ::mlir::Type destRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> destTypes(destRawTypes); + + scalarOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(scalarRawOperands[0])) + return ::mlir::failure(); + if (parser.parseKeyword("into")) + return ::mlir::failure(); + + destOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(destRawOperands[0])) + return ::mlir::failure(); + if (parser.parseLSquare()) + return ::mlir::failure(); + + indicesOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(indicesOperands)) + return ::mlir::failure(); + if (parser.parseRSquare()) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::RankedTensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + destRawTypes[0] = type; + } + for (::mlir::Type type : destTypes) { + (void)type; + if (!(((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return (true); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return parser.emitError(parser.getNameLoc()) << "'dest' must be ranked tensor of any type values, but got " << type; + } + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + result.addTypes(destTypes[0]); + if (parser.resolveOperands(scalarOperands, ::llvm::cast(destTypes[0]).getElementType(), scalarOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(destOperands, destTypes, destOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(indicesOperands, odsBuildableType0, indicesOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void InsertOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getScalar(); + _odsPrinter << ' ' << "into"; + _odsPrinter << ' '; + _odsPrinter << getDest(); + _odsPrinter << "["; + _odsPrinter << getIndices(); + _odsPrinter << "]"; + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getDest().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::RankedTensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void InsertOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::tensor::InsertOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::InsertSliceOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +InsertSliceOpGenericAdaptorBase::InsertSliceOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("tensor.insert_slice", odsAttrs.getContext()); +} + +InsertSliceOpGenericAdaptorBase::InsertSliceOpGenericAdaptorBase(InsertSliceOp op) : InsertSliceOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair InsertSliceOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; + + unsigned start = 0; + for (unsigned i = 0; i < index; ++i) + start += sizeAttr[i]; + return {start, sizeAttr[index]}; +} + +::mlir::DictionaryAttr InsertSliceOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::DenseI64ArrayAttr InsertSliceOpGenericAdaptorBase::getStaticOffsetsAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().static_offsets); + return attr; +} + +::llvm::ArrayRef InsertSliceOpGenericAdaptorBase::getStaticOffsets() { + auto attr = getStaticOffsetsAttr(); + return attr; +} + +::mlir::DenseI64ArrayAttr InsertSliceOpGenericAdaptorBase::getStaticSizesAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().static_sizes); + return attr; +} + +::llvm::ArrayRef InsertSliceOpGenericAdaptorBase::getStaticSizes() { + auto attr = getStaticSizesAttr(); + return attr; +} + +::mlir::DenseI64ArrayAttr InsertSliceOpGenericAdaptorBase::getStaticStridesAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().static_strides); + return attr; +} + +::llvm::ArrayRef InsertSliceOpGenericAdaptorBase::getStaticStrides() { + auto attr = getStaticStridesAttr(); + return attr; +} + +} // namespace detail +InsertSliceOpAdaptor::InsertSliceOpAdaptor(InsertSliceOp op) : InsertSliceOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult InsertSliceOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_static_offsets = getProperties().static_offsets; (void)tblgen_static_offsets; + if (!tblgen_static_offsets) return emitError(loc, "'tensor.insert_slice' op ""requires attribute 'static_offsets'"); + auto tblgen_static_sizes = getProperties().static_sizes; (void)tblgen_static_sizes; + if (!tblgen_static_sizes) return emitError(loc, "'tensor.insert_slice' op ""requires attribute 'static_sizes'"); + auto tblgen_static_strides = getProperties().static_strides; (void)tblgen_static_strides; + if (!tblgen_static_strides) return emitError(loc, "'tensor.insert_slice' op ""requires attribute 'static_strides'"); + + if (tblgen_static_offsets && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_static_offsets)))) + return emitError(loc, "'tensor.insert_slice' op ""attribute 'static_offsets' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_static_sizes && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_static_sizes)))) + return emitError(loc, "'tensor.insert_slice' op ""attribute 'static_sizes' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_static_strides && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_static_strides)))) + return emitError(loc, "'tensor.insert_slice' op ""attribute 'static_strides' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +std::pair InsertSliceOp::getODSOperandIndexAndLength(unsigned index) { + ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; + + unsigned start = 0; + for (unsigned i = 0; i < index; ++i) + start += sizeAttr[i]; + return {start, sizeAttr[index]}; +} + +::mlir::Operation::operand_range InsertSliceOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::RankedTensorType> InsertSliceOp::getSource() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::RankedTensorType> InsertSliceOp::getDest() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); +} + +::mlir::Operation::operand_range InsertSliceOp::getOffsets() { + return getODSOperands(2); +} + +::mlir::Operation::operand_range InsertSliceOp::getSizes() { + return getODSOperands(3); +} + +::mlir::Operation::operand_range InsertSliceOp::getStrides() { + return getODSOperands(4); +} + +::mlir::OpOperand &InsertSliceOp::getSourceMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &InsertSliceOp::getDestMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange InsertSliceOp::getOffsetsMutable() { + auto range = getODSOperandIndexAndLength(2); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); + return mutableRange; +} + +::mlir::MutableOperandRange InsertSliceOp::getSizesMutable() { + auto range = getODSOperandIndexAndLength(3); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); + return mutableRange; +} + +::mlir::MutableOperandRange InsertSliceOp::getStridesMutable() { + auto range = getODSOperandIndexAndLength(4); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(4u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); + return mutableRange; +} + +std::pair InsertSliceOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range InsertSliceOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::RankedTensorType> InsertSliceOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult InsertSliceOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.static_offsets; + auto attr = dict.get("static_offsets"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for static_offsets in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `static_offsets` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.static_sizes; + auto attr = dict.get("static_sizes"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for static_sizes in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `static_sizes` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.static_strides; + auto attr = dict.get("static_strides"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for static_strides in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `static_strides` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } +; + { + auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, + ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return convertFromAttribute(propStorage, propAttr, emitError);; + }; + auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; + if (!attr) { + emitError() << "expected key entry for operandSegmentSizes in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + if (::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute InsertSliceOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.static_offsets; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("static_offsets", + propStorage)); + } + + { + const auto &propStorage = prop.static_sizes; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("static_sizes", + propStorage)); + } + + { + const auto &propStorage = prop.static_strides; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("static_strides", + propStorage)); + } + + { + const auto &propStorage = prop.operandSegmentSizes; + attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", + ::mlir::DenseI32ArrayAttr::get(ctx, propStorage))); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code InsertSliceOp::computePropertiesHash(const Properties &prop) { + auto hash_operandSegmentSizes = [] (const auto &propStorage) -> llvm::hash_code { + return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; + }; + return llvm::hash_combine( + llvm::hash_value(prop.static_offsets.getAsOpaquePointer()), + llvm::hash_value(prop.static_sizes.getAsOpaquePointer()), + llvm::hash_value(prop.static_strides.getAsOpaquePointer()), + hash_operandSegmentSizes(prop.operandSegmentSizes)); +} + +std::optional InsertSliceOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "static_offsets") + return prop.static_offsets; + + if (name == "static_sizes") + return prop.static_sizes; + + if (name == "static_strides") + return prop.static_strides; + if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); + return std::nullopt; +} + +void InsertSliceOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "static_offsets") { + prop.static_offsets = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "static_sizes") { + prop.static_sizes = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "static_strides") { + prop.static_strides = ::llvm::dyn_cast_or_null>(value); + return; + } + if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { + auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); + if (!arrAttr) return; + if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) + return; + llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); + return; + } +} + +void InsertSliceOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.static_offsets) attrs.append("static_offsets", prop.static_offsets); + + if (prop.static_sizes) attrs.append("static_sizes", prop.static_sizes); + + if (prop.static_strides) attrs.append("static_strides", prop.static_strides); + attrs.append("operandSegmentSizes", ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes)); +} + +::mlir::LogicalResult InsertSliceOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getStaticOffsetsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(attr, "static_offsets", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getStaticSizesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(attr, "static_sizes", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getStaticStridesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(attr, "static_strides", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult InsertSliceOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.static_offsets))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.static_sizes))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.static_strides))) + return ::mlir::failure(); + + { + auto &propStorage = prop.operandSegmentSizes; + auto readProp = [&]() { + +if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { + ::mlir::DenseI32ArrayAttr attr; + if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); + if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { + reader.emitError("size mismatch for operand/result_segment_size"); + return ::mlir::failure(); + } + ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); +} else { + return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); +} +; + return ::mlir::success(); + }; + if (::mlir::failed(readProp())) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +void InsertSliceOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.static_offsets); + writer.writeAttribute(prop.static_sizes); + writer.writeAttribute(prop.static_strides); + + { + auto &propStorage = prop.operandSegmentSizes; + +if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) + writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(getContext(), propStorage)); +else + writer.writeSparseArray(::llvm::ArrayRef(propStorage)); +; + } +} + +::mlir::DenseI64ArrayAttr InsertSliceOp::getStaticOffsetsAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().static_offsets); +} + +::llvm::ArrayRef InsertSliceOp::getStaticOffsets() { + auto attr = getStaticOffsetsAttr(); + return attr; +} + +::mlir::DenseI64ArrayAttr InsertSliceOp::getStaticSizesAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().static_sizes); +} + +::llvm::ArrayRef InsertSliceOp::getStaticSizes() { + auto attr = getStaticSizesAttr(); + return attr; +} + +::mlir::DenseI64ArrayAttr InsertSliceOp::getStaticStridesAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().static_strides); +} + +::llvm::ArrayRef InsertSliceOp::getStaticStrides() { + auto attr = getStaticStridesAttr(); + return attr; +} + +void InsertSliceOp::setStaticOffsetsAttr(::mlir::DenseI64ArrayAttr attr) { + (*this)->setAttr(getStaticOffsetsAttrName(), attr); +} + +void InsertSliceOp::setStaticOffsets(::llvm::ArrayRef attrValue) { + (*this)->setAttr(getStaticOffsetsAttrName(), ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue)); +} + +void InsertSliceOp::setStaticSizesAttr(::mlir::DenseI64ArrayAttr attr) { + (*this)->setAttr(getStaticSizesAttrName(), attr); +} + +void InsertSliceOp::setStaticSizes(::llvm::ArrayRef attrValue) { + (*this)->setAttr(getStaticSizesAttrName(), ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue)); +} + +void InsertSliceOp::setStaticStridesAttr(::mlir::DenseI64ArrayAttr attr) { + (*this)->setAttr(getStaticStridesAttrName(), attr); +} + +void InsertSliceOp::setStaticStrides(::llvm::ArrayRef attrValue) { + (*this)->setAttr(getStaticStridesAttrName(), ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue)); +} + +void InsertSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::Value dest, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::mlir::DenseI64ArrayAttr static_offsets, ::mlir::DenseI64ArrayAttr static_sizes, ::mlir::DenseI64ArrayAttr static_strides) { + odsState.addOperands(source); + odsState.addOperands(dest); + odsState.addOperands(offsets); + odsState.addOperands(sizes); + odsState.addOperands(strides); + ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(offsets.size()), static_cast(sizes.size()), static_cast(strides.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + odsState.getOrAddProperties().static_offsets = static_offsets; + odsState.getOrAddProperties().static_sizes = static_sizes; + odsState.getOrAddProperties().static_strides = static_strides; + odsState.addTypes(result); +} + +void InsertSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value source, ::mlir::Value dest, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::mlir::DenseI64ArrayAttr static_offsets, ::mlir::DenseI64ArrayAttr static_sizes, ::mlir::DenseI64ArrayAttr static_strides) { + odsState.addOperands(source); + odsState.addOperands(dest); + odsState.addOperands(offsets); + odsState.addOperands(sizes); + odsState.addOperands(strides); + ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(offsets.size()), static_cast(sizes.size()), static_cast(strides.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + odsState.getOrAddProperties().static_offsets = static_offsets; + odsState.getOrAddProperties().static_sizes = static_sizes; + odsState.getOrAddProperties().static_strides = static_strides; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(InsertSliceOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void InsertSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::mlir::DenseI64ArrayAttr static_offsets, ::mlir::DenseI64ArrayAttr static_sizes, ::mlir::DenseI64ArrayAttr static_strides) { + odsState.addOperands(source); + odsState.addOperands(dest); + odsState.addOperands(offsets); + odsState.addOperands(sizes); + odsState.addOperands(strides); + ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(offsets.size()), static_cast(sizes.size()), static_cast(strides.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + odsState.getOrAddProperties().static_offsets = static_offsets; + odsState.getOrAddProperties().static_sizes = static_sizes; + odsState.getOrAddProperties().static_strides = static_strides; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void InsertSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::Value dest, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::llvm::ArrayRef static_offsets, ::llvm::ArrayRef static_sizes, ::llvm::ArrayRef static_strides) { + odsState.addOperands(source); + odsState.addOperands(dest); + odsState.addOperands(offsets); + odsState.addOperands(sizes); + odsState.addOperands(strides); + ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(offsets.size()), static_cast(sizes.size()), static_cast(strides.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + odsState.getOrAddProperties().static_offsets = odsBuilder.getDenseI64ArrayAttr(static_offsets); + odsState.getOrAddProperties().static_sizes = odsBuilder.getDenseI64ArrayAttr(static_sizes); + odsState.getOrAddProperties().static_strides = odsBuilder.getDenseI64ArrayAttr(static_strides); + odsState.addTypes(result); +} + +void InsertSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value source, ::mlir::Value dest, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::llvm::ArrayRef static_offsets, ::llvm::ArrayRef static_sizes, ::llvm::ArrayRef static_strides) { + odsState.addOperands(source); + odsState.addOperands(dest); + odsState.addOperands(offsets); + odsState.addOperands(sizes); + odsState.addOperands(strides); + ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(offsets.size()), static_cast(sizes.size()), static_cast(strides.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + odsState.getOrAddProperties().static_offsets = odsBuilder.getDenseI64ArrayAttr(static_offsets); + odsState.getOrAddProperties().static_sizes = odsBuilder.getDenseI64ArrayAttr(static_sizes); + odsState.getOrAddProperties().static_strides = odsBuilder.getDenseI64ArrayAttr(static_strides); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(InsertSliceOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void InsertSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::llvm::ArrayRef static_offsets, ::llvm::ArrayRef static_sizes, ::llvm::ArrayRef static_strides) { + odsState.addOperands(source); + odsState.addOperands(dest); + odsState.addOperands(offsets); + odsState.addOperands(sizes); + odsState.addOperands(strides); + ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(offsets.size()), static_cast(sizes.size()), static_cast(strides.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + odsState.getOrAddProperties().static_offsets = odsBuilder.getDenseI64ArrayAttr(static_offsets); + odsState.getOrAddProperties().static_sizes = odsBuilder.getDenseI64ArrayAttr(static_sizes); + odsState.getOrAddProperties().static_strides = odsBuilder.getDenseI64ArrayAttr(static_strides); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void InsertSliceOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void InsertSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(InsertSliceOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult InsertSliceOp::verifyInvariantsImpl() { + auto tblgen_static_offsets = getProperties().static_offsets; (void)tblgen_static_offsets; + if (!tblgen_static_offsets) return emitOpError("requires attribute 'static_offsets'"); + auto tblgen_static_sizes = getProperties().static_sizes; (void)tblgen_static_sizes; + if (!tblgen_static_sizes) return emitOpError("requires attribute 'static_sizes'"); + auto tblgen_static_strides = getProperties().static_strides; (void)tblgen_static_strides; + if (!tblgen_static_strides) return emitOpError("requires attribute 'static_strides'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(*this, tblgen_static_offsets, "static_offsets"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(*this, tblgen_static_sizes, "static_sizes"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(*this, tblgen_static_strides, "static_strides"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup3 = getODSOperands(3); + + for (auto v : valueGroup3) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup4 = getODSOperands(4); + + for (auto v : valueGroup4) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((std::equal_to<>()((*this->getODSOperands(1).begin()).getType(), (*this->getODSResults(0).begin()).getType())))) + return emitOpError("failed to verify that expected result type to match dest type"); + return ::mlir::success(); +} + +::mlir::LogicalResult InsertSliceOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::LogicalResult InsertSliceOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = operands[1].getType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult InsertSliceOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(sourceRawOperands); ::llvm::SMLoc sourceOperandsLoc; + (void)sourceOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand destRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> destOperands(destRawOperands); ::llvm::SMLoc destOperandsLoc; + (void)destOperandsLoc; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> offsetsOperands; + ::llvm::SMLoc offsetsOperandsLoc; + (void)offsetsOperandsLoc; + ::mlir::DenseI64ArrayAttr static_offsetsAttr; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> sizesOperands; + ::llvm::SMLoc sizesOperandsLoc; + (void)sizesOperandsLoc; + ::mlir::DenseI64ArrayAttr static_sizesAttr; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> stridesOperands; + ::llvm::SMLoc stridesOperandsLoc; + (void)stridesOperandsLoc; + ::mlir::DenseI64ArrayAttr static_stridesAttr; + ::mlir::Type sourceRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> sourceTypes(sourceRawTypes); + ::mlir::Type destRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> destTypes(destRawTypes); + + sourceOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(sourceRawOperands[0])) + return ::mlir::failure(); + if (parser.parseKeyword("into")) + return ::mlir::failure(); + + destOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(destRawOperands[0])) + return ::mlir::failure(); + { + offsetsOperandsLoc = parser.getCurrentLocation(); + auto odsResult = parseDynamicIndexList(parser, offsetsOperands, static_offsetsAttr); + if (odsResult) return ::mlir::failure(); + result.getOrAddProperties().static_offsets = static_offsetsAttr; + } + { + sizesOperandsLoc = parser.getCurrentLocation(); + auto odsResult = parseDynamicIndexList(parser, sizesOperands, static_sizesAttr); + if (odsResult) return ::mlir::failure(); + result.getOrAddProperties().static_sizes = static_sizesAttr; + } + { + stridesOperandsLoc = parser.getCurrentLocation(); + auto odsResult = parseDynamicIndexList(parser, stridesOperands, static_stridesAttr); + if (odsResult) return ::mlir::failure(); + result.getOrAddProperties().static_strides = static_stridesAttr; + } + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::RankedTensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + sourceRawTypes[0] = type; + } + if (parser.parseKeyword("into")) + return ::mlir::failure(); + + { + ::mlir::RankedTensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + destRawTypes[0] = type; + } +::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(offsetsOperands.size()), static_cast(sizesOperands.size()), static_cast(stridesOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); + for (::mlir::Type type : destTypes) { + (void)type; + if (!(((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return (true); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return parser.emitError(parser.getNameLoc()) << "'dest' must be ranked tensor of any type values, but got " << type; + } + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + result.addTypes(destTypes[0]); + if (parser.resolveOperands(sourceOperands, sourceTypes, sourceOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(destOperands, destTypes, destOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(offsetsOperands, odsBuildableType0, offsetsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(sizesOperands, odsBuildableType0, sizesOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(stridesOperands, odsBuildableType0, stridesOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void InsertSliceOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getSource(); + _odsPrinter << ' ' << "into"; + _odsPrinter << ' '; + _odsPrinter << getDest(); + printDynamicIndexList(_odsPrinter, *this, getOffsets(), getStaticOffsetsAttr()); + _odsPrinter << ' '; + printDynamicIndexList(_odsPrinter, *this, getSizes(), getStaticSizesAttr()); + _odsPrinter << ' '; + printDynamicIndexList(_odsPrinter, *this, getStrides(), getStaticStridesAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("operandSegmentSizes"); + elidedAttrs.push_back("static_offsets"); + elidedAttrs.push_back("static_sizes"); + elidedAttrs.push_back("static_strides"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getSource().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::RankedTensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "into"; + _odsPrinter << ' '; + { + auto type = getDest().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::RankedTensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void InsertSliceOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::tensor::InsertSliceOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::PackOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +PackOpGenericAdaptorBase::PackOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("tensor.pack", odsAttrs.getContext()); +} + +PackOpGenericAdaptorBase::PackOpGenericAdaptorBase(PackOp op) : PackOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair PackOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; + + unsigned start = 0; + for (unsigned i = 0; i < index; ++i) + start += sizeAttr[i]; + return {start, sizeAttr[index]}; +} + +::mlir::DictionaryAttr PackOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::DenseI64ArrayAttr PackOpGenericAdaptorBase::getOuterDimsPermAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().outer_dims_perm); + if (!attr) + attr = ::mlir::Builder(odsAttrs.getContext()).getDenseI64ArrayAttr({}); + return attr; +} + +::llvm::ArrayRef PackOpGenericAdaptorBase::getOuterDimsPerm() { + auto attr = getOuterDimsPermAttr(); + if (!attr) + return ::mlir::Builder(odsAttrs.getContext()).getDenseI64ArrayAttr({}); + return attr; +} + +::mlir::DenseI64ArrayAttr PackOpGenericAdaptorBase::getInnerDimsPosAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().inner_dims_pos); + return attr; +} + +::llvm::ArrayRef PackOpGenericAdaptorBase::getInnerDimsPos() { + auto attr = getInnerDimsPosAttr(); + return attr; +} + +::mlir::DenseI64ArrayAttr PackOpGenericAdaptorBase::getStaticInnerTilesAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().static_inner_tiles); + return attr; +} + +::llvm::ArrayRef PackOpGenericAdaptorBase::getStaticInnerTiles() { + auto attr = getStaticInnerTilesAttr(); + return attr; +} + +} // namespace detail +PackOpAdaptor::PackOpAdaptor(PackOp op) : PackOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult PackOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_inner_dims_pos = getProperties().inner_dims_pos; (void)tblgen_inner_dims_pos; + if (!tblgen_inner_dims_pos) return emitError(loc, "'tensor.pack' op ""requires attribute 'inner_dims_pos'"); + auto tblgen_outer_dims_perm = getProperties().outer_dims_perm; (void)tblgen_outer_dims_perm; + auto tblgen_static_inner_tiles = getProperties().static_inner_tiles; (void)tblgen_static_inner_tiles; + if (!tblgen_static_inner_tiles) return emitError(loc, "'tensor.pack' op ""requires attribute 'static_inner_tiles'"); + + if (tblgen_outer_dims_perm && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_outer_dims_perm)))) + return emitError(loc, "'tensor.pack' op ""attribute 'outer_dims_perm' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_inner_dims_pos && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_inner_dims_pos)))) + return emitError(loc, "'tensor.pack' op ""attribute 'inner_dims_pos' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_static_inner_tiles && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_static_inner_tiles)))) + return emitError(loc, "'tensor.pack' op ""attribute 'static_inner_tiles' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +std::pair PackOp::getODSOperandIndexAndLength(unsigned index) { + ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; + + unsigned start = 0; + for (unsigned i = 0; i < index; ++i) + start += sizeAttr[i]; + return {start, sizeAttr[index]}; +} + +::mlir::Operation::operand_range PackOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::RankedTensorType> PackOp::getSource() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::RankedTensorType> PackOp::getDest() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); +} + +::mlir::Value PackOp::getPaddingValue() { + auto operands = getODSOperands(2); + return operands.empty() ? ::mlir::Value{} : ::llvm::cast<::mlir::Value>(*operands.begin()); +} + +::mlir::Operation::operand_range PackOp::getInnerTiles() { + return getODSOperands(3); +} + +::mlir::OpOperand &PackOp::getSourceMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &PackOp::getDestMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange PackOp::getPaddingValueMutable() { + auto range = getODSOperandIndexAndLength(2); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); + return mutableRange; +} + +::mlir::MutableOperandRange PackOp::getInnerTilesMutable() { + auto range = getODSOperandIndexAndLength(3); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); + return mutableRange; +} + +std::pair PackOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range PackOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::RankedTensorType> PackOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult PackOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.inner_dims_pos; + auto attr = dict.get("inner_dims_pos"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for inner_dims_pos in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `inner_dims_pos` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.outer_dims_perm; + auto attr = dict.get("outer_dims_perm"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for outer_dims_perm in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `outer_dims_perm` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.static_inner_tiles; + auto attr = dict.get("static_inner_tiles"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for static_inner_tiles in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `static_inner_tiles` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } +; + { + auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, + ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return convertFromAttribute(propStorage, propAttr, emitError);; + }; + auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; + if (!attr) { + emitError() << "expected key entry for operandSegmentSizes in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + if (::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute PackOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.inner_dims_pos; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("inner_dims_pos", + propStorage)); + } + + { + const auto &propStorage = prop.outer_dims_perm; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("outer_dims_perm", + propStorage)); + } + + { + const auto &propStorage = prop.static_inner_tiles; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("static_inner_tiles", + propStorage)); + } + + { + const auto &propStorage = prop.operandSegmentSizes; + attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", + ::mlir::DenseI32ArrayAttr::get(ctx, propStorage))); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code PackOp::computePropertiesHash(const Properties &prop) { + auto hash_operandSegmentSizes = [] (const auto &propStorage) -> llvm::hash_code { + return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; + }; + return llvm::hash_combine( + llvm::hash_value(prop.inner_dims_pos.getAsOpaquePointer()), + llvm::hash_value(prop.outer_dims_perm.getAsOpaquePointer()), + llvm::hash_value(prop.static_inner_tiles.getAsOpaquePointer()), + hash_operandSegmentSizes(prop.operandSegmentSizes)); +} + +std::optional PackOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "inner_dims_pos") + return prop.inner_dims_pos; + + if (name == "outer_dims_perm") + return prop.outer_dims_perm; + + if (name == "static_inner_tiles") + return prop.static_inner_tiles; + if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); + return std::nullopt; +} + +void PackOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "inner_dims_pos") { + prop.inner_dims_pos = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "outer_dims_perm") { + prop.outer_dims_perm = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "static_inner_tiles") { + prop.static_inner_tiles = ::llvm::dyn_cast_or_null>(value); + return; + } + if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { + auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); + if (!arrAttr) return; + if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) + return; + llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); + return; + } +} + +void PackOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.inner_dims_pos) attrs.append("inner_dims_pos", prop.inner_dims_pos); + + if (prop.outer_dims_perm) attrs.append("outer_dims_perm", prop.outer_dims_perm); + + if (prop.static_inner_tiles) attrs.append("static_inner_tiles", prop.static_inner_tiles); + attrs.append("operandSegmentSizes", ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes)); +} + +::mlir::LogicalResult PackOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getInnerDimsPosAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(attr, "inner_dims_pos", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getOuterDimsPermAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(attr, "outer_dims_perm", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getStaticInnerTilesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(attr, "static_inner_tiles", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult PackOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.inner_dims_pos))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.outer_dims_perm))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.static_inner_tiles))) + return ::mlir::failure(); + + { + auto &propStorage = prop.operandSegmentSizes; + auto readProp = [&]() { + +if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { + ::mlir::DenseI32ArrayAttr attr; + if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); + if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { + reader.emitError("size mismatch for operand/result_segment_size"); + return ::mlir::failure(); + } + ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); +} else { + return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); +} +; + return ::mlir::success(); + }; + if (::mlir::failed(readProp())) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +void PackOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.inner_dims_pos); + + writer.writeOptionalAttribute(prop.outer_dims_perm); + writer.writeAttribute(prop.static_inner_tiles); + + { + auto &propStorage = prop.operandSegmentSizes; + +if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) + writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(getContext(), propStorage)); +else + writer.writeSparseArray(::llvm::ArrayRef(propStorage)); +; + } +} + +::mlir::DenseI64ArrayAttr PackOp::getOuterDimsPermAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().outer_dims_perm); +} + +::llvm::ArrayRef PackOp::getOuterDimsPerm() { + auto attr = getOuterDimsPermAttr(); + if (!attr) + return ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr({}); + return attr; +} + +::mlir::DenseI64ArrayAttr PackOp::getInnerDimsPosAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().inner_dims_pos); +} + +::llvm::ArrayRef PackOp::getInnerDimsPos() { + auto attr = getInnerDimsPosAttr(); + return attr; +} + +::mlir::DenseI64ArrayAttr PackOp::getStaticInnerTilesAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().static_inner_tiles); +} + +::llvm::ArrayRef PackOp::getStaticInnerTiles() { + auto attr = getStaticInnerTilesAttr(); + return attr; +} + +void PackOp::setOuterDimsPermAttr(::mlir::DenseI64ArrayAttr attr) { + (*this)->setAttr(getOuterDimsPermAttrName(), attr); +} + +void PackOp::setOuterDimsPerm(::std::optional<::llvm::ArrayRef> attrValue) { + if (attrValue) + return (*this)->setAttr(getOuterDimsPermAttrName(), ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue)); + (*this)->removeAttr(getOuterDimsPermAttrName()); +} + +void PackOp::setInnerDimsPosAttr(::mlir::DenseI64ArrayAttr attr) { + (*this)->setAttr(getInnerDimsPosAttrName(), attr); +} + +void PackOp::setInnerDimsPos(::llvm::ArrayRef attrValue) { + (*this)->setAttr(getInnerDimsPosAttrName(), ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue)); +} + +void PackOp::setStaticInnerTilesAttr(::mlir::DenseI64ArrayAttr attr) { + (*this)->setAttr(getStaticInnerTilesAttrName(), attr); +} + +void PackOp::setStaticInnerTiles(::llvm::ArrayRef attrValue) { + (*this)->setAttr(getStaticInnerTilesAttrName(), ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue)); +} + +::mlir::Attribute PackOp::removeOuterDimsPermAttr() { + auto &attr = getProperties().outer_dims_perm; + attr = {}; + return attr; +} + +void PackOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::Value padding_value, /*optional*/::mlir::DenseI64ArrayAttr outer_dims_perm, ::mlir::DenseI64ArrayAttr inner_dims_pos, ::mlir::ValueRange inner_tiles, ::mlir::DenseI64ArrayAttr static_inner_tiles) { + odsState.addOperands(source); + odsState.addOperands(dest); + if (padding_value) + odsState.addOperands(padding_value); + odsState.addOperands(inner_tiles); + ::llvm::copy(::llvm::ArrayRef({1, 1, (padding_value ? 1 : 0), static_cast(inner_tiles.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + if (outer_dims_perm) { + odsState.getOrAddProperties().outer_dims_perm = outer_dims_perm; + } + odsState.getOrAddProperties().inner_dims_pos = inner_dims_pos; + odsState.getOrAddProperties().static_inner_tiles = static_inner_tiles; + odsState.addTypes(result); +} + +void PackOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::Value padding_value, /*optional*/::mlir::DenseI64ArrayAttr outer_dims_perm, ::mlir::DenseI64ArrayAttr inner_dims_pos, ::mlir::ValueRange inner_tiles, ::mlir::DenseI64ArrayAttr static_inner_tiles) { + odsState.addOperands(source); + odsState.addOperands(dest); + if (padding_value) + odsState.addOperands(padding_value); + odsState.addOperands(inner_tiles); + ::llvm::copy(::llvm::ArrayRef({1, 1, (padding_value ? 1 : 0), static_cast(inner_tiles.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + if (outer_dims_perm) { + odsState.getOrAddProperties().outer_dims_perm = outer_dims_perm; + } + odsState.getOrAddProperties().inner_dims_pos = inner_dims_pos; + odsState.getOrAddProperties().static_inner_tiles = static_inner_tiles; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(PackOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void PackOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::Value padding_value, /*optional*/::mlir::DenseI64ArrayAttr outer_dims_perm, ::mlir::DenseI64ArrayAttr inner_dims_pos, ::mlir::ValueRange inner_tiles, ::mlir::DenseI64ArrayAttr static_inner_tiles) { + odsState.addOperands(source); + odsState.addOperands(dest); + if (padding_value) + odsState.addOperands(padding_value); + odsState.addOperands(inner_tiles); + ::llvm::copy(::llvm::ArrayRef({1, 1, (padding_value ? 1 : 0), static_cast(inner_tiles.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + if (outer_dims_perm) { + odsState.getOrAddProperties().outer_dims_perm = outer_dims_perm; + } + odsState.getOrAddProperties().inner_dims_pos = inner_dims_pos; + odsState.getOrAddProperties().static_inner_tiles = static_inner_tiles; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void PackOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::Value padding_value, /*optional*/::llvm::ArrayRef outer_dims_perm, ::llvm::ArrayRef inner_dims_pos, ::mlir::ValueRange inner_tiles, ::llvm::ArrayRef static_inner_tiles) { + odsState.addOperands(source); + odsState.addOperands(dest); + if (padding_value) + odsState.addOperands(padding_value); + odsState.addOperands(inner_tiles); + ::llvm::copy(::llvm::ArrayRef({1, 1, (padding_value ? 1 : 0), static_cast(inner_tiles.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + odsState.getOrAddProperties().outer_dims_perm = odsBuilder.getDenseI64ArrayAttr(outer_dims_perm); + odsState.getOrAddProperties().inner_dims_pos = odsBuilder.getDenseI64ArrayAttr(inner_dims_pos); + odsState.getOrAddProperties().static_inner_tiles = odsBuilder.getDenseI64ArrayAttr(static_inner_tiles); + odsState.addTypes(result); +} + +void PackOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::Value padding_value, /*optional*/::llvm::ArrayRef outer_dims_perm, ::llvm::ArrayRef inner_dims_pos, ::mlir::ValueRange inner_tiles, ::llvm::ArrayRef static_inner_tiles) { + odsState.addOperands(source); + odsState.addOperands(dest); + if (padding_value) + odsState.addOperands(padding_value); + odsState.addOperands(inner_tiles); + ::llvm::copy(::llvm::ArrayRef({1, 1, (padding_value ? 1 : 0), static_cast(inner_tiles.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + odsState.getOrAddProperties().outer_dims_perm = odsBuilder.getDenseI64ArrayAttr(outer_dims_perm); + odsState.getOrAddProperties().inner_dims_pos = odsBuilder.getDenseI64ArrayAttr(inner_dims_pos); + odsState.getOrAddProperties().static_inner_tiles = odsBuilder.getDenseI64ArrayAttr(static_inner_tiles); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(PackOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void PackOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::Value padding_value, /*optional*/::llvm::ArrayRef outer_dims_perm, ::llvm::ArrayRef inner_dims_pos, ::mlir::ValueRange inner_tiles, ::llvm::ArrayRef static_inner_tiles) { + odsState.addOperands(source); + odsState.addOperands(dest); + if (padding_value) + odsState.addOperands(padding_value); + odsState.addOperands(inner_tiles); + ::llvm::copy(::llvm::ArrayRef({1, 1, (padding_value ? 1 : 0), static_cast(inner_tiles.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + odsState.getOrAddProperties().outer_dims_perm = odsBuilder.getDenseI64ArrayAttr(outer_dims_perm); + odsState.getOrAddProperties().inner_dims_pos = odsBuilder.getDenseI64ArrayAttr(inner_dims_pos); + odsState.getOrAddProperties().static_inner_tiles = odsBuilder.getDenseI64ArrayAttr(static_inner_tiles); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void PackOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void PackOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(PackOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult PackOp::verifyInvariantsImpl() { + auto tblgen_inner_dims_pos = getProperties().inner_dims_pos; (void)tblgen_inner_dims_pos; + if (!tblgen_inner_dims_pos) return emitOpError("requires attribute 'inner_dims_pos'"); + auto tblgen_outer_dims_perm = getProperties().outer_dims_perm; (void)tblgen_outer_dims_perm; + auto tblgen_static_inner_tiles = getProperties().static_inner_tiles; (void)tblgen_static_inner_tiles; + if (!tblgen_static_inner_tiles) return emitOpError("requires attribute 'static_inner_tiles'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(*this, tblgen_outer_dims_perm, "outer_dims_perm"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(*this, tblgen_inner_dims_pos, "inner_dims_pos"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(*this, tblgen_static_inner_tiles, "static_inner_tiles"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + if (valueGroup2.size() > 1) { + return emitOpError("operand group starting at #") << index + << " requires 0 or 1 element, but found " << valueGroup2.size(); + } + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps4(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup3 = getODSOperands(3); + + for (auto v : valueGroup3) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((std::equal_to<>()((*this->getODSOperands(1).begin()).getType(), (*this->getODSResults(0).begin()).getType())))) + return emitOpError("failed to verify that result type matches type of dest"); + return ::mlir::success(); +} + +::mlir::LogicalResult PackOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +void PackOp::getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context) { + results.add(canonicalize); +} + +::mlir::LogicalResult PackOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = operands[1].getType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult PackOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(sourceRawOperands); ::llvm::SMLoc sourceOperandsLoc; + (void)sourceOperandsLoc; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> padding_valueOperands; + ::llvm::SMLoc padding_valueOperandsLoc; + (void)padding_valueOperandsLoc; + ::llvm::SmallVector<::mlir::Type, 1> padding_valueTypes; + ::mlir::DenseI64ArrayAttr outer_dims_permAttr; + ::mlir::DenseI64ArrayAttr inner_dims_posAttr; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> inner_tilesOperands; + ::llvm::SMLoc inner_tilesOperandsLoc; + (void)inner_tilesOperandsLoc; + ::mlir::DenseI64ArrayAttr static_inner_tilesAttr; + ::mlir::OpAsmParser::UnresolvedOperand destRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> destOperands(destRawOperands); ::llvm::SMLoc destOperandsLoc; + (void)destOperandsLoc; + ::mlir::Type sourceRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> sourceTypes(sourceRawTypes); + ::mlir::Type destRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> destTypes(destRawTypes); + + sourceOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(sourceRawOperands[0])) + return ::mlir::failure(); + if (::mlir::succeeded(parser.parseOptionalKeyword("padding_value"))) { + if (parser.parseLParen()) + return ::mlir::failure(); + + { + padding_valueOperandsLoc = parser.getCurrentLocation(); + ::mlir::OpAsmParser::UnresolvedOperand operand; + ::mlir::OptionalParseResult parseResult = + parser.parseOptionalOperand(operand); + if (parseResult.has_value()) { + if (failed(*parseResult)) + return ::mlir::failure(); + padding_valueOperands.push_back(operand); + } + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::Type optionalType; + ::mlir::OptionalParseResult parseResult = + parser.parseOptionalType(optionalType); + if (parseResult.has_value()) { + if (failed(*parseResult)) + return ::mlir::failure(); + padding_valueTypes.push_back(optionalType); + } + } + if (parser.parseRParen()) + return ::mlir::failure(); + } + if (::mlir::succeeded(parser.parseOptionalKeyword("outer_dims_perm"))) { + if (parser.parseEqual()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(outer_dims_permAttr, ::mlir::Type{})) { + return ::mlir::failure(); + } + if (outer_dims_permAttr) result.getOrAddProperties().outer_dims_perm = outer_dims_permAttr; + } + if (parser.parseKeyword("inner_dims_pos")) + return ::mlir::failure(); + if (parser.parseEqual()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(inner_dims_posAttr, ::mlir::Type{})) { + return ::mlir::failure(); + } + if (inner_dims_posAttr) result.getOrAddProperties().inner_dims_pos = inner_dims_posAttr; + if (parser.parseKeyword("inner_tiles")) + return ::mlir::failure(); + if (parser.parseEqual()) + return ::mlir::failure(); + { + inner_tilesOperandsLoc = parser.getCurrentLocation(); + auto odsResult = parseDynamicIndexList(parser, inner_tilesOperands, static_inner_tilesAttr); + if (odsResult) return ::mlir::failure(); + result.getOrAddProperties().static_inner_tiles = static_inner_tilesAttr; + } + if (parser.parseKeyword("into")) + return ::mlir::failure(); + + destOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(destRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::RankedTensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + sourceRawTypes[0] = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::RankedTensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + destRawTypes[0] = type; + } +::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(padding_valueOperands.size()), static_cast(inner_tilesOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); + for (::mlir::Type type : destTypes) { + (void)type; + if (!(((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return (true); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return parser.emitError(parser.getNameLoc()) << "'dest' must be ranked tensor of any type values, but got " << type; + } + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + result.addTypes(destTypes[0]); + if (parser.resolveOperands(sourceOperands, sourceTypes, sourceOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(destOperands, destTypes, destOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(padding_valueOperands, padding_valueTypes, padding_valueOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(inner_tilesOperands, odsBuildableType0, inner_tilesOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void PackOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getSource(); + if (getPaddingValue()) { + _odsPrinter << ' ' << "padding_value"; + _odsPrinter << "("; + if (::mlir::Value value = getPaddingValue()) + _odsPrinter << value; + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter << (getPaddingValue() ? ::llvm::ArrayRef<::mlir::Type>(getPaddingValue().getType()) : ::llvm::ArrayRef<::mlir::Type>()); + _odsPrinter << ")"; + } + if (getOuterDimsPermAttr()) { + _odsPrinter << ' ' << "outer_dims_perm"; + _odsPrinter << ' ' << "="; + _odsPrinter << ' '; + _odsPrinter.printStrippedAttrOrType(getOuterDimsPermAttr()); + } + _odsPrinter << ' ' << "inner_dims_pos"; + _odsPrinter << ' ' << "="; + _odsPrinter << ' '; +_odsPrinter.printStrippedAttrOrType(getInnerDimsPosAttr()); + _odsPrinter << ' ' << "inner_tiles"; + _odsPrinter << ' ' << "="; + _odsPrinter << ' '; + printDynamicIndexList(_odsPrinter, *this, getInnerTiles(), getStaticInnerTilesAttr()); + _odsPrinter << ' ' << "into"; + _odsPrinter << ' '; + _odsPrinter << getDest(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("operandSegmentSizes"); + elidedAttrs.push_back("outer_dims_perm"); + elidedAttrs.push_back("inner_dims_pos"); + elidedAttrs.push_back("static_inner_tiles"); + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getOuterDimsPermAttr(); + if(attr && (attr == odsBuilder.getDenseI64ArrayAttr({}))) + elidedAttrs.push_back("outer_dims_perm"); + } + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getSource().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::RankedTensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getDest().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::RankedTensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void PackOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::tensor::PackOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::PadOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +PadOpGenericAdaptorBase::PadOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("tensor.pad", odsAttrs.getContext()); +} + +PadOpGenericAdaptorBase::PadOpGenericAdaptorBase(PadOp op) : PadOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair PadOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; + + unsigned start = 0; + for (unsigned i = 0; i < index; ++i) + start += sizeAttr[i]; + return {start, sizeAttr[index]}; +} + +::mlir::DictionaryAttr PadOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::DenseI64ArrayAttr PadOpGenericAdaptorBase::getStaticLowAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().static_low); + return attr; +} + +::llvm::ArrayRef PadOpGenericAdaptorBase::getStaticLow() { + auto attr = getStaticLowAttr(); + return attr; +} + +::mlir::DenseI64ArrayAttr PadOpGenericAdaptorBase::getStaticHighAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().static_high); + return attr; +} + +::llvm::ArrayRef PadOpGenericAdaptorBase::getStaticHigh() { + auto attr = getStaticHighAttr(); + return attr; +} + +::mlir::UnitAttr PadOpGenericAdaptorBase::getNofoldAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().nofold); + if (!attr) + attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); + return attr; +} + +bool PadOpGenericAdaptorBase::getNofold() { + auto attr = getNofoldAttr(); + if (!attr) + return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; + return attr != nullptr; +} + +::mlir::Region &PadOpGenericAdaptorBase::getRegion() { + return *odsRegions[0]; +} + +::mlir::RegionRange PadOpGenericAdaptorBase::getRegions() { + return odsRegions; +} + +} // namespace detail +PadOpAdaptor::PadOpAdaptor(PadOp op) : PadOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult PadOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_nofold = getProperties().nofold; (void)tblgen_nofold; + auto tblgen_static_high = getProperties().static_high; (void)tblgen_static_high; + if (!tblgen_static_high) return emitError(loc, "'tensor.pad' op ""requires attribute 'static_high'"); + auto tblgen_static_low = getProperties().static_low; (void)tblgen_static_low; + if (!tblgen_static_low) return emitError(loc, "'tensor.pad' op ""requires attribute 'static_low'"); + + if (tblgen_static_low && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_static_low)))) + return emitError(loc, "'tensor.pad' op ""attribute 'static_low' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_static_high && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_static_high)))) + return emitError(loc, "'tensor.pad' op ""attribute 'static_high' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_nofold && !((::llvm::isa<::mlir::UnitAttr>(tblgen_nofold)))) + return emitError(loc, "'tensor.pad' op ""attribute 'nofold' failed to satisfy constraint: unit attribute"); + return ::mlir::success(); +} + +std::pair PadOp::getODSOperandIndexAndLength(unsigned index) { + ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; + + unsigned start = 0; + for (unsigned i = 0; i < index; ++i) + start += sizeAttr[i]; + return {start, sizeAttr[index]}; +} + +::mlir::Operation::operand_range PadOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::RankedTensorType> PadOp::getSource() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); +} + +::mlir::Operation::operand_range PadOp::getLow() { + return getODSOperands(1); +} + +::mlir::Operation::operand_range PadOp::getHigh() { + return getODSOperands(2); +} + +::mlir::OpOperand &PadOp::getSourceMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange PadOp::getLowMutable() { + auto range = getODSOperandIndexAndLength(1); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); + return mutableRange; +} + +::mlir::MutableOperandRange PadOp::getHighMutable() { + auto range = getODSOperandIndexAndLength(2); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); + return mutableRange; +} + +std::pair PadOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range PadOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::RankedTensorType> PadOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); +} + +::mlir::Region &PadOp::getRegion() { + return (*this)->getRegion(0); +} + +::mlir::LogicalResult PadOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.nofold; + auto attr = dict.get("nofold"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for nofold in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `nofold` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.static_high; + auto attr = dict.get("static_high"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for static_high in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `static_high` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.static_low; + auto attr = dict.get("static_low"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for static_low in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `static_low` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } +; + { + auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, + ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return convertFromAttribute(propStorage, propAttr, emitError);; + }; + auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; + if (!attr) { + emitError() << "expected key entry for operandSegmentSizes in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + if (::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute PadOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.nofold; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("nofold", + propStorage)); + } + + { + const auto &propStorage = prop.static_high; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("static_high", + propStorage)); + } + + { + const auto &propStorage = prop.static_low; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("static_low", + propStorage)); + } + + { + const auto &propStorage = prop.operandSegmentSizes; + attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", + ::mlir::DenseI32ArrayAttr::get(ctx, propStorage))); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code PadOp::computePropertiesHash(const Properties &prop) { + auto hash_operandSegmentSizes = [] (const auto &propStorage) -> llvm::hash_code { + return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; + }; + return llvm::hash_combine( + llvm::hash_value(prop.nofold.getAsOpaquePointer()), + llvm::hash_value(prop.static_high.getAsOpaquePointer()), + llvm::hash_value(prop.static_low.getAsOpaquePointer()), + hash_operandSegmentSizes(prop.operandSegmentSizes)); +} + +std::optional PadOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "nofold") + return prop.nofold; + + if (name == "static_high") + return prop.static_high; + + if (name == "static_low") + return prop.static_low; + if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); + return std::nullopt; +} + +void PadOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "nofold") { + prop.nofold = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "static_high") { + prop.static_high = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "static_low") { + prop.static_low = ::llvm::dyn_cast_or_null>(value); + return; + } + if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { + auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); + if (!arrAttr) return; + if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) + return; + llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); + return; + } +} + +void PadOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.nofold) attrs.append("nofold", prop.nofold); + + if (prop.static_high) attrs.append("static_high", prop.static_high); + + if (prop.static_low) attrs.append("static_low", prop.static_low); + attrs.append("operandSegmentSizes", ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes)); +} + +::mlir::LogicalResult PadOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getNofoldAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps2(attr, "nofold", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getStaticHighAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(attr, "static_high", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getStaticLowAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(attr, "static_low", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult PadOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.nofold))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.static_high))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.static_low))) + return ::mlir::failure(); + + { + auto &propStorage = prop.operandSegmentSizes; + auto readProp = [&]() { + +if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { + ::mlir::DenseI32ArrayAttr attr; + if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); + if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { + reader.emitError("size mismatch for operand/result_segment_size"); + return ::mlir::failure(); + } + ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); +} else { + return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); +} +; + return ::mlir::success(); + }; + if (::mlir::failed(readProp())) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +void PadOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.nofold); + writer.writeAttribute(prop.static_high); + writer.writeAttribute(prop.static_low); + + { + auto &propStorage = prop.operandSegmentSizes; + +if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) + writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(getContext(), propStorage)); +else + writer.writeSparseArray(::llvm::ArrayRef(propStorage)); +; + } +} + +::mlir::DenseI64ArrayAttr PadOp::getStaticLowAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().static_low); +} + +::llvm::ArrayRef PadOp::getStaticLow() { + auto attr = getStaticLowAttr(); + return attr; +} + +::mlir::DenseI64ArrayAttr PadOp::getStaticHighAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().static_high); +} + +::llvm::ArrayRef PadOp::getStaticHigh() { + auto attr = getStaticHighAttr(); + return attr; +} + +::mlir::UnitAttr PadOp::getNofoldAttr() { + return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().nofold); +} + +bool PadOp::getNofold() { + auto attr = getNofoldAttr(); + if (!attr) + return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; + return attr != nullptr; +} + +void PadOp::setStaticLowAttr(::mlir::DenseI64ArrayAttr attr) { + (*this)->setAttr(getStaticLowAttrName(), attr); +} + +void PadOp::setStaticLow(::llvm::ArrayRef attrValue) { + (*this)->setAttr(getStaticLowAttrName(), ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue)); +} + +void PadOp::setStaticHighAttr(::mlir::DenseI64ArrayAttr attr) { + (*this)->setAttr(getStaticHighAttrName(), attr); +} + +void PadOp::setStaticHigh(::llvm::ArrayRef attrValue) { + (*this)->setAttr(getStaticHighAttrName(), ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue)); +} + +void PadOp::setNofoldAttr(::mlir::UnitAttr attr) { + (*this)->setAttr(getNofoldAttrName(), attr); +} + +void PadOp::setNofold(bool attrValue) { + if (attrValue) + return (*this)->setAttr(getNofoldAttrName(), ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr)); + (*this)->removeAttr(getNofoldAttrName()); +} + +::mlir::Attribute PadOp::removeNofoldAttr() { + auto &attr = getProperties().nofold; + attr = {}; + return attr; +} + +void PadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::ValueRange low, ::mlir::ValueRange high, ::mlir::DenseI64ArrayAttr static_low, ::mlir::DenseI64ArrayAttr static_high, /*optional*/::mlir::UnitAttr nofold) { + odsState.addOperands(source); + odsState.addOperands(low); + odsState.addOperands(high); + ::llvm::copy(::llvm::ArrayRef({1, static_cast(low.size()), static_cast(high.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + odsState.getOrAddProperties().static_low = static_low; + odsState.getOrAddProperties().static_high = static_high; + if (nofold) { + odsState.getOrAddProperties().nofold = nofold; + } + (void)odsState.addRegion(); + odsState.addTypes(result); +} + +void PadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::ValueRange low, ::mlir::ValueRange high, ::mlir::DenseI64ArrayAttr static_low, ::mlir::DenseI64ArrayAttr static_high, /*optional*/::mlir::UnitAttr nofold) { + odsState.addOperands(source); + odsState.addOperands(low); + odsState.addOperands(high); + ::llvm::copy(::llvm::ArrayRef({1, static_cast(low.size()), static_cast(high.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + odsState.getOrAddProperties().static_low = static_low; + odsState.getOrAddProperties().static_high = static_high; + if (nofold) { + odsState.getOrAddProperties().nofold = nofold; + } + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void PadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::ValueRange low, ::mlir::ValueRange high, ::llvm::ArrayRef static_low, ::llvm::ArrayRef static_high, /*optional*/bool nofold) { + odsState.addOperands(source); + odsState.addOperands(low); + odsState.addOperands(high); + ::llvm::copy(::llvm::ArrayRef({1, static_cast(low.size()), static_cast(high.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + odsState.getOrAddProperties().static_low = odsBuilder.getDenseI64ArrayAttr(static_low); + odsState.getOrAddProperties().static_high = odsBuilder.getDenseI64ArrayAttr(static_high); + if (nofold) { + odsState.getOrAddProperties().nofold = ((nofold) ? odsBuilder.getUnitAttr() : nullptr); + } + (void)odsState.addRegion(); + odsState.addTypes(result); +} + +void PadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::ValueRange low, ::mlir::ValueRange high, ::llvm::ArrayRef static_low, ::llvm::ArrayRef static_high, /*optional*/bool nofold) { + odsState.addOperands(source); + odsState.addOperands(low); + odsState.addOperands(high); + ::llvm::copy(::llvm::ArrayRef({1, static_cast(low.size()), static_cast(high.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + odsState.getOrAddProperties().static_low = odsBuilder.getDenseI64ArrayAttr(static_low); + odsState.getOrAddProperties().static_high = odsBuilder.getDenseI64ArrayAttr(static_high); + if (nofold) { + odsState.getOrAddProperties().nofold = ((nofold) ? odsBuilder.getUnitAttr() : nullptr); + } + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void PadOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult PadOp::verifyInvariantsImpl() { + auto tblgen_nofold = getProperties().nofold; (void)tblgen_nofold; + auto tblgen_static_high = getProperties().static_high; (void)tblgen_static_high; + if (!tblgen_static_high) return emitOpError("requires attribute 'static_high'"); + auto tblgen_static_low = getProperties().static_low; (void)tblgen_static_low; + if (!tblgen_static_low) return emitOpError("requires attribute 'static_low'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(*this, tblgen_static_low, "static_low"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(*this, tblgen_static_high, "static_high"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps2(*this, tblgen_nofold, "nofold"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_TensorOps0(*this, region, "region", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult PadOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult PadOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(sourceRawOperands); ::llvm::SMLoc sourceOperandsLoc; + (void)sourceOperandsLoc; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> lowOperands; + ::llvm::SMLoc lowOperandsLoc; + (void)lowOperandsLoc; + ::mlir::DenseI64ArrayAttr static_lowAttr; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> highOperands; + ::llvm::SMLoc highOperandsLoc; + (void)highOperandsLoc; + ::mlir::DenseI64ArrayAttr static_highAttr; + std::unique_ptr<::mlir::Region> regionRegion = std::make_unique<::mlir::Region>(); + ::mlir::Type sourceRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> sourceTypes(sourceRawTypes); + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + sourceOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(sourceRawOperands[0])) + return ::mlir::failure(); + if (::mlir::succeeded(parser.parseOptionalKeyword("nofold"))) { + result.getOrAddProperties().nofold = parser.getBuilder().getUnitAttr(); } + if (parser.parseKeyword("low")) + return ::mlir::failure(); + { + lowOperandsLoc = parser.getCurrentLocation(); + auto odsResult = parseDynamicIndexList(parser, lowOperands, static_lowAttr); + if (odsResult) return ::mlir::failure(); + result.getOrAddProperties().static_low = static_lowAttr; + } + if (parser.parseKeyword("high")) + return ::mlir::failure(); + { + highOperandsLoc = parser.getCurrentLocation(); + auto odsResult = parseDynamicIndexList(parser, highOperands, static_highAttr); + if (odsResult) return ::mlir::failure(); + result.getOrAddProperties().static_high = static_highAttr; + } + + if (parser.parseRegion(*regionRegion)) + return ::mlir::failure(); + + ensureTerminator(*regionRegion, parser.getBuilder(), result.location); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::RankedTensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + sourceRawTypes[0] = type; + } + if (parser.parseKeyword("to")) + return ::mlir::failure(); + + { + ::mlir::RankedTensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + result.addRegion(std::move(regionRegion)); +::llvm::copy(::llvm::ArrayRef({1, static_cast(lowOperands.size()), static_cast(highOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + result.addTypes(resultTypes); + if (parser.resolveOperands(sourceOperands, sourceTypes, sourceOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(lowOperands, odsBuildableType0, lowOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(highOperands, odsBuildableType0, highOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void PadOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getSource(); + if (getNofoldAttr()) { + _odsPrinter << ' ' << "nofold"; + } + _odsPrinter << ' ' << "low"; + printDynamicIndexList(_odsPrinter, *this, getLow(), getStaticLowAttr()); + _odsPrinter << ' ' << "high"; + printDynamicIndexList(_odsPrinter, *this, getHigh(), getStaticHighAttr()); + _odsPrinter << ' '; + + { + bool printTerminator = true; + if (auto *term = getRegion().empty() ? nullptr : getRegion().begin()->getTerminator()) { + printTerminator = !term->getAttrDictionary().empty() || + term->getNumOperands() != 0 || + term->getNumResults() != 0; + } + _odsPrinter.printRegion(getRegion(), /*printEntryBlockArgs=*/true, + /*printBlockTerminators=*/printTerminator); + } + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("operandSegmentSizes"); + elidedAttrs.push_back("nofold"); + elidedAttrs.push_back("static_low"); + elidedAttrs.push_back("static_high"); + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getNofoldAttr(); + if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) + elidedAttrs.push_back("nofold"); + } + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getSource().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::RankedTensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "to"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::RankedTensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void PadOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::tensor::PadOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::ParallelInsertSliceOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ParallelInsertSliceOpGenericAdaptorBase::ParallelInsertSliceOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("tensor.parallel_insert_slice", odsAttrs.getContext()); +} + +ParallelInsertSliceOpGenericAdaptorBase::ParallelInsertSliceOpGenericAdaptorBase(ParallelInsertSliceOp op) : ParallelInsertSliceOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ParallelInsertSliceOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; + + unsigned start = 0; + for (unsigned i = 0; i < index; ++i) + start += sizeAttr[i]; + return {start, sizeAttr[index]}; +} + +::mlir::DictionaryAttr ParallelInsertSliceOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::DenseI64ArrayAttr ParallelInsertSliceOpGenericAdaptorBase::getStaticOffsetsAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().static_offsets); + return attr; +} + +::llvm::ArrayRef ParallelInsertSliceOpGenericAdaptorBase::getStaticOffsets() { + auto attr = getStaticOffsetsAttr(); + return attr; +} + +::mlir::DenseI64ArrayAttr ParallelInsertSliceOpGenericAdaptorBase::getStaticSizesAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().static_sizes); + return attr; +} + +::llvm::ArrayRef ParallelInsertSliceOpGenericAdaptorBase::getStaticSizes() { + auto attr = getStaticSizesAttr(); + return attr; +} + +::mlir::DenseI64ArrayAttr ParallelInsertSliceOpGenericAdaptorBase::getStaticStridesAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().static_strides); + return attr; +} + +::llvm::ArrayRef ParallelInsertSliceOpGenericAdaptorBase::getStaticStrides() { + auto attr = getStaticStridesAttr(); + return attr; +} + +} // namespace detail +ParallelInsertSliceOpAdaptor::ParallelInsertSliceOpAdaptor(ParallelInsertSliceOp op) : ParallelInsertSliceOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ParallelInsertSliceOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_static_offsets = getProperties().static_offsets; (void)tblgen_static_offsets; + if (!tblgen_static_offsets) return emitError(loc, "'tensor.parallel_insert_slice' op ""requires attribute 'static_offsets'"); + auto tblgen_static_sizes = getProperties().static_sizes; (void)tblgen_static_sizes; + if (!tblgen_static_sizes) return emitError(loc, "'tensor.parallel_insert_slice' op ""requires attribute 'static_sizes'"); + auto tblgen_static_strides = getProperties().static_strides; (void)tblgen_static_strides; + if (!tblgen_static_strides) return emitError(loc, "'tensor.parallel_insert_slice' op ""requires attribute 'static_strides'"); + + if (tblgen_static_offsets && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_static_offsets)))) + return emitError(loc, "'tensor.parallel_insert_slice' op ""attribute 'static_offsets' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_static_sizes && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_static_sizes)))) + return emitError(loc, "'tensor.parallel_insert_slice' op ""attribute 'static_sizes' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_static_strides && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_static_strides)))) + return emitError(loc, "'tensor.parallel_insert_slice' op ""attribute 'static_strides' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +std::pair ParallelInsertSliceOp::getODSOperandIndexAndLength(unsigned index) { + ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; + + unsigned start = 0; + for (unsigned i = 0; i < index; ++i) + start += sizeAttr[i]; + return {start, sizeAttr[index]}; +} + +::mlir::Operation::operand_range ParallelInsertSliceOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::RankedTensorType> ParallelInsertSliceOp::getSource() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::RankedTensorType> ParallelInsertSliceOp::getDest() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); +} + +::mlir::Operation::operand_range ParallelInsertSliceOp::getOffsets() { + return getODSOperands(2); +} + +::mlir::Operation::operand_range ParallelInsertSliceOp::getSizes() { + return getODSOperands(3); +} + +::mlir::Operation::operand_range ParallelInsertSliceOp::getStrides() { + return getODSOperands(4); +} + +::mlir::OpOperand &ParallelInsertSliceOp::getSourceMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &ParallelInsertSliceOp::getDestMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange ParallelInsertSliceOp::getOffsetsMutable() { + auto range = getODSOperandIndexAndLength(2); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); + return mutableRange; +} + +::mlir::MutableOperandRange ParallelInsertSliceOp::getSizesMutable() { + auto range = getODSOperandIndexAndLength(3); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); + return mutableRange; +} + +::mlir::MutableOperandRange ParallelInsertSliceOp::getStridesMutable() { + auto range = getODSOperandIndexAndLength(4); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(4u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); + return mutableRange; +} + +std::pair ParallelInsertSliceOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ParallelInsertSliceOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::LogicalResult ParallelInsertSliceOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.static_offsets; + auto attr = dict.get("static_offsets"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for static_offsets in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `static_offsets` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.static_sizes; + auto attr = dict.get("static_sizes"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for static_sizes in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `static_sizes` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.static_strides; + auto attr = dict.get("static_strides"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for static_strides in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `static_strides` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } +; + { + auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, + ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return convertFromAttribute(propStorage, propAttr, emitError);; + }; + auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; + if (!attr) { + emitError() << "expected key entry for operandSegmentSizes in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + if (::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute ParallelInsertSliceOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.static_offsets; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("static_offsets", + propStorage)); + } + + { + const auto &propStorage = prop.static_sizes; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("static_sizes", + propStorage)); + } + + { + const auto &propStorage = prop.static_strides; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("static_strides", + propStorage)); + } + + { + const auto &propStorage = prop.operandSegmentSizes; + attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", + ::mlir::DenseI32ArrayAttr::get(ctx, propStorage))); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ParallelInsertSliceOp::computePropertiesHash(const Properties &prop) { + auto hash_operandSegmentSizes = [] (const auto &propStorage) -> llvm::hash_code { + return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; + }; + return llvm::hash_combine( + llvm::hash_value(prop.static_offsets.getAsOpaquePointer()), + llvm::hash_value(prop.static_sizes.getAsOpaquePointer()), + llvm::hash_value(prop.static_strides.getAsOpaquePointer()), + hash_operandSegmentSizes(prop.operandSegmentSizes)); +} + +std::optional ParallelInsertSliceOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "static_offsets") + return prop.static_offsets; + + if (name == "static_sizes") + return prop.static_sizes; + + if (name == "static_strides") + return prop.static_strides; + if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); + return std::nullopt; +} + +void ParallelInsertSliceOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "static_offsets") { + prop.static_offsets = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "static_sizes") { + prop.static_sizes = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "static_strides") { + prop.static_strides = ::llvm::dyn_cast_or_null>(value); + return; + } + if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { + auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); + if (!arrAttr) return; + if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) + return; + llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); + return; + } +} + +void ParallelInsertSliceOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.static_offsets) attrs.append("static_offsets", prop.static_offsets); + + if (prop.static_sizes) attrs.append("static_sizes", prop.static_sizes); + + if (prop.static_strides) attrs.append("static_strides", prop.static_strides); + attrs.append("operandSegmentSizes", ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes)); +} + +::mlir::LogicalResult ParallelInsertSliceOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getStaticOffsetsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(attr, "static_offsets", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getStaticSizesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(attr, "static_sizes", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getStaticStridesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(attr, "static_strides", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ParallelInsertSliceOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.static_offsets))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.static_sizes))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.static_strides))) + return ::mlir::failure(); + + { + auto &propStorage = prop.operandSegmentSizes; + auto readProp = [&]() { + +if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { + ::mlir::DenseI32ArrayAttr attr; + if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); + if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { + reader.emitError("size mismatch for operand/result_segment_size"); + return ::mlir::failure(); + } + ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); +} else { + return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); +} +; + return ::mlir::success(); + }; + if (::mlir::failed(readProp())) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +void ParallelInsertSliceOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.static_offsets); + writer.writeAttribute(prop.static_sizes); + writer.writeAttribute(prop.static_strides); + + { + auto &propStorage = prop.operandSegmentSizes; + +if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) + writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(getContext(), propStorage)); +else + writer.writeSparseArray(::llvm::ArrayRef(propStorage)); +; + } +} + +::mlir::DenseI64ArrayAttr ParallelInsertSliceOp::getStaticOffsetsAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().static_offsets); +} + +::llvm::ArrayRef ParallelInsertSliceOp::getStaticOffsets() { + auto attr = getStaticOffsetsAttr(); + return attr; +} + +::mlir::DenseI64ArrayAttr ParallelInsertSliceOp::getStaticSizesAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().static_sizes); +} + +::llvm::ArrayRef ParallelInsertSliceOp::getStaticSizes() { + auto attr = getStaticSizesAttr(); + return attr; +} + +::mlir::DenseI64ArrayAttr ParallelInsertSliceOp::getStaticStridesAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().static_strides); +} + +::llvm::ArrayRef ParallelInsertSliceOp::getStaticStrides() { + auto attr = getStaticStridesAttr(); + return attr; +} + +void ParallelInsertSliceOp::setStaticOffsetsAttr(::mlir::DenseI64ArrayAttr attr) { + (*this)->setAttr(getStaticOffsetsAttrName(), attr); +} + +void ParallelInsertSliceOp::setStaticOffsets(::llvm::ArrayRef attrValue) { + (*this)->setAttr(getStaticOffsetsAttrName(), ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue)); +} + +void ParallelInsertSliceOp::setStaticSizesAttr(::mlir::DenseI64ArrayAttr attr) { + (*this)->setAttr(getStaticSizesAttrName(), attr); +} + +void ParallelInsertSliceOp::setStaticSizes(::llvm::ArrayRef attrValue) { + (*this)->setAttr(getStaticSizesAttrName(), ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue)); +} + +void ParallelInsertSliceOp::setStaticStridesAttr(::mlir::DenseI64ArrayAttr attr) { + (*this)->setAttr(getStaticStridesAttrName(), attr); +} + +void ParallelInsertSliceOp::setStaticStrides(::llvm::ArrayRef attrValue) { + (*this)->setAttr(getStaticStridesAttrName(), ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue)); +} + +void ParallelInsertSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value source, ::mlir::Value dest, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::mlir::DenseI64ArrayAttr static_offsets, ::mlir::DenseI64ArrayAttr static_sizes, ::mlir::DenseI64ArrayAttr static_strides) { + odsState.addOperands(source); + odsState.addOperands(dest); + odsState.addOperands(offsets); + odsState.addOperands(sizes); + odsState.addOperands(strides); + ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(offsets.size()), static_cast(sizes.size()), static_cast(strides.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + odsState.getOrAddProperties().static_offsets = static_offsets; + odsState.getOrAddProperties().static_sizes = static_sizes; + odsState.getOrAddProperties().static_strides = static_strides; +} + +void ParallelInsertSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::mlir::DenseI64ArrayAttr static_offsets, ::mlir::DenseI64ArrayAttr static_sizes, ::mlir::DenseI64ArrayAttr static_strides) { + odsState.addOperands(source); + odsState.addOperands(dest); + odsState.addOperands(offsets); + odsState.addOperands(sizes); + odsState.addOperands(strides); + ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(offsets.size()), static_cast(sizes.size()), static_cast(strides.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + odsState.getOrAddProperties().static_offsets = static_offsets; + odsState.getOrAddProperties().static_sizes = static_sizes; + odsState.getOrAddProperties().static_strides = static_strides; + assert(resultTypes.size() == 0u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ParallelInsertSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value source, ::mlir::Value dest, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::llvm::ArrayRef static_offsets, ::llvm::ArrayRef static_sizes, ::llvm::ArrayRef static_strides) { + odsState.addOperands(source); + odsState.addOperands(dest); + odsState.addOperands(offsets); + odsState.addOperands(sizes); + odsState.addOperands(strides); + ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(offsets.size()), static_cast(sizes.size()), static_cast(strides.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + odsState.getOrAddProperties().static_offsets = odsBuilder.getDenseI64ArrayAttr(static_offsets); + odsState.getOrAddProperties().static_sizes = odsBuilder.getDenseI64ArrayAttr(static_sizes); + odsState.getOrAddProperties().static_strides = odsBuilder.getDenseI64ArrayAttr(static_strides); +} + +void ParallelInsertSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::llvm::ArrayRef static_offsets, ::llvm::ArrayRef static_sizes, ::llvm::ArrayRef static_strides) { + odsState.addOperands(source); + odsState.addOperands(dest); + odsState.addOperands(offsets); + odsState.addOperands(sizes); + odsState.addOperands(strides); + ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(offsets.size()), static_cast(sizes.size()), static_cast(strides.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + odsState.getOrAddProperties().static_offsets = odsBuilder.getDenseI64ArrayAttr(static_offsets); + odsState.getOrAddProperties().static_sizes = odsBuilder.getDenseI64ArrayAttr(static_sizes); + odsState.getOrAddProperties().static_strides = odsBuilder.getDenseI64ArrayAttr(static_strides); + assert(resultTypes.size() == 0u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ParallelInsertSliceOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ParallelInsertSliceOp::verifyInvariantsImpl() { + auto tblgen_static_offsets = getProperties().static_offsets; (void)tblgen_static_offsets; + if (!tblgen_static_offsets) return emitOpError("requires attribute 'static_offsets'"); + auto tblgen_static_sizes = getProperties().static_sizes; (void)tblgen_static_sizes; + if (!tblgen_static_sizes) return emitOpError("requires attribute 'static_sizes'"); + auto tblgen_static_strides = getProperties().static_strides; (void)tblgen_static_strides; + if (!tblgen_static_strides) return emitOpError("requires attribute 'static_strides'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(*this, tblgen_static_offsets, "static_offsets"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(*this, tblgen_static_sizes, "static_sizes"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(*this, tblgen_static_strides, "static_strides"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup3 = getODSOperands(3); + + for (auto v : valueGroup3) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup4 = getODSOperands(4); + + for (auto v : valueGroup4) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ParallelInsertSliceOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult ParallelInsertSliceOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(sourceRawOperands); ::llvm::SMLoc sourceOperandsLoc; + (void)sourceOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand destRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> destOperands(destRawOperands); ::llvm::SMLoc destOperandsLoc; + (void)destOperandsLoc; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> offsetsOperands; + ::llvm::SMLoc offsetsOperandsLoc; + (void)offsetsOperandsLoc; + ::mlir::DenseI64ArrayAttr static_offsetsAttr; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> sizesOperands; + ::llvm::SMLoc sizesOperandsLoc; + (void)sizesOperandsLoc; + ::mlir::DenseI64ArrayAttr static_sizesAttr; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> stridesOperands; + ::llvm::SMLoc stridesOperandsLoc; + (void)stridesOperandsLoc; + ::mlir::DenseI64ArrayAttr static_stridesAttr; + ::mlir::Type sourceRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> sourceTypes(sourceRawTypes); + ::mlir::Type destRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> destTypes(destRawTypes); + + sourceOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(sourceRawOperands[0])) + return ::mlir::failure(); + if (parser.parseKeyword("into")) + return ::mlir::failure(); + + destOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(destRawOperands[0])) + return ::mlir::failure(); + { + offsetsOperandsLoc = parser.getCurrentLocation(); + auto odsResult = parseDynamicIndexList(parser, offsetsOperands, static_offsetsAttr); + if (odsResult) return ::mlir::failure(); + result.getOrAddProperties().static_offsets = static_offsetsAttr; + } + { + sizesOperandsLoc = parser.getCurrentLocation(); + auto odsResult = parseDynamicIndexList(parser, sizesOperands, static_sizesAttr); + if (odsResult) return ::mlir::failure(); + result.getOrAddProperties().static_sizes = static_sizesAttr; + } + { + stridesOperandsLoc = parser.getCurrentLocation(); + auto odsResult = parseDynamicIndexList(parser, stridesOperands, static_stridesAttr); + if (odsResult) return ::mlir::failure(); + result.getOrAddProperties().static_strides = static_stridesAttr; + } + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::RankedTensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + sourceRawTypes[0] = type; + } + if (parser.parseKeyword("into")) + return ::mlir::failure(); + + { + ::mlir::RankedTensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + destRawTypes[0] = type; + } +::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(offsetsOperands.size()), static_cast(sizesOperands.size()), static_cast(stridesOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + if (parser.resolveOperands(sourceOperands, sourceTypes, sourceOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(destOperands, destTypes, destOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(offsetsOperands, odsBuildableType0, offsetsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(sizesOperands, odsBuildableType0, sizesOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(stridesOperands, odsBuildableType0, stridesOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ParallelInsertSliceOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getSource(); + _odsPrinter << ' ' << "into"; + _odsPrinter << ' '; + _odsPrinter << getDest(); + printDynamicIndexList(_odsPrinter, *this, getOffsets(), getStaticOffsetsAttr()); + _odsPrinter << ' '; + printDynamicIndexList(_odsPrinter, *this, getSizes(), getStaticSizesAttr()); + _odsPrinter << ' '; + printDynamicIndexList(_odsPrinter, *this, getStrides(), getStaticStridesAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("operandSegmentSizes"); + elidedAttrs.push_back("static_offsets"); + elidedAttrs.push_back("static_sizes"); + elidedAttrs.push_back("static_strides"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getSource().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::RankedTensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "into"; + _odsPrinter << ' '; + { + auto type = getDest().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::RankedTensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +} // namespace tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::tensor::ParallelInsertSliceOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::RankOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +RankOpGenericAdaptorBase::RankOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("tensor.rank", odsAttrs.getContext()); +} + +RankOpGenericAdaptorBase::RankOpGenericAdaptorBase(RankOp op) : RankOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair RankOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr RankOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +RankOpAdaptor::RankOpAdaptor(RankOp op) : RankOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult RankOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair RankOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range RankOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::TensorType> RankOp::getTensor() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &RankOp::getTensorMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair RankOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range RankOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +void RankOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value tensor) { + odsState.addOperands(tensor); + odsState.addTypes(resultType0); +} + +void RankOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value tensor) { + odsState.addOperands(tensor); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(RankOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void RankOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tensor) { + odsState.addOperands(tensor); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void RankOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void RankOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(RankOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult RankOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult RankOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::LogicalResult RankOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = odsBuilder.getIndexType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult RankOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand tensorRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> tensorOperands(tensorRawOperands); ::llvm::SMLoc tensorOperandsLoc; + (void)tensorOperandsLoc; + ::mlir::Type tensorRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> tensorTypes(tensorRawTypes); + + tensorOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(tensorRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::TensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + tensorRawTypes[0] = type; + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + result.addTypes(odsBuildableType0); + if (parser.resolveOperands(tensorOperands, tensorTypes, tensorOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void RankOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getTensor(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getTensor().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void RankOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::tensor::RankOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::ReshapeOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ReshapeOpGenericAdaptorBase::ReshapeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("tensor.reshape", odsAttrs.getContext()); +} + +ReshapeOpGenericAdaptorBase::ReshapeOpGenericAdaptorBase(ReshapeOp op) : ReshapeOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ReshapeOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ReshapeOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +ReshapeOpAdaptor::ReshapeOpAdaptor(ReshapeOp op) : ReshapeOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ReshapeOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair ReshapeOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ReshapeOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::TensorType> ReshapeOp::getSource() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::RankedTensorType> ReshapeOp::getShape() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); +} + +::mlir::OpOperand &ReshapeOp::getSourceMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &ReshapeOp::getShapeMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +std::pair ReshapeOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ReshapeOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::TensorType> ReshapeOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::TensorType>>(*getODSResults(0).begin()); +} + +void ReshapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, TensorType resultType, Value operand, Value shape) { + odsState.addOperands(operand); + odsState.addOperands(shape); + odsState.addTypes(resultType); + +} + +void ReshapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::Value shape) { + odsState.addOperands(source); + odsState.addOperands(shape); + odsState.addTypes(result); +} + +void ReshapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value shape) { + odsState.addOperands(source); + odsState.addOperands(shape); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ReshapeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ReshapeOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps7(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps0(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ReshapeOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult ReshapeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(sourceRawOperands); ::llvm::SMLoc sourceOperandsLoc; + (void)sourceOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand shapeRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> shapeOperands(shapeRawOperands); ::llvm::SMLoc shapeOperandsLoc; + (void)shapeOperandsLoc; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + + sourceOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(sourceRawOperands[0])) + return ::mlir::failure(); + if (parser.parseLParen()) + return ::mlir::failure(); + + shapeOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(shapeRawOperands[0])) + return ::mlir::failure(); + if (parser.parseRParen()) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(::llvm::concat(sourceOperands, shapeOperands), allOperandTypes, parser.getNameLoc(), result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ReshapeOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getSource(); + _odsPrinter << "("; + _odsPrinter << getShape(); + _odsPrinter << ")"; + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +void ReshapeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::tensor::ReshapeOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::ScatterOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ScatterOpGenericAdaptorBase::ScatterOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("tensor.scatter", odsAttrs.getContext()); +} + +ScatterOpGenericAdaptorBase::ScatterOpGenericAdaptorBase(ScatterOp op) : ScatterOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ScatterOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ScatterOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::DenseI64ArrayAttr ScatterOpGenericAdaptorBase::getScatterDimsAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().scatter_dims); + return attr; +} + +::llvm::ArrayRef ScatterOpGenericAdaptorBase::getScatterDims() { + auto attr = getScatterDimsAttr(); + return attr; +} + +::mlir::UnitAttr ScatterOpGenericAdaptorBase::getUniqueAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().unique); + if (!attr) + attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); + return attr; +} + +bool ScatterOpGenericAdaptorBase::getUnique() { + auto attr = getUniqueAttr(); + if (!attr) + return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; + return attr != nullptr; +} + +} // namespace detail +ScatterOpAdaptor::ScatterOpAdaptor(ScatterOp op) : ScatterOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ScatterOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_scatter_dims = getProperties().scatter_dims; (void)tblgen_scatter_dims; + if (!tblgen_scatter_dims) return emitError(loc, "'tensor.scatter' op ""requires attribute 'scatter_dims'"); + auto tblgen_unique = getProperties().unique; (void)tblgen_unique; + + if (tblgen_scatter_dims && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_scatter_dims)))) + return emitError(loc, "'tensor.scatter' op ""attribute 'scatter_dims' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_unique && !((::llvm::isa<::mlir::UnitAttr>(tblgen_unique)))) + return emitError(loc, "'tensor.scatter' op ""attribute 'unique' failed to satisfy constraint: unit attribute"); + return ::mlir::success(); +} + +std::pair ScatterOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ScatterOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::RankedTensorType> ScatterOp::getSource() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::RankedTensorType> ScatterOp::getDest() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); +} + +::mlir::TypedValue<::mlir::RankedTensorType> ScatterOp::getIndices() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(2).begin()); +} + +::mlir::OpOperand &ScatterOp::getSourceMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &ScatterOp::getDestMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &ScatterOp::getIndicesMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); +} + +std::pair ScatterOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ScatterOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::RankedTensorType> ScatterOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult ScatterOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.scatter_dims; + auto attr = dict.get("scatter_dims"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for scatter_dims in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `scatter_dims` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.unique; + auto attr = dict.get("unique"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for unique in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `unique` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ScatterOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.scatter_dims; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("scatter_dims", + propStorage)); + } + + { + const auto &propStorage = prop.unique; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("unique", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ScatterOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.scatter_dims.getAsOpaquePointer()), + llvm::hash_value(prop.unique.getAsOpaquePointer())); +} + +std::optional ScatterOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "scatter_dims") + return prop.scatter_dims; + + if (name == "unique") + return prop.unique; + return std::nullopt; +} + +void ScatterOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "scatter_dims") { + prop.scatter_dims = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "unique") { + prop.unique = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ScatterOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.scatter_dims) attrs.append("scatter_dims", prop.scatter_dims); + + if (prop.unique) attrs.append("unique", prop.unique); +} + +::mlir::LogicalResult ScatterOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getScatterDimsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(attr, "scatter_dims", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getUniqueAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps2(attr, "unique", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ScatterOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.scatter_dims))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.unique))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ScatterOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.scatter_dims); + + writer.writeOptionalAttribute(prop.unique); +} + +::mlir::DenseI64ArrayAttr ScatterOp::getScatterDimsAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().scatter_dims); +} + +::llvm::ArrayRef ScatterOp::getScatterDims() { + auto attr = getScatterDimsAttr(); + return attr; +} + +::mlir::UnitAttr ScatterOp::getUniqueAttr() { + return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().unique); +} + +bool ScatterOp::getUnique() { + auto attr = getUniqueAttr(); + if (!attr) + return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; + return attr != nullptr; +} + +void ScatterOp::setScatterDimsAttr(::mlir::DenseI64ArrayAttr attr) { + (*this)->setAttr(getScatterDimsAttrName(), attr); +} + +void ScatterOp::setScatterDims(::llvm::ArrayRef attrValue) { + (*this)->setAttr(getScatterDimsAttrName(), ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue)); +} + +void ScatterOp::setUniqueAttr(::mlir::UnitAttr attr) { + (*this)->setAttr(getUniqueAttrName(), attr); +} + +void ScatterOp::setUnique(bool attrValue) { + if (attrValue) + return (*this)->setAttr(getUniqueAttrName(), ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr)); + (*this)->removeAttr(getUniqueAttrName()); +} + +::mlir::Attribute ScatterOp::removeUniqueAttr() { + auto &attr = getProperties().unique; + attr = {}; + return attr; +} + +void ScatterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::Value dest, ::mlir::Value indices, ::mlir::DenseI64ArrayAttr scatter_dims, /*optional*/::mlir::UnitAttr unique) { + odsState.addOperands(source); + odsState.addOperands(dest); + odsState.addOperands(indices); + odsState.getOrAddProperties().scatter_dims = scatter_dims; + if (unique) { + odsState.getOrAddProperties().unique = unique; + } + odsState.addTypes(result); +} + +void ScatterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, ::mlir::Value indices, ::mlir::DenseI64ArrayAttr scatter_dims, /*optional*/::mlir::UnitAttr unique) { + odsState.addOperands(source); + odsState.addOperands(dest); + odsState.addOperands(indices); + odsState.getOrAddProperties().scatter_dims = scatter_dims; + if (unique) { + odsState.getOrAddProperties().unique = unique; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ScatterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::Value dest, ::mlir::Value indices, ::llvm::ArrayRef scatter_dims, /*optional*/bool unique) { + odsState.addOperands(source); + odsState.addOperands(dest); + odsState.addOperands(indices); + odsState.getOrAddProperties().scatter_dims = odsBuilder.getDenseI64ArrayAttr(scatter_dims); + if (unique) { + odsState.getOrAddProperties().unique = ((unique) ? odsBuilder.getUnitAttr() : nullptr); + } + odsState.addTypes(result); +} + +void ScatterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, ::mlir::Value indices, ::llvm::ArrayRef scatter_dims, /*optional*/bool unique) { + odsState.addOperands(source); + odsState.addOperands(dest); + odsState.addOperands(indices); + odsState.getOrAddProperties().scatter_dims = odsBuilder.getDenseI64ArrayAttr(scatter_dims); + if (unique) { + odsState.getOrAddProperties().unique = ((unique) ? odsBuilder.getUnitAttr() : nullptr); + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ScatterOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ScatterOp::verifyInvariantsImpl() { + auto tblgen_scatter_dims = getProperties().scatter_dims; (void)tblgen_scatter_dims; + if (!tblgen_scatter_dims) return emitOpError("requires attribute 'scatter_dims'"); + auto tblgen_unique = getProperties().unique; (void)tblgen_unique; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(*this, tblgen_scatter_dims, "scatter_dims"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps2(*this, tblgen_unique, "unique"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ScatterOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult ScatterOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(sourceRawOperands); ::llvm::SMLoc sourceOperandsLoc; + (void)sourceOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand destRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> destOperands(destRawOperands); ::llvm::SMLoc destOperandsLoc; + (void)destOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand indicesRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> indicesOperands(indicesRawOperands); ::llvm::SMLoc indicesOperandsLoc; + (void)indicesOperandsLoc; + ::mlir::DenseI64ArrayAttr scatter_dimsAttr; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + + sourceOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(sourceRawOperands[0])) + return ::mlir::failure(); + if (parser.parseKeyword("into")) + return ::mlir::failure(); + + destOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(destRawOperands[0])) + return ::mlir::failure(); + if (parser.parseLSquare()) + return ::mlir::failure(); + + indicesOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(indicesRawOperands[0])) + return ::mlir::failure(); + if (parser.parseRSquare()) + return ::mlir::failure(); + if (parser.parseKeyword("scatter_dims")) + return ::mlir::failure(); + if (parser.parseLParen()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(scatter_dimsAttr, ::mlir::Type{})) { + return ::mlir::failure(); + } + if (scatter_dimsAttr) result.getOrAddProperties().scatter_dims = scatter_dimsAttr; + if (parser.parseRParen()) + return ::mlir::failure(); + if (::mlir::succeeded(parser.parseOptionalKeyword("unique"))) { + result.getOrAddProperties().unique = parser.getBuilder().getUnitAttr(); } + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(::llvm::concat(sourceOperands, destOperands, indicesOperands), allOperandTypes, parser.getNameLoc(), result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ScatterOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getSource(); + _odsPrinter << ' ' << "into"; + _odsPrinter << ' '; + _odsPrinter << getDest(); + _odsPrinter << "["; + _odsPrinter << getIndices(); + _odsPrinter << "]"; + _odsPrinter << ' ' << "scatter_dims"; + _odsPrinter << "("; +_odsPrinter.printStrippedAttrOrType(getScatterDimsAttr()); + _odsPrinter << ")"; + if (getUniqueAttr()) { + _odsPrinter << ' ' << "unique"; + } + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("scatter_dims"); + elidedAttrs.push_back("unique"); + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getUniqueAttr(); + if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) + elidedAttrs.push_back("unique"); + } + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +void ScatterOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::tensor::ScatterOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::SplatOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +SplatOpGenericAdaptorBase::SplatOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("tensor.splat", odsAttrs.getContext()); +} + +SplatOpGenericAdaptorBase::SplatOpGenericAdaptorBase(SplatOp op) : SplatOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair SplatOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr SplatOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +SplatOpAdaptor::SplatOpAdaptor(SplatOp op) : SplatOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult SplatOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair SplatOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range SplatOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value SplatOp::getInput() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &SplatOp::getInputMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair SplatOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range SplatOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::RankedTensorType> SplatOp::getAggregate() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); +} + +void SplatOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value element, Type aggregateType) { + build(odsBuilder, odsState, aggregateType, element); +} + +void SplatOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type aggregate, ::mlir::Value input) { + odsState.addOperands(input); + odsState.addTypes(aggregate); +} + +void SplatOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input) { + odsState.addOperands(input); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SplatOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult SplatOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps5(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((std::equal_to<>()(::llvm::cast((*this->getODSResults(0).begin()).getType()).getElementType(), (*this->getODSOperands(0).begin()).getType())))) + return emitOpError("failed to verify that operand type matches element type of result"); + return ::mlir::success(); +} + +::mlir::LogicalResult SplatOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult SplatOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand inputRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> inputOperands(inputRawOperands); ::llvm::SMLoc inputOperandsLoc; + (void)inputOperandsLoc; + ::mlir::Type aggregateRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> aggregateTypes(aggregateRawTypes); + + inputOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(inputRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::RankedTensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + aggregateRawTypes[0] = type; + } + for (::mlir::Type type : aggregateTypes) { + (void)type; + if (!((((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::cast<::mlir::ShapedType>(type).hasStaticShape()))) && ([](::mlir::Type elementType) { return (true); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return parser.emitError(parser.getNameLoc()) << "'aggregate' must be statically shaped tensor of any type values, but got " << type; + } + } + result.addTypes(aggregateTypes); + if (parser.resolveOperands(inputOperands, ::llvm::cast(aggregateTypes[0]).getElementType(), inputOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SplatOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getInput(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getAggregate().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::RankedTensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void SplatOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::tensor::SplatOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::UnPackOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +UnPackOpGenericAdaptorBase::UnPackOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("tensor.unpack", odsAttrs.getContext()); +} + +UnPackOpGenericAdaptorBase::UnPackOpGenericAdaptorBase(UnPackOp op) : UnPackOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair UnPackOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 2) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr UnPackOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::DenseI64ArrayAttr UnPackOpGenericAdaptorBase::getOuterDimsPermAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().outer_dims_perm); + if (!attr) + attr = ::mlir::Builder(odsAttrs.getContext()).getDenseI64ArrayAttr({}); + return attr; +} + +::llvm::ArrayRef UnPackOpGenericAdaptorBase::getOuterDimsPerm() { + auto attr = getOuterDimsPermAttr(); + if (!attr) + return ::mlir::Builder(odsAttrs.getContext()).getDenseI64ArrayAttr({}); + return attr; +} + +::mlir::DenseI64ArrayAttr UnPackOpGenericAdaptorBase::getInnerDimsPosAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().inner_dims_pos); + return attr; +} + +::llvm::ArrayRef UnPackOpGenericAdaptorBase::getInnerDimsPos() { + auto attr = getInnerDimsPosAttr(); + return attr; +} + +::mlir::DenseI64ArrayAttr UnPackOpGenericAdaptorBase::getStaticInnerTilesAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().static_inner_tiles); + return attr; +} + +::llvm::ArrayRef UnPackOpGenericAdaptorBase::getStaticInnerTiles() { + auto attr = getStaticInnerTilesAttr(); + return attr; +} + +} // namespace detail +UnPackOpAdaptor::UnPackOpAdaptor(UnPackOp op) : UnPackOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult UnPackOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_inner_dims_pos = getProperties().inner_dims_pos; (void)tblgen_inner_dims_pos; + if (!tblgen_inner_dims_pos) return emitError(loc, "'tensor.unpack' op ""requires attribute 'inner_dims_pos'"); + auto tblgen_outer_dims_perm = getProperties().outer_dims_perm; (void)tblgen_outer_dims_perm; + auto tblgen_static_inner_tiles = getProperties().static_inner_tiles; (void)tblgen_static_inner_tiles; + if (!tblgen_static_inner_tiles) return emitError(loc, "'tensor.unpack' op ""requires attribute 'static_inner_tiles'"); + + if (tblgen_outer_dims_perm && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_outer_dims_perm)))) + return emitError(loc, "'tensor.unpack' op ""attribute 'outer_dims_perm' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_inner_dims_pos && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_inner_dims_pos)))) + return emitError(loc, "'tensor.unpack' op ""attribute 'inner_dims_pos' failed to satisfy constraint: i64 dense array attribute"); + + if (tblgen_static_inner_tiles && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_static_inner_tiles)))) + return emitError(loc, "'tensor.unpack' op ""attribute 'static_inner_tiles' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +std::pair UnPackOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 2) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range UnPackOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::RankedTensorType> UnPackOp::getSource() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::RankedTensorType> UnPackOp::getDest() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSOperands(1).begin()); +} + +::mlir::Operation::operand_range UnPackOp::getInnerTiles() { + return getODSOperands(2); +} + +::mlir::OpOperand &UnPackOp::getSourceMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &UnPackOp::getDestMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange UnPackOp::getInnerTilesMutable() { + auto range = getODSOperandIndexAndLength(2); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair UnPackOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range UnPackOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::RankedTensorType> UnPackOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult UnPackOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.inner_dims_pos; + auto attr = dict.get("inner_dims_pos"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for inner_dims_pos in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `inner_dims_pos` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.outer_dims_perm; + auto attr = dict.get("outer_dims_perm"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for outer_dims_perm in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `outer_dims_perm` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.static_inner_tiles; + auto attr = dict.get("static_inner_tiles"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for static_inner_tiles in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `static_inner_tiles` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute UnPackOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.inner_dims_pos; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("inner_dims_pos", + propStorage)); + } + + { + const auto &propStorage = prop.outer_dims_perm; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("outer_dims_perm", + propStorage)); + } + + { + const auto &propStorage = prop.static_inner_tiles; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("static_inner_tiles", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code UnPackOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.inner_dims_pos.getAsOpaquePointer()), + llvm::hash_value(prop.outer_dims_perm.getAsOpaquePointer()), + llvm::hash_value(prop.static_inner_tiles.getAsOpaquePointer())); +} + +std::optional UnPackOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "inner_dims_pos") + return prop.inner_dims_pos; + + if (name == "outer_dims_perm") + return prop.outer_dims_perm; + + if (name == "static_inner_tiles") + return prop.static_inner_tiles; + return std::nullopt; +} + +void UnPackOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "inner_dims_pos") { + prop.inner_dims_pos = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "outer_dims_perm") { + prop.outer_dims_perm = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "static_inner_tiles") { + prop.static_inner_tiles = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void UnPackOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.inner_dims_pos) attrs.append("inner_dims_pos", prop.inner_dims_pos); + + if (prop.outer_dims_perm) attrs.append("outer_dims_perm", prop.outer_dims_perm); + + if (prop.static_inner_tiles) attrs.append("static_inner_tiles", prop.static_inner_tiles); +} + +::mlir::LogicalResult UnPackOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getInnerDimsPosAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(attr, "inner_dims_pos", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getOuterDimsPermAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(attr, "outer_dims_perm", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getStaticInnerTilesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(attr, "static_inner_tiles", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult UnPackOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.inner_dims_pos))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.outer_dims_perm))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.static_inner_tiles))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void UnPackOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.inner_dims_pos); + + writer.writeOptionalAttribute(prop.outer_dims_perm); + writer.writeAttribute(prop.static_inner_tiles); +} + +::mlir::DenseI64ArrayAttr UnPackOp::getOuterDimsPermAttr() { + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(getProperties().outer_dims_perm); +} + +::llvm::ArrayRef UnPackOp::getOuterDimsPerm() { + auto attr = getOuterDimsPermAttr(); + if (!attr) + return ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr({}); + return attr; +} + +::mlir::DenseI64ArrayAttr UnPackOp::getInnerDimsPosAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().inner_dims_pos); +} + +::llvm::ArrayRef UnPackOp::getInnerDimsPos() { + auto attr = getInnerDimsPosAttr(); + return attr; +} + +::mlir::DenseI64ArrayAttr UnPackOp::getStaticInnerTilesAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().static_inner_tiles); +} + +::llvm::ArrayRef UnPackOp::getStaticInnerTiles() { + auto attr = getStaticInnerTilesAttr(); + return attr; +} + +void UnPackOp::setOuterDimsPermAttr(::mlir::DenseI64ArrayAttr attr) { + (*this)->setAttr(getOuterDimsPermAttrName(), attr); +} + +void UnPackOp::setOuterDimsPerm(::std::optional<::llvm::ArrayRef> attrValue) { + if (attrValue) + return (*this)->setAttr(getOuterDimsPermAttrName(), ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(*attrValue)); + (*this)->removeAttr(getOuterDimsPermAttrName()); +} + +void UnPackOp::setInnerDimsPosAttr(::mlir::DenseI64ArrayAttr attr) { + (*this)->setAttr(getInnerDimsPosAttrName(), attr); +} + +void UnPackOp::setInnerDimsPos(::llvm::ArrayRef attrValue) { + (*this)->setAttr(getInnerDimsPosAttrName(), ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue)); +} + +void UnPackOp::setStaticInnerTilesAttr(::mlir::DenseI64ArrayAttr attr) { + (*this)->setAttr(getStaticInnerTilesAttrName(), attr); +} + +void UnPackOp::setStaticInnerTiles(::llvm::ArrayRef attrValue) { + (*this)->setAttr(getStaticInnerTilesAttrName(), ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue)); +} + +::mlir::Attribute UnPackOp::removeOuterDimsPermAttr() { + auto &attr = getProperties().outer_dims_perm; + attr = {}; + return attr; +} + +void UnPackOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::DenseI64ArrayAttr outer_dims_perm, ::mlir::DenseI64ArrayAttr inner_dims_pos, ::mlir::ValueRange inner_tiles, ::mlir::DenseI64ArrayAttr static_inner_tiles) { + odsState.addOperands(source); + odsState.addOperands(dest); + odsState.addOperands(inner_tiles); + if (outer_dims_perm) { + odsState.getOrAddProperties().outer_dims_perm = outer_dims_perm; + } + odsState.getOrAddProperties().inner_dims_pos = inner_dims_pos; + odsState.getOrAddProperties().static_inner_tiles = static_inner_tiles; + odsState.addTypes(result); +} + +void UnPackOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::DenseI64ArrayAttr outer_dims_perm, ::mlir::DenseI64ArrayAttr inner_dims_pos, ::mlir::ValueRange inner_tiles, ::mlir::DenseI64ArrayAttr static_inner_tiles) { + odsState.addOperands(source); + odsState.addOperands(dest); + odsState.addOperands(inner_tiles); + if (outer_dims_perm) { + odsState.getOrAddProperties().outer_dims_perm = outer_dims_perm; + } + odsState.getOrAddProperties().inner_dims_pos = inner_dims_pos; + odsState.getOrAddProperties().static_inner_tiles = static_inner_tiles; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(UnPackOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void UnPackOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::DenseI64ArrayAttr outer_dims_perm, ::mlir::DenseI64ArrayAttr inner_dims_pos, ::mlir::ValueRange inner_tiles, ::mlir::DenseI64ArrayAttr static_inner_tiles) { + odsState.addOperands(source); + odsState.addOperands(dest); + odsState.addOperands(inner_tiles); + if (outer_dims_perm) { + odsState.getOrAddProperties().outer_dims_perm = outer_dims_perm; + } + odsState.getOrAddProperties().inner_dims_pos = inner_dims_pos; + odsState.getOrAddProperties().static_inner_tiles = static_inner_tiles; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void UnPackOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::Value dest, /*optional*/::llvm::ArrayRef outer_dims_perm, ::llvm::ArrayRef inner_dims_pos, ::mlir::ValueRange inner_tiles, ::llvm::ArrayRef static_inner_tiles) { + odsState.addOperands(source); + odsState.addOperands(dest); + odsState.addOperands(inner_tiles); + odsState.getOrAddProperties().outer_dims_perm = odsBuilder.getDenseI64ArrayAttr(outer_dims_perm); + odsState.getOrAddProperties().inner_dims_pos = odsBuilder.getDenseI64ArrayAttr(inner_dims_pos); + odsState.getOrAddProperties().static_inner_tiles = odsBuilder.getDenseI64ArrayAttr(static_inner_tiles); + odsState.addTypes(result); +} + +void UnPackOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value source, ::mlir::Value dest, /*optional*/::llvm::ArrayRef outer_dims_perm, ::llvm::ArrayRef inner_dims_pos, ::mlir::ValueRange inner_tiles, ::llvm::ArrayRef static_inner_tiles) { + odsState.addOperands(source); + odsState.addOperands(dest); + odsState.addOperands(inner_tiles); + odsState.getOrAddProperties().outer_dims_perm = odsBuilder.getDenseI64ArrayAttr(outer_dims_perm); + odsState.getOrAddProperties().inner_dims_pos = odsBuilder.getDenseI64ArrayAttr(inner_dims_pos); + odsState.getOrAddProperties().static_inner_tiles = odsBuilder.getDenseI64ArrayAttr(static_inner_tiles); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(UnPackOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void UnPackOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, /*optional*/::llvm::ArrayRef outer_dims_perm, ::llvm::ArrayRef inner_dims_pos, ::mlir::ValueRange inner_tiles, ::llvm::ArrayRef static_inner_tiles) { + odsState.addOperands(source); + odsState.addOperands(dest); + odsState.addOperands(inner_tiles); + odsState.getOrAddProperties().outer_dims_perm = odsBuilder.getDenseI64ArrayAttr(outer_dims_perm); + odsState.getOrAddProperties().inner_dims_pos = odsBuilder.getDenseI64ArrayAttr(inner_dims_pos); + odsState.getOrAddProperties().static_inner_tiles = odsBuilder.getDenseI64ArrayAttr(static_inner_tiles); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void UnPackOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void UnPackOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(UnPackOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult UnPackOp::verifyInvariantsImpl() { + auto tblgen_inner_dims_pos = getProperties().inner_dims_pos; (void)tblgen_inner_dims_pos; + if (!tblgen_inner_dims_pos) return emitOpError("requires attribute 'inner_dims_pos'"); + auto tblgen_outer_dims_perm = getProperties().outer_dims_perm; (void)tblgen_outer_dims_perm; + auto tblgen_static_inner_tiles = getProperties().static_inner_tiles; (void)tblgen_static_inner_tiles; + if (!tblgen_static_inner_tiles) return emitOpError("requires attribute 'static_inner_tiles'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(*this, tblgen_outer_dims_perm, "outer_dims_perm"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(*this, tblgen_inner_dims_pos, "inner_dims_pos"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TensorOps1(*this, tblgen_static_inner_tiles, "static_inner_tiles"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((std::equal_to<>()((*this->getODSOperands(1).begin()).getType(), (*this->getODSResults(0).begin()).getType())))) + return emitOpError("failed to verify that result type matches type of dest"); + return ::mlir::success(); +} + +::mlir::LogicalResult UnPackOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +void UnPackOp::getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context) { + results.add(canonicalize); +} + +::mlir::LogicalResult UnPackOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = operands[1].getType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult UnPackOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(sourceRawOperands); ::llvm::SMLoc sourceOperandsLoc; + (void)sourceOperandsLoc; + ::mlir::DenseI64ArrayAttr outer_dims_permAttr; + ::mlir::DenseI64ArrayAttr inner_dims_posAttr; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> inner_tilesOperands; + ::llvm::SMLoc inner_tilesOperandsLoc; + (void)inner_tilesOperandsLoc; + ::mlir::DenseI64ArrayAttr static_inner_tilesAttr; + ::mlir::OpAsmParser::UnresolvedOperand destRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> destOperands(destRawOperands); ::llvm::SMLoc destOperandsLoc; + (void)destOperandsLoc; + ::mlir::Type sourceRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> sourceTypes(sourceRawTypes); + ::mlir::Type destRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> destTypes(destRawTypes); + + sourceOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(sourceRawOperands[0])) + return ::mlir::failure(); + if (::mlir::succeeded(parser.parseOptionalKeyword("outer_dims_perm"))) { + if (parser.parseEqual()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(outer_dims_permAttr, ::mlir::Type{})) { + return ::mlir::failure(); + } + if (outer_dims_permAttr) result.getOrAddProperties().outer_dims_perm = outer_dims_permAttr; + } + if (parser.parseKeyword("inner_dims_pos")) + return ::mlir::failure(); + if (parser.parseEqual()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(inner_dims_posAttr, ::mlir::Type{})) { + return ::mlir::failure(); + } + if (inner_dims_posAttr) result.getOrAddProperties().inner_dims_pos = inner_dims_posAttr; + if (parser.parseKeyword("inner_tiles")) + return ::mlir::failure(); + if (parser.parseEqual()) + return ::mlir::failure(); + { + inner_tilesOperandsLoc = parser.getCurrentLocation(); + auto odsResult = parseDynamicIndexList(parser, inner_tilesOperands, static_inner_tilesAttr); + if (odsResult) return ::mlir::failure(); + result.getOrAddProperties().static_inner_tiles = static_inner_tilesAttr; + } + if (parser.parseKeyword("into")) + return ::mlir::failure(); + + destOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(destRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::RankedTensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + sourceRawTypes[0] = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::RankedTensorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + destRawTypes[0] = type; + } + for (::mlir::Type type : destTypes) { + (void)type; + if (!(((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return (true); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return parser.emitError(parser.getNameLoc()) << "'dest' must be ranked tensor of any type values, but got " << type; + } + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + result.addTypes(destTypes[0]); + if (parser.resolveOperands(sourceOperands, sourceTypes, sourceOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(destOperands, destTypes, destOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(inner_tilesOperands, odsBuildableType0, inner_tilesOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void UnPackOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getSource(); + if (getOuterDimsPermAttr()) { + _odsPrinter << ' ' << "outer_dims_perm"; + _odsPrinter << ' ' << "="; + _odsPrinter << ' '; + _odsPrinter.printStrippedAttrOrType(getOuterDimsPermAttr()); + } + _odsPrinter << ' ' << "inner_dims_pos"; + _odsPrinter << ' ' << "="; + _odsPrinter << ' '; +_odsPrinter.printStrippedAttrOrType(getInnerDimsPosAttr()); + _odsPrinter << ' ' << "inner_tiles"; + _odsPrinter << ' ' << "="; + _odsPrinter << ' '; + printDynamicIndexList(_odsPrinter, *this, getInnerTiles(), getStaticInnerTilesAttr()); + _odsPrinter << ' ' << "into"; + _odsPrinter << ' '; + _odsPrinter << getDest(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("outer_dims_perm"); + elidedAttrs.push_back("inner_dims_pos"); + elidedAttrs.push_back("static_inner_tiles"); + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getOuterDimsPermAttr(); + if(attr && (attr == odsBuilder.getDenseI64ArrayAttr({}))) + elidedAttrs.push_back("outer_dims_perm"); + } + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getSource().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::RankedTensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getDest().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::RankedTensorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void UnPackOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::tensor::UnPackOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::YieldOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +YieldOpGenericAdaptorBase::YieldOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("tensor.yield", odsAttrs.getContext()); +} + +YieldOpGenericAdaptorBase::YieldOpGenericAdaptorBase(YieldOp op) : YieldOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair YieldOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr YieldOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +YieldOpAdaptor::YieldOpAdaptor(YieldOp op) : YieldOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult YieldOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair YieldOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range YieldOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value YieldOp::getValue() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &YieldOp::getValueMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair YieldOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range YieldOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +void YieldOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { + /* nothing to do */ +} + +void YieldOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value value) { + odsState.addOperands(value); +} + +void YieldOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value value) { + odsState.addOperands(value); + assert(resultTypes.size() == 0u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void YieldOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult YieldOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TensorOps4(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult YieldOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult YieldOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand valueRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> valueOperands(valueRawOperands); ::llvm::SMLoc valueOperandsLoc; + (void)valueOperandsLoc; + ::mlir::Type valueRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> valueTypes(valueRawTypes); + + valueOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(valueRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + valueRawTypes[0] = type; + } + if (parser.resolveOperands(valueOperands, valueTypes, valueOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void YieldOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getValue(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getValue().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void YieldOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::mlir::MutableOperandRange YieldOp::getMutableSuccessorOperands( + ::mlir::RegionBranchPoint point) { + return ::mlir::MutableOperandRange(*this); +} + +} // namespace tensor +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::tensor::YieldOp) + + +#endif // GET_OP_CLASSES + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/IR/TensorOps.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/IR/TensorOps.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..4208426b915966a7d3979aa18d669639918c388d --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/IR/TensorOps.h.inc @@ -0,0 +1,4144 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Op Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: TensorOps.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#if defined(GET_OP_CLASSES) || defined(GET_OP_FWD_DEFINES) +#undef GET_OP_FWD_DEFINES +namespace mlir { +namespace tensor { +class BitcastOp; +} // namespace tensor +} // namespace mlir +namespace mlir { +namespace tensor { +class CastOp; +} // namespace tensor +} // namespace mlir +namespace mlir { +namespace tensor { +class CollapseShapeOp; +} // namespace tensor +} // namespace mlir +namespace mlir { +namespace tensor { +class DimOp; +} // namespace tensor +} // namespace mlir +namespace mlir { +namespace tensor { +class EmptyOp; +} // namespace tensor +} // namespace mlir +namespace mlir { +namespace tensor { +class ExpandShapeOp; +} // namespace tensor +} // namespace mlir +namespace mlir { +namespace tensor { +class ExtractOp; +} // namespace tensor +} // namespace mlir +namespace mlir { +namespace tensor { +class ExtractSliceOp; +} // namespace tensor +} // namespace mlir +namespace mlir { +namespace tensor { +class FromElementsOp; +} // namespace tensor +} // namespace mlir +namespace mlir { +namespace tensor { +class GatherOp; +} // namespace tensor +} // namespace mlir +namespace mlir { +namespace tensor { +class GenerateOp; +} // namespace tensor +} // namespace mlir +namespace mlir { +namespace tensor { +class InsertOp; +} // namespace tensor +} // namespace mlir +namespace mlir { +namespace tensor { +class InsertSliceOp; +} // namespace tensor +} // namespace mlir +namespace mlir { +namespace tensor { +class PackOp; +} // namespace tensor +} // namespace mlir +namespace mlir { +namespace tensor { +class PadOp; +} // namespace tensor +} // namespace mlir +namespace mlir { +namespace tensor { +class ParallelInsertSliceOp; +} // namespace tensor +} // namespace mlir +namespace mlir { +namespace tensor { +class RankOp; +} // namespace tensor +} // namespace mlir +namespace mlir { +namespace tensor { +class ReshapeOp; +} // namespace tensor +} // namespace mlir +namespace mlir { +namespace tensor { +class ScatterOp; +} // namespace tensor +} // namespace mlir +namespace mlir { +namespace tensor { +class SplatOp; +} // namespace tensor +} // namespace mlir +namespace mlir { +namespace tensor { +class UnPackOp; +} // namespace tensor +} // namespace mlir +namespace mlir { +namespace tensor { +class YieldOp; +} // namespace tensor +} // namespace mlir +#endif + +#ifdef GET_OP_CLASSES +#undef GET_OP_CLASSES + + +//===----------------------------------------------------------------------===// +// Local Utility Method Definitions +//===----------------------------------------------------------------------===// + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::BitcastOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BitcastOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + BitcastOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + BitcastOpGenericAdaptorBase(BitcastOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class BitcastOpGenericAdaptor : public detail::BitcastOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BitcastOpGenericAdaptorBase; +public: + BitcastOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BitcastOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BitcastOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + BitcastOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSource() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BitcastOpAdaptor : public BitcastOpGenericAdaptor<::mlir::ValueRange> { +public: + using BitcastOpGenericAdaptor::BitcastOpGenericAdaptor; + BitcastOpAdaptor(BitcastOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class BitcastOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::CastOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = BitcastOpAdaptor; + template + using GenericAdaptor = BitcastOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("tensor.bitcast"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::TensorType> getSource(); + ::mlir::OpOperand &getSourceMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::TensorType> getDest(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dest, ::mlir::Value source); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + static bool areCastCompatible(::mlir::TypeRange inputs, ::mlir::TypeRange outputs); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::tensor::BitcastOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::CastOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CastOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + CastOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + CastOpGenericAdaptorBase(CastOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class CastOpGenericAdaptor : public detail::CastOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CastOpGenericAdaptorBase; +public: + CastOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CastOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CastOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + CastOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSource() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class CastOpAdaptor : public CastOpGenericAdaptor<::mlir::ValueRange> { +public: + using CastOpGenericAdaptor::CastOpGenericAdaptor; + CastOpAdaptor(CastOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class CastOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::CastOpInterface::Trait, ::mlir::OpAsmOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = CastOpAdaptor; + template + using GenericAdaptor = CastOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("tensor.cast"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::TensorType> getSource(); + ::mlir::OpOperand &getSourceMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::TensorType> getDest(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dest, ::mlir::Value source); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + static bool areCastCompatible(::mlir::TypeRange inputs, ::mlir::TypeRange outputs); + void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::tensor::CastOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::CollapseShapeOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CollapseShapeOpGenericAdaptorBase { +public: + struct Properties { + using reassociationTy = ::mlir::ArrayAttr; + reassociationTy reassociation; + + auto getReassociation() { + auto &propStorage = this->reassociation; + return ::llvm::cast<::mlir::ArrayAttr>(propStorage); + } + void setReassociation(const ::mlir::ArrayAttr &propValue) { + this->reassociation = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.reassociation == this->reassociation && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + CollapseShapeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + CollapseShapeOpGenericAdaptorBase(CollapseShapeOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::ArrayAttr getReassociationAttr(); + ::mlir::ArrayAttr getReassociation(); +}; +} // namespace detail +template +class CollapseShapeOpGenericAdaptor : public detail::CollapseShapeOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CollapseShapeOpGenericAdaptorBase; +public: + CollapseShapeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CollapseShapeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CollapseShapeOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + CollapseShapeOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSrc() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class CollapseShapeOpAdaptor : public CollapseShapeOpGenericAdaptor<::mlir::ValueRange> { +public: + using CollapseShapeOpGenericAdaptor::CollapseShapeOpGenericAdaptor; + CollapseShapeOpAdaptor(CollapseShapeOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class CollapseShapeOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpAsmOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = CollapseShapeOpAdaptor; + template + using GenericAdaptor = CollapseShapeOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("reassociation")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getReassociationAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getReassociationAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("tensor.collapse_shape"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::RankedTensorType> getSrc(); + ::mlir::OpOperand &getSrcMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::RankedTensorType> getResult(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::ArrayAttr getReassociationAttr(); + ::mlir::ArrayAttr getReassociation(); + void setReassociationAttr(::mlir::ArrayAttr attr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value src, ArrayRef reassociation, ArrayRef attrs = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value src, ArrayRef reassociation, ArrayRef attrs = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType, Value src, ArrayRef reassociation, ArrayRef attrs = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType, Value src, ArrayRef reassociation, ArrayRef attrs = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value src, ::mlir::ArrayAttr reassociation); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::ArrayAttr reassociation); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + static StringRef getReassociationAttrStrName() { return "reassociation"; } + SmallVector getReassociationMaps(); + SmallVector getReassociationExprs(); + SmallVector getReassociationIndices() { + SmallVector reassociationIndices; + for (auto attr : getReassociation()) + reassociationIndices.push_back(llvm::to_vector<2>( + llvm::map_range(::llvm::cast(attr), [&](Attribute indexAttr) { + return ::llvm::cast(indexAttr).getInt(); + }))); + return reassociationIndices; + } + RankedTensorType getSrcType() { + return ::llvm::cast(getSrc().getType()); + } + RankedTensorType getResultType() { + return ::llvm::cast(getResult().getType()); + } + + static RankedTensorType + inferCollapsedType(RankedTensorType type, ArrayRef reassociation); + static RankedTensorType + inferCollapsedType(RankedTensorType type, + SmallVector reassociation); +}; +} // namespace tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::tensor::CollapseShapeOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::DimOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class DimOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + DimOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + DimOpGenericAdaptorBase(DimOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class DimOpGenericAdaptor : public detail::DimOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::DimOpGenericAdaptorBase; +public: + DimOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + DimOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : DimOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + DimOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSource() { + return (*getODSOperands(0).begin()); + } + + ValueT getIndex() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class DimOpAdaptor : public DimOpGenericAdaptor<::mlir::ValueRange> { +public: + using DimOpGenericAdaptor::DimOpGenericAdaptor; + DimOpAdaptor(DimOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class DimOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::OpAsmOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::ShapedDimOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = DimOpAdaptor; + template + using GenericAdaptor = DimOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("tensor.dim"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::TensorType> getSource(); + ::mlir::TypedValue<::mlir::IndexType> getIndex(); + ::mlir::OpOperand &getSourceMutable(); + ::mlir::OpOperand &getIndexMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::IndexType> getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value source, int64_t index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::Value index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value source, ::mlir::Value index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value index); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + /// Helper function to get the index as a simple integer if it is constant. + std::optional getConstantIndex(); + + /// Interface method of ShapedDimOpInterface: Return the source tensor. + Value getShapedValue() { return getSource(); } + + /// Interface method of ShapedDimOpInterface: Return the dimension. + OpFoldResult getDimension() { return getIndex(); } + + /// Interface method for ConditionallySpeculatable. + Speculation::Speculatability getSpeculatability(); +}; +} // namespace tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::tensor::DimOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::EmptyOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class EmptyOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + EmptyOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + EmptyOpGenericAdaptorBase(EmptyOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class EmptyOpGenericAdaptor : public detail::EmptyOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::EmptyOpGenericAdaptorBase; +public: + EmptyOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + EmptyOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : EmptyOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + EmptyOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getDynamicSizes() { + return getODSOperands(0); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class EmptyOpAdaptor : public EmptyOpGenericAdaptor<::mlir::ValueRange> { +public: + using EmptyOpGenericAdaptor::EmptyOpGenericAdaptor; + EmptyOpAdaptor(EmptyOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class EmptyOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::ReifyRankedShapedTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = EmptyOpAdaptor; + template + using GenericAdaptor = EmptyOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("tensor.empty"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Operation::operand_range getDynamicSizes(); + ::mlir::MutableOperandRange getDynamicSizesMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::RankedTensorType> getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ArrayRef staticShape, Type elementType, Attribute encoding = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ArrayRef staticShape, Type elementType, ValueRange dynamicSizes, Attribute encoding = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ArrayRef sizes, Type elementType, Attribute encoding = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange dynamicSizes); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::mlir::LogicalResult reifyResultShapes(::mlir::OpBuilder &builder, ::mlir::ReifiedRankedShapedTypeDims &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + RankedTensorType getType() { + return ::llvm::cast(getResult().getType()); + } + + // Return both static and dynamic sizes as a list of `OpFoldResult`. + SmallVector getMixedSizes(); + + // Return the Value of the dynamic size of the tensor at dimension `idx`. + // Asserts that the shape is dynamic at that `idx`. + Value getDynamicSize(unsigned idx); +}; +} // namespace tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::tensor::EmptyOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::ExpandShapeOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ExpandShapeOpGenericAdaptorBase { +public: + struct Properties { + using reassociationTy = ::mlir::ArrayAttr; + reassociationTy reassociation; + + auto getReassociation() { + auto &propStorage = this->reassociation; + return ::llvm::cast<::mlir::ArrayAttr>(propStorage); + } + void setReassociation(const ::mlir::ArrayAttr &propValue) { + this->reassociation = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.reassociation == this->reassociation && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ExpandShapeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + ExpandShapeOpGenericAdaptorBase(ExpandShapeOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::ArrayAttr getReassociationAttr(); + ::mlir::ArrayAttr getReassociation(); +}; +} // namespace detail +template +class ExpandShapeOpGenericAdaptor : public detail::ExpandShapeOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ExpandShapeOpGenericAdaptorBase; +public: + ExpandShapeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ExpandShapeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ExpandShapeOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + ExpandShapeOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSrc() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ExpandShapeOpAdaptor : public ExpandShapeOpGenericAdaptor<::mlir::ValueRange> { +public: + using ExpandShapeOpGenericAdaptor::ExpandShapeOpGenericAdaptor; + ExpandShapeOpAdaptor(ExpandShapeOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ExpandShapeOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpAsmOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ExpandShapeOpAdaptor; + template + using GenericAdaptor = ExpandShapeOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("reassociation")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getReassociationAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getReassociationAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("tensor.expand_shape"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::RankedTensorType> getSrc(); + ::mlir::OpOperand &getSrcMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::RankedTensorType> getResult(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::ArrayAttr getReassociationAttr(); + ::mlir::ArrayAttr getReassociation(); + void setReassociationAttr(::mlir::ArrayAttr attr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType, Value src, ArrayRef reassociation, ArrayRef attrs = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType, Value src, ArrayRef reassociation, ArrayRef attrs = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value src, ::mlir::ArrayAttr reassociation); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::ArrayAttr reassociation); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + static StringRef getReassociationAttrStrName() { return "reassociation"; } + SmallVector getReassociationMaps(); + SmallVector getReassociationExprs(); + SmallVector getReassociationIndices() { + SmallVector reassociationIndices; + for (auto attr : getReassociation()) + reassociationIndices.push_back(llvm::to_vector<2>( + llvm::map_range(::llvm::cast(attr), [&](Attribute indexAttr) { + return ::llvm::cast(indexAttr).getInt(); + }))); + return reassociationIndices; + } + RankedTensorType getSrcType() { + return ::llvm::cast(getSrc().getType()); + } + RankedTensorType getResultType() { + return ::llvm::cast(getResult().getType()); + } + + int64_t getCorrespondingSourceDim(int64_t resultDim); +}; +} // namespace tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::tensor::ExpandShapeOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::ExtractOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ExtractOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + ExtractOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + ExtractOpGenericAdaptorBase(ExtractOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class ExtractOpGenericAdaptor : public detail::ExtractOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ExtractOpGenericAdaptorBase; +public: + ExtractOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ExtractOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ExtractOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + ExtractOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getTensor() { + return (*getODSOperands(0).begin()); + } + + RangeT getIndices() { + return getODSOperands(1); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ExtractOpAdaptor : public ExtractOpGenericAdaptor<::mlir::ValueRange> { +public: + using ExtractOpGenericAdaptor::ExtractOpGenericAdaptor; + ExtractOpAdaptor(ExtractOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ExtractOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<1>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::OpAsmOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ExtractOpAdaptor; + template + using GenericAdaptor = ExtractOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("tensor.extract"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::RankedTensorType> getTensor(); + ::mlir::Operation::operand_range getIndices(); + ::mlir::OpOperand &getTensorMutable(); + ::mlir::MutableOperandRange getIndicesMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value tensor, ::mlir::ValueRange indices); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value tensor, ::mlir::ValueRange indices); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tensor, ::mlir::ValueRange indices); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::tensor::ExtractOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::ExtractSliceOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ExtractSliceOpGenericAdaptorBase { +public: + struct Properties { + using static_offsetsTy = ::mlir::DenseI64ArrayAttr; + static_offsetsTy static_offsets; + + auto getStaticOffsets() { + auto &propStorage = this->static_offsets; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setStaticOffsets(const ::mlir::DenseI64ArrayAttr &propValue) { + this->static_offsets = propValue; + } + using static_sizesTy = ::mlir::DenseI64ArrayAttr; + static_sizesTy static_sizes; + + auto getStaticSizes() { + auto &propStorage = this->static_sizes; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setStaticSizes(const ::mlir::DenseI64ArrayAttr &propValue) { + this->static_sizes = propValue; + } + using static_stridesTy = ::mlir::DenseI64ArrayAttr; + static_stridesTy static_strides; + + auto getStaticStrides() { + auto &propStorage = this->static_strides; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setStaticStrides(const ::mlir::DenseI64ArrayAttr &propValue) { + this->static_strides = propValue; + } + using operandSegmentSizesTy = std::array; + operandSegmentSizesTy operandSegmentSizes; + ::llvm::ArrayRef getOperandSegmentSizes() { + auto &propStorage = this->operandSegmentSizes; + return propStorage; + } + void setOperandSegmentSizes(const ::llvm::ArrayRef &propValue) { + auto &propStorage = this->operandSegmentSizes; + ::llvm::copy(propValue, propStorage.begin()); + } + bool operator==(const Properties &rhs) const { + return + rhs.static_offsets == this->static_offsets && + rhs.static_sizes == this->static_sizes && + rhs.static_strides == this->static_strides && + rhs.operandSegmentSizes == this->operandSegmentSizes && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ExtractSliceOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + ExtractSliceOpGenericAdaptorBase(ExtractSliceOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::DenseI64ArrayAttr getStaticOffsetsAttr(); + ::llvm::ArrayRef getStaticOffsets(); + ::mlir::DenseI64ArrayAttr getStaticSizesAttr(); + ::llvm::ArrayRef getStaticSizes(); + ::mlir::DenseI64ArrayAttr getStaticStridesAttr(); + ::llvm::ArrayRef getStaticStrides(); +}; +} // namespace detail +template +class ExtractSliceOpGenericAdaptor : public detail::ExtractSliceOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ExtractSliceOpGenericAdaptorBase; +public: + ExtractSliceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ExtractSliceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ExtractSliceOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + ExtractSliceOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSource() { + return (*getODSOperands(0).begin()); + } + + RangeT getOffsets() { + return getODSOperands(1); + } + + RangeT getSizes() { + return getODSOperands(2); + } + + RangeT getStrides() { + return getODSOperands(3); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ExtractSliceOpAdaptor : public ExtractSliceOpGenericAdaptor<::mlir::ValueRange> { +public: + using ExtractSliceOpGenericAdaptor::ExtractSliceOpGenericAdaptor; + ExtractSliceOpAdaptor(ExtractSliceOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ExtractSliceOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<1>::Impl, ::mlir::OpTrait::AttrSizedOperandSegments, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpAsmOpInterface::Trait, ::mlir::ReifyRankedShapedTypeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OffsetSizeAndStrideOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ExtractSliceOpAdaptor; + template + using GenericAdaptor = ExtractSliceOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("static_offsets"), ::llvm::StringRef("static_sizes"), ::llvm::StringRef("static_strides"), ::llvm::StringRef("operandSegmentSizes")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getStaticOffsetsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getStaticOffsetsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getStaticSizesAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getStaticSizesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getStaticStridesAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getStaticStridesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getOperandSegmentSizesAttrName() { + return (*this)->getName().getAttributeNames().back(); + } + + static ::mlir::StringAttr getOperandSegmentSizesAttrName(::mlir::OperationName name) { + return name.getAttributeNames().back(); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("tensor.extract_slice"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::RankedTensorType> getSource(); + ::mlir::Operation::operand_range getOffsets(); + ::mlir::Operation::operand_range getSizes(); + ::mlir::Operation::operand_range getStrides(); + ::mlir::OpOperand &getSourceMutable(); + ::mlir::MutableOperandRange getOffsetsMutable(); + ::mlir::MutableOperandRange getSizesMutable(); + ::mlir::MutableOperandRange getStridesMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::RankedTensorType> getResult(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getStaticOffsetsAttr(); + ::llvm::ArrayRef getStaticOffsets(); + ::mlir::DenseI64ArrayAttr getStaticSizesAttr(); + ::llvm::ArrayRef getStaticSizes(); + ::mlir::DenseI64ArrayAttr getStaticStridesAttr(); + ::llvm::ArrayRef getStaticStrides(); + void setStaticOffsetsAttr(::mlir::DenseI64ArrayAttr attr); + void setStaticOffsets(::llvm::ArrayRef attrValue); + void setStaticSizesAttr(::mlir::DenseI64ArrayAttr attr); + void setStaticSizes(::llvm::ArrayRef attrValue); + void setStaticStridesAttr(::mlir::DenseI64ArrayAttr attr); + void setStaticStrides(::llvm::ArrayRef attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value source, ArrayRef offsets, ArrayRef sizes, ArrayRef strides, ArrayRef attrs = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, RankedTensorType resultType, Value source, ArrayRef offsets, ArrayRef sizes, ArrayRef strides, ArrayRef attrs = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value source, ValueRange offsets, ValueRange sizes, ValueRange strides, ArrayRef attrs = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, RankedTensorType resultType, Value source, ValueRange offsets, ValueRange sizes, ValueRange strides, ArrayRef attrs = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value source, ArrayRef ranges, ArrayRef attrs = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::mlir::DenseI64ArrayAttr static_offsets, ::mlir::DenseI64ArrayAttr static_sizes, ::mlir::DenseI64ArrayAttr static_strides); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::mlir::DenseI64ArrayAttr static_offsets, ::mlir::DenseI64ArrayAttr static_sizes, ::mlir::DenseI64ArrayAttr static_strides); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::llvm::ArrayRef static_offsets, ::llvm::ArrayRef static_sizes, ::llvm::ArrayRef static_strides); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::llvm::ArrayRef static_offsets, ::llvm::ArrayRef static_sizes, ::llvm::ArrayRef static_strides); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn); + ::mlir::LogicalResult reifyResultShapes(::mlir::OpBuilder &builder, ::mlir::ReifiedRankedShapedTypeDims &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 3 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + /// Return the type of the base tensor operand. + ::mlir::RankedTensorType getSourceType() { + return ::llvm::cast(getSource().getType()); + } + + /// Return the type of the result tensor. + ::mlir::RankedTensorType getResultType() { + return ::llvm::cast(getResult().getType()); + } + + /// Return the dynamic sizes for this subview operation if specified. + ::mlir::Operation::operand_range getDynamicSizes() { return getSizes(); } + + /// Return the list of Range (i.e. offset, size, stride). Each + /// Range entry contains either the dynamic value or a ConstantIndexOp + /// constructed with `b` at location `loc`. + ::mlir::SmallVector<::mlir::Range, 8> getOrCreateRanges( + ::mlir::OpBuilder &b, ::mlir::Location loc) { + return ::mlir::getOrCreateRanges(*this, b, loc); + } + + /// The result of an extract_slice is always a tensor. + // TODO: deprecate + RankedTensorType getType() { + return getResultType(); + } + + /// Compute the rank-reduction mask that can be applied to map the source + /// tensor type to the result tensor type by dropping unit dims. + std::optional> + computeRankReductionMask() { + return ::mlir::computeRankReductionMask(getSourceType().getShape(), + getType().getShape()); + }; + + /// An extract_slice result type can be inferred, when it is not + /// rank-reduced, from the source type and the static representation of + /// offsets, sizes and strides. Special sentinels encode the dynamic case. + static RankedTensorType inferResultType( + RankedTensorType sourceTensorType, + ArrayRef staticOffsets, + ArrayRef staticSizes, + ArrayRef staticStrides); + static RankedTensorType inferResultType( + RankedTensorType sourceTensorType, + ArrayRef staticOffsets, + ArrayRef staticSizes, + ArrayRef staticStrides); + + /// If the rank is reduced (i.e. the desiredResultRank is smaller than the + /// number of sizes), drop as many size 1 as needed to produce an inferred type + /// with the desired rank. + /// + /// Note that there may be multiple ways to compute this rank-reduced type: + /// e.g. 1x6x1 can rank-reduce to either 1x6 or 6x1 2-D tensors. + /// + /// To disambiguate, this function always drops the first 1 sizes occurrences. + static RankedTensorType inferCanonicalRankReducedResultType( + unsigned resultRank, + RankedTensorType sourceRankedTensorType, + ArrayRef staticOffsets, + ArrayRef staticSizes, + ArrayRef staticStrides); + static RankedTensorType inferCanonicalRankReducedResultType( + unsigned resultRank, + RankedTensorType sourceRankedTensorType, + ArrayRef staticOffsets, + ArrayRef staticSizes, + ArrayRef staticStrides); + + /// Return the expected rank of each of the`static_offsets`, `static_sizes` + /// and `static_strides` attributes. + std::array getArrayAttrMaxRanks() { + unsigned rank = getSourceType().getRank(); + return {rank, rank, rank}; + } + + /// Return the number of leading operands before the `offsets`, `sizes` and + /// and `strides` operands. + static unsigned getOffsetSizeAndStrideStartOperandIndex() { return 1; } + + /// Return the dimensions of the source that are dropped in the + /// result when the result is rank-reduced. + llvm::SmallBitVector getDroppedDims(); + + /// Given a `value`, asserted to be of RankedTensorType, build an + /// ExtractSliceOp that results in a rank-reducing extract to the desired + /// tensor shape and return the new value created. + /// If the shape of `value` is already the `desiredShape`, just return + /// `value`. + /// If the shape of `value` cannot be rank-reduced to `desiredShape`, fail. + static FailureOr rankReduceIfNeeded( + OpBuilder &b, Location loc, Value value, ArrayRef desiredShape); +}; +} // namespace tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::tensor::ExtractSliceOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::FromElementsOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class FromElementsOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + FromElementsOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + FromElementsOpGenericAdaptorBase(FromElementsOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class FromElementsOpGenericAdaptor : public detail::FromElementsOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::FromElementsOpGenericAdaptorBase; +public: + FromElementsOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + FromElementsOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : FromElementsOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + FromElementsOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getElements() { + return getODSOperands(0); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class FromElementsOpAdaptor : public FromElementsOpGenericAdaptor<::mlir::ValueRange> { +public: + using FromElementsOpGenericAdaptor::FromElementsOpGenericAdaptor; + FromElementsOpAdaptor(FromElementsOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class FromElementsOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::OpInvariants, ::mlir::OpAsmOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = FromElementsOpAdaptor; + template + using GenericAdaptor = FromElementsOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("tensor.from_elements"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Operation::operand_range getElements(); + ::mlir::MutableOperandRange getElementsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::RankedTensorType> getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ValueRange elements); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange elements); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::tensor::FromElementsOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::GatherOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class GatherOpGenericAdaptorBase { +public: + struct Properties { + using gather_dimsTy = ::mlir::DenseI64ArrayAttr; + gather_dimsTy gather_dims; + + auto getGatherDims() { + auto &propStorage = this->gather_dims; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setGatherDims(const ::mlir::DenseI64ArrayAttr &propValue) { + this->gather_dims = propValue; + } + using uniqueTy = ::mlir::UnitAttr; + uniqueTy unique; + + auto getUnique() { + auto &propStorage = this->unique; + return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(propStorage); + } + void setUnique(const ::mlir::UnitAttr &propValue) { + this->unique = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.gather_dims == this->gather_dims && + rhs.unique == this->unique && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + GatherOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + GatherOpGenericAdaptorBase(GatherOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::DenseI64ArrayAttr getGatherDimsAttr(); + ::llvm::ArrayRef getGatherDims(); + ::mlir::UnitAttr getUniqueAttr(); + bool getUnique(); +}; +} // namespace detail +template +class GatherOpGenericAdaptor : public detail::GatherOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::GatherOpGenericAdaptorBase; +public: + GatherOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + GatherOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : GatherOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + GatherOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSource() { + return (*getODSOperands(0).begin()); + } + + ValueT getIndices() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class GatherOpAdaptor : public GatherOpGenericAdaptor<::mlir::ValueRange> { +public: + using GatherOpGenericAdaptor::GatherOpGenericAdaptor; + GatherOpAdaptor(GatherOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class GatherOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpAsmOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = GatherOpAdaptor; + template + using GenericAdaptor = GatherOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("gather_dims"), ::llvm::StringRef("unique")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getGatherDimsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getGatherDimsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getUniqueAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getUniqueAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("tensor.gather"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::RankedTensorType> getSource(); + ::mlir::TypedValue<::mlir::RankedTensorType> getIndices(); + ::mlir::OpOperand &getSourceMutable(); + ::mlir::OpOperand &getIndicesMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::RankedTensorType> getResult(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getGatherDimsAttr(); + ::llvm::ArrayRef getGatherDims(); + ::mlir::UnitAttr getUniqueAttr(); + bool getUnique(); + void setGatherDimsAttr(::mlir::DenseI64ArrayAttr attr); + void setGatherDims(::llvm::ArrayRef attrValue); + void setUniqueAttr(::mlir::UnitAttr attr); + void setUnique(bool attrValue); + ::mlir::Attribute removeUniqueAttr(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::Value indices, ::mlir::DenseI64ArrayAttr gather_dims, /*optional*/::mlir::UnitAttr unique); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value indices, ::mlir::DenseI64ArrayAttr gather_dims, /*optional*/::mlir::UnitAttr unique); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::Value indices, ::llvm::ArrayRef gather_dims, /*optional*/bool unique = false); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value indices, ::llvm::ArrayRef gather_dims, /*optional*/bool unique = false); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + // TODO: InferTypeOpInterface once enough confidence is built with + // tensor and its lwoering to memref. + static RankedTensorType inferResultType(RankedTensorType sourceType, + RankedTensorType indicesType, + ArrayRef gatherDims, + bool rankReduced); + RankedTensorType getIndicesType() { + return ::llvm::cast(getIndices().getType()); + } + RankedTensorType getSourceType() { + return ::llvm::cast(getSource().getType()); + } + RankedTensorType getResultType() { + return ::llvm::cast(getResult().getType()); + } +}; +} // namespace tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::tensor::GatherOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::GenerateOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class GenerateOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + GenerateOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + GenerateOpGenericAdaptorBase(GenerateOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); + ::mlir::Region &getBody(); + ::mlir::RegionRange getRegions(); +}; +} // namespace detail +template +class GenerateOpGenericAdaptor : public detail::GenerateOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::GenerateOpGenericAdaptorBase; +public: + GenerateOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + GenerateOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : GenerateOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + GenerateOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getDynamicExtents() { + return getODSOperands(0); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class GenerateOpAdaptor : public GenerateOpGenericAdaptor<::mlir::ValueRange> { +public: + using GenerateOpGenericAdaptor::GenerateOpGenericAdaptor; + GenerateOpAdaptor(GenerateOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class GenerateOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::SingleBlock, ::mlir::OpTrait::SingleBlockImplicitTerminator::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::OpAsmOpInterface::Trait, ::mlir::OpTrait::HasRecursiveMemoryEffects, ::mlir::ReifyRankedShapedTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = GenerateOpAdaptor; + template + using GenericAdaptor = GenerateOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("tensor.generate"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Operation::operand_range getDynamicExtents(); + ::mlir::MutableOperandRange getDynamicExtentsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::RankedTensorType> getResult(); + ::mlir::Region &getBody(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultTy, ValueRange dynamicExtents, function_ref odsArg2); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange dynamicExtents); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + ::mlir::LogicalResult verifyRegions(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn); + ::mlir::LogicalResult reifyResultShapes(::mlir::OpBuilder &builder, ::mlir::ReifiedRankedShapedTypeDims &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +public: +}; +} // namespace tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::tensor::GenerateOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::InsertOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class InsertOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + InsertOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + InsertOpGenericAdaptorBase(InsertOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class InsertOpGenericAdaptor : public detail::InsertOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::InsertOpGenericAdaptorBase; +public: + InsertOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + InsertOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : InsertOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + InsertOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getScalar() { + return (*getODSOperands(0).begin()); + } + + ValueT getDest() { + return (*getODSOperands(1).begin()); + } + + RangeT getIndices() { + return getODSOperands(2); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class InsertOpAdaptor : public InsertOpGenericAdaptor<::mlir::ValueRange> { +public: + using InsertOpGenericAdaptor::InsertOpGenericAdaptor; + InsertOpAdaptor(InsertOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class InsertOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::OpAsmOpInterface::Trait, ::mlir::DestinationStyleOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = InsertOpAdaptor; + template + using GenericAdaptor = InsertOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("tensor.insert"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getScalar(); + ::mlir::TypedValue<::mlir::RankedTensorType> getDest(); + ::mlir::Operation::operand_range getIndices(); + ::mlir::OpOperand &getScalarMutable(); + ::mlir::OpOperand &getDestMutable(); + ::mlir::MutableOperandRange getIndicesMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::RankedTensorType> getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value scalar, ::mlir::Value dest, ::mlir::ValueRange indices); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value scalar, ::mlir::Value dest, ::mlir::ValueRange indices); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value scalar, ::mlir::Value dest, ::mlir::ValueRange indices); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + MutableOperandRange getDpsInitsMutable() { return getDestMutable(); } +}; +} // namespace tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::tensor::InsertOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::InsertSliceOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class InsertSliceOpGenericAdaptorBase { +public: + struct Properties { + using static_offsetsTy = ::mlir::DenseI64ArrayAttr; + static_offsetsTy static_offsets; + + auto getStaticOffsets() { + auto &propStorage = this->static_offsets; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setStaticOffsets(const ::mlir::DenseI64ArrayAttr &propValue) { + this->static_offsets = propValue; + } + using static_sizesTy = ::mlir::DenseI64ArrayAttr; + static_sizesTy static_sizes; + + auto getStaticSizes() { + auto &propStorage = this->static_sizes; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setStaticSizes(const ::mlir::DenseI64ArrayAttr &propValue) { + this->static_sizes = propValue; + } + using static_stridesTy = ::mlir::DenseI64ArrayAttr; + static_stridesTy static_strides; + + auto getStaticStrides() { + auto &propStorage = this->static_strides; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setStaticStrides(const ::mlir::DenseI64ArrayAttr &propValue) { + this->static_strides = propValue; + } + using operandSegmentSizesTy = std::array; + operandSegmentSizesTy operandSegmentSizes; + ::llvm::ArrayRef getOperandSegmentSizes() { + auto &propStorage = this->operandSegmentSizes; + return propStorage; + } + void setOperandSegmentSizes(const ::llvm::ArrayRef &propValue) { + auto &propStorage = this->operandSegmentSizes; + ::llvm::copy(propValue, propStorage.begin()); + } + bool operator==(const Properties &rhs) const { + return + rhs.static_offsets == this->static_offsets && + rhs.static_sizes == this->static_sizes && + rhs.static_strides == this->static_strides && + rhs.operandSegmentSizes == this->operandSegmentSizes && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + InsertSliceOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + InsertSliceOpGenericAdaptorBase(InsertSliceOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::DenseI64ArrayAttr getStaticOffsetsAttr(); + ::llvm::ArrayRef getStaticOffsets(); + ::mlir::DenseI64ArrayAttr getStaticSizesAttr(); + ::llvm::ArrayRef getStaticSizes(); + ::mlir::DenseI64ArrayAttr getStaticStridesAttr(); + ::llvm::ArrayRef getStaticStrides(); +}; +} // namespace detail +template +class InsertSliceOpGenericAdaptor : public detail::InsertSliceOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::InsertSliceOpGenericAdaptorBase; +public: + InsertSliceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + InsertSliceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : InsertSliceOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + InsertSliceOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSource() { + return (*getODSOperands(0).begin()); + } + + ValueT getDest() { + return (*getODSOperands(1).begin()); + } + + RangeT getOffsets() { + return getODSOperands(2); + } + + RangeT getSizes() { + return getODSOperands(3); + } + + RangeT getStrides() { + return getODSOperands(4); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class InsertSliceOpAdaptor : public InsertSliceOpGenericAdaptor<::mlir::ValueRange> { +public: + using InsertSliceOpGenericAdaptor::InsertSliceOpGenericAdaptor; + InsertSliceOpAdaptor(InsertSliceOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class InsertSliceOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<2>::Impl, ::mlir::OpTrait::AttrSizedOperandSegments, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpAsmOpInterface::Trait, ::mlir::ReifyRankedShapedTypeOpInterface::Trait, ::mlir::DestinationStyleOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OffsetSizeAndStrideOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = InsertSliceOpAdaptor; + template + using GenericAdaptor = InsertSliceOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("static_offsets"), ::llvm::StringRef("static_sizes"), ::llvm::StringRef("static_strides"), ::llvm::StringRef("operandSegmentSizes")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getStaticOffsetsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getStaticOffsetsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getStaticSizesAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getStaticSizesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getStaticStridesAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getStaticStridesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getOperandSegmentSizesAttrName() { + return (*this)->getName().getAttributeNames().back(); + } + + static ::mlir::StringAttr getOperandSegmentSizesAttrName(::mlir::OperationName name) { + return name.getAttributeNames().back(); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("tensor.insert_slice"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::RankedTensorType> getSource(); + ::mlir::TypedValue<::mlir::RankedTensorType> getDest(); + ::mlir::Operation::operand_range getOffsets(); + ::mlir::Operation::operand_range getSizes(); + ::mlir::Operation::operand_range getStrides(); + ::mlir::OpOperand &getSourceMutable(); + ::mlir::OpOperand &getDestMutable(); + ::mlir::MutableOperandRange getOffsetsMutable(); + ::mlir::MutableOperandRange getSizesMutable(); + ::mlir::MutableOperandRange getStridesMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::RankedTensorType> getResult(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getStaticOffsetsAttr(); + ::llvm::ArrayRef getStaticOffsets(); + ::mlir::DenseI64ArrayAttr getStaticSizesAttr(); + ::llvm::ArrayRef getStaticSizes(); + ::mlir::DenseI64ArrayAttr getStaticStridesAttr(); + ::llvm::ArrayRef getStaticStrides(); + void setStaticOffsetsAttr(::mlir::DenseI64ArrayAttr attr); + void setStaticOffsets(::llvm::ArrayRef attrValue); + void setStaticSizesAttr(::mlir::DenseI64ArrayAttr attr); + void setStaticSizes(::llvm::ArrayRef attrValue); + void setStaticStridesAttr(::mlir::DenseI64ArrayAttr attr); + void setStaticStrides(::llvm::ArrayRef attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value source, Value dest, ArrayRef offsets, ArrayRef sizes, ArrayRef strides, ArrayRef attrs = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value source, Value dest, ValueRange offsets, ValueRange sizes, ValueRange strides, ArrayRef attrs = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value source, Value dest, ArrayRef ranges, ArrayRef attrs = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::Value dest, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::mlir::DenseI64ArrayAttr static_offsets, ::mlir::DenseI64ArrayAttr static_sizes, ::mlir::DenseI64ArrayAttr static_strides); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value source, ::mlir::Value dest, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::mlir::DenseI64ArrayAttr static_offsets, ::mlir::DenseI64ArrayAttr static_sizes, ::mlir::DenseI64ArrayAttr static_strides); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::mlir::DenseI64ArrayAttr static_offsets, ::mlir::DenseI64ArrayAttr static_sizes, ::mlir::DenseI64ArrayAttr static_strides); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::Value dest, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::llvm::ArrayRef static_offsets, ::llvm::ArrayRef static_sizes, ::llvm::ArrayRef static_strides); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value source, ::mlir::Value dest, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::llvm::ArrayRef static_offsets, ::llvm::ArrayRef static_sizes, ::llvm::ArrayRef static_strides); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::llvm::ArrayRef static_offsets, ::llvm::ArrayRef static_sizes, ::llvm::ArrayRef static_strides); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn); + ::mlir::LogicalResult reifyResultShapes(::mlir::OpBuilder &builder, ::mlir::ReifiedRankedShapedTypeDims &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 3 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + /// Return the type of the base tensor operand. + ::mlir::RankedTensorType getSourceType() { + return ::llvm::cast(getSource().getType()); + } + + /// Return the type of the result tensor. + ::mlir::RankedTensorType getResultType() { + return ::llvm::cast(getResult().getType()); + } + + /// Return the dynamic sizes for this subview operation if specified. + ::mlir::Operation::operand_range getDynamicSizes() { return getSizes(); } + + /// Return the list of Range (i.e. offset, size, stride). Each + /// Range entry contains either the dynamic value or a ConstantIndexOp + /// constructed with `b` at location `loc`. + ::mlir::SmallVector<::mlir::Range, 8> getOrCreateRanges( + ::mlir::OpBuilder &b, ::mlir::Location loc) { + return ::mlir::getOrCreateRanges(*this, b, loc); + } + + /// The result of a insert_slice is always a tensor. + // TODO: Deprecate this method. + RankedTensorType getType() { + return getResultType(); + } + + /// The `dest` type is the same as the result type. + RankedTensorType getDestType() { + return getResultType(); + } + + /// Return the expected rank of each of the`static_offsets`, `static_sizes` + /// and `static_strides` attributes. + std::array getArrayAttrMaxRanks() { + unsigned rank = getResultType().getRank(); + return {rank, rank, rank}; + } + + /// Return the dimensions of the dest that are omitted to insert a source + /// when the result is rank-extended. + llvm::SmallBitVector getDroppedDims(); + + /// Return the number of leading operands before the `offsets`, `sizes` and + /// and `strides` operands. + static unsigned getOffsetSizeAndStrideStartOperandIndex() { return 2; } + + MutableOperandRange getDpsInitsMutable() { return getDestMutable(); } +}; +} // namespace tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::tensor::InsertSliceOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::PackOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class PackOpGenericAdaptorBase { +public: + struct Properties { + using inner_dims_posTy = ::mlir::DenseI64ArrayAttr; + inner_dims_posTy inner_dims_pos; + + auto getInnerDimsPos() { + auto &propStorage = this->inner_dims_pos; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setInnerDimsPos(const ::mlir::DenseI64ArrayAttr &propValue) { + this->inner_dims_pos = propValue; + } + using outer_dims_permTy = ::mlir::DenseI64ArrayAttr; + outer_dims_permTy outer_dims_perm; + + auto getOuterDimsPerm() { + auto &propStorage = this->outer_dims_perm; + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setOuterDimsPerm(const ::mlir::DenseI64ArrayAttr &propValue) { + this->outer_dims_perm = propValue; + } + using static_inner_tilesTy = ::mlir::DenseI64ArrayAttr; + static_inner_tilesTy static_inner_tiles; + + auto getStaticInnerTiles() { + auto &propStorage = this->static_inner_tiles; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setStaticInnerTiles(const ::mlir::DenseI64ArrayAttr &propValue) { + this->static_inner_tiles = propValue; + } + using operandSegmentSizesTy = std::array; + operandSegmentSizesTy operandSegmentSizes; + ::llvm::ArrayRef getOperandSegmentSizes() { + auto &propStorage = this->operandSegmentSizes; + return propStorage; + } + void setOperandSegmentSizes(const ::llvm::ArrayRef &propValue) { + auto &propStorage = this->operandSegmentSizes; + ::llvm::copy(propValue, propStorage.begin()); + } + bool operator==(const Properties &rhs) const { + return + rhs.inner_dims_pos == this->inner_dims_pos && + rhs.outer_dims_perm == this->outer_dims_perm && + rhs.static_inner_tiles == this->static_inner_tiles && + rhs.operandSegmentSizes == this->operandSegmentSizes && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + PackOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + PackOpGenericAdaptorBase(PackOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::DenseI64ArrayAttr getOuterDimsPermAttr(); + ::llvm::ArrayRef getOuterDimsPerm(); + ::mlir::DenseI64ArrayAttr getInnerDimsPosAttr(); + ::llvm::ArrayRef getInnerDimsPos(); + ::mlir::DenseI64ArrayAttr getStaticInnerTilesAttr(); + ::llvm::ArrayRef getStaticInnerTiles(); +}; +} // namespace detail +template +class PackOpGenericAdaptor : public detail::PackOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::PackOpGenericAdaptorBase; +public: + PackOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + PackOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : PackOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + PackOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSource() { + return (*getODSOperands(0).begin()); + } + + ValueT getDest() { + return (*getODSOperands(1).begin()); + } + + ValueT getPaddingValue() { + auto operands = getODSOperands(2); + return operands.empty() ? ValueT{} : (*operands.begin()); + } + + RangeT getInnerTiles() { + return getODSOperands(3); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class PackOpAdaptor : public PackOpGenericAdaptor<::mlir::ValueRange> { +public: + using PackOpGenericAdaptor::PackOpGenericAdaptor; + PackOpAdaptor(PackOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class PackOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<2>::Impl, ::mlir::OpTrait::AttrSizedOperandSegments, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpAsmOpInterface::Trait, ::mlir::DestinationStyleOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::ReifyRankedShapedTypeOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = PackOpAdaptor; + template + using GenericAdaptor = PackOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("inner_dims_pos"), ::llvm::StringRef("outer_dims_perm"), ::llvm::StringRef("static_inner_tiles"), ::llvm::StringRef("operandSegmentSizes")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getInnerDimsPosAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getInnerDimsPosAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getOuterDimsPermAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getOuterDimsPermAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getStaticInnerTilesAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getStaticInnerTilesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getOperandSegmentSizesAttrName() { + return (*this)->getName().getAttributeNames().back(); + } + + static ::mlir::StringAttr getOperandSegmentSizesAttrName(::mlir::OperationName name) { + return name.getAttributeNames().back(); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("tensor.pack"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::RankedTensorType> getSource(); + ::mlir::TypedValue<::mlir::RankedTensorType> getDest(); + ::mlir::Value getPaddingValue(); + ::mlir::Operation::operand_range getInnerTiles(); + ::mlir::OpOperand &getSourceMutable(); + ::mlir::OpOperand &getDestMutable(); + ::mlir::MutableOperandRange getPaddingValueMutable(); + ::mlir::MutableOperandRange getInnerTilesMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::RankedTensorType> getResult(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getOuterDimsPermAttr(); + ::llvm::ArrayRef getOuterDimsPerm(); + ::mlir::DenseI64ArrayAttr getInnerDimsPosAttr(); + ::llvm::ArrayRef getInnerDimsPos(); + ::mlir::DenseI64ArrayAttr getStaticInnerTilesAttr(); + ::llvm::ArrayRef getStaticInnerTiles(); + void setOuterDimsPermAttr(::mlir::DenseI64ArrayAttr attr); + void setOuterDimsPerm(::std::optional<::llvm::ArrayRef> attrValue); + void setInnerDimsPosAttr(::mlir::DenseI64ArrayAttr attr); + void setInnerDimsPos(::llvm::ArrayRef attrValue); + void setStaticInnerTilesAttr(::mlir::DenseI64ArrayAttr attr); + void setStaticInnerTiles(::llvm::ArrayRef attrValue); + ::mlir::Attribute removeOuterDimsPermAttr(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value source, Value dest, ArrayRef innerDimsPos, ArrayRef innerTiles, std::optional paddingValue = std::nullopt, ArrayRef outerDimsPerm = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::Value padding_value, /*optional*/::mlir::DenseI64ArrayAttr outer_dims_perm, ::mlir::DenseI64ArrayAttr inner_dims_pos, ::mlir::ValueRange inner_tiles, ::mlir::DenseI64ArrayAttr static_inner_tiles); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::Value padding_value, /*optional*/::mlir::DenseI64ArrayAttr outer_dims_perm, ::mlir::DenseI64ArrayAttr inner_dims_pos, ::mlir::ValueRange inner_tiles, ::mlir::DenseI64ArrayAttr static_inner_tiles); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::Value padding_value, /*optional*/::mlir::DenseI64ArrayAttr outer_dims_perm, ::mlir::DenseI64ArrayAttr inner_dims_pos, ::mlir::ValueRange inner_tiles, ::mlir::DenseI64ArrayAttr static_inner_tiles); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::Value padding_value, /*optional*/::llvm::ArrayRef outer_dims_perm, ::llvm::ArrayRef inner_dims_pos, ::mlir::ValueRange inner_tiles, ::llvm::ArrayRef static_inner_tiles); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::Value padding_value, /*optional*/::llvm::ArrayRef outer_dims_perm, ::llvm::ArrayRef inner_dims_pos, ::mlir::ValueRange inner_tiles, ::llvm::ArrayRef static_inner_tiles); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::Value padding_value, /*optional*/::llvm::ArrayRef outer_dims_perm, ::llvm::ArrayRef inner_dims_pos, ::mlir::ValueRange inner_tiles, ::llvm::ArrayRef static_inner_tiles); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static ::mlir::LogicalResult canonicalize(PackOp op, ::mlir::PatternRewriter &rewriter); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn); + ::mlir::LogicalResult reifyResultShapes(::mlir::OpBuilder &builder, ::mlir::ReifiedRankedShapedTypeDims &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 3 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + size_t getSourceRank() { return getSourceType().getRank(); }; + size_t getDestRank() { return getDestType().getRank(); }; + RankedTensorType getSourceType() { + return ::llvm::cast(getSource().getType()); }; + RankedTensorType getDestType() { + return ::llvm::cast(getDest().getType()); }; + + MutableOperandRange getDpsInitsMutable() { return getDestMutable(); } + + /// Interface method for ConditionallySpeculatable. + Speculation::Speculatability getSpeculatability(); + + /// Return a mapping from positions `inner_dims_pos` to their + /// tile factors. + DenseMap getDimAndTileMapping(); + + /// Return the tile sizes as OpFoldResult. + SmallVector getMixedTiles(); + + /// Return the tile sizes as `int64_t`. If a tile size is dynamic + /// a sentinel `kDynamic` is introduced at that position in + /// the returned vector. + SmallVector getStaticTiles(); + + // Method to get the shape of the result as `SmallVector`. + // This is a static method to allow getting the shape of the destination + // expected while creating a `pack` op. + static SmallVector getResultShape(OpBuilder &builder, + Location loc, ArrayRef sourceDims, + ArrayRef innerTileDims, ArrayRef innerDimsPos, + ArrayRef outerDimsPerm = {}); + + // Method to get the `RankedTensorType` of the result based on the inner + // tiles, position of the inner tiles (innerDimsPos) and interchange vector + // of outer loops (outerDimsPerm). + static RankedTensorType inferPackedType(RankedTensorType sourceType, + ArrayRef innerTileSizes, ArrayRef innerDimsPos, + ArrayRef outerDimsPerm = {}); + + // Returns true if we have enough static information to catch undefined + // behavior when the tile size does not divide perfectly the dimension of + // the input tensor. If a given dimension or a tile associated with it is + // dynamic, the dimension is not considered as we don't have enough static + // information to understand if the tile perfectly divides that dimension. + static bool requirePaddingValue(ArrayRef inputShape, + ArrayRef innerDimsPos, + ArrayRef innerTiles); + + static Value createDestinationTensor(OpBuilder &b, Location loc, + Value source, ArrayRef innerTileSizes, + ArrayRef innerDimsPos, ArrayRef outerDimsPerm); + + /// Build and return a new PackOp that is a clone of the current PackOp with + /// (innerDimsPos, innerTiles) (resp. outerDimsPerm) are permuted by + /// innerPermutation (resp. outerPermutation). + /// A new `tensor.empty` of the proper shape is built in the process. + /// Asserts that: + /// - At least one of innerPermutation or outerPermutation is non-empty. + /// - If not empty, innerPermutation is a valid permutation of size + /// matching innerDimPos. + /// - If not empty, outerPermutation is a valid permutation of size + /// matching outerDimsPerm. + PackOp createTransposedClone(OpBuilder &b, + Location loc, + ArrayRef innerPermutation, + ArrayRef outerPermutation); + + /// Check if this PackOp is like a simple pad operation. + /// In other words, this operation: + /// 1. adds useless dimensions (dimension of size 1), + /// 2. pads the other ones, and + /// 3. doesn't shuffle the dimensions + bool isLikePad(); +}; +} // namespace tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::tensor::PackOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::PadOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class PadOpGenericAdaptorBase { +public: + struct Properties { + using nofoldTy = ::mlir::UnitAttr; + nofoldTy nofold; + + auto getNofold() { + auto &propStorage = this->nofold; + return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(propStorage); + } + void setNofold(const ::mlir::UnitAttr &propValue) { + this->nofold = propValue; + } + using static_highTy = ::mlir::DenseI64ArrayAttr; + static_highTy static_high; + + auto getStaticHigh() { + auto &propStorage = this->static_high; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setStaticHigh(const ::mlir::DenseI64ArrayAttr &propValue) { + this->static_high = propValue; + } + using static_lowTy = ::mlir::DenseI64ArrayAttr; + static_lowTy static_low; + + auto getStaticLow() { + auto &propStorage = this->static_low; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setStaticLow(const ::mlir::DenseI64ArrayAttr &propValue) { + this->static_low = propValue; + } + using operandSegmentSizesTy = std::array; + operandSegmentSizesTy operandSegmentSizes; + ::llvm::ArrayRef getOperandSegmentSizes() { + auto &propStorage = this->operandSegmentSizes; + return propStorage; + } + void setOperandSegmentSizes(const ::llvm::ArrayRef &propValue) { + auto &propStorage = this->operandSegmentSizes; + ::llvm::copy(propValue, propStorage.begin()); + } + bool operator==(const Properties &rhs) const { + return + rhs.nofold == this->nofold && + rhs.static_high == this->static_high && + rhs.static_low == this->static_low && + rhs.operandSegmentSizes == this->operandSegmentSizes && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + PadOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + PadOpGenericAdaptorBase(PadOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::DenseI64ArrayAttr getStaticLowAttr(); + ::llvm::ArrayRef getStaticLow(); + ::mlir::DenseI64ArrayAttr getStaticHighAttr(); + ::llvm::ArrayRef getStaticHigh(); + ::mlir::UnitAttr getNofoldAttr(); + bool getNofold(); + ::mlir::Region &getRegion(); + ::mlir::RegionRange getRegions(); +}; +} // namespace detail +template +class PadOpGenericAdaptor : public detail::PadOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::PadOpGenericAdaptorBase; +public: + PadOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + PadOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : PadOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + PadOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSource() { + return (*getODSOperands(0).begin()); + } + + RangeT getLow() { + return getODSOperands(1); + } + + RangeT getHigh() { + return getODSOperands(2); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class PadOpAdaptor : public PadOpGenericAdaptor<::mlir::ValueRange> { +public: + using PadOpGenericAdaptor::PadOpGenericAdaptor; + PadOpAdaptor(PadOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class PadOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<1>::Impl, ::mlir::OpTrait::AttrSizedOperandSegments, ::mlir::OpTrait::SingleBlock, ::mlir::OpTrait::SingleBlockImplicitTerminator::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpAsmOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = PadOpAdaptor; + template + using GenericAdaptor = PadOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("nofold"), ::llvm::StringRef("static_high"), ::llvm::StringRef("static_low"), ::llvm::StringRef("operandSegmentSizes")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getNofoldAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getNofoldAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getStaticHighAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getStaticHighAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getStaticLowAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getStaticLowAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getOperandSegmentSizesAttrName() { + return (*this)->getName().getAttributeNames().back(); + } + + static ::mlir::StringAttr getOperandSegmentSizesAttrName(::mlir::OperationName name) { + return name.getAttributeNames().back(); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("tensor.pad"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::RankedTensorType> getSource(); + ::mlir::Operation::operand_range getLow(); + ::mlir::Operation::operand_range getHigh(); + ::mlir::OpOperand &getSourceMutable(); + ::mlir::MutableOperandRange getLowMutable(); + ::mlir::MutableOperandRange getHighMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::RankedTensorType> getResult(); + ::mlir::Region &getRegion(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getStaticLowAttr(); + ::llvm::ArrayRef getStaticLow(); + ::mlir::DenseI64ArrayAttr getStaticHighAttr(); + ::llvm::ArrayRef getStaticHigh(); + ::mlir::UnitAttr getNofoldAttr(); + bool getNofold(); + void setStaticLowAttr(::mlir::DenseI64ArrayAttr attr); + void setStaticLow(::llvm::ArrayRef attrValue); + void setStaticHighAttr(::mlir::DenseI64ArrayAttr attr); + void setStaticHigh(::llvm::ArrayRef attrValue); + void setNofoldAttr(::mlir::UnitAttr attr); + void setNofold(bool attrValue); + ::mlir::Attribute removeNofoldAttr(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType, Value source, ArrayRef staticLow, ArrayRef staticHigh, ValueRange low, ValueRange high, bool nofold = false, ArrayRef attrs = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType, Value source, ValueRange low, ValueRange high, bool nofold = false, ArrayRef attrs = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType, Value source, ArrayRef low, ArrayRef high, bool nofold = false, ArrayRef attrs = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type resultType, Value source, ArrayRef low, ArrayRef high, Value constantPadValue, bool nofold = false, ArrayRef attrs = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::ValueRange low, ::mlir::ValueRange high, ::mlir::DenseI64ArrayAttr static_low, ::mlir::DenseI64ArrayAttr static_high, /*optional*/::mlir::UnitAttr nofold); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::ValueRange low, ::mlir::ValueRange high, ::mlir::DenseI64ArrayAttr static_low, ::mlir::DenseI64ArrayAttr static_high, /*optional*/::mlir::UnitAttr nofold); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::ValueRange low, ::mlir::ValueRange high, ::llvm::ArrayRef static_low, ::llvm::ArrayRef static_high, /*optional*/bool nofold = false); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::ValueRange low, ::mlir::ValueRange high, ::llvm::ArrayRef static_low, ::llvm::ArrayRef static_high, /*optional*/bool nofold = false); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + ::mlir::LogicalResult verifyRegions(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 3 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + static StringRef getStaticLowAttrStrName() { + return "static_low"; + } + + static StringRef getStaticHighAttrStrName() { + return "static_high"; + } + + RankedTensorType getSourceType() { + return ::llvm::cast(getSource().getType()); + } + RankedTensorType getResultType() { + return ::llvm::cast(getResult().getType()); + } + + // Infer the shape of the result tensor given the type of the source tensor + // and paddings. Known result dimensions that cannot necessarily be inferred + // from low/high padding sizes can be optionally specified. Those will be + // considered when computing the result type. + static RankedTensorType inferResultType( + RankedTensorType sourceType, + ArrayRef staticLow, + ArrayRef staticHigh, + ArrayRef resultShape = {}); + + // Return the pad value if it is a constant. Return null value otherwise. + Value getConstantPaddingValue(); + + // Return a vector of all the static or dynamic values (low/high padding) of + // the op. + inline SmallVector getMixedPadImpl(ArrayRef staticAttrs, + ValueRange values) { + Builder builder(*this); + SmallVector res; + unsigned numDynamic = 0; + unsigned count = staticAttrs.size(); + for (unsigned idx = 0; idx < count; ++idx) { + if (ShapedType::isDynamic(staticAttrs[idx])) + res.push_back(values[numDynamic++]); + else + res.push_back(builder.getI64IntegerAttr(staticAttrs[idx])); + } + return res; + } + SmallVector getMixedLowPad() { + return getMixedPadImpl(getStaticLow(), getLow()); + } + SmallVector getMixedHighPad() { + return getMixedPadImpl(getStaticHigh(), getHigh()); + } + // Return true if low padding is guaranteed to be 0. + bool hasZeroLowPad() { + return llvm::all_of(getMixedLowPad(), [](OpFoldResult ofr) { + return getConstantIntValue(ofr) == static_cast(0); + }); + } + // Return true if high padding is guaranteed to be 0. + bool hasZeroHighPad() { + return llvm::all_of(getMixedHighPad(), [](OpFoldResult ofr) { + return getConstantIntValue(ofr) == static_cast(0); + }); + } + /// Return the dimensions with a non-zero low or high padding. + llvm::SmallBitVector getPaddedDims(); +}; +} // namespace tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::tensor::PadOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::ParallelInsertSliceOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ParallelInsertSliceOpGenericAdaptorBase { +public: + struct Properties { + using static_offsetsTy = ::mlir::DenseI64ArrayAttr; + static_offsetsTy static_offsets; + + auto getStaticOffsets() { + auto &propStorage = this->static_offsets; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setStaticOffsets(const ::mlir::DenseI64ArrayAttr &propValue) { + this->static_offsets = propValue; + } + using static_sizesTy = ::mlir::DenseI64ArrayAttr; + static_sizesTy static_sizes; + + auto getStaticSizes() { + auto &propStorage = this->static_sizes; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setStaticSizes(const ::mlir::DenseI64ArrayAttr &propValue) { + this->static_sizes = propValue; + } + using static_stridesTy = ::mlir::DenseI64ArrayAttr; + static_stridesTy static_strides; + + auto getStaticStrides() { + auto &propStorage = this->static_strides; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setStaticStrides(const ::mlir::DenseI64ArrayAttr &propValue) { + this->static_strides = propValue; + } + using operandSegmentSizesTy = std::array; + operandSegmentSizesTy operandSegmentSizes; + ::llvm::ArrayRef getOperandSegmentSizes() { + auto &propStorage = this->operandSegmentSizes; + return propStorage; + } + void setOperandSegmentSizes(const ::llvm::ArrayRef &propValue) { + auto &propStorage = this->operandSegmentSizes; + ::llvm::copy(propValue, propStorage.begin()); + } + bool operator==(const Properties &rhs) const { + return + rhs.static_offsets == this->static_offsets && + rhs.static_sizes == this->static_sizes && + rhs.static_strides == this->static_strides && + rhs.operandSegmentSizes == this->operandSegmentSizes && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ParallelInsertSliceOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + ParallelInsertSliceOpGenericAdaptorBase(ParallelInsertSliceOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::DenseI64ArrayAttr getStaticOffsetsAttr(); + ::llvm::ArrayRef getStaticOffsets(); + ::mlir::DenseI64ArrayAttr getStaticSizesAttr(); + ::llvm::ArrayRef getStaticSizes(); + ::mlir::DenseI64ArrayAttr getStaticStridesAttr(); + ::llvm::ArrayRef getStaticStrides(); +}; +} // namespace detail +template +class ParallelInsertSliceOpGenericAdaptor : public detail::ParallelInsertSliceOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ParallelInsertSliceOpGenericAdaptorBase; +public: + ParallelInsertSliceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ParallelInsertSliceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ParallelInsertSliceOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + ParallelInsertSliceOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSource() { + return (*getODSOperands(0).begin()); + } + + ValueT getDest() { + return (*getODSOperands(1).begin()); + } + + RangeT getOffsets() { + return getODSOperands(2); + } + + RangeT getSizes() { + return getODSOperands(3); + } + + RangeT getStrides() { + return getODSOperands(4); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ParallelInsertSliceOpAdaptor : public ParallelInsertSliceOpGenericAdaptor<::mlir::ValueRange> { +public: + using ParallelInsertSliceOpGenericAdaptor::ParallelInsertSliceOpGenericAdaptor; + ParallelInsertSliceOpAdaptor(ParallelInsertSliceOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ParallelInsertSliceOp : public ::mlir::Op::Impl, ::mlir::OpTrait::AttrSizedOperandSegments, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OffsetSizeAndStrideOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ParallelInsertSliceOpAdaptor; + template + using GenericAdaptor = ParallelInsertSliceOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("static_offsets"), ::llvm::StringRef("static_sizes"), ::llvm::StringRef("static_strides"), ::llvm::StringRef("operandSegmentSizes")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getStaticOffsetsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getStaticOffsetsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getStaticSizesAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getStaticSizesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getStaticStridesAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getStaticStridesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getOperandSegmentSizesAttrName() { + return (*this)->getName().getAttributeNames().back(); + } + + static ::mlir::StringAttr getOperandSegmentSizesAttrName(::mlir::OperationName name) { + return name.getAttributeNames().back(); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("tensor.parallel_insert_slice"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::RankedTensorType> getSource(); + ::mlir::TypedValue<::mlir::RankedTensorType> getDest(); + ::mlir::Operation::operand_range getOffsets(); + ::mlir::Operation::operand_range getSizes(); + ::mlir::Operation::operand_range getStrides(); + ::mlir::OpOperand &getSourceMutable(); + ::mlir::OpOperand &getDestMutable(); + ::mlir::MutableOperandRange getOffsetsMutable(); + ::mlir::MutableOperandRange getSizesMutable(); + ::mlir::MutableOperandRange getStridesMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getStaticOffsetsAttr(); + ::llvm::ArrayRef getStaticOffsets(); + ::mlir::DenseI64ArrayAttr getStaticSizesAttr(); + ::llvm::ArrayRef getStaticSizes(); + ::mlir::DenseI64ArrayAttr getStaticStridesAttr(); + ::llvm::ArrayRef getStaticStrides(); + void setStaticOffsetsAttr(::mlir::DenseI64ArrayAttr attr); + void setStaticOffsets(::llvm::ArrayRef attrValue); + void setStaticSizesAttr(::mlir::DenseI64ArrayAttr attr); + void setStaticSizes(::llvm::ArrayRef attrValue); + void setStaticStridesAttr(::mlir::DenseI64ArrayAttr attr); + void setStaticStrides(::llvm::ArrayRef attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value source, Value dest, ArrayRef offsets, ArrayRef sizes, ArrayRef strides, ArrayRef attrs = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value source, Value dest, ArrayRef ranges, ArrayRef attrs = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value source, Value dest, ValueRange offsets, ValueRange sizes, ValueRange strides, ArrayRef attrs = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value source, ::mlir::Value dest, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::mlir::DenseI64ArrayAttr static_offsets, ::mlir::DenseI64ArrayAttr static_sizes, ::mlir::DenseI64ArrayAttr static_strides); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::mlir::DenseI64ArrayAttr static_offsets, ::mlir::DenseI64ArrayAttr static_sizes, ::mlir::DenseI64ArrayAttr static_strides); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value source, ::mlir::Value dest, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::llvm::ArrayRef static_offsets, ::llvm::ArrayRef static_sizes, ::llvm::ArrayRef static_strides); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, ::mlir::ValueRange offsets, ::mlir::ValueRange sizes, ::mlir::ValueRange strides, ::llvm::ArrayRef static_offsets, ::llvm::ArrayRef static_sizes, ::llvm::ArrayRef static_strides); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 3 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + Type yieldedType() { return getDest().getType(); } + + RankedTensorType getSourceType() { + return ::llvm::cast(getSource().getType()); + } + + RankedTensorType getDestType() { + return ::llvm::cast(getDest().getType()); + } + + ParallelCombiningOpInterface getParallelCombiningParent() { + return dyn_cast( + getOperation()->getParentOp()); + } + + /// Return the expected rank of each of the `static_offsets`, `static_sizes` + /// and `static_strides` attributes. + std::array getArrayAttrMaxRanks() { + unsigned rank = getDestType().getRank(); + return {rank, rank, rank}; + } + + /// Return the number of leading operands before `offsets`, `sizes` and + /// `strides` operands. + static unsigned getOffsetSizeAndStrideStartOperandIndex() { return 1; } + + /// Return the OpResult of the enclosing ForallOp that is + /// corresponding to this ParallelInsertSliceOp. + OpResult getTiedOpResult(); + + /// Return the dimensions of the dest that are omitted to insert a source + /// when the result is rank-extended. + llvm::SmallBitVector getDroppedDims(); +}; +} // namespace tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::tensor::ParallelInsertSliceOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::RankOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class RankOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + RankOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + RankOpGenericAdaptorBase(RankOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class RankOpGenericAdaptor : public detail::RankOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::RankOpGenericAdaptorBase; +public: + RankOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + RankOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : RankOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + RankOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getTensor() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class RankOpAdaptor : public RankOpGenericAdaptor<::mlir::ValueRange> { +public: + using RankOpGenericAdaptor::RankOpGenericAdaptor; + RankOpAdaptor(RankOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class RankOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::OpAsmOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = RankOpAdaptor; + template + using GenericAdaptor = RankOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("tensor.rank"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::TensorType> getTensor(); + ::mlir::OpOperand &getTensorMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value tensor); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value tensor); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tensor); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::tensor::RankOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::ReshapeOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ReshapeOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + ReshapeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + ReshapeOpGenericAdaptorBase(ReshapeOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class ReshapeOpGenericAdaptor : public detail::ReshapeOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ReshapeOpGenericAdaptorBase; +public: + ReshapeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ReshapeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ReshapeOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + ReshapeOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSource() { + return (*getODSOperands(0).begin()); + } + + ValueT getShape() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ReshapeOpAdaptor : public ReshapeOpGenericAdaptor<::mlir::ValueRange> { +public: + using ReshapeOpGenericAdaptor::ReshapeOpGenericAdaptor; + ReshapeOpAdaptor(ReshapeOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ReshapeOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::OpAsmOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ReshapeOpAdaptor; + template + using GenericAdaptor = ReshapeOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("tensor.reshape"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::TensorType> getSource(); + ::mlir::TypedValue<::mlir::RankedTensorType> getShape(); + ::mlir::OpOperand &getSourceMutable(); + ::mlir::OpOperand &getShapeMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::TensorType> getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, TensorType resultType, Value operand, Value shape); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::Value shape); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value shape); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + TensorType getResultType() { return ::llvm::cast(getResult().getType()); } +}; +} // namespace tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::tensor::ReshapeOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::ScatterOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ScatterOpGenericAdaptorBase { +public: + struct Properties { + using scatter_dimsTy = ::mlir::DenseI64ArrayAttr; + scatter_dimsTy scatter_dims; + + auto getScatterDims() { + auto &propStorage = this->scatter_dims; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setScatterDims(const ::mlir::DenseI64ArrayAttr &propValue) { + this->scatter_dims = propValue; + } + using uniqueTy = ::mlir::UnitAttr; + uniqueTy unique; + + auto getUnique() { + auto &propStorage = this->unique; + return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(propStorage); + } + void setUnique(const ::mlir::UnitAttr &propValue) { + this->unique = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.scatter_dims == this->scatter_dims && + rhs.unique == this->unique && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ScatterOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + ScatterOpGenericAdaptorBase(ScatterOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::DenseI64ArrayAttr getScatterDimsAttr(); + ::llvm::ArrayRef getScatterDims(); + ::mlir::UnitAttr getUniqueAttr(); + bool getUnique(); +}; +} // namespace detail +template +class ScatterOpGenericAdaptor : public detail::ScatterOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ScatterOpGenericAdaptorBase; +public: + ScatterOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ScatterOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ScatterOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + ScatterOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSource() { + return (*getODSOperands(0).begin()); + } + + ValueT getDest() { + return (*getODSOperands(1).begin()); + } + + ValueT getIndices() { + return (*getODSOperands(2).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ScatterOpAdaptor : public ScatterOpGenericAdaptor<::mlir::ValueRange> { +public: + using ScatterOpGenericAdaptor::ScatterOpGenericAdaptor; + ScatterOpAdaptor(ScatterOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ScatterOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<3>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpAsmOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ScatterOpAdaptor; + template + using GenericAdaptor = ScatterOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("scatter_dims"), ::llvm::StringRef("unique")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getScatterDimsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getScatterDimsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getUniqueAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getUniqueAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("tensor.scatter"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::RankedTensorType> getSource(); + ::mlir::TypedValue<::mlir::RankedTensorType> getDest(); + ::mlir::TypedValue<::mlir::RankedTensorType> getIndices(); + ::mlir::OpOperand &getSourceMutable(); + ::mlir::OpOperand &getDestMutable(); + ::mlir::OpOperand &getIndicesMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::RankedTensorType> getResult(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getScatterDimsAttr(); + ::llvm::ArrayRef getScatterDims(); + ::mlir::UnitAttr getUniqueAttr(); + bool getUnique(); + void setScatterDimsAttr(::mlir::DenseI64ArrayAttr attr); + void setScatterDims(::llvm::ArrayRef attrValue); + void setUniqueAttr(::mlir::UnitAttr attr); + void setUnique(bool attrValue); + ::mlir::Attribute removeUniqueAttr(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::Value dest, ::mlir::Value indices, ::mlir::DenseI64ArrayAttr scatter_dims, /*optional*/::mlir::UnitAttr unique); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, ::mlir::Value indices, ::mlir::DenseI64ArrayAttr scatter_dims, /*optional*/::mlir::UnitAttr unique); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::Value dest, ::mlir::Value indices, ::llvm::ArrayRef scatter_dims, /*optional*/bool unique = false); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, ::mlir::Value indices, ::llvm::ArrayRef scatter_dims, /*optional*/bool unique = false); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + RankedTensorType getDestType() { + return ::llvm::cast(getDest().getType()); + } + RankedTensorType getIndicesType() { + return ::llvm::cast(getIndices().getType()); + } + RankedTensorType getSourceType() { + return ::llvm::cast(getSource().getType()); + } + RankedTensorType getResultType() { + return ::llvm::cast(getResult().getType()); + } +}; +} // namespace tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::tensor::ScatterOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::SplatOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class SplatOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + SplatOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + SplatOpGenericAdaptorBase(SplatOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class SplatOpGenericAdaptor : public detail::SplatOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::SplatOpGenericAdaptorBase; +public: + SplatOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + SplatOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : SplatOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + SplatOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getInput() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class SplatOpAdaptor : public SplatOpGenericAdaptor<::mlir::ValueRange> { +public: + using SplatOpGenericAdaptor::SplatOpGenericAdaptor; + SplatOpAdaptor(SplatOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class SplatOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::OpAsmOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = SplatOpAdaptor; + template + using GenericAdaptor = SplatOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("tensor.splat"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getInput(); + ::mlir::OpOperand &getInputMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::RankedTensorType> getAggregate(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value element, Type aggregateType); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type aggregate, ::mlir::Value input); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::tensor::SplatOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::UnPackOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class UnPackOpGenericAdaptorBase { +public: + struct Properties { + using inner_dims_posTy = ::mlir::DenseI64ArrayAttr; + inner_dims_posTy inner_dims_pos; + + auto getInnerDimsPos() { + auto &propStorage = this->inner_dims_pos; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setInnerDimsPos(const ::mlir::DenseI64ArrayAttr &propValue) { + this->inner_dims_pos = propValue; + } + using outer_dims_permTy = ::mlir::DenseI64ArrayAttr; + outer_dims_permTy outer_dims_perm; + + auto getOuterDimsPerm() { + auto &propStorage = this->outer_dims_perm; + return ::llvm::dyn_cast_or_null<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setOuterDimsPerm(const ::mlir::DenseI64ArrayAttr &propValue) { + this->outer_dims_perm = propValue; + } + using static_inner_tilesTy = ::mlir::DenseI64ArrayAttr; + static_inner_tilesTy static_inner_tiles; + + auto getStaticInnerTiles() { + auto &propStorage = this->static_inner_tiles; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setStaticInnerTiles(const ::mlir::DenseI64ArrayAttr &propValue) { + this->static_inner_tiles = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.inner_dims_pos == this->inner_dims_pos && + rhs.outer_dims_perm == this->outer_dims_perm && + rhs.static_inner_tiles == this->static_inner_tiles && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + UnPackOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + UnPackOpGenericAdaptorBase(UnPackOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::DenseI64ArrayAttr getOuterDimsPermAttr(); + ::llvm::ArrayRef getOuterDimsPerm(); + ::mlir::DenseI64ArrayAttr getInnerDimsPosAttr(); + ::llvm::ArrayRef getInnerDimsPos(); + ::mlir::DenseI64ArrayAttr getStaticInnerTilesAttr(); + ::llvm::ArrayRef getStaticInnerTiles(); +}; +} // namespace detail +template +class UnPackOpGenericAdaptor : public detail::UnPackOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::UnPackOpGenericAdaptorBase; +public: + UnPackOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + UnPackOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : UnPackOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + UnPackOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSource() { + return (*getODSOperands(0).begin()); + } + + ValueT getDest() { + return (*getODSOperands(1).begin()); + } + + RangeT getInnerTiles() { + return getODSOperands(2); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class UnPackOpAdaptor : public UnPackOpGenericAdaptor<::mlir::ValueRange> { +public: + using UnPackOpGenericAdaptor::UnPackOpGenericAdaptor; + UnPackOpAdaptor(UnPackOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class UnPackOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpAsmOpInterface::Trait, ::mlir::DestinationStyleOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::ReifyRankedShapedTypeOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = UnPackOpAdaptor; + template + using GenericAdaptor = UnPackOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("inner_dims_pos"), ::llvm::StringRef("outer_dims_perm"), ::llvm::StringRef("static_inner_tiles")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getInnerDimsPosAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getInnerDimsPosAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getOuterDimsPermAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getOuterDimsPermAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getStaticInnerTilesAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getStaticInnerTilesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("tensor.unpack"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::RankedTensorType> getSource(); + ::mlir::TypedValue<::mlir::RankedTensorType> getDest(); + ::mlir::Operation::operand_range getInnerTiles(); + ::mlir::OpOperand &getSourceMutable(); + ::mlir::OpOperand &getDestMutable(); + ::mlir::MutableOperandRange getInnerTilesMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::RankedTensorType> getResult(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getOuterDimsPermAttr(); + ::llvm::ArrayRef getOuterDimsPerm(); + ::mlir::DenseI64ArrayAttr getInnerDimsPosAttr(); + ::llvm::ArrayRef getInnerDimsPos(); + ::mlir::DenseI64ArrayAttr getStaticInnerTilesAttr(); + ::llvm::ArrayRef getStaticInnerTiles(); + void setOuterDimsPermAttr(::mlir::DenseI64ArrayAttr attr); + void setOuterDimsPerm(::std::optional<::llvm::ArrayRef> attrValue); + void setInnerDimsPosAttr(::mlir::DenseI64ArrayAttr attr); + void setInnerDimsPos(::llvm::ArrayRef attrValue); + void setStaticInnerTilesAttr(::mlir::DenseI64ArrayAttr attr); + void setStaticInnerTiles(::llvm::ArrayRef attrValue); + ::mlir::Attribute removeOuterDimsPermAttr(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value source, Value dest, ArrayRef innerDimsPos, ArrayRef innerTiles, ArrayRef outerDimsPerm = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::DenseI64ArrayAttr outer_dims_perm, ::mlir::DenseI64ArrayAttr inner_dims_pos, ::mlir::ValueRange inner_tiles, ::mlir::DenseI64ArrayAttr static_inner_tiles); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::DenseI64ArrayAttr outer_dims_perm, ::mlir::DenseI64ArrayAttr inner_dims_pos, ::mlir::ValueRange inner_tiles, ::mlir::DenseI64ArrayAttr static_inner_tiles); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::DenseI64ArrayAttr outer_dims_perm, ::mlir::DenseI64ArrayAttr inner_dims_pos, ::mlir::ValueRange inner_tiles, ::mlir::DenseI64ArrayAttr static_inner_tiles); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::Value dest, /*optional*/::llvm::ArrayRef outer_dims_perm, ::llvm::ArrayRef inner_dims_pos, ::mlir::ValueRange inner_tiles, ::llvm::ArrayRef static_inner_tiles); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value source, ::mlir::Value dest, /*optional*/::llvm::ArrayRef outer_dims_perm, ::llvm::ArrayRef inner_dims_pos, ::mlir::ValueRange inner_tiles, ::llvm::ArrayRef static_inner_tiles); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, /*optional*/::llvm::ArrayRef outer_dims_perm, ::llvm::ArrayRef inner_dims_pos, ::mlir::ValueRange inner_tiles, ::llvm::ArrayRef static_inner_tiles); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static ::mlir::LogicalResult canonicalize(UnPackOp op, ::mlir::PatternRewriter &rewriter); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn); + ::mlir::LogicalResult reifyResultShapes(::mlir::OpBuilder &builder, ::mlir::ReifiedRankedShapedTypeDims &reifiedReturnShapes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 3 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + size_t getSourceRank() { return getSourceType().getRank(); }; + size_t getDestRank() { return getDestType().getRank(); }; + RankedTensorType getSourceType() { + return ::llvm::cast(getSource().getType()); }; + RankedTensorType getDestType() { + return ::llvm::cast(getDest().getType()); }; + + MutableOperandRange getDpsInitsMutable() { return getDestMutable(); } + + /// Interface method for ConditionallySpeculatable. + Speculation::Speculatability getSpeculatability(); + + /// Return a mapping from positions `inner_dims_pos` to their + /// tile factors. + DenseMap getDimAndTileMapping(); + + /// Return the tile sizes as OpFoldResult. + SmallVector getMixedTiles(); + + /// Return the tile sizes as `int64_t`. If a tile size is dynamic + /// a sentinel `kDynamic` is introduced at that position in + /// the returned vector. + SmallVector getStaticTiles(); + + static Value createDestinationTensor(OpBuilder &b, Location loc, + Value source, ArrayRef innerTileSizes, + ArrayRef innerDimsPos, ArrayRef outerDimsPerm); + + /// Build and return a new UnPackOp that is a clone of the current UnPackOp + /// with (innerDimsPos, innerTiles) (resp. outerDimsPerm) are permuted by + /// innerPermutation (resp. outerPermutation). + /// Asserts that: + /// - At least one of innerPermutation or outerPermutation is non-empty. + /// - If not empty, innerPermutation is a valid permutation of size + /// matching innerDimPos. + /// - If not empty, outerPermutation is a valid permutation of size + /// matching outerDimsPerm. + UnPackOp createTransposedClone(OpBuilder &b, + Location loc, + Value transposedSource, + ArrayRef innerPermutation, + ArrayRef outerPermutation); + + /// Check if this UnPackOp is like a simple unpad operation. + /// In other words, this operation: + /// 1. drops useless dimensions (dimension of size 1), and + /// 2. reduces dimensions in place (i.e., no tranpose.) + bool isLikeUnPad(); +}; +} // namespace tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::tensor::UnPackOp) + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// ::mlir::tensor::YieldOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class YieldOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + YieldOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + YieldOpGenericAdaptorBase(YieldOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class YieldOpGenericAdaptor : public detail::YieldOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::YieldOpGenericAdaptorBase; +public: + YieldOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + YieldOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : YieldOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + YieldOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getValue() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class YieldOpAdaptor : public YieldOpGenericAdaptor<::mlir::ValueRange> { +public: + using YieldOpGenericAdaptor::YieldOpGenericAdaptor; + YieldOpAdaptor(YieldOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class YieldOp : public ::mlir::Op::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::RegionBranchTerminatorOpInterface::Trait, ::mlir::OpTrait::ReturnLike, ::mlir::OpTrait::IsTerminator> { +public: + using Op::Op; + using Op::print; + using Adaptor = YieldOpAdaptor; + template + using GenericAdaptor = YieldOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("tensor.yield"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getValue(); + ::mlir::OpOperand &getValueMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value value); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value value); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::MutableOperandRange getMutableSuccessorOperands(::mlir::RegionBranchPoint point); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::tensor::YieldOp) + + +#endif // GET_OP_CLASSES + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/IR/TensorOpsDialect.cpp.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/IR/TensorOpsDialect.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..e97472bcdb7ed27a743ca72b82a7e1f71a77966a --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/IR/TensorOpsDialect.cpp.inc @@ -0,0 +1,29 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Dialect Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: TensorOps.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::tensor::TensorDialect) +namespace mlir { +namespace tensor { + +TensorDialect::TensorDialect(::mlir::MLIRContext *context) + : ::mlir::Dialect(getDialectNamespace(), context, ::mlir::TypeID::get()) { + + getContext()->loadDialect(); + + getContext()->loadDialect(); + + getContext()->loadDialect(); + + initialize(); +} + +TensorDialect::~TensorDialect() = default; + +} // namespace tensor +} // namespace mlir diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/IR/TensorOpsDialect.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/IR/TensorOpsDialect.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..d959c648e28cdc04736f821d60d2e038916426e9 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/IR/TensorOpsDialect.h.inc @@ -0,0 +1,37 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Dialect Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: TensorOps.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace tensor { + +class TensorDialect : public ::mlir::Dialect { + explicit TensorDialect(::mlir::MLIRContext *context); + + void initialize(); + friend class ::mlir::MLIRContext; +public: + ~TensorDialect() override; + static constexpr ::llvm::StringLiteral getDialectNamespace() { + return ::llvm::StringLiteral("tensor"); + } + + /// Register canonicalization patterns. + void getCanonicalizationPatterns( + ::mlir::RewritePatternSet &results) const override; + + /// Materialize a single constant operation from a given attribute value with + /// the desired resultant type. + ::mlir::Operation *materializeConstant(::mlir::OpBuilder &builder, + ::mlir::Attribute value, + ::mlir::Type type, + ::mlir::Location loc) override; +}; +} // namespace tensor +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::tensor::TensorDialect) diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/IR/TensorTilingInterfaceImpl.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/IR/TensorTilingInterfaceImpl.h new file mode 100644 index 0000000000000000000000000000000000000000..7228a5a297ad8188d1a0bff803e5097d43a395d9 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/IR/TensorTilingInterfaceImpl.h @@ -0,0 +1,70 @@ +//===- TensorTilingOpInterfaceImpl.h - ------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file implements Tiling interface for TensorOps with ExternalModel. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_TENSOR_IR_TENSORTILINGINTERFACEIMPL_H_ +#define MLIR_DIALECT_TENSOR_IR_TENSORTILINGINTERFACEIMPL_H_ + +#include "mlir/IR/Dialect.h" + +namespace mlir { + +struct TilingResult; + +namespace tensor { + +class PadOp; + +/// Bubbles up a slice of this pad by taking the slice first and then performing +/// the padding. `offsets` and `strides` specifies each dimension's start offset +/// and size for the slice. The slice has unit strides along all dimensions. +/// +/// Specifically, this function converts: +/// ``` +/// %0 = tensor.pad %source low[...] high[...] { linalg.yield %cst } +/// %1 = %0 offsets=[...], sizes[...] +/// ``` +/// into +/// ``` +/// %0 = tensor.extract_slice %source ... +/// %0 = tensor.pad %0 low[...] high[...] { linalg.yield %cst } +/// ``` +/// +/// If `generateZeroSliceGuard` is true, the generated IR will contain logic +/// to guard against the case that we might take a zero-sized slice from the +/// original source. For such cases, we `tensor.generate` to generate the +/// full tensor. +FailureOr bubbleUpPadSlice(OpBuilder &b, tensor::PadOp padOp, + ArrayRef offsets, + ArrayRef sizes, + bool generateZeroSliceGuard = true); + +/// Registers external models for Tiling interface for tensor ops. +/// Currently, it registers: +/// +/// * TilingInterface for `tensor.pad`, `tensor.pack`, and `tensor.unpack`. +/// +/// Unfortunately, a "normal" internal registration is not possible at the +/// moment, because of the dependency of the interface implementation for these +/// ops on `affine.apply` and Affine dialect already depends on TensorOps. In +/// order to break the cyclic dependency (TensorOps->AffineOps->TensorOps) the +/// implementation is moved to a separate library. +void registerTilingInterfaceExternalModels(mlir::DialectRegistry ®istry); + +/// Similar to the above registeration, but it is only for `tensor.pack` and +/// `tensor.unpack` ops. +void registerTilingInterfaceExternalModelsForPackUnPackOps( + DialectRegistry ®istry); + +} // namespace tensor +} // namespace mlir + +#endif // MLIR_DIALECT_TENSOR_IR_TENSORTILINGINTERFACEIMPL_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/IR/ValueBoundsOpInterfaceImpl.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/IR/ValueBoundsOpInterfaceImpl.h new file mode 100644 index 0000000000000000000000000000000000000000..a75ee9df3217d0729b3d50e21a82cf67fb01e120 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/IR/ValueBoundsOpInterfaceImpl.h @@ -0,0 +1,20 @@ +//===- ValueBoundsOpInterfaceImpl.h - Impl. of ValueBoundsOpInterface -----===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_TENSOR_IR_VALUEBOUNDSOPINTERFACEIMPL_H +#define MLIR_DIALECT_TENSOR_IR_VALUEBOUNDSOPINTERFACEIMPL_H + +namespace mlir { +class DialectRegistry; + +namespace tensor { +void registerValueBoundsOpInterfaceExternalModels(DialectRegistry ®istry); +} // namespace tensor +} // namespace mlir + +#endif // MLIR_DIALECT_TENSOR_IR_VALUEBOUNDSOPINTERFACEIMPL_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.h new file mode 100644 index 0000000000000000000000000000000000000000..298c2259c1fab8072d74e0d2940d557e18672871 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.h @@ -0,0 +1,20 @@ +//===- BufferizableOpInterfaceImpl.h - Impl. of BufferizableOpInterface ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_TENSOR_BUFFERIZABLEOPINTERFACEIMPL_H +#define MLIR_DIALECT_TENSOR_BUFFERIZABLEOPINTERFACEIMPL_H + +namespace mlir { +class DialectRegistry; + +namespace tensor { +void registerBufferizableOpInterfaceExternalModels(DialectRegistry ®istry); +} // namespace tensor +} // namespace mlir + +#endif // MLIR_DIALECT_TENSOR_BUFFERIZABLEOPINTERFACEIMPL_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/Transforms/Passes.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/Transforms/Passes.h new file mode 100644 index 0000000000000000000000000000000000000000..48f9066934a25e276c5546a2f2246ee112f09374 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/Transforms/Passes.h @@ -0,0 +1,38 @@ +//===- Passes.h - Pass Entrypoints ------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_TENSOR_TRANSFORMS_PASSES_H_ +#define MLIR_DIALECT_TENSOR_TRANSFORMS_PASSES_H_ + +#include "mlir/Pass/Pass.h" + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// Passes +//===----------------------------------------------------------------------===// + +/// Creates an instance of the `tensor` subset folding pass. +std::unique_ptr createFoldTensorSubsetOpsPass(); + +/// Creates an instance of the `tensor` dialect bufferization pass. +std::unique_ptr createTensorBufferizePass(); + +//===----------------------------------------------------------------------===// +// Registration +//===----------------------------------------------------------------------===// + +/// Generate the code for registering passes. +#define GEN_PASS_REGISTRATION +#include "mlir/Dialect/Tensor/Transforms/Passes.h.inc" + +} // namespace tensor +} // namespace mlir + +#endif // MLIR_DIALECT_TENSOR_TRANSFORMS_PASSES_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/Transforms/Passes.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/Transforms/Passes.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..062474dc360f69b98be29c447b16ecb8eece34e9 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/Transforms/Passes.h.inc @@ -0,0 +1,276 @@ +/* Autogenerated by mlir-tblgen; don't manually edit */ + +#ifdef GEN_PASS_DECL +// Generate declarations for all passes. +#define GEN_PASS_DECL_FOLDTENSORSUBSETOPS +#define GEN_PASS_DECL_TENSORBUFFERIZE +#undef GEN_PASS_DECL +#endif // GEN_PASS_DECL + +//===----------------------------------------------------------------------===// +// FoldTensorSubsetOps +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_FOLDTENSORSUBSETOPS +#undef GEN_PASS_DECL_FOLDTENSORSUBSETOPS +#endif // GEN_PASS_DECL_FOLDTENSORSUBSETOPS +#ifdef GEN_PASS_DEF_FOLDTENSORSUBSETOPS +namespace impl { + +template +class FoldTensorSubsetOpsBase : public ::mlir::OperationPass<> { +public: + using Base = FoldTensorSubsetOpsBase; + + FoldTensorSubsetOpsBase() : ::mlir::OperationPass<>(::mlir::TypeID::get()) {} + FoldTensorSubsetOpsBase(const FoldTensorSubsetOpsBase &other) : ::mlir::OperationPass<>(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("fold-tensor-subset-ops"); + } + ::llvm::StringRef getArgument() const override { return "fold-tensor-subset-ops"; } + + ::llvm::StringRef getDescription() const override { return "Fold tensor subset ops into producer/consumer ops"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("FoldTensorSubsetOps"); + } + ::llvm::StringRef getName() const override { return "FoldTensorSubsetOps"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + registry.insert(); + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(FoldTensorSubsetOpsBase) + +protected: +private: +}; +} // namespace impl +#undef GEN_PASS_DEF_FOLDTENSORSUBSETOPS +#endif // GEN_PASS_DEF_FOLDTENSORSUBSETOPS + +//===----------------------------------------------------------------------===// +// TensorBufferize +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_TENSORBUFFERIZE +#undef GEN_PASS_DECL_TENSORBUFFERIZE +#endif // GEN_PASS_DECL_TENSORBUFFERIZE +#ifdef GEN_PASS_DEF_TENSORBUFFERIZE +namespace impl { + +template +class TensorBufferizeBase : public ::mlir::OperationPass { +public: + using Base = TensorBufferizeBase; + + TensorBufferizeBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + TensorBufferizeBase(const TensorBufferizeBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("tensor-bufferize"); + } + ::llvm::StringRef getArgument() const override { return "tensor-bufferize"; } + + ::llvm::StringRef getDescription() const override { return "Bufferize the `tensor` dialect"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("TensorBufferize"); + } + ::llvm::StringRef getName() const override { return "TensorBufferize"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TensorBufferizeBase) + +protected: +private: +}; +} // namespace impl +#undef GEN_PASS_DEF_TENSORBUFFERIZE +#endif // GEN_PASS_DEF_TENSORBUFFERIZE +#ifdef GEN_PASS_REGISTRATION + +//===----------------------------------------------------------------------===// +// FoldTensorSubsetOps Registration +//===----------------------------------------------------------------------===// + +inline void registerFoldTensorSubsetOps() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::tensor::createFoldTensorSubsetOpsPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerFoldTensorSubsetOpsPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::tensor::createFoldTensorSubsetOpsPass(); + }); +} + +//===----------------------------------------------------------------------===// +// TensorBufferize Registration +//===----------------------------------------------------------------------===// + +inline void registerTensorBufferize() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::tensor::createTensorBufferizePass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerTensorBufferizePass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::tensor::createTensorBufferizePass(); + }); +} + +//===----------------------------------------------------------------------===// +// Tensor Registration +//===----------------------------------------------------------------------===// + +inline void registerTensorPasses() { + registerFoldTensorSubsetOps(); + registerTensorBufferize(); +} +#undef GEN_PASS_REGISTRATION +#endif // GEN_PASS_REGISTRATION +// Deprecated. Please use the new per-pass macros. +#ifdef GEN_PASS_CLASSES + +template +class FoldTensorSubsetOpsBase : public ::mlir::OperationPass<> { +public: + using Base = FoldTensorSubsetOpsBase; + + FoldTensorSubsetOpsBase() : ::mlir::OperationPass<>(::mlir::TypeID::get()) {} + FoldTensorSubsetOpsBase(const FoldTensorSubsetOpsBase &other) : ::mlir::OperationPass<>(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("fold-tensor-subset-ops"); + } + ::llvm::StringRef getArgument() const override { return "fold-tensor-subset-ops"; } + + ::llvm::StringRef getDescription() const override { return "Fold tensor subset ops into producer/consumer ops"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("FoldTensorSubsetOps"); + } + ::llvm::StringRef getName() const override { return "FoldTensorSubsetOps"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + registry.insert(); + + registry.insert(); + + registry.insert(); + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(FoldTensorSubsetOpsBase) + +protected: +}; + +template +class TensorBufferizeBase : public ::mlir::OperationPass { +public: + using Base = TensorBufferizeBase; + + TensorBufferizeBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + TensorBufferizeBase(const TensorBufferizeBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("tensor-bufferize"); + } + ::llvm::StringRef getArgument() const override { return "tensor-bufferize"; } + + ::llvm::StringRef getDescription() const override { return "Bufferize the `tensor` dialect"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("TensorBufferize"); + } + ::llvm::StringRef getName() const override { return "TensorBufferize"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TensorBufferizeBase) + +protected: +}; +#undef GEN_PASS_CLASSES +#endif // GEN_PASS_CLASSES diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/Transforms/SubsetInsertionOpInterfaceImpl.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/Transforms/SubsetInsertionOpInterfaceImpl.h new file mode 100644 index 0000000000000000000000000000000000000000..e21b07d8a2705a0efd097120a2dc9d5bb83928c7 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/Transforms/SubsetInsertionOpInterfaceImpl.h @@ -0,0 +1,21 @@ +//===- SubsetInsertionOpInterfaceImpl.h - Tensor subsets ------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_TENSOR_SUBSETINSERTIONOPINTERFACEIMPL_H +#define MLIR_DIALECT_TENSOR_SUBSETINSERTIONOPINTERFACEIMPL_H + +namespace mlir { +class DialectRegistry; + +namespace tensor { +void registerSubsetInsertionOpInterfaceExternalModels( + DialectRegistry ®istry); +} // namespace tensor +} // namespace mlir + +#endif // MLIR_DIALECT_TENSOR_SUBSETINSERTIONOPINTERFACEIMPL_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/Transforms/TransformUtils.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/Transforms/TransformUtils.h new file mode 100644 index 0000000000000000000000000000000000000000..040b2a5d413449cca523aa607a22405a3a37f615 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/Transforms/TransformUtils.h @@ -0,0 +1,270 @@ +//===- TransformsUtils.h - Tensor Transformation Utilities-------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +#ifndef MLIR_DIALECT_TENSOR_TRANSFORMS_TRANSFORMUTILS_H +#define MLIR_DIALECT_TENSOR_TRANSFORMS_TRANSFORMUTILS_H + +#include "mlir/Dialect/Tensor/IR/Tensor.h" +#include "mlir/IR/PatternMatch.h" + +namespace mlir { +namespace tensor { + +//===----------------------------------------------------------------------===// +// Extract slice from `tensor.collapse_shape` +//===----------------------------------------------------------------------===// + +/// This class assists with generating IR required to materialize an +/// arbitrary-sized slice from the result of a CollapseShapeOp. In order to +/// accomplish this, a loop nest or similar operation must be created by the +/// caller. The purpose of the loop nest is to generate a "tiling by 1" of all +/// sliced dimensions. The "tiling by 1" assembles all elements of the result +/// tile over dimensions that would have been impossible to directly slice. +/// +/// The class provides three methods: +/// 1. `ExtractSliceFromCollapseHelper::create`: emits IR that should +/// appear before the loop nest and populates the internal state. +/// 2. `ExtractSliceFromCollapseHelper::getIterationSpaceSizes`: returns +/// parameters used by the caller to construct the loop nest. +/// 3. `ExtractSliceFromCollapseHelper::emitLoopNestBody`: +/// emits IR to construct a "size-1 tile" of the desired result and returns a +/// set of ranges where the tile should be inserted into the destination +/// tensor. +/// +/// ### Intended usage: +/// +/// The caller should first call `ExtractSliceFromCollapseHelper::create` and +/// then create a destination tensor that is the same size as the desired slice. +/// The caller then creates a loop nest that iterates over the multi-dimensional +/// iteration space defined by `[0, ub[0]) x [0, ub[1]] x ... x [0, ub[N-1]]` +/// where `ub` is the upper bound given by +/// `ExtractSliceFromCollapseHelper::getIterationSpaceSizes`. Inside the body of +/// the loop nest, the caller should call +/// `ExtractSliceFromCollapseHelper::emitLoopNestBody` and provide the induction +/// variables. This returns a sub-tile and a set of ranges that describe where +/// this tile should be inserted into the result by the caller. For a complete +/// example of usage, see the examples in the TestTensorTransforms pass. +/// +/// ### Example: +/// Consider the following IR: +/// ``` +/// %0 = linalg.generic ... -> tensor<3x?x?x11x?xf32> +/// %1 = tensor.collapse_shape %0 [[0, 1, 2], [3, 4]] +/// : tensor<3x?x?x11x?xf32> into tensor +/// %2 = tensor.extract_slice %1 [%offt0, %offt1][%size0, %size1][1, 1] +/// : tensor to tensor +/// ``` +/// +/// We can construct %2 by generating the following, which only uses `%0`: +/// +/// ``` +/// %dest = tensor.empty(%size0, %size1) : tensor +/// %1 = tensor.dim %0, %c1 : tensor<3x?x?x11x?xf32> +/// %2 = tensor.dim %0, %c2 : tensor<3x?x?x11x?xf32> +/// %3 = tensor.dim %0, %c4 : tensor<3x?x?x11x?xf32> +/// +/// %result = scf.for %iv0 = %c0 to %arg2 step %c1 iter_args(%arg6 = %dest) -> +/// (tensor) { +/// %5 = scf.for %iv1 = %c0 to %arg4 step %c1 iter_args(%arg8 = %arg6) +/// -> (tensor) { +/// %lin0 = (affine.apply) %iv0 + %offt0 +/// %lin1 = (affine.apply) %iv1 + %offt1 +/// +/// %mi0:3 = affine.delinearize_index %lin0 into (%c3, %1, %2) +/// %mi1:2 = affine.delinearize_index %lin1 into (%c11, %3) +/// +/// %sub_tile = tensor.extract_slice %0 +/// [%mi0#0, %mi0#1, %mi0#2, %mi1#0, %mi1#1] +/// [1, 1, 1, 1, 1] +/// [1, 1, 1, 1, 1] +/// : tensor<3x?x?x11x?xf32> to tensor<1x1x1x1x1xf32> +/// %sub_tile_collapsed = tensor.collapse_shape %sub_tile +/// [[0, 1, 2], [3, 4]] +/// : tensor<1x1x1x1x1xf32> into tensor<1x1xf3 +/// +/// %12 = tensor.insert_slice %sub_tile_collapsed into +/// %arg8[%iv0, %iv1] [1, 1] [1, 1] +/// : tensor<1x1xf32> into tensor +/// scf.yield %12 : tensor +/// } +/// scf.yield %5 : tensor +/// } +/// ``` +/// +/// ### Explanation of example: +/// +/// Each step above is explained below. +/// +/// #### Step 0: Create %dest and materialization of shapes. +/// This step is self-explanatory and performed by the caller. It can be +/// done before or after calling `ExtractSliceFromCollapseHelper::create`, +/// which materializes the source shape (`%0, %1, %2`). +/// +/// #### Step 1: Create loop nest. +/// +/// The caller creates the loop nest (depicted here is `scf.for`, but any other +/// similar op can be used). The iteration should start at zero and proceed with +/// step size 1 to the upper bounds given by +/// `ExtractSliceFromCollapseHelper::getIterationSpaceSizes`. This forms the +/// basis for the "tiling by 1". +/// +/// #### Step 2: Transform (%iv0, %iv1) from the index space of %3 to the index +/// space of %0. +/// +/// This step is performed by +/// `ExtractSliceFromCollapseHelper::emitLoopNestBody`. +/// +/// The induction variables `%iv0` and `%iv1` live in the +/// index space of %2 (for dimensions 0 and 1, respectively). `%lin0` and +/// `%lin1` are the result of inverting or resolve the index space +/// transformation represented by the slice operation, accounting for offset and +/// stride. Subsequently, `%mi0` and `%mi1` are the result of applying the +/// inverse index space transformation represented by `tensor.collapse_shape`. +/// This is accomplished using `affine.delinearize_index`. Note that %iv0 +/// and %iv1 now correspond to multi-indices `%mi0:3` and `%mi1:2`. +/// +/// #### Step 3: Extract a sub-tile slice from the source. +/// +/// This step is also performed by +/// `ExtractSliceFromCollapseHelper::emitLoopNestBody`. +/// +/// The indices `%mi0` and `%mi1` are used to extract a slice from %0. This +/// slice is then collapsed down to match the result rank. +/// +/// #### Step 4: Insert sub-tile into the destination +/// +/// This step is performed by the caller using the results of +/// `ExtractSliceFromCollapseHelper::emitLoopNestBody`. +/// +/// In the above example, the slice insertion parameters are straightforward, +/// but in other possible situations, the slice parameters are more complicated, +/// which is why this helper calculates them for the caller. These other +/// situations correspond to: +/// 1. The presence of linearized dimensions that are not sliced +/// 2. The presence of non-linearized dimensions that are sliced. +class ExtractSliceFromCollapseHelper { +public: + /// Given a CollapseShapeOp and a set of ranges describing the desired slice + /// of its result, emits IR to materialize the shapes of the input and output + /// tensors, and returns an instance of the initialized class. Returns failure + /// if the slice is rank-reducing. + static FailureOr + create(OpBuilder &b, tensor::CollapseShapeOp op, ArrayRef sliceParams); + + /// Given a CollapseShapeOp and an ExtractSliceOp acting on its result, emits + /// IR to materialize the shapes of the input and output tensors of the + /// CollapseShapeOp, and returns an instance of the initialized class. Returns + /// failure if the slice is rank-reducing. + static FailureOr + create(OpBuilder &b, tensor::CollapseShapeOp collapseOp, + tensor::ExtractSliceOp extractOp); + + ExtractSliceFromCollapseHelper( + tensor::CollapseShapeOp collapseShapeOp, + ArrayRef collapseShapeInputShape, + ArrayRef collapseShapeOutputShape, + ArrayRef extractSliceParams, + const llvm::SmallBitVector &linearizedDimensions, + const llvm::SmallBitVector &slicedDimensions, ArrayRef tiledSizes) + : collapseShapeOp(collapseShapeOp), + collapseShapeInputShape(collapseShapeInputShape), + collapseShapeOutputShape(collapseShapeOutputShape), + sliceParams(extractSliceParams), + linearizedDimensions(linearizedDimensions), + slicedDimensions(slicedDimensions), tiledSizes(tiledSizes) {} + + /// Return the upper bounds of the iteration space (with 0 offset and stride + /// 1) required to create the desired slice. Note that this is not the same + /// as the `sizes` parameters of the ExtractSliceOp because not all dimensions + /// of the slice are required to be tiled to form the result. + const SmallVector &getIterationSpaceSizes() { return tiledSizes; } + + /// Generates the IR inside of the caller's loop nest for 1) inverting the + /// index mappings of the ExtractSliceOp->CollapseShapeOp chain and 2) + /// extracting the CollapseShapeOp source tensor tile for this specified + /// iteration space point `tileInductionVars` and 3) calculating where to + /// insert the extracted tile. The returned pair consists of the results of + /// (2) and (3) and should be used by the caller to insert into the + /// destination tensor. + std::pair> + emitLoopNestBody(OpBuilder &builder, Location loc, + ValueRange tileInductionVars); + +private: + tensor::CollapseShapeOp collapseShapeOp; + SmallVector collapseShapeInputShape; + SmallVector collapseShapeOutputShape; + SmallVector sliceParams; + llvm::SmallBitVector linearizedDimensions; + llvm::SmallBitVector slicedDimensions; + SmallVector tiledSizes; +}; + +/// Tries to simplify a `tensor.collapse_shape` operation by inserting a single +/// rank-reducing `tensor.extract_slice` operation. The `extract_slice` op will +/// either take the place of the source, allowing for a new, simpler +/// `collapse_shape` op to replace `op`, or the `collapse_shape` op will be +/// completely replaced by the `extract_slice` result. Either way, `op` is +/// replaced and the new op is returned. +/// +/// ### Example: +/// ``` +/// %result = tensor.collapse_shape %0 [[0, 1], [2, 3]] +/// : tensor to tensor +/// ``` +/// can be transformed to +/// +/// ``` +/// %tmp = tensor.extract_slice %0 [0, 0, 0, 0] +/// [0, %dim1, 30, 30] +/// [1, 1, 1 1] +/// : tensor to tensor +/// %result = tensor.collapse_shape %tmp [[0], [1, 2]] +/// : tensor to tensor +/// ``` +/// +/// ### Example: +/// +/// ``` +/// %result = tensor.collapse_shape %1 [[0, 1], [2]] +/// : tensor to tensor +/// ``` +/// can be transformed to +/// ``` +/// %result = tensor.extract_slice %1 [0, 0, 0] +/// [%dim2, 1, 30] +/// [1, 1, 1] +/// : tensor to tensor +/// ``` +/// +/// ### Unsupported cases: +/// +/// This transform doesn't yet support reducing the rank of the reassociation +/// indices, which would require inserting a `tensor.expand_shape` op similar to +/// the following example: +/// ``` +/// %result = tensor.collapse_shape %0 [[0, 1], [2, 3]] +/// : tensor<1x1x30x10xf32> to tensor<1x300xf32> +/// ``` +/// can be transformed to +/// ``` +/// %tmp = tensor.extract_slice %0 [0, 0, 0, 0] +/// [0, 1, 30, 30] +/// [1, 1, 1 1] +/// : tensor<1x1x30x10xf32> to tensor<30x10xf32> +/// %result0 = tensor.collapse_shape %tmp [[0, 1]] +/// : tensor<30x10xf32> to tensor<300xf32> +/// %result1 = tensor.expand_shape %tmp [[0, 1], [2]] :... tensor<1x300xf32> +/// ``` +/// +FailureOr +simplifyCollapseShapeWithRankReducingExtractSlice(tensor::CollapseShapeOp op, + RewriterBase &rewriter); +} // namespace tensor +} // namespace mlir + +#endif // MLIR_DIALECT_TENSOR_TRANSFORMS_TRANSFORMUTILS_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/Transforms/Transforms.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/Transforms/Transforms.h new file mode 100644 index 0000000000000000000000000000000000000000..705b30e7ded4779e138e32d1e77fcf64ca1f7090 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/Transforms/Transforms.h @@ -0,0 +1,121 @@ +//===- Transforms.h - Tensor Transformation Patterns ------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_TENSOR_TRANSFORMS_TRANSFORMS_H +#define MLIR_DIALECT_TENSOR_TRANSFORMS_TRANSFORMS_H + +#include "mlir/Dialect/Tensor/IR/Tensor.h" +#include "mlir/IR/PatternMatch.h" + +namespace mlir { + +struct TilingResult; + +namespace tensor { + +//===----------------------------------------------------------------------===// +// Patterns +//===----------------------------------------------------------------------===// + +/// Pattern to swap an `tensor.extract_slice` with its producer when the +/// producer implements the `TilingInterface`. The pattern itself does not +/// provide a mechanism to control where the application happens. With use of +/// transform dialect that control is done within the transform dialect. Other +/// use cases can inherit from this pattern and add necessary controls. +FailureOr replaceExtractSliceWithTiledProducer( + OpBuilder &builder, tensor::ExtractSliceOp sliceOp, OpResult producerOp); + +//===----------------------------------------------------------------------===// +// Populate functions. +//===----------------------------------------------------------------------===// + +/// Appends patterns for folding tensor subset ops into consumer load/store +/// ops into `patterns`. (This includes patterns for folding tensor subset ops +/// into vector transfer ops.) +void populateFoldTensorSubsetOpPatterns(RewritePatternSet &patterns); + +/// Appends patterns for folding tensor subset ops into vector transfer ops. +void populateFoldTensorSubsetIntoVectorTransferPatterns( + RewritePatternSet &patterns); + +/// Collects patterns to merge consecutive tensor.insert_slice/extract_slice +/// into one. These patterns are in this separate entry point because the +/// bufferization is sensitive to IR structure, particularly those +/// tensor.extract_slice and tensor.insert_slice ops for creating the slices. +void populateMergeConsecutiveInsertExtractSlicePatterns( + RewritePatternSet &patterns); + +/// Populates `patterns` with patterns that drop redundant tensor.insert_slice +/// rank expansions. +void populateDropRedundantInsertSliceRankExpansionPatterns( + RewritePatternSet &patterns); + +/// Populates `patterns` with patterns that fold `tensor.expand_shape` and +/// `tensor.collapse_shape` into other ops. +void populateReassociativeReshapeFoldingPatterns(RewritePatternSet &patterns); + +/// Populates `patterns` with patterns that fold tensor.empty with +/// tensor.[extract_slice|expand_shape|collapse_shape]. +/// +/// If `singleUseOnly` is set to "true", only tensor.empty ops with a single +/// use are folded. +void populateFoldTensorEmptyPatterns(RewritePatternSet &patterns, + bool foldSingleUseOnly = false); + +/// Populates `patterns` with patterns that fold operations like `tensor.pad` +/// and `tensor.extract_slice` into `tensor.pack` and `tensor.unpack` operations +/// respectively. +void populateFoldIntoPackAndUnpackPatterns(RewritePatternSet &patterns); + +/// Populates `patterns` with patterns that replace tensor ops (such as +/// tensor.generate) with constants when possible. +void populateRewriteAsConstantPatterns(RewritePatternSet &patterns); + +//===----------------------------------------------------------------------===// +// Transform helpers +//===----------------------------------------------------------------------===// + +/// Build a new tensor::PadOp with low/high padding that is independent of all +/// given independencies. If the op is already independent of all +/// independencies, the same PadOp result is returned. +/// +/// Failure indicates the no suitable upper bound for low/high padding could be +/// found. +/// +/// Example: +/// scf.for %iv = %lb to %ub step %step { +/// %high = affine.apply affine_map<(d0)[s0] -> (s0 - d0)> (%i)[%ub] +/// %p = tensor.pad %t low[5] high[%high] ... +/// ... +/// } +/// +/// The function builds IR such as: +/// %high_new = affine.apply affine_map<()[s0, s1] -> (-s0 + s1)> ()[%lb, %ub] +/// %p_hoistable = tensor.pad %t low[5] high[%high_new] +/// %dim = tensor.dim %t, %c0 +/// %size = affine.apply affine_map<(d0)[s0, s1] -> (-d0 + s0 + s1 + 5)> +/// (%iv)[%ub, %dim] +/// %slice = tensor.extract_slice %p_hoistable [0] [%size] [1] +/// +/// The slice is returned. +FailureOr buildIndependentOp(OpBuilder &b, tensor::PadOp padOp, + ValueRange independencies); + +/// Build a new tensor::EmptyOp who's dynamic sizes are independent of all +/// given independencies. If the op is already independent of all +/// independencies, the same EmptyOp result is returned. +/// +/// Failure indicates the no suitable upper bound for the dynamic sizes could be +/// found. +FailureOr buildIndependentOp(OpBuilder &b, tensor::EmptyOp emptyOp, + ValueRange independencies); + +} // namespace tensor +} // namespace mlir + +#endif // MLIR_DIALECT_TENSOR_TRANSFORMS_TRANSFORMS_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/Utils/Utils.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/Utils/Utils.h new file mode 100644 index 0000000000000000000000000000000000000000..04b4de4a33a52fc410074fb3cd4155ca0a357863 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Tensor/Utils/Utils.h @@ -0,0 +1,47 @@ +//===- Utils.h - Utilities to support the Tensor dialect -------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_TENSOR_UTILS_UTILS_H_ +#define MLIR_DIALECT_TENSOR_UTILS_UTILS_H_ + +#include "mlir/Dialect/Tensor/IR/Tensor.h" + +namespace mlir { +namespace tensor { + +// Return a PadOp that pads `source` to `type` size where the static +// sizes are assumed to be greater than the dynamic sizes. If `type` has dynamic +// dimensions the padding width is set to zero. The op performs "high" padding +// (i.e. it adds trailing padding values until the desired size is met). +PadOp createPadHighOp(RankedTensorType type, Value source, Value pad, + bool nofold, Location loc, OpBuilder &builder); + +// Creates dim ops for each dynamic dimension of the ranked tensor argument and +// returns these as values. +SmallVector createDynamicDimValues(OpBuilder &b, Location loc, + Value rankedTensor); + +/// Returns the transposed `rankedTensorType` if `transposeVector` is non-empty. +/// Fail if `transposeVector` is not a permutation matching the tensor rank. +FailureOr +computeTransposedType(RankedTensorType rankedTensorType, + ArrayRef transposeVector); + +/// A tensor.insert_slice is a cast-like operation if it merely rank-extends the +/// source tensor or inserts the source tensor into a destination tensor with +/// the same shape. +bool isCastLikeInsertSliceOp(InsertSliceOp op); + +/// A tensor.extract_slice is a cast-like operation if it merely rank-reduces +/// unit dimensions of the source tensor or extracts the entire source tensor. +bool isCastLikeExtractSliceOp(ExtractSliceOp op); + +} // namespace tensor +} // namespace mlir + +#endif // MLIR_DIALECT_TENSOR_UTILS_UTILS_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/MatchInterfaces.cpp.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/MatchInterfaces.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..862aec1bc4d1307dde91aafa90783c2d9972528c --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/MatchInterfaces.cpp.inc @@ -0,0 +1,27 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Interface Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +/// Applies the transformation represented by the current operation. This +/// accepts as arguments the object that must be populated with results of +/// the current transformation and a transformation state object that can be +/// used for queries, e.g., to obtain the list of operations on which the +/// transformation represented by the current op is targeted. Returns a +/// special status object indicating whether the transformation succeeded +/// or failed, and, if it failed, whether the failure is recoverable or not. +/// +/// IR must be created, modified and deleted with the provided rewriter. +/// implementations are responsible for setting the insertion point of the +/// rewriter to the desired location. +::mlir::DiagnosedSilenceableFailure mlir::transform::MatchOpInterface::apply(::mlir::transform::TransformRewriter & rewriter, ::mlir::transform::TransformResults & transformResults, ::mlir::transform::TransformState & state) { + return getImpl()->implTransformOpInterface->apply(getImpl()->implTransformOpInterface, getOperation(), rewriter, transformResults, state); + } +/// Indicates whether the op instance allows its handle operands to be +/// associated with the same payload operations. +bool mlir::transform::MatchOpInterface::allowsRepeatedHandleOperands() { + return getImpl()->implTransformOpInterface->allowsRepeatedHandleOperands(getImpl()->implTransformOpInterface, getOperation()); + } diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/MatchInterfaces.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/MatchInterfaces.h new file mode 100644 index 0000000000000000000000000000000000000000..b155b110677d6c76372a72c1913face2636acd71 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/MatchInterfaces.h @@ -0,0 +1,176 @@ +//===- MatchInterfaces.h - Transform Dialect Interfaces ---------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_TRANSFORM_IR_MATCHINTERFACES_H +#define MLIR_DIALECT_TRANSFORM_IR_MATCHINTERFACES_H + +#include "mlir/Dialect/Transform/IR/TransformInterfaces.h" +#include "mlir/IR/OpDefinition.h" +#include "llvm/ADT/STLExtras.h" +#include +#include + +namespace mlir { +namespace transform { +class MatchOpInterface; + +namespace detail { +/// Dispatch `matchOperation` based on Operation* or std::optional +/// first operand. +template +DiagnosedSilenceableFailure matchOptionalOperation(OpTy op, + TransformResults &results, + TransformState &state) { + if constexpr (std::is_same_v< + typename llvm::function_traits< + decltype(&OpTy::matchOperation)>::template arg_t<0>, + Operation *>) { + return op.matchOperation(nullptr, results, state); + } else { + return op.matchOperation(std::nullopt, results, state); + } +} +} // namespace detail + +template +class AtMostOneOpMatcherOpTrait + : public OpTrait::TraitBase { + template + using has_get_operand_handle = + decltype(std::declval().getOperandHandle()); + template + using has_match_operation_ptr = decltype(std::declval().matchOperation( + std::declval(), std::declval(), + std::declval())); + template + using has_match_operation_optional = + decltype(std::declval().matchOperation( + std::declval>(), + std::declval(), + std::declval())); + +public: + static LogicalResult verifyTrait(Operation *op) { + static_assert(llvm::is_detected::value, + "AtMostOneOpMatcherOpTrait/SingleOpMatcherOpTrait expects " + "operation type to have the getOperandHandle() method"); + static_assert( + llvm::is_detected::value || + llvm::is_detected::value, + "AtMostOneOpMatcherOpTrait/SingleOpMatcherOpTrait expected operation " + "type to have either the matchOperation(Operation *, TransformResults " + "&, TransformState &) or the matchOperation(std::optional, " + "TransformResults &, TransformState &) method"); + + // This must be a dynamic assert because interface registration is dynamic. + assert( + isa(op) && + "AtMostOneOpMatcherOpTrait/SingleOpMatchOpTrait is only available on " + "operations with MatchOpInterface"); + Value operandHandle = cast(op).getOperandHandle(); + if (!isa(operandHandle.getType())) { + return op->emitError() << "AtMostOneOpMatcherOpTrait/" + "SingleOpMatchOpTrait requires the op handle " + "to be of TransformHandleTypeInterface"; + } + + return success(); + } + + DiagnosedSilenceableFailure apply(TransformRewriter &rewriter, + TransformResults &results, + TransformState &state) { + Value operandHandle = cast(this->getOperation()).getOperandHandle(); + auto payload = state.getPayloadOps(operandHandle); + if (!llvm::hasNItemsOrLess(payload, 1)) { + return emitDefiniteFailure(this->getOperation()->getLoc()) + << "AtMostOneOpMatcherOpTrait requires the operand handle to " + "point to at most one payload op"; + } + if (payload.empty()) { + return detail::matchOptionalOperation(cast(this->getOperation()), + results, state); + } + return cast(this->getOperation()) + .matchOperation(*payload.begin(), results, state); + } + + void getEffects(SmallVectorImpl &effects) { + onlyReadsHandle(this->getOperation()->getOperands(), effects); + producesHandle(this->getOperation()->getResults(), effects); + onlyReadsPayload(effects); + } +}; + +template +class SingleOpMatcherOpTrait : public AtMostOneOpMatcherOpTrait { + +public: + DiagnosedSilenceableFailure apply(TransformRewriter &rewriter, + TransformResults &results, + TransformState &state) { + Value operandHandle = cast(this->getOperation()).getOperandHandle(); + auto payload = state.getPayloadOps(operandHandle); + if (!llvm::hasSingleElement(payload)) { + return emitDefiniteFailure(this->getOperation()->getLoc()) + << "SingleOpMatchOpTrait requires the operand handle to point to " + "a single payload op"; + } + return static_cast *>(this)->apply( + rewriter, results, state); + } +}; + +template +class SingleValueMatcherOpTrait + : public OpTrait::TraitBase { +public: + static LogicalResult verifyTrait(Operation *op) { + // This must be a dynamic assert because interface registration is + // dynamic. + assert(isa(op) && + "SingleValueMatchOpTrait is only available on operations with " + "MatchOpInterface"); + + Value operandHandle = cast(op).getOperandHandle(); + if (!isa(operandHandle.getType())) { + return op->emitError() << "SingleValueMatchOpTrait requires an operand " + "of TransformValueHandleTypeInterface"; + } + + return success(); + } + + DiagnosedSilenceableFailure apply(TransformRewriter &rewriter, + TransformResults &results, + TransformState &state) { + Value operandHandle = cast(this->getOperation()).getOperandHandle(); + auto payload = state.getPayloadValues(operandHandle); + if (!llvm::hasSingleElement(payload)) { + return emitDefiniteFailure(this->getOperation()->getLoc()) + << "SingleValueMatchOpTrait requires the value handle to point " + "to a single payload value"; + } + + return cast(this->getOperation()) + .matchValue(*payload.begin(), results, state); + } + + void getEffects(SmallVectorImpl &effects) { + onlyReadsHandle(this->getOperation()->getOperands(), effects); + producesHandle(this->getOperation()->getResults(), effects); + onlyReadsPayload(effects); + } +}; + +} // namespace transform +} // namespace mlir + +#include "mlir/Dialect/Transform/IR/MatchInterfaces.h.inc" + +#endif // MLIR_DIALECT_TRANSFORM_IR_MATCHINTERFACES_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/MatchInterfaces.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/MatchInterfaces.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..577c9893d784d1ab2bed377d43f81202ab0b1d67 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/MatchInterfaces.h.inc @@ -0,0 +1,129 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Interface Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace transform { +class MatchOpInterface; +namespace detail { +struct MatchOpInterfaceInterfaceTraits { + struct Concept { + /// The methods defined by the interface. + /// The base classes of this interface. + const ::mlir::transform::TransformOpInterface::Concept *implTransformOpInterface = nullptr; + + void initializeInterfaceConcept(::mlir::detail::InterfaceMap &interfaceMap) { + implTransformOpInterface = interfaceMap.lookup<::mlir::transform::TransformOpInterface>(); + assert(implTransformOpInterface && "`::mlir::transform::MatchOpInterface` expected its base interface `::mlir::transform::TransformOpInterface` to be registered"); + } + }; + template + class Model : public Concept { + public: + using Interface = ::mlir::transform::MatchOpInterface; + Model() : Concept{} {} + + }; + template + class FallbackModel : public Concept { + public: + using Interface = ::mlir::transform::MatchOpInterface; + FallbackModel() : Concept{} {} + + }; + template + class ExternalModel : public FallbackModel { + public: + using ConcreteEntity = ConcreteOp; + }; +};template +struct MatchOpInterfaceTrait; + +} // namespace detail +class MatchOpInterface : public ::mlir::OpInterface { +public: + using ::mlir::OpInterface::OpInterface; + template + struct Trait : public detail::MatchOpInterfaceTrait {}; + //===----------------------------------------------------------------===// + // Inherited from ::mlir::transform::TransformOpInterface + //===----------------------------------------------------------------===// + + operator ::mlir::transform::TransformOpInterface () const { + if (!*this) return nullptr; + return ::mlir::transform::TransformOpInterface(*this, getImpl()->implTransformOpInterface); + } + + /// Applies the transformation represented by the current operation. This + /// accepts as arguments the object that must be populated with results of + /// the current transformation and a transformation state object that can be + /// used for queries, e.g., to obtain the list of operations on which the + /// transformation represented by the current op is targeted. Returns a + /// special status object indicating whether the transformation succeeded + /// or failed, and, if it failed, whether the failure is recoverable or not. + /// + /// IR must be created, modified and deleted with the provided rewriter. + /// implementations are responsible for setting the insertion point of the + /// rewriter to the desired location. + ::mlir::DiagnosedSilenceableFailure apply(::mlir::transform::TransformRewriter & rewriter, ::mlir::transform::TransformResults & transformResults, ::mlir::transform::TransformState & state); + /// Indicates whether the op instance allows its handle operands to be + /// associated with the same payload operations. + bool allowsRepeatedHandleOperands(); + + /// Creates the silenceable failure object with a diagnostic located at the + /// current operation. Silenceable failure must be suppressed or reported + /// explicitly at some later time. + DiagnosedSilenceableFailure + emitSilenceableError(const ::llvm::Twine &message = {}) { + return ::mlir::emitSilenceableFailure((*this), message); + } + + /// Creates the definite failure object with a diagnostic located at the + /// current operation. Definite failure will be reported when the object + /// is destroyed or converted. + DiagnosedDefiniteFailure + emitDefiniteFailure(const ::llvm::Twine &message = {}) { + return ::mlir::emitDefiniteFailure((*this), message); + } + + /// Emits a generic definite failure for the current transform operation + /// targeting the given Payload IR operation and returns failure. Should + /// be only used as a last resort when the transformation itself provides + /// no further indication as to the reason of the failure. + DiagnosedDefiniteFailure emitDefaultDefiniteFailure( + ::mlir::Operation *target) { + auto diag = ::mlir::emitDefiniteFailure((*this), "failed to apply"); + diag.attachNote(target->getLoc()) << "attempted to apply to this op"; + return diag; + } + + /// Creates the default silenceable failure for a transform op that failed + /// to properly apply to a target. + DiagnosedSilenceableFailure emitDefaultSilenceableFailure( + Operation *target) { + DiagnosedSilenceableFailure diag = emitSilenceableFailure((*this)->getLoc()); + diag << (*this)->getName() << " failed to apply"; + diag.attachNote(target->getLoc()) << "when applied to this op"; + return diag; + } + + /// Returns all operands that are handles and being consumed by this op. + ::llvm::SmallVector getConsumedHandleOpOperands() { + return ::mlir::transform::detail::getConsumedHandleOpOperands((*this)); + } +}; +namespace detail { + template + struct MatchOpInterfaceTrait : public ::mlir::OpInterface::Trait { + }; +}// namespace detail +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +} // namespace transform +} // namespace mlir diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformAttrs.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformAttrs.h new file mode 100644 index 0000000000000000000000000000000000000000..3cb935003b4c4f8702c0d38ded19dd4e77018e3b --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformAttrs.h @@ -0,0 +1,20 @@ +//===- TransformAttr.h - Transform Dialect Attribute Definition -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_TRANSFORM_IR_TRANSFORMATTRS_H +#define MLIR_DIALECT_TRANSFORM_IR_TRANSFORMATTRS_H + +#include "mlir/IR/Attributes.h" +#include "mlir/IR/BuiltinAttributes.h" + +#include +#include + +#include "mlir/Dialect/Transform/IR/TransformDialectEnums.h.inc" + +#endif // MLIR_DIALECT_TRANSFORM_IR_TRANSFORMATTRS_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformDialect.cpp.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformDialect.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..a2abc871ee87fc049bbfbbd305f7b92252c0dc12 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformDialect.cpp.inc @@ -0,0 +1,23 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Dialect Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: TransformDialect.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::TransformDialect) +namespace mlir { +namespace transform { + +TransformDialect::TransformDialect(::mlir::MLIRContext *context) + : ::mlir::Dialect(getDialectNamespace(), context, ::mlir::TypeID::get()) { + + initialize(); +} + +TransformDialect::~TransformDialect() = default; + +} // namespace transform +} // namespace mlir diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformDialect.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformDialect.h new file mode 100644 index 0000000000000000000000000000000000000000..db27f2c6fc49b75adb9ece2a58335f141861156b --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformDialect.h @@ -0,0 +1,321 @@ +//===- TransformDialect.h - Transform Dialect Definition --------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_TRANSFORM_IR_TRANSFORMDIALECT_H +#define MLIR_DIALECT_TRANSFORM_IR_TRANSFORMDIALECT_H + +#include "mlir/IR/Dialect.h" +#include "mlir/IR/PatternMatch.h" +#include "mlir/Support/LLVM.h" +#include "mlir/Support/TypeID.h" +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/StringMap.h" +#include + +namespace mlir { +namespace transform { + +namespace detail { +/// Concrete base class for CRTP TransformDialectDataBase. Must not be used +/// directly. +class TransformDialectDataBase { +public: + virtual ~TransformDialectDataBase() = default; + + /// Returns the dynamic type ID of the subclass. + TypeID getTypeID() const { return typeID; } + +protected: + /// Must be called by the subclass with the appropriate type ID. + explicit TransformDialectDataBase(TypeID typeID, MLIRContext *ctx) + : typeID(typeID), ctx(ctx) {} + + /// Return the MLIR context. + MLIRContext *getContext() const { return ctx; } + +private: + /// The type ID of the subclass. + const TypeID typeID; + + /// The MLIR context. + MLIRContext *ctx; +}; +} // namespace detail + +/// Base class for additional data owned by the Transform dialect. Extensions +/// may communicate with each other using this data. The data object is +/// identified by the TypeID of the specific data subclass, querying the data of +/// the same subclass returns a reference to the same object. When a Transform +/// dialect extension is initialized, it can populate the data in the specific +/// subclass. When a Transform op is applied, it can read (but not mutate) the +/// data in the specific subclass, including the data provided by other +/// extensions. +/// +/// This follows CRTP: derived classes must list themselves as template +/// argument. +template +class TransformDialectData : public detail::TransformDialectDataBase { +protected: + /// Forward the TypeID of the derived class to the base. + TransformDialectData(MLIRContext *ctx) + : TransformDialectDataBase(TypeID::get(), ctx) {} +}; + +#ifndef NDEBUG +namespace detail { +/// Asserts that the operations provided as template arguments implement the +/// TransformOpInterface and MemoryEffectsOpInterface. This must be a dynamic +/// assertion since interface implementations may be registered at runtime. +void checkImplementsTransformOpInterface(StringRef name, MLIRContext *context); + +/// Asserts that the type provided as template argument implements the +/// TransformHandleTypeInterface. This must be a dynamic assertion since +/// interface implementations may be registered at runtime. +void checkImplementsTransformHandleTypeInterface(TypeID typeID, + MLIRContext *context); +} // namespace detail +#endif // NDEBUG +} // namespace transform +} // namespace mlir + +#include "mlir/Dialect/Transform/IR/TransformDialect.h.inc" + +namespace mlir { +namespace transform { + +/// Base class for extensions of the Transform dialect that supports injecting +/// operations into the Transform dialect at load time. Concrete extensions are +/// expected to derive this class and register operations in the constructor. +/// They can be registered with the DialectRegistry and automatically applied +/// to the Transform dialect when it is loaded. +/// +/// Derived classes are expected to define a `void init()` function in which +/// they can call various protected methods of the base class to register +/// extension operations and declare their dependencies. +/// +/// By default, the extension is configured both for construction of the +/// Transform IR and for its application to some payload. If only the +/// construction is desired, the extension can be switched to "build-only" mode +/// that avoids loading the dialects that are only necessary for transforming +/// the payload. To perform the switch, the extension must be wrapped into the +/// `BuildOnly` class template (see below) when it is registered, as in: +/// +/// dialectRegistry.addExtension>(); +/// +/// instead of: +/// +/// dialectRegistry.addExtension(); +/// +/// Derived classes must reexport the constructor of this class or otherwise +/// forward its boolean argument to support this behavior. +template +class TransformDialectExtension + : public DialectExtension { + using Initializer = std::function; + using DialectLoader = std::function; + +public: + /// Extension application hook. Actually loads the dependent dialects and + /// registers the additional operations. Not expected to be called directly. + void apply(MLIRContext *context, TransformDialect *transformDialect, + ExtraDialects *...) const final { + for (const DialectLoader &loader : dialectLoaders) + loader(context); + + // Only load generated dialects if the user intends to apply + // transformations specified by the extension. + if (!buildOnly) + for (const DialectLoader &loader : generatedDialectLoaders) + loader(context); + + for (const Initializer &init : initializers) + init(transformDialect); + } + +protected: + using Base = TransformDialectExtension; + + /// Extension constructor. The argument indicates whether to skip generated + /// dialects when applying the extension. + explicit TransformDialectExtension(bool buildOnly = false) + : buildOnly(buildOnly) { + static_cast(this)->init(); + } + + /// Registers a custom initialization step to be performed when the extension + /// is applied to the dialect while loading. This is discouraged in favor of + /// more specific calls `declareGeneratedDialect`, `addDialectDataInitializer` + /// etc. `Func` must be convertible to the `void (MLIRContext *)` form. It + /// will be called during the extension initialization and given the current + /// MLIR context. This may be used to attach additional interfaces that cannot + /// be attached elsewhere. + template + void addCustomInitializationStep(Func &&func) { + std::function initializer = func; + dialectLoaders.push_back( + [init = std::move(initializer)](MLIRContext *ctx) { init(ctx); }); + } + + /// Registers the given function as one of the initializers for the + /// dialect-owned data of the kind specified as template argument. The + /// function must be convertible to the `void (DataTy &)` form. It will be + /// called during the extension initialization and will be given a mutable + /// reference to `DataTy`. The callback is expected to append data to the + /// given storage, and is not allowed to remove or destructively mutate the + /// existing data. The order in which callbacks from different extensions are + /// executed is unspecified so the callbacks may not rely on data being + /// already present. `DataTy` must be a class deriving `TransformDialectData`. + template + void addDialectDataInitializer(Func &&func) { + static_assert(std::is_base_of_v, + "only classes deriving TransformDialectData are accepted"); + + std::function initializer = func; + initializers.push_back( + [init = std::move(initializer)](TransformDialect *transformDialect) { + init(transformDialect->getOrCreateExtraData()); + }); + } + + /// Hook for derived classes to inject constructor behavior. + void init() {} + + /// Injects the operations into the Transform dialect. The operations must + /// implement the TransformOpInterface and MemoryEffectsOpInterface, and the + /// implementations must be already available when the operation is injected. + template + void registerTransformOps() { + initializers.push_back([](TransformDialect *transformDialect) { + transformDialect->addOperationsChecked(); + }); + } + + /// Injects the types into the Transform dialect. The types must implement + /// the TransformHandleTypeInterface and the implementation must be already + /// available when the type is injected. Furthermore, the types must provide + /// a `getMnemonic` static method returning an object convertible to + /// `StringRef` that is unique across all injected types. + template + void registerTypes() { + initializers.push_back([](TransformDialect *transformDialect) { + transformDialect->addTypesChecked(); + }); + } + + /// Declares that this Transform dialect extension depends on the dialect + /// provided as template parameter. When the Transform dialect is loaded, + /// dependent dialects will be loaded as well. This is intended for dialects + /// that contain attributes and types used in creation and canonicalization of + /// the injected operations, similarly to how the dialect definition may list + /// dependent dialects. This is *not* intended for dialects entities from + /// which may be produced when applying the transformations specified by ops + /// registered by this extension. + template + void declareDependentDialect() { + dialectLoaders.push_back( + [](MLIRContext *context) { context->loadDialect(); }); + } + + /// Declares that the transformations associated with the operations + /// registered by this dialect extension may produce operations from the + /// dialect provided as template parameter while processing payload IR that + /// does not contain the operations from said dialect. This is similar to + /// dependent dialects of a pass. These dialects will be loaded along with the + /// transform dialect unless the extension is in the build-only mode. + template + void declareGeneratedDialect() { + generatedDialectLoaders.push_back( + [](MLIRContext *context) { context->loadDialect(); }); + } + +private: + /// Callbacks performing extension initialization, e.g., registering ops, + /// types and defining the additional data. + SmallVector initializers; + + /// Callbacks loading the dependent dialects, i.e. the dialect needed for the + /// extension ops. + SmallVector dialectLoaders; + + /// Callbacks loading the generated dialects, i.e. the dialects produced when + /// applying the transformations. + SmallVector generatedDialectLoaders; + + /// Indicates that the extension is in build-only mode. + bool buildOnly; +}; + +template +void TransformDialect::addOperationIfNotRegistered() { + StringRef name = OpTy::getOperationName(); + std::optional opName = + RegisteredOperationName::lookup(name, getContext()); + if (!opName) { + addOperations(); +#ifndef NDEBUG + detail::checkImplementsTransformOpInterface(name, getContext()); +#endif // NDEBUG + return; + } + + if (opName->getTypeID() == TypeID::get()) + return; + + reportDuplicateOpRegistration(name); +} + +template +void TransformDialect::addTypeIfNotRegistered() { + // Use the address of the parse method as a proxy for identifying whether we + // are registering the same type class for the same mnemonic. + StringRef mnemonic = Type::getMnemonic(); + auto [it, inserted] = typeParsingHooks.try_emplace(mnemonic, Type::parse); + if (!inserted) { + const ExtensionTypeParsingHook &parsingHook = it->getValue(); + if (parsingHook != &Type::parse) + reportDuplicateTypeRegistration(mnemonic); + else + return; + } + typePrintingHooks.try_emplace( + TypeID::get(), +[](mlir::Type type, AsmPrinter &printer) { + printer << Type::getMnemonic(); + cast(type).print(printer); + }); + addTypes(); + +#ifndef NDEBUG + detail::checkImplementsTransformHandleTypeInterface(TypeID::get(), + getContext()); +#endif // NDEBUG +} + +template +DataTy &TransformDialect::getOrCreateExtraData() { + TypeID typeID = TypeID::get(); + auto it = extraData.find(typeID); + if (it != extraData.end()) + return static_cast(*it->getSecond()); + + auto emplaced = + extraData.try_emplace(typeID, std::make_unique(getContext())); + return static_cast(*emplaced.first->getSecond()); +} + +/// A wrapper for transform dialect extensions that forces them to be +/// constructed in the build-only mode. +template +class BuildOnly : public DerivedTy { +public: + BuildOnly() : DerivedTy(/*buildOnly=*/true) {} +}; + +} // namespace transform +} // namespace mlir + +#endif // MLIR_DIALECT_TRANSFORM_IR_TRANSFORMDIALECT_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformDialect.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformDialect.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..78b9e45393bd0e695803fab6fa7ce7adf585fde5 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformDialect.h.inc @@ -0,0 +1,169 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Dialect Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: TransformDialect.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace transform { + +class TransformDialect : public ::mlir::Dialect { + explicit TransformDialect(::mlir::MLIRContext *context); + + void initialize(); + friend class ::mlir::MLIRContext; +public: + ~TransformDialect() override; + static constexpr ::llvm::StringLiteral getDialectNamespace() { + return ::llvm::StringLiteral("transform"); + } + + /// Provides a hook for verifying dialect attributes attached to the given + /// op. + ::mlir::LogicalResult verifyOperationAttribute( + ::mlir::Operation *op, ::mlir::NamedAttribute attribute) override; + + /// Symbol name for the default entry point "named sequence". + constexpr const static ::llvm::StringLiteral + kTransformEntryPointSymbolName = "__transform_main"; + + /// Name of the attribute attachable to the symbol table operation + /// containing named sequences. This is used to trigger verification. + constexpr const static ::llvm::StringLiteral + kWithNamedSequenceAttrName = "transform.with_named_sequence"; + + /// Name of the attribute attachable to an operation so it can be + /// identified as root by the default interpreter pass. + constexpr const static ::llvm::StringLiteral kTargetTagAttrName = + "transform.target_tag"; + + /// Name of the attribute attachable to an operation, indicating that + /// TrackingListener failures should be silenced. + constexpr const static ::llvm::StringLiteral + kSilenceTrackingFailuresAttrName = + "transform.silence_tracking_failures"; + + /// Names of the attributes indicating whether an argument of an external + /// transform dialect symbol is consumed or only read. + constexpr const static ::llvm::StringLiteral kArgConsumedAttrName = + "transform.consumed"; + constexpr const static ::llvm::StringLiteral kArgReadOnlyAttrName = + "transform.readonly"; + + /// Names of the attributes indicating whether an argument of an external + /// transform dialect symbol is consumed or only read. + StringAttr getConsumedAttrName() const { + return StringAttr::get(getContext(), kArgConsumedAttrName); + } + StringAttr getReadOnlyAttrName() const { + return StringAttr::get(getContext(), kArgReadOnlyAttrName); + } + + template + const DataTy &getExtraData() const { + return *static_cast( + extraData.at(::mlir::TypeID::get()).get()); + } + + /// Parses a type registered by this dialect or one of its extensions. + ::mlir::Type parseType(::mlir::DialectAsmParser & parser) const override; + + /// Prints a type registered by this dialect or one of its extensions. + void printType(::mlir::Type type, ::mlir::DialectAsmPrinter & printer) + const override; + + /// Parser callback for an individual type registered by this dialect or + /// its extensions. + using ExtensionTypeParsingHook = ::mlir::Type (*)(::mlir::AsmParser &); + + /// Printer callback for an individual type registered by this dialect or + /// its extensions. + using ExtensionTypePrintingHook = + std::function; + + /// Appends the given module as a transform symbol library available to + /// all dialect users. + void registerLibraryModule(::mlir::OwningOpRef<::mlir::ModuleOp> && + library) { + libraryModules.push_back(std::move(library)); + } + + /// Returns a range of registered library modules. + auto getLibraryModules() const { + return ::llvm::map_range( + libraryModules, + [](const ::mlir::OwningOpRef<::mlir::ModuleOp> &library) { + return library.get(); + }); + } + + private: + /// Registers operations specified as template parameters with this + /// dialect. Checks that they implement the required interfaces. + template + void addOperationsChecked() { + (addOperationIfNotRegistered(), ...); + } + template + void addOperationIfNotRegistered(); + + /// Reports a repeated registration error of an op with the given name. + [[noreturn]] void reportDuplicateOpRegistration(StringRef opName); + + /// Registers types specified as template parameters with the Transform + /// dialect. Checks that they meet the requirements for Transform IR types. + template + void addTypesChecked() { + (addTypeIfNotRegistered(), ...); + } + template + void addTypeIfNotRegistered(); + + /// Reports a repeated registration error of a type with the given + /// mnemonic. + [[noreturn]] void reportDuplicateTypeRegistration(StringRef mnemonic); + + /// Registers dialect types with the context. + void initializeTypes(); + + // Give extensions access to injection functions. + template + friend class TransformDialectExtension; + + /// Gets a mutable reference to extra data of the kind specified as + /// template argument. Allocates the data on the first call. + template + DataTy &getOrCreateExtraData(); + + //===----------------------------------------------------------------===// + // Data fields + //===----------------------------------------------------------------===// + + /// Additional data associated with and owned by the dialect. Accessible + /// to extensions. + ::llvm::DenseMap< + ::mlir::TypeID, + std::unique_ptr<::mlir::transform::detail::TransformDialectDataBase>> + extraData; + + /// A map from type mnemonic to its parsing function for the remainder of + /// the syntax. The parser has access to the mnemonic, so it is used for + /// further dispatch. + ::llvm::StringMap typeParsingHooks; + + /// A map from type TypeID to its printing function. No need to do string + /// lookups when the type is fully constructed. + ::llvm::DenseMap<::mlir::TypeID, ExtensionTypePrintingHook> + typePrintingHooks; + + /// Modules containing symbols, e.g. named sequences, that will be + /// resolved by the interpreter when used. + ::llvm::SmallVector<::mlir::OwningOpRef<::mlir::ModuleOp>, 2> + libraryModules; + }; +} // namespace transform +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::TransformDialect) diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformDialectEnums.cpp.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformDialectEnums.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..1545c3fcd154c18d976812bdc3e4daf170e28dc7 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformDialectEnums.cpp.inc @@ -0,0 +1,97 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Enum Utility Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: TransformAttrs.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace transform { +::llvm::StringRef stringifyFailurePropagationMode(FailurePropagationMode val) { + switch (val) { + case FailurePropagationMode::Propagate: return "propagate"; + case FailurePropagationMode::Suppress: return "suppress"; + } + return ""; +} + +::std::optional symbolizeFailurePropagationMode(::llvm::StringRef str) { + return ::llvm::StringSwitch<::std::optional>(str) + .Case("propagate", FailurePropagationMode::Propagate) + .Case("suppress", FailurePropagationMode::Suppress) + .Default(::std::nullopt); +} +::std::optional symbolizeFailurePropagationMode(uint32_t value) { + switch (value) { + case 1: return FailurePropagationMode::Propagate; + case 2: return FailurePropagationMode::Suppress; + default: return ::std::nullopt; + } +} + +bool FailurePropagationModeAttr::classof(::mlir::Attribute attr) { + return (((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(32)))) && (((::llvm::cast<::mlir::IntegerAttr>(attr).getInt() == 1)) || ((::llvm::cast<::mlir::IntegerAttr>(attr).getInt() == 2))); +} +FailurePropagationModeAttr FailurePropagationModeAttr::get(::mlir::MLIRContext *context, FailurePropagationMode val) { + ::mlir::IntegerType intType = ::mlir::IntegerType::get(context, 32); + ::mlir::IntegerAttr baseAttr = ::mlir::IntegerAttr::get(intType, static_cast(val)); + return ::llvm::cast(baseAttr); +} +FailurePropagationMode FailurePropagationModeAttr::getValue() const { + return static_cast(::mlir::IntegerAttr::getInt()); +} +} // namespace transform +} // namespace mlir + +namespace mlir { +namespace transform { +::llvm::StringRef stringifyMatchCmpIPredicate(MatchCmpIPredicate val) { + switch (val) { + case MatchCmpIPredicate::eq: return "eq"; + case MatchCmpIPredicate::ne: return "ne"; + case MatchCmpIPredicate::lt: return "lt"; + case MatchCmpIPredicate::le: return "le"; + case MatchCmpIPredicate::gt: return "gt"; + case MatchCmpIPredicate::ge: return "ge"; + } + return ""; +} + +::std::optional symbolizeMatchCmpIPredicate(::llvm::StringRef str) { + return ::llvm::StringSwitch<::std::optional>(str) + .Case("eq", MatchCmpIPredicate::eq) + .Case("ne", MatchCmpIPredicate::ne) + .Case("lt", MatchCmpIPredicate::lt) + .Case("le", MatchCmpIPredicate::le) + .Case("gt", MatchCmpIPredicate::gt) + .Case("ge", MatchCmpIPredicate::ge) + .Default(::std::nullopt); +} +::std::optional symbolizeMatchCmpIPredicate(uint32_t value) { + switch (value) { + case 0: return MatchCmpIPredicate::eq; + case 1: return MatchCmpIPredicate::ne; + case 2: return MatchCmpIPredicate::lt; + case 3: return MatchCmpIPredicate::le; + case 4: return MatchCmpIPredicate::gt; + case 5: return MatchCmpIPredicate::ge; + default: return ::std::nullopt; + } +} + +bool MatchCmpIPredicateAttr::classof(::mlir::Attribute attr) { + return (((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(32)))) && (((::llvm::cast<::mlir::IntegerAttr>(attr).getInt() == 0)) || ((::llvm::cast<::mlir::IntegerAttr>(attr).getInt() == 1)) || ((::llvm::cast<::mlir::IntegerAttr>(attr).getInt() == 2)) || ((::llvm::cast<::mlir::IntegerAttr>(attr).getInt() == 3)) || ((::llvm::cast<::mlir::IntegerAttr>(attr).getInt() == 4)) || ((::llvm::cast<::mlir::IntegerAttr>(attr).getInt() == 5))); +} +MatchCmpIPredicateAttr MatchCmpIPredicateAttr::get(::mlir::MLIRContext *context, MatchCmpIPredicate val) { + ::mlir::IntegerType intType = ::mlir::IntegerType::get(context, 32); + ::mlir::IntegerAttr baseAttr = ::mlir::IntegerAttr::get(intType, static_cast(val)); + return ::llvm::cast(baseAttr); +} +MatchCmpIPredicate MatchCmpIPredicateAttr::getValue() const { + return static_cast(::mlir::IntegerAttr::getInt()); +} +} // namespace transform +} // namespace mlir + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformDialectEnums.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformDialectEnums.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..5c6f8e55b25209c27aece3f4e23b30b88c5d1a26 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformDialectEnums.h.inc @@ -0,0 +1,193 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Enum Utility Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: TransformAttrs.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace transform { +// Silenceable error propagation policy +enum class FailurePropagationMode : uint32_t { + Propagate = 1, + Suppress = 2, +}; + +::std::optional symbolizeFailurePropagationMode(uint32_t); +::llvm::StringRef stringifyFailurePropagationMode(FailurePropagationMode); +::std::optional symbolizeFailurePropagationMode(::llvm::StringRef); +inline constexpr unsigned getMaxEnumValForFailurePropagationMode() { + return 2; +} + + +inline ::llvm::StringRef stringifyEnum(FailurePropagationMode enumValue) { + return stringifyFailurePropagationMode(enumValue); +} + +template +::std::optional symbolizeEnum(::llvm::StringRef); + +template <> +inline ::std::optional symbolizeEnum(::llvm::StringRef str) { + return symbolizeFailurePropagationMode(str); +} + +class FailurePropagationModeAttr : public ::mlir::IntegerAttr { +public: + using ValueType = FailurePropagationMode; + using ::mlir::IntegerAttr::IntegerAttr; + static bool classof(::mlir::Attribute attr); + static FailurePropagationModeAttr get(::mlir::MLIRContext *context, FailurePropagationMode val); + FailurePropagationMode getValue() const; +}; +} // namespace transform +} // namespace mlir + +namespace mlir { +template +struct FieldParser; + +template<> +struct FieldParser<::mlir::transform::FailurePropagationMode, ::mlir::transform::FailurePropagationMode> { + template + static FailureOr<::mlir::transform::FailurePropagationMode> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return parser.emitError(loc, "expected keyword for Silenceable error propagation policy"); + + // Symbolize the keyword. + if (::std::optional<::mlir::transform::FailurePropagationMode> attr = ::mlir::transform::symbolizeEnum<::mlir::transform::FailurePropagationMode>(enumKeyword)) + return *attr; + return parser.emitError(loc, "invalid Silenceable error propagation policy specification: ") << enumKeyword; + } +}; +} // namespace mlir + +namespace llvm { +inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::transform::FailurePropagationMode value) { + auto valueStr = stringifyEnum(value); + return p << valueStr; +} +} // namespace llvm + +namespace llvm { +template<> struct DenseMapInfo<::mlir::transform::FailurePropagationMode> { + using StorageInfo = ::llvm::DenseMapInfo; + + static inline ::mlir::transform::FailurePropagationMode getEmptyKey() { + return static_cast<::mlir::transform::FailurePropagationMode>(StorageInfo::getEmptyKey()); + } + + static inline ::mlir::transform::FailurePropagationMode getTombstoneKey() { + return static_cast<::mlir::transform::FailurePropagationMode>(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const ::mlir::transform::FailurePropagationMode &val) { + return StorageInfo::getHashValue(static_cast(val)); + } + + static bool isEqual(const ::mlir::transform::FailurePropagationMode &lhs, const ::mlir::transform::FailurePropagationMode &rhs) { + return lhs == rhs; + } +}; +} + +namespace mlir { +namespace transform { +// allowed 32-bit signless integer cases: 0, 1, 2, 3, 4, 5 +enum class MatchCmpIPredicate : uint32_t { + eq = 0, + ne = 1, + lt = 2, + le = 3, + gt = 4, + ge = 5, +}; + +::std::optional symbolizeMatchCmpIPredicate(uint32_t); +::llvm::StringRef stringifyMatchCmpIPredicate(MatchCmpIPredicate); +::std::optional symbolizeMatchCmpIPredicate(::llvm::StringRef); +inline constexpr unsigned getMaxEnumValForMatchCmpIPredicate() { + return 5; +} + + +inline ::llvm::StringRef stringifyEnum(MatchCmpIPredicate enumValue) { + return stringifyMatchCmpIPredicate(enumValue); +} + +template +::std::optional symbolizeEnum(::llvm::StringRef); + +template <> +inline ::std::optional symbolizeEnum(::llvm::StringRef str) { + return symbolizeMatchCmpIPredicate(str); +} + +class MatchCmpIPredicateAttr : public ::mlir::IntegerAttr { +public: + using ValueType = MatchCmpIPredicate; + using ::mlir::IntegerAttr::IntegerAttr; + static bool classof(::mlir::Attribute attr); + static MatchCmpIPredicateAttr get(::mlir::MLIRContext *context, MatchCmpIPredicate val); + MatchCmpIPredicate getValue() const; +}; +} // namespace transform +} // namespace mlir + +namespace mlir { +template +struct FieldParser; + +template<> +struct FieldParser<::mlir::transform::MatchCmpIPredicate, ::mlir::transform::MatchCmpIPredicate> { + template + static FailureOr<::mlir::transform::MatchCmpIPredicate> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return parser.emitError(loc, "expected keyword for allowed 32-bit signless integer cases: 0, 1, 2, 3, 4, 5"); + + // Symbolize the keyword. + if (::std::optional<::mlir::transform::MatchCmpIPredicate> attr = ::mlir::transform::symbolizeEnum<::mlir::transform::MatchCmpIPredicate>(enumKeyword)) + return *attr; + return parser.emitError(loc, "invalid allowed 32-bit signless integer cases: 0, 1, 2, 3, 4, 5 specification: ") << enumKeyword; + } +}; +} // namespace mlir + +namespace llvm { +inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::transform::MatchCmpIPredicate value) { + auto valueStr = stringifyEnum(value); + return p << valueStr; +} +} // namespace llvm + +namespace llvm { +template<> struct DenseMapInfo<::mlir::transform::MatchCmpIPredicate> { + using StorageInfo = ::llvm::DenseMapInfo; + + static inline ::mlir::transform::MatchCmpIPredicate getEmptyKey() { + return static_cast<::mlir::transform::MatchCmpIPredicate>(StorageInfo::getEmptyKey()); + } + + static inline ::mlir::transform::MatchCmpIPredicate getTombstoneKey() { + return static_cast<::mlir::transform::MatchCmpIPredicate>(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const ::mlir::transform::MatchCmpIPredicate &val) { + return StorageInfo::getHashValue(static_cast(val)); + } + + static bool isEqual(const ::mlir::transform::MatchCmpIPredicate &lhs, const ::mlir::transform::MatchCmpIPredicate &rhs) { + return lhs == rhs; + } +}; +} + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformInterfaces.cpp.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformInterfaces.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..eb51f0be3f22978403189692c6508b6521376734 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformInterfaces.cpp.inc @@ -0,0 +1,76 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Interface Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +/// Populate conversion patterns into the given pattern set with the +/// given type converter. +void mlir::transform::ConversionPatternDescriptorOpInterface::populatePatterns(::mlir::TypeConverter & typeConverter, ::mlir::RewritePatternSet & patterns) { + return getImpl()->populatePatterns(getImpl(), getOperation(), typeConverter, patterns); + } +/// Populate the ConversionTarget using the final TypeConverter. The default +/// implementation is to do nothing. Overriding this method can be useful +/// in order to setup the ConversionTarget for structural type conversions. +/// In such a situation, an op's legality depends on using the TypeConverter +/// to determine whether the op's operand and result types are legal +/// (defined as converting to themselves). +/// +void mlir::transform::ConversionPatternDescriptorOpInterface::populateConversionTargetRules(const ::mlir::TypeConverter & typeConverter, ::mlir::ConversionTarget & conversionTarget) { + return getImpl()->populateConversionTargetRules(getImpl(), getOperation(), typeConverter, conversionTarget); + } +/// Return the type converter to be used with this pattern set. If no +/// type converter is specified, the default type converter of the enclosing +/// "apply_conversion_patterns" op is used. +std::unique_ptr<::mlir::TypeConverter> mlir::transform::ConversionPatternDescriptorOpInterface::getTypeConverter() { + return getImpl()->getTypeConverter(getImpl(), getOperation()); + } +/// Verify the default type converter that is provided by the enclosing +/// "apply_conversion_patterns" op. +::mlir::LogicalResult mlir::transform::ConversionPatternDescriptorOpInterface::verifyTypeConverter(TypeConverterBuilderOpInterface builder) { + return getImpl()->verifyTypeConverter(getImpl(), getOperation(), builder); + } +/// Return the operands at which the lookup for replacement payload ops +/// should continue. +::llvm::SmallVector<::mlir::Value> mlir::transform::FindPayloadReplacementOpInterface::getNextOperands() { + return getImpl()->getNextOperands(getImpl(), getOperation()); + } +/// Populate rewrite patterns into the given pattern set. +void mlir::transform::PatternDescriptorOpInterface::populatePatterns(::mlir::RewritePatternSet & patterns) { + return getImpl()->populatePatterns(getImpl(), getOperation(), patterns); + } +/// Populate rewrite patterns into the given pattern set taking into account +/// the transform state. +void mlir::transform::PatternDescriptorOpInterface::populatePatternsWithState(::mlir::RewritePatternSet & patterns, ::mlir::transform::TransformState & state) { + return getImpl()->populatePatternsWithState(getImpl(), getOperation(), patterns, state); + } +/// Applies the transformation represented by the current operation. This +/// accepts as arguments the object that must be populated with results of +/// the current transformation and a transformation state object that can be +/// used for queries, e.g., to obtain the list of operations on which the +/// transformation represented by the current op is targeted. Returns a +/// special status object indicating whether the transformation succeeded +/// or failed, and, if it failed, whether the failure is recoverable or not. +/// +/// IR must be created, modified and deleted with the provided rewriter. +/// implementations are responsible for setting the insertion point of the +/// rewriter to the desired location. +::mlir::DiagnosedSilenceableFailure mlir::transform::TransformOpInterface::apply(::mlir::transform::TransformRewriter & rewriter, ::mlir::transform::TransformResults & transformResults, ::mlir::transform::TransformState & state) { + return getImpl()->apply(getImpl(), getOperation(), rewriter, transformResults, state); + } +/// Indicates whether the op instance allows its handle operands to be +/// associated with the same payload operations. +bool mlir::transform::TransformOpInterface::allowsRepeatedHandleOperands() { + return getImpl()->allowsRepeatedHandleOperands(getImpl(), getOperation()); + } +/// Return the type converter to be used with a dialect conversion. +std::unique_ptr<::mlir::TypeConverter> mlir::transform::TypeConverterBuilderOpInterface::getTypeConverter() { + return getImpl()->getTypeConverter(getImpl(), getOperation()); + } +/// Return the type of type converter that this `getTypeConverter` returns. +/// This function is used for op verification. +StringRef mlir::transform::TypeConverterBuilderOpInterface::getTypeConverterType() { + return getImpl()->getTypeConverterType(); + } diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformInterfaces.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformInterfaces.h new file mode 100644 index 0000000000000000000000000000000000000000..7b37245fc3d117baf8da94243a4b76027187a311 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformInterfaces.h @@ -0,0 +1,1566 @@ +//===- TransformInterfaces.h - Transform Dialect Interfaces -----*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_TRANSFORM_IR_TRANSFORMINTERFACES_H +#define MLIR_DIALECT_TRANSFORM_IR_TRANSFORMINTERFACES_H + +#include "mlir/Dialect/Transform/IR/TransformTypes.h" +#include "mlir/Dialect/Transform/Utils/DiagnosedSilenceableFailure.h" +#include "mlir/Dialect/Transform/Utils/RaggedArray.h" +#include "mlir/IR/OpDefinition.h" +#include "mlir/IR/PatternMatch.h" +#include "mlir/Interfaces/SideEffectInterfaces.h" +#include "mlir/Support/LogicalResult.h" +#include "mlir/Transforms/DialectConversion.h" + +namespace mlir { +namespace transform { + +class TransformOpInterface; +class TransformResults; +class TransformRewriter; +class TransformState; + +using Param = Attribute; +using MappedValue = llvm::PointerUnion; + +namespace detail { +/// Maps the only block argument of the op with PossibleTopLevelTransformOpTrait +/// to either the list of operations associated with its operand or the root of +/// the payload IR, depending on what is available in the context. +LogicalResult +mapPossibleTopLevelTransformOpBlockArguments(TransformState &state, + Operation *op, Region ®ion); + +/// Verification hook for PossibleTopLevelTransformOpTrait. +LogicalResult verifyPossibleTopLevelTransformOpTrait(Operation *op); + +/// Populates `effects` with side effects implied by +/// PossibleTopLevelTransformOpTrait for the given operation. The operation may +/// have an optional `root` operand, indicating it is not in fact top-level. It +/// is also expected to have a single-block body. +void getPotentialTopLevelEffects( + Operation *operation, Value root, Block &body, + SmallVectorImpl &effects); + +/// Verification hook for TransformOpInterface. +LogicalResult verifyTransformOpInterface(Operation *op); + +/// Populates `mappings` with mapped values associated with the given transform +/// IR values in the given `state`. +void prepareValueMappings( + SmallVectorImpl> &mappings, + ValueRange values, const transform::TransformState &state); + +/// Populates `results` with payload associations that match exactly those of +/// the operands to `block`'s terminator. +void forwardTerminatorOperands(Block *block, transform::TransformState &state, + transform::TransformResults &results); + +/// Make a dummy transform state for testing purposes. This MUST NOT be used +/// outside of test cases. +TransformState makeTransformStateForTesting(Region *region, + Operation *payloadRoot); + +/// Returns all operands that are handles and being consumed by the given op. +SmallVector +getConsumedHandleOpOperands(transform::TransformOpInterface transformOp); +} // namespace detail +} // namespace transform +} // namespace mlir + +#include "mlir/Dialect/Transform/IR/TransformInterfaces.h.inc" + +namespace mlir { +namespace transform { + +/// Options controlling the application of transform operations by the +/// TransformState. +class TransformOptions { +public: + TransformOptions() = default; + TransformOptions(const TransformOptions &) = default; + TransformOptions &operator=(const TransformOptions &) = default; + + /// Requests computationally expensive checks of the transform and payload IR + /// well-formedness to be performed before each transformation. In particular, + /// these ensure that the handles still point to valid operations when used. + TransformOptions &enableExpensiveChecks(bool enable = true) { + expensiveChecksEnabled = enable; + return *this; + } + + /// Returns true if the expensive checks are requested. + bool getExpensiveChecksEnabled() const { return expensiveChecksEnabled; } + +private: + bool expensiveChecksEnabled = true; +}; + +/// Entry point to the Transform dialect infrastructure. Applies the +/// transformation specified by `transform` to payload IR contained in +/// `payloadRoot`. The `transform` operation may contain other operations that +/// will be executed following the internal logic of the operation. It must +/// have the `PossibleTopLevelTransformOp` trait and not have any operands. +/// This function internally keeps track of the transformation state. +LogicalResult +applyTransforms(Operation *payloadRoot, TransformOpInterface transform, + const RaggedArray &extraMapping = {}, + const TransformOptions &options = TransformOptions(), + bool enforceToplevelTransformOp = true); + +/// The state maintained across applications of various ops implementing the +/// TransformOpInterface. The operations implementing this interface and the +/// surrounding structure are referred to as transform IR. The operations to +/// which transformations apply are referred to as payload IR. Transform IR +/// operates on values that can be associated either with a list of payload IR +/// operations (such values are referred to as handles) or with a list of +/// parameters represented as attributes. The state thus contains the mapping +/// between values defined in the transform IR ops and either payload IR ops or +/// parameters. For payload ops, the mapping is many-to-many and the reverse +/// mapping is also stored. The "expensive-checks" option can be passed to the +/// constructor at transformation execution time that transform IR values used +/// as operands by a transform IR operation are not associated with dangling +/// pointers to payload IR operations that are known to have been erased by +/// previous transformation through the same or a different transform IR value. +/// +/// A reference to this class is passed as an argument to "apply" methods of the +/// transform op interface. Thus the "apply" method can call either +/// `state.getPayloadOps( getSomeOperand() )` to obtain the list of operations +/// or `state.getParams( getSomeOperand() )` to obtain the list of parameters +/// associated with its operand. The method is expected to populate the +/// `TransformResults` class instance in order to update the mapping. The +/// `applyTransform` method takes care of propagating the state of +/// `TransformResults` into the instance of this class. +/// +/// When applying transform IR operations with regions, the client is expected +/// to create a `RegionScope` RAII object to create a new "stack frame" for +/// values defined inside the region. The mappings from and to these values will +/// be automatically dropped when the object goes out of scope, typically at the +/// end of the `apply` function of the parent operation. If a region contains +/// blocks with arguments, the client can map those arguments to payload IR ops +/// using `mapBlockArguments`. +class TransformState { +public: + using Param = transform::Param; + +private: + /// Mapping between a Value in the transform IR and the corresponding set of + /// operations in the payload IR. + using TransformOpMapping = DenseMap>; + + /// Mapping between a payload IR operation and the transform IR values it is + /// associated with. + using TransformOpReverseMapping = + DenseMap>; + + /// Mapping between a Value in the transform IR and the corresponding list of + /// parameters. + using ParamMapping = DenseMap>; + + /// Mapping between a Value in the transform IR and the corrsponding list of + /// values in the payload IR. Also works for reverse mappings. + using ValueMapping = DenseMap>; + + /// Mapping between a Value in the transform IR and an error message that + /// should be emitted when the value is used. + using InvalidatedHandleMap = DenseMap>; + +#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS + /// Debug only: A timestamp is associated with each transform IR value, so + /// that invalid iterator usage can be detected more reliably. + using TransformIRTimestampMapping = DenseMap; +#endif // LLVM_ENABLE_ABI_BREAKING_CHECKS + + /// The bidirectional mappings between transform IR values and payload IR + /// operations, and the mapping between transform IR values and parameters. + struct Mappings { + TransformOpMapping direct; + TransformOpReverseMapping reverse; + ParamMapping params; + ValueMapping values; + ValueMapping reverseValues; + +#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS + TransformIRTimestampMapping timestamps; + void incrementTimestamp(Value value) { ++timestamps[value]; } +#endif // LLVM_ENABLE_ABI_BREAKING_CHECKS + }; + + friend LogicalResult applyTransforms(Operation *, TransformOpInterface, + const RaggedArray &, + const TransformOptions &, bool); + + friend TransformState + detail::makeTransformStateForTesting(Region *region, Operation *payloadRoot); + +public: + const TransformOptions &getOptions() const { return options; } + + /// Returns the op at which the transformation state is rooted. This is + /// typically helpful for transformations that apply globally. + Operation *getTopLevel() const; + + /// Returns the number of extra mappings for the top-level operation. + size_t getNumTopLevelMappings() const { return topLevelMappedValues.size(); } + + /// Returns the position-th extra mapping for the top-level operation. + ArrayRef getTopLevelMapping(size_t position) const { + return topLevelMappedValues[position]; + } + + /// Returns an iterator that enumerates all ops that the given transform IR + /// value corresponds to. Ops may be erased while iterating; erased ops are + /// not enumerated. This function is helpful for transformations that apply to + /// a particular handle. + auto getPayloadOps(Value value) const { + ArrayRef view = getPayloadOpsView(value); + +#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS + // Memorize the current timestamp and make sure that it has not changed + // when incrementing or dereferencing the iterator returned by this + // function. The timestamp is incremented when the "direct" mapping is + // resized; this would invalidate the iterator returned by this function. + int64_t currentTimestamp = getMapping(value).timestamps.lookup(value); +#endif // LLVM_ENABLE_ABI_BREAKING_CHECKS + + // When ops are replaced/erased, they are replaced with nullptr (until + // the data structure is compacted). Do not enumerate these ops. + return llvm::make_filter_range(view, [=](Operation *op) { +#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS + [[maybe_unused]] bool sameTimestamp = + currentTimestamp == this->getMapping(value).timestamps.lookup(value); + assert(sameTimestamp && "iterator was invalidated during iteration"); +#endif // LLVM_ENABLE_ABI_BREAKING_CHECKS + return op != nullptr; + }); + } + + /// Returns the list of parameters that the given transform IR value + /// corresponds to. + ArrayRef getParams(Value value) const; + + /// Returns an iterator that enumerates all payload IR values that the given + /// transform IR value corresponds to. + auto getPayloadValues(Value handleValue) const { + ArrayRef view = getPayloadValuesView(handleValue); + +#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS + // Memorize the current timestamp and make sure that it has not changed + // when incrementing or dereferencing the iterator returned by this + // function. The timestamp is incremented when the "values" mapping is + // resized; this would invalidate the iterator returned by this function. + int64_t currentTimestamp = + getMapping(handleValue).timestamps.lookup(handleValue); + return llvm::make_filter_range(view, [=](Value v) { + [[maybe_unused]] bool sameTimestamp = + currentTimestamp == + this->getMapping(handleValue).timestamps.lookup(handleValue); + assert(sameTimestamp && "iterator was invalidated during iteration"); + return true; + }); +#else + return llvm::make_range(view.begin(), view.end()); +#endif // LLVM_ENABLE_ABI_BREAKING_CHECKS + } + + /// Populates `handles` with all handles pointing to the given Payload IR op. + /// Returns success if such handles exist, failure otherwise. + /// If `includeOutOfScope` is set to "true", handles that are defined in + /// regions beyond the most recent isolated from above region are included. + LogicalResult getHandlesForPayloadOp(Operation *op, + SmallVectorImpl &handles, + bool includeOutOfScope = false) const; + + /// Populates `handles` with all handles pointing to the given payload IR + /// value. Returns success if such handles exist, failure otherwise. + /// If `includeOutOfScope` is set to "true", handles that are defined in + /// regions beyond the most recent isolated from above region are included. + LogicalResult getHandlesForPayloadValue(Value payloadValue, + SmallVectorImpl &handles, + bool includeOutOfScope = false) const; + + /// Applies the transformation specified by the given transform op and updates + /// the state accordingly. + DiagnosedSilenceableFailure applyTransform(TransformOpInterface transform); + + /// Records the mapping between a block argument in the transform IR and a + /// list of operations in the payload IR. The arguments must be defined in + /// blocks of the currently processed transform IR region, typically after a + /// region scope is defined. + /// + /// Returns failure if the payload does not satisfy the conditions associated + /// with the type of the handle value. + LogicalResult mapBlockArguments(BlockArgument argument, + ArrayRef operations) { +#if LLVM_ENABLE_ABI_BREAKING_CHECKS + assert(argument.getParentRegion() == regionStack.back() && + "mapping block arguments from a region other than the active one"); +#endif // LLVM_ENABLE_ABI_BREAKING_CHECKS + return setPayloadOps(argument, operations); + } + LogicalResult mapBlockArgument(BlockArgument argument, + ArrayRef values); + + // Forward declarations to support limited visibility. + class RegionScope; + + /// Creates a new region scope for the given region. The region is expected to + /// be nested in the currently processed region. + // Implementation note: this method is inline but implemented outside of the + // class body to comply with visibility and full-declaration requirements. + inline RegionScope make_region_scope(Region ®ion); + + /// A RAII object maintaining a "stack frame" for a transform IR region. When + /// applying a transform IR operation that contains a region, the caller is + /// expected to create a RegionScope before applying the ops contained in the + /// region. This ensures that the mappings between values defined in the + /// transform IR region and payload IR operations are cleared when the region + /// processing ends; such values cannot be accessed outside the region. + class RegionScope { + public: + /// Forgets the mapping from or to values defined in the associated + /// transform IR region, and restores the mapping that existed before + /// entering this scope. + ~RegionScope(); + + private: + /// Creates a new scope for mappings between values defined in the given + /// transform IR region and payload IR objects. + RegionScope(TransformState &state, Region ®ion) + : state(state), region(®ion) { + auto res = state.mappings.insert( + std::make_pair(®ion, std::make_unique())); + assert(res.second && "the region scope is already present"); + (void)res; +#if LLVM_ENABLE_ABI_BREAKING_CHECKS + state.regionStack.push_back(®ion); +#endif // LLVM_ENABLE_ABI_BREAKING_CHECKS + } + + /// Back-reference to the transform state. + TransformState &state; + + /// The region this scope is associated with. + Region *region; + + friend RegionScope TransformState::make_region_scope(Region &); + }; + friend class RegionScope; + + /// Base class for TransformState extensions that allow TransformState to + /// contain user-specified information in the state object. Clients are + /// expected to derive this class, add the desired fields, and make the + /// derived class compatible with the MLIR TypeID mechanism: + /// + /// ```mlir + /// class MyExtension final : public TransformState::Extension { + /// public: + /// MyExtension(TranfsormState &state, int myData) + /// : Extension(state) {...} + /// private: + /// int mySupplementaryData; + /// }; + /// ``` + /// + /// Instances of this and derived classes are not expected to be created by + /// the user, instead they are directly constructed within a TransformState. A + /// TransformState can only contain one extension with the given TypeID. + /// Extensions can be obtained from a TransformState instance, and can be + /// removed when they are no longer required. + /// + /// ```mlir + /// transformState.addExtension(/*myData=*/42); + /// MyExtension *ext = transformState.getExtension(); + /// ext->doSomething(); + /// ``` + class Extension { + // Allow TransformState to allocate Extensions. + friend class TransformState; + + public: + /// Base virtual destructor. + // Out-of-line definition ensures symbols are emitted in a single object + // file. + virtual ~Extension(); + + protected: + /// Constructs an extension of the given TransformState object. + Extension(TransformState &state) : state(state) {} + + /// Provides read-only access to the parent TransformState object. + const TransformState &getTransformState() const { return state; } + + /// Replaces the given payload op with another op. If the replacement op is + /// null, removes the association of the payload op with its handle. Returns + /// failure if the op is not associated with any handle. + /// + /// Note: This function does not update value handles. None of the original + /// op's results are allowed to be mapped to any value handle. + LogicalResult replacePayloadOp(Operation *op, Operation *replacement); + + /// Replaces the given payload value with another value. If the replacement + /// value is null, removes the association of the payload value with its + /// handle. Returns failure if the value is not associated with any handle. + LogicalResult replacePayloadValue(Value value, Value replacement); + + private: + /// Back-reference to the state that is being extended. + TransformState &state; + }; + + /// Adds a new Extension of the type specified as template parameter, + /// constructing it with the arguments provided. The extension is owned by the + /// TransformState. It is expected that the state does not already have an + /// extension of the same type. Extension constructors are expected to take + /// a reference to TransformState as first argument, automatically supplied + /// by this call. + template + Ty &addExtension(Args &&...args) { + static_assert( + std::is_base_of::value, + "only an class derived from TransformState::Extension is allowed here"); + auto ptr = std::make_unique(*this, std::forward(args)...); + auto result = extensions.try_emplace(TypeID::get(), std::move(ptr)); + assert(result.second && "extension already added"); + return *static_cast(result.first->second.get()); + } + + /// Returns the extension of the specified type. + template + Ty *getExtension() { + static_assert( + std::is_base_of::value, + "only an class derived from TransformState::Extension is allowed here"); + auto iter = extensions.find(TypeID::get()); + if (iter == extensions.end()) + return nullptr; + return static_cast(iter->second.get()); + } + + /// Removes the extension of the specified type. + template + void removeExtension() { + static_assert( + std::is_base_of::value, + "only an class derived from TransformState::Extension is allowed here"); + extensions.erase(TypeID::get()); + } + +private: + /// Identifier for storing top-level value in the `operations` mapping. + static constexpr Value kTopLevelValue = Value(); + + /// Creates a state for transform ops living in the given region. The second + /// argument points to the root operation in the payload IR being transformed, + /// which may or may not contain the region with transform ops. Additional + /// options can be provided through the trailing configuration object. + TransformState(Region *region, Operation *payloadRoot, + const RaggedArray &extraMappings = {}, + const TransformOptions &options = TransformOptions()); + + /// Returns the mappings frame for the region in which the value is defined. + /// If `allowOutOfScope` is set to "false", asserts that the value is in + /// scope, based on the current stack of frames. + const Mappings &getMapping(Value value, bool allowOutOfScope = false) const { + return const_cast(this)->getMapping(value, + allowOutOfScope); + } + Mappings &getMapping(Value value, bool allowOutOfScope = false) { + Region *region = value.getParentRegion(); + auto it = mappings.find(region); + assert(it != mappings.end() && + "trying to find a mapping for a value from an unmapped region"); +#ifndef NDEBUG + if (!allowOutOfScope) { + for (Region *r : llvm::reverse(llvm::make_first_range(mappings))) { + if (r == region) + break; + if (r->getParentOp()->hasTrait()) + llvm_unreachable("trying to get mapping beyond region that is " + "isolated from above"); + } + } +#endif // NDEBUG + return *it->second; + } + + /// Returns the mappings frame for the region in which the operation resides. + /// If `allowOutOfScope` is set to "false", asserts that the operation is in + /// scope, based on the current stack of frames. + const Mappings &getMapping(Operation *operation, + bool allowOutOfScope = false) const { + return const_cast(this)->getMapping(operation, + allowOutOfScope); + } + Mappings &getMapping(Operation *operation, bool allowOutOfScope = false) { + Region *region = operation->getParentRegion(); + auto it = mappings.find(region); + assert(it != mappings.end() && + "trying to find a mapping for an operation from an unmapped region"); +#ifndef NDEBUG + if (!allowOutOfScope) { + for (Region *r : llvm::reverse(llvm::make_first_range(mappings))) { + if (r == region) + break; + if (r->getParentOp()->hasTrait()) + llvm_unreachable("trying to get mapping beyond region that is " + "isolated from above"); + } + } +#endif // NDEBUG + return *it->second; + } + + /// Updates the state to include the associations between op results and the + /// provided result of applying a transform op. + LogicalResult updateStateFromResults(const TransformResults &results, + ResultRange opResults); + + /// Returns a list of all ops that the given transform IR value corresponds + /// to. In case an op was erased, the returned list contains nullptr. This + /// function is helpful for transformations that apply to a particular handle. + ArrayRef getPayloadOpsView(Value value) const; + + /// Returns a list of payload IR values that the given transform IR value + /// corresponds to. + ArrayRef getPayloadValuesView(Value handleValue) const; + + /// Sets the payload IR ops associated with the given transform IR value + /// (handle). A payload op may be associated multiple handles as long as + /// at most one of them gets consumed by further transformations. + /// For example, a hypothetical "find function by name" may be called twice in + /// a row to produce two handles pointing to the same function: + /// + /// %0 = transform.find_func_by_name { name = "myfunc" } + /// %1 = transform.find_func_by_name { name = "myfunc" } + /// + /// which is valid by itself. However, calling a hypothetical "rewrite and + /// rename function" transform on both handles: + /// + /// transform.rewrite_and_rename %0 { new_name = "func" } + /// transform.rewrite_and_rename %1 { new_name = "func" } + /// + /// is invalid given the transformation "consumes" the handle as expressed + /// by side effects. Practically, a transformation consuming a handle means + /// that the associated payload operation may no longer exist. + /// + /// Similarly, operation handles may be invalidate and should not be used + /// after a transform that consumed a value handle pointing to a payload value + /// defined by the operation as either block argument or op result. For + /// example, in the following sequence, the last transform operation rewrites + /// the callee to not return a specified result: + /// + /// %0 = transform.find_call "myfunc" + /// %1 = transform.find_results_of_calling "myfunc" + /// transform.drop_call_result_from_signature %1[0] + /// + /// which requires the call operations to be recreated. Therefore, the handle + /// %0 becomes associated with a dangling pointer and should not be used. + /// + /// Returns failure if the payload does not satisfy the conditions associated + /// with the type of the handle value. The value is expected to have a type + /// implementing TransformHandleTypeInterface. + LogicalResult setPayloadOps(Value value, ArrayRef targets); + + /// Sets the payload IR values association with the given transform IR value + /// (handle). A payload value may be associated with multiple handles as long + /// as at most one of them is consumed by further transformations. For + /// example, a hypothetical "get results of calls to function with the given + /// name" transform may be performed twice in a row producing handles pointing + /// to the same values: + /// + /// %0 = transform.find_results_of_calling "myfunc" + /// %1 = transform.find_results_of_calling "myfunc" + /// + /// which is valid by itself. However, calling a hypothetical "erase value + /// producer" transform on both handles: + /// + /// transform.erase_value_produce %0 + /// transform.erase_value_produce %1 + /// + /// is invalid provided the transformation "consumes" the handle as expressed + /// by side effects (which themselves reflect the semantics of the transform + /// erasing the producer and making the handle dangling). Practically, a + /// transformation consuming a handle means the associated payload value may + /// no longer exist. + /// + /// Similarly, value handles are invalidated and should not be used after a + /// transform that consumed an operation handle pointing to the payload IR + /// operation defining the values associated the value handle, as either block + /// arguments or op results, or any ancestor operation. For example, + /// + /// %0 = transform.find_call "myfunc" + /// %1 = transform.find_results_of_calling "myfunc" + /// transform.rewrite_and_rename %0 { new_name = "func" } + /// + /// makes %1 unusable after the last transformation if it consumes %0. When an + /// operation handle is consumed, it usually indicates that the operation was + /// destroyed or heavily modified, meaning that the values it defines may no + /// longer exist. + /// + /// Returns failure if the payload values do not satisfy the conditions + /// associated with the type of the handle value. The value is expected to + /// have a type implementing TransformValueHandleTypeInterface. + LogicalResult setPayloadValues(Value handle, ValueRange payloadValues); + + /// Sets the parameters associated with the given transform IR value. Returns + /// failure if the parameters do not satisfy the conditions associated with + /// the type of the value. The value is expected to have a type implementing + /// TransformParamTypeInterface. + LogicalResult setParams(Value value, ArrayRef params); + + /// Forgets the payload IR ops associated with the given transform IR value, + /// as well as any association between value handles and the results of said + /// payload IR op. + /// + /// If `allowOutOfScope` is set to "false", asserts that the handle is in + /// scope, based on the current stack of frames. + void forgetMapping(Value opHandle, ValueRange origOpFlatResults, + bool allowOutOfScope = false); + + void forgetValueMapping(Value valueHandle, + ArrayRef payloadOperations); + + /// Replaces the given payload op with another op. If the replacement op is + /// null, removes the association of the payload op with its handle. Returns + /// failure if the op is not associated with any handle. + /// + /// Note: This function does not update value handles. None of the original + /// op's results are allowed to be mapped to any value handle. + LogicalResult replacePayloadOp(Operation *op, Operation *replacement); + + /// Replaces the given payload value with another value. If the replacement + /// value is null, removes the association of the payload value with its + /// handle. Returns failure if the value is not associated with any handle. + LogicalResult replacePayloadValue(Value value, Value replacement); + + /// Records handle invalidation reporters into `newlyInvalidated`. + /// Specifically, + /// - `handle` is the op operand that consumes the handle, + /// - `potentialAncestors` is a list of ancestors of the payload operation + /// that the consumed handle is associated with, including itself, + /// - `throughValue` is the payload value the handle to which is consumed, + /// when it is the case, null when the operation handle is consumed + /// directly. + /// Iterates over all known operation and value handles and records reporters + /// for any potential future use of `handle` or any other handle that is + /// invalidated by its consumption, i.e., any handle pointing to any payload + /// IR entity (operation or value) associated with the same payload IR entity + /// as the consumed handle, or any nested payload IR entity. If + /// `potentialAncestors` is empty, records the reporter anyway. Does not + /// override existing reporters. This must remain a const method so it doesn't + /// inadvertently mutate `invalidatedHandles` too early. + void recordOpHandleInvalidation(OpOperand &consumingHandle, + ArrayRef potentialAncestors, + Value throughValue, + InvalidatedHandleMap &newlyInvalidated) const; + + /// Records handle invalidation reporters into `newlyInvalidated`. + /// Specifically, + /// - `consumingHandle` is the op operand that consumes the handle, + /// - `potentialAncestors` is a list of ancestors of the payload operation + /// that the consumed handle is associated with, including itself, + /// - `payloadOp` is the operation itself, + /// - `otherHandle` is another that may be associated with the affected + /// payload operations + /// - `throughValue` is the payload value the handle to which is consumed, + /// when it is the case, null when the operation handle is consumed + /// directly. + /// Looks at the payload opreations associated with `otherHandle` and if any + /// of these operations has an ancestor (or is itself) listed in + /// `potentialAncestors`, records the error message describing the use of the + /// invalidated handle. Does nothing if `otherHandle` already has a reporter + /// associated with it. This must remain a const method so it doesn't + /// inadvertently mutate `invalidatedHandles` too early. + void recordOpHandleInvalidationOne( + OpOperand &consumingHandle, ArrayRef potentialAncestors, + Operation *payloadOp, Value otherHandle, Value throughValue, + InvalidatedHandleMap &newlyInvalidated) const; + + /// Records handle invalidation reporters into `newlyInvalidated`. + /// Specifically, + /// - `opHandle` is the op operand that consumes the handle; + /// - `potentialAncestors` is a list of ancestors of the payload operation + /// that the consumed handle is associated with, including itself; + /// - `payloadValue` is the value defined by the operation associated with + /// the consuming handle as either op result or block argument; + /// - `valueHandle` is another that may be associated with the payload value. + /// Looks at the payload values associated with `valueHandle` and if any of + /// these values is defined, as op result or block argument, by an operation + /// whose ancestor (or the operation itself) is listed in + /// `potentialAncestors`, records the error message describing the use of the + /// invalidated handle. Does nothing if `valueHandle` already has a reporter + /// associated with it. This must remain a const method so it doesn't + /// inadvertently mutate `invalidatedHandles` too early. + void recordValueHandleInvalidationByOpHandleOne( + OpOperand &opHandle, ArrayRef potentialAncestors, + Value payloadValue, Value valueHandle, + InvalidatedHandleMap &newlyInvalidated) const; + + /// Records handle invalidation reporters into `newlyInvalidated`. + /// Specifically, + /// - `valueHandle` is the op operand that consumes the handle, + /// - `throughValue` is the payload value the handle to which is consumed, + /// when it is the case, null when the operation handle is consumed + /// directly. + /// Iterates over all known operation and value handles and records reporters + /// for any potential future use of `handle` or any other handle that is + /// invalidated by its consumption, i.e., any handle pointing to any payload + /// IR entity (operation or value) associated with the same payload IR entity + /// as the consumed handle, or any nested payload IR entity. Does not override + /// existing reporters. This must remain a const method so it doesn't + /// inadvertently mutate `invalidatedHandles` too early. + void + recordValueHandleInvalidation(OpOperand &valueHandle, + InvalidatedHandleMap &newlyInvalidated) const; + + /// Checks that the operation does not use invalidated handles as operands. + /// Reports errors and returns failure if it does. Otherwise, invalidates the + /// handles consumed by the operation as well as any handles pointing to + /// payload IR operations nested in the operations associated with the + /// consumed handles. + LogicalResult + checkAndRecordHandleInvalidation(TransformOpInterface transform); + + /// Implementation of the checkAndRecordHandleInvalidation. This must remain a + /// const method so it doesn't inadvertently mutate `invalidatedHandles` too + /// early. + LogicalResult checkAndRecordHandleInvalidationImpl( + transform::TransformOpInterface transform, + transform::TransformState::InvalidatedHandleMap &newlyInvalidated) const; + + /// Remove all nullptrs from op handles that were added by `replacePayloadOp`. + void compactOpHandles(); + + /// A stack of mappings between transform IR values and payload IR ops, + /// aggregated by the region in which the transform IR values are defined. + /// We use a pointer to the Mappings struct so that reallocations inside + /// MapVector don't invalidate iterators when we apply nested transform ops + /// while also iterating over the mappings. + llvm::MapVector> mappings; + + /// Op handles may be temporarily mapped to nullptr to avoid invalidating + /// payload op iterators. This set contains all op handles with nullptrs. + /// These handles are "compacted" (i.e., nullptrs removed) at the end of each + /// transform. + DenseSet opHandlesToCompact; + + /// Extensions attached to the TransformState, identified by the TypeID of + /// their type. Only one extension of any given type is allowed. + DenseMap> extensions; + + /// The top-level operation that contains all payload IR, typically a module. + Operation *topLevel; + + /// Extra mapped values (payload operations, values or parameters) to be + /// associated with additional entry block arguments of the top-level + /// transform operation. + RaggedArray topLevelMappedValues; + + /// Additional options controlling the transformation state behavior. + TransformOptions options; + + /// The mapping from invalidated handles to the error-reporting functions that + /// describe when the handles were invalidated. Calling such a function emits + /// a user-visible diagnostic with an additional note pointing to the given + /// location. + InvalidatedHandleMap invalidatedHandles; + +#if LLVM_ENABLE_ABI_BREAKING_CHECKS + /// A stack of nested regions that are being processed in the transform IR. + /// Each region must be an ancestor of the following regions in this list. + /// These are also the keys for "mappings". + SmallVector regionStack; + + /// This cache stores operation names for operations that are tracked in the + /// transform dialect state. It is used to detect missing memory side effects + /// and op tracking. + /// + /// All tracked ops are added to this cache before a transform op is applied. + /// After the application of the transform op, the names of all tracked ops + /// are compared with the names in the cache. If there is a mismatch (or a + /// crash), op tracking is missing somewhere. This is typically a missing + /// "consumesHandle" side effect or a pattern that removes an op without + /// notifying a TrackingListener. + DenseMap cachedNames; +#endif // LLVM_ENABLE_ABI_BREAKING_CHECKS +}; + +/// Local mapping between values defined by a specific op implementing the +/// TransformOpInterface and the payload IR ops they correspond to. +class TransformResults { + friend class TransformState; + +public: + /// Indicates that the result of the transform IR op at the given position + /// corresponds to the given list of payload IR ops. Each result must be set + /// by the transformation exactly once in case of transformation succeeding. + /// The value must have a type implementing TransformHandleTypeInterface. + template + void set(OpResult value, Range &&ops) { + int64_t position = value.getResultNumber(); + assert(position < static_cast(operations.size()) && + "setting results for a non-existent handle"); + assert(operations[position].data() == nullptr && "results already set"); + assert(params[position].data() == nullptr && + "another kind of results already set"); + assert(values[position].data() == nullptr && + "another kind of results already set"); + operations.replace(position, std::forward(ops)); + } + + /// Indicates that the result of the transform IR op at the given position + /// corresponds to the given list of payload IR ops. Each result must be set + /// by the transformation exactly once in case of transformation succeeding. + /// The value must have a type implementing TransformHandleTypeInterface. + void set(OpResult value, std::initializer_list ops) { + set(value, ArrayRef(ops)); + } + + /// Indicates that the result of the transform IR op at the given position + /// corresponds to the given list of parameters. Each result must be set by + /// the transformation exactly once in case of transformation succeeding. The + /// value must have a type implementing TransformParamTypeInterface. + void setParams(OpResult value, ArrayRef params); + + /// Indicates that the result of the transform IR op at the given position + /// corresponds to the given range of payload IR values. Each result must be + /// set by the transformation exactly once in case of transformation + /// succeeding. The value must have a type implementing + /// TransformValueHandleTypeInterface. + template + void setValues(OpResult handle, Range &&values) { + int64_t position = handle.getResultNumber(); + assert(position < static_cast(this->values.size()) && + "setting values for a non-existent handle"); + assert(this->values[position].data() == nullptr && "values already set"); + assert(operations[position].data() == nullptr && + "another kind of results already set"); + assert(params[position].data() == nullptr && + "another kind of results already set"); + this->values.replace(position, std::forward(values)); + } + + /// Indicates that the result of the transform IR op at the given position + /// corresponds to the given range of payload IR values. Each result must be + /// set by the transformation exactly once in case of transformation + /// succeeding. The value must have a type implementing + /// TransformValueHandleTypeInterface. + void setValues(OpResult handle, std::initializer_list values) { + setValues(handle, ArrayRef(values)); + } + + /// Indicates that the result of the transform IR op at the given position + /// corresponds to the given range of mapped values. All mapped values are + /// expected to be compatible with the type of the result, e.g., if the result + /// is an operation handle, all mapped values are expected to be payload + /// operations. + void setMappedValues(OpResult handle, ArrayRef values); + + /// Sets the currently unset results to empty lists of the kind expected by + /// the corresponding results of the given `transform` op. + void setRemainingToEmpty(TransformOpInterface transform); + +private: + /// Creates an instance of TransformResults that expects mappings for + /// `numSegments` values, which may be associated with payload operations or + /// parameters. + explicit TransformResults(unsigned numSegments); + + /// Gets the list of operations associated with the result identified by its + /// number in the list of operation results. The result must have been set to + /// be associated with payload IR operations. + ArrayRef get(unsigned resultNumber) const; + + /// Gets the list of parameters associated with the result identified by its + /// number in the list of operation results. The result must have been set to + /// be associated with parameters. + ArrayRef getParams(unsigned resultNumber) const; + + /// Gets the list of payload IR values associated with the result identified + /// by its number in the list of operation results. The result must have been + /// set to be associated with payload IR values. + ArrayRef getValues(unsigned resultNumber) const; + + /// Returns `true` if the result identified by its number in the list of + /// operation results is associated with a list of parameters, `false` + /// otherwise. + bool isParam(unsigned resultNumber) const; + + /// Returns `true` if the result identified by its number in the list of + /// operation results is associated with a list of payload IR value, `false` + /// otherwise. + bool isValue(unsigned resultNumber) const; + + /// Returns `true` if the result identified by its number in the list of + /// operation results is associated with something. + bool isSet(unsigned resultNumber) const; + + /// Pointers to payload IR ops that are associated with results of a transform + /// IR op. + RaggedArray operations; + + /// Parameters that are associated with results of the transform IR op. + RaggedArray params; + + /// Payload IR values that are associated with results of a transform IR op. + RaggedArray values; +}; + +/// Creates a RAII object the lifetime of which corresponds to the new mapping +/// for transform IR values defined in the given region. Values defined in +/// surrounding regions remain accessible. +TransformState::RegionScope TransformState::make_region_scope(Region ®ion) { + return RegionScope(*this, region); +} + +/// A listener that updates a TransformState based on IR modifications. This +/// listener can be used during a greedy pattern rewrite to keep the transform +/// state up-to-date. +class TrackingListener : public RewriterBase::Listener, + public TransformState::Extension { +public: + /// Create a new TrackingListener for usage in the specified transform op. + TrackingListener(TransformState &state, TransformOpInterface op); + +protected: + /// Return a replacement payload op for the given op, which is going to be + /// replaced with the given values. By default, if all values are defined by + /// the same op, which also has the same type as the given op, that defining + /// op is used as a replacement. + /// + /// A "failure" return value indicates that no replacement operation could be + /// found. A "nullptr" return value indicates that no replacement op is needed + /// (e.g., handle is dead or was consumed) and that the payload op should + /// be dropped from the mapping. + /// + /// Example: A tracked "linalg.generic" with two results is replaced with two + /// values defined by (another) "linalg.generic". It is reasonable to assume + /// that the replacement "linalg.generic" represents the same "computation". + /// Therefore, the payload op mapping is updated to the defining op of the + /// replacement values. + /// + /// Counter Example: A "linalg.generic" is replaced with values defined by an + /// "scf.for". Without further investigation, the relationship between the + /// "linalg.generic" and the "scf.for" is unclear. They may not represent the + /// same computation; e.g., there may be tiled "linalg.generic" inside the + /// loop body that represents the original computation. Therefore, the + /// TrackingListener is conservative by default: it drops the mapping and + /// triggers the "payload replacement not found" notification. + /// + /// If no replacement op could be found according to the rules mentioned + /// above, this function tries to skip over cast-like ops that implement + /// `CastOpInterface`. + /// + /// Example: A tracked "linalg.generic" is replaced with "linalg.generic", + /// wrapped in a "tensor.cast". A cast is a metadata-only operation and it is + /// reasonable to assume that the wrapped "linalg.generic" represents the same + /// computation as the original "linalg.generic". The mapping is updated + /// accordingly. + /// + /// Certain ops (typically also metadata-only ops) are not considered casts, + /// but should be skipped nonetheless. Such ops should implement + /// `FindPayloadReplacementOpInterface` to specify with which operands the + /// lookup should continue. + /// + /// Example: A tracked "linalg.generic" is replaced with "linalg.generic", + /// wrapped in a "tensor.reshape". A reshape is a metadata-only operation but + /// not cast. (Implementing `CastOpInterface` would be incorrect and cause + /// invalid foldings.) However, due to its `FindPayloadReplacementOpInterface` + /// implementation, the replacement op lookup continues with the wrapped + /// "linalg.generic" and the mapping is updated accordingly. + /// + /// Derived classes may override `findReplacementOp` to specify custom + /// replacement rules. + virtual DiagnosedSilenceableFailure + findReplacementOp(Operation *&result, Operation *op, + ValueRange newValues) const; + + /// Notify the listener that the pattern failed to match the given operation, + /// and provide a callback to populate a diagnostic with the reason why the + /// failure occurred. + LogicalResult + notifyMatchFailure(Location loc, + function_ref reasonCallback) override; + + /// This function is called when a tracked payload op is dropped because no + /// replacement op was found. Derived classes can implement this function for + /// custom error handling. + virtual void + notifyPayloadReplacementNotFound(Operation *op, ValueRange values, + DiagnosedSilenceableFailure &&diag) {} + + /// Return the single op that defines all given values (if any). + static Operation *getCommonDefiningOp(ValueRange values); + + /// Return the transform op in which this TrackingListener is used. + TransformOpInterface getTransformOp() const { return transformOp; } + +private: + friend class TransformRewriter; + + void notifyOperationRemoved(Operation *op) override; + + void notifyOperationReplaced(Operation *op, ValueRange newValues) override; + using Listener::notifyOperationReplaced; + + /// The transform op in which this TrackingListener is used. + TransformOpInterface transformOp; + + /// The handles that are consumed by the transform op. + DenseSet consumedHandles; +}; + +/// A specialized listener that keeps track of cases in which no replacement +/// payload could be found. The error state of this listener must be checked +/// before the end of its lifetime. +class ErrorCheckingTrackingListener : public TrackingListener { +public: + using transform::TrackingListener::TrackingListener; + + ~ErrorCheckingTrackingListener() override; + + /// Check and return the current error state of this listener. Afterwards, + /// resets the error state to "success". + DiagnosedSilenceableFailure checkAndResetError(); + + /// Return "true" if this tracking listener had a failure. + bool failed() const; + +protected: + void + notifyPayloadReplacementNotFound(Operation *op, ValueRange values, + DiagnosedSilenceableFailure &&diag) override; + +private: + /// The error state of this listener. "Success" indicates that no error + /// happened so far. + DiagnosedSilenceableFailure status = DiagnosedSilenceableFailure::success(); + + /// The number of errors that have been encountered. + int64_t errorCounter = 0; +}; + +/// This is a special rewriter to be used in transform op implementations, +/// providing additional helper functions to update the transform state, etc. +// TODO: Helper functions will be added in a subsequent change. +class TransformRewriter : public RewriterBase { +protected: + friend class TransformState; + + /// Create a new TransformRewriter. + explicit TransformRewriter(MLIRContext *ctx, + ErrorCheckingTrackingListener *listener); + +public: + /// Return "true" if the tracking listener had failures. + bool hasTrackingFailures() const; + + /// Silence all tracking failures that have been encountered so far. + void silenceTrackingFailure(); + + /// Notify the transform dialect interpreter that the given op has been + /// replaced with another op and that the mapping between handles and payload + /// ops/values should be updated. This function should be called before the + /// original op is erased. It fails if the operation could not be replaced, + /// e.g., because the original operation is not tracked. + /// + /// Note: As long as IR modifications are performed through this rewriter, + /// the transform state is usually updated automatically. This function should + /// be used when unsupported rewriter API is used; e.g., updating all uses of + /// a tracked operation one-by-one instead of using `RewriterBase::replaceOp`. + LogicalResult notifyPayloadOperationReplaced(Operation *op, + Operation *replacement); + +private: + ErrorCheckingTrackingListener *const listener; +}; + +/// This trait is supposed to be attached to Transform dialect operations that +/// can be standalone top-level transforms. Such operations typically contain +/// other Transform dialect operations that can be executed following some +/// control flow logic specific to the current operation. The operations with +/// this trait are expected to have at least one single-block region with at +/// least one argument of type implementing TransformHandleTypeInterface. The +/// operations are also expected to be valid without operands, in which case +/// they are considered top-level, and with one or more arguments, in which case +/// they are considered nested. Top-level operations have the block argument of +/// the entry block in the Transform IR correspond to the root operation of +/// Payload IR. Nested operations have the block argument of the entry block in +/// the Transform IR correspond to a list of Payload IR operations mapped to the +/// first operand of the Transform IR operation. The operation must implement +/// TransformOpInterface. +template +class PossibleTopLevelTransformOpTrait + : public OpTrait::TraitBase { +public: + /// Verifies that `op` satisfies the invariants of this trait. Not expected to + /// be called directly. + static LogicalResult verifyTrait(Operation *op) { + return detail::verifyPossibleTopLevelTransformOpTrait(op); + } + + /// Returns the single block of the given region. + Block *getBodyBlock(unsigned region = 0) { + return &this->getOperation()->getRegion(region).front(); + } + + /// Populates `effects` with side effects implied by this trait. + void getPotentialTopLevelEffects( + SmallVectorImpl &effects) { + detail::getPotentialTopLevelEffects( + this->getOperation(), cast(this->getOperation()).getRoot(), + *getBodyBlock(), effects); + } + + /// Sets up the mapping between the entry block of the given region of this op + /// and the relevant list of Payload IR operations in the given state. The + /// state is expected to be already scoped at the region of this operation. + LogicalResult mapBlockArguments(TransformState &state, Region ®ion) { + assert(region.getParentOp() == this->getOperation() && + "op comes from the wrong region"); + return detail::mapPossibleTopLevelTransformOpBlockArguments( + state, this->getOperation(), region); + } + LogicalResult mapBlockArguments(TransformState &state) { + assert( + this->getOperation()->getNumRegions() == 1 && + "must indicate the region to map if the operation has more than one"); + return mapBlockArguments(state, this->getOperation()->getRegion(0)); + } +}; + +class ApplyToEachResultList; + +/// Trait implementing the TransformOpInterface for operations applying a +/// transformation to a single operation handle and producing an arbitrary +/// number of handles and parameter values. +/// The op must implement a method with the following signature: +/// - DiagnosedSilenceableFailure applyToOne(OpTy, +/// ApplyToEachResultList &results, TransformState &state) +/// to perform a transformation that is applied in turn to all payload IR +/// operations that correspond to the handle of the transform IR operation. +/// In `applyToOne`, OpTy is either Operation* or a concrete payload IR Op class +/// that the transformation is applied to (and NOT the class of the transform IR +/// op). +/// The `applyToOne` method takes an empty `results` vector that it fills with +/// zero, one or multiple operations depending on the number of results expected +/// by the transform op. +/// The number of results must match the number of results of the transform op. +/// `applyToOne` is allowed to fill the `results` with all null elements to +/// signify that the transformation did not apply to the payload IR operations. +/// Such null elements are filtered out from results before return. +/// +/// The transform op having this trait is expected to have a single operand. +template +class TransformEachOpTrait + : public OpTrait::TraitBase { +public: + /// Calls `applyToOne` for every payload operation associated with the operand + /// of this transform IR op, the following case disjunction happens: + /// 1. If not target payload ops are associated to the operand then fill the + /// results vector with the expected number of null elements and return + /// success. This is the corner case handling that allows propagating + /// the "no-op" case gracefully to improve usability. + /// 2. If any `applyToOne` returns definiteFailure, the transformation is + /// immediately considered definitely failed and we return. + /// 3. All applications of `applyToOne` are checked to return a number of + /// results expected by the transform IR op. If not, this is a definite + /// failure and we return early. + /// 4. If `applyToOne` produces ops, associate them with the result of this + /// transform op. + /// 5. If any `applyToOne` return silenceableFailure, the transformation is + /// considered silenceable. + /// 6. Otherwise the transformation is considered successful. + DiagnosedSilenceableFailure apply(transform::TransformRewriter &rewriter, + TransformResults &transformResults, + TransformState &state); + + /// Checks that the op matches the expectations of this trait. + static LogicalResult verifyTrait(Operation *op); +}; + +/// Side effect resource corresponding to the mapping between Transform IR +/// values and Payload IR operations. An Allocate effect from this resource +/// means creating a new mapping entry, it is always accompanied by a Write +/// effect. A Read effect from this resource means accessing the mapping. A Free +/// effect on this resource indicates the removal of the mapping entry, +/// typically after a transformation that modifies the Payload IR operations +/// associated with one of the Transform IR operation's operands. It is always +/// accompanied by a Read effect. Read-after-Free and double-Free are not +/// allowed (they would be problematic with "regular" memory effects too) as +/// they indicate an attempt to access Payload IR operations that have been +/// modified, potentially erased, by the previous transformations. +// TODO: consider custom effects if these are not enabling generic passes such +// as CSE/DCE to work. +struct TransformMappingResource + : public SideEffects::Resource::Base { + StringRef getName() override { return "transform.mapping"; } +}; + +/// Side effect resource corresponding to the Payload IR itself. Only Read and +/// Write effects are expected on this resource, with Write always accompanied +/// by a Read (short of fully replacing the top-level Payload IR operation, one +/// cannot modify the Payload IR without reading it first). This is intended +/// to disallow reordering of Transform IR operations that mutate the Payload IR +/// while still allowing the reordering of those that only access it. +struct PayloadIRResource + : public SideEffects::Resource::Base { + StringRef getName() override { return "transform.payload_ir"; } +}; + +/// Populates `effects` with the memory effects indicating the operation on the +/// given handle value: +/// - consumes = Read + Free, +/// - produces = Allocate + Write, +/// - onlyReads = Read. +void consumesHandle(ValueRange handles, + SmallVectorImpl &effects); +void producesHandle(ValueRange handles, + SmallVectorImpl &effects); +void onlyReadsHandle(ValueRange handles, + SmallVectorImpl &effects); + +/// Checks whether the transform op consumes the given handle. +bool isHandleConsumed(Value handle, transform::TransformOpInterface transform); + +/// Populates `effects` with the memory effects indicating the access to payload +/// IR resource. +void modifiesPayload(SmallVectorImpl &effects); +void onlyReadsPayload(SmallVectorImpl &effects); + +/// Checks whether the transform op modifies the payload. +bool doesModifyPayload(transform::TransformOpInterface transform); +/// Checks whether the transform op reads the payload. +bool doesReadPayload(transform::TransformOpInterface transform); + +/// Populates `consumedArguments` with positions of `block` arguments that are +/// consumed by the operations in the `block`. +void getConsumedBlockArguments( + Block &block, llvm::SmallDenseSet &consumedArguments); + +/// Trait implementing the MemoryEffectOpInterface for operations that "consume" +/// their operands and produce new results. +template +class FunctionalStyleTransformOpTrait + : public OpTrait::TraitBase { +public: + /// This op "consumes" the operands by reading and freeing then, "produces" + /// the results by allocating and writing it and reads/writes the payload IR + /// in the process. + void getEffects(SmallVectorImpl &effects) { + consumesHandle(this->getOperation()->getOperands(), effects); + producesHandle(this->getOperation()->getResults(), effects); + modifiesPayload(effects); + } + + /// Checks that the op matches the expectations of this trait. + static LogicalResult verifyTrait(Operation *op) { + if (!op->getName().getInterface()) { + op->emitError() + << "FunctionalStyleTransformOpTrait should only be attached to ops " + "that implement MemoryEffectOpInterface"; + } + return success(); + } +}; + +/// Trait implementing the MemoryEffectOpInterface for single-operand +/// single-result operations that use their operand without consuming and +/// without modifying the Payload IR to produce a new handle. +template +class NavigationTransformOpTrait + : public OpTrait::TraitBase { +public: + /// This op produces handles to the Payload IR without consuming the original + /// handles and without modifying the IR itself. + void getEffects(SmallVectorImpl &effects) { + onlyReadsHandle(this->getOperation()->getOperands(), effects); + producesHandle(this->getOperation()->getResults(), effects); + onlyReadsPayload(effects); + } + + /// Checks that the op matches the expectation of this trait. + static LogicalResult verifyTrait(Operation *op) { + static_assert(OpTy::template hasTrait(), + "expected single-operand op"); + static_assert(OpTy::template hasTrait(), + "expected single-result op"); + if (!op->getName().getInterface()) { + op->emitError() << "NavigationTransformOpTrait should only be attached " + "to ops that implement MemoryEffectOpInterface"; + } + return success(); + } +}; + +namespace detail { +/// Non-template implementation of ParamProducerTransformOpTrait::getEffects(). +void getParamProducerTransformOpTraitEffects( + Operation *op, SmallVectorImpl &effects); +/// Non-template implementation of ParamProducerTransformOpTrait::verify(). +LogicalResult verifyParamProducerTransformOpTrait(Operation *op); +} // namespace detail + +/// Trait implementing the MemoryEffectsOpInterface for operations that produce +/// transform dialect parameters. It marks all op results of +/// TransformHandleTypeInterface as produced by the op, all operands as only +/// read by the op and, if at least one of the operand is a handle to payload +/// ops, the entire payload as potentially read. The op must only produce +/// parameter-typed results. +template +class ParamProducerTransformOpTrait + : public OpTrait::TraitBase { +public: + /// Populates `effects` with effect instances described in the trait + /// documentation. + void getEffects(SmallVectorImpl &effects) { + detail::getParamProducerTransformOpTraitEffects(this->getOperation(), + effects); + } + + /// Checks that the op matches the expectation of this trait, i.e., that it + /// implements the MemoryEffectsOpInterface and only produces parameter-typed + /// results. + static LogicalResult verifyTrait(Operation *op) { + return detail::verifyParamProducerTransformOpTrait(op); + } +}; + +/// `TrackingListener` failures are reported only for ops that have this trait. +/// The purpose of this trait is to give users more time to update their custom +/// transform ops to use the provided `TransformRewriter` for all IR +/// modifications. This trait will eventually be removed, and failures will be +/// reported for all transform ops. +template +class ReportTrackingListenerFailuresOpTrait + : public OpTrait::TraitBase {}; + +/// A single result of applying a transform op with `ApplyEachOpTrait` to a +/// single payload operation. +using ApplyToEachResult = MappedValue; + +/// A list of results of applying a transform op with `ApplyEachOpTrait` to a +/// single payload operation, co-indexed with the results of the transform op. +class ApplyToEachResultList { +public: + ApplyToEachResultList() = default; + explicit ApplyToEachResultList(unsigned size) : results(size) {} + + /// Sets the list of results to `size` null pointers. + void assign(unsigned size, std::nullptr_t) { results.assign(size, nullptr); } + + /// Sets the list of results to the given range of values. + template + void assign(Range &&range) { + // This is roughly the implementation of SmallVectorImpl::assign. + // Dispatching to it with map_range and template type inference would result + // in more complex code here. + results.clear(); + results.reserve(llvm::size(range)); + for (auto element : range) { + if constexpr (std::is_convertible_v) { + results.push_back(static_cast(element)); + } else if constexpr (std::is_convertible_v) { + results.push_back(element.template get()); + } else { + results.push_back(static_cast(element)); + } + } + } + + /// Appends an element to the list. + // Using ApplyToEachResult that can be implicitly constructed from a Value but + // not from a concrete Op that is implicitly convertible to a Value to avoid + // ambiguity. + void push_back(Operation *op) { results.push_back(op); } + void push_back(Attribute attr) { results.push_back(attr); } + void push_back(ApplyToEachResult r) { results.push_back(r); } + + /// Reserves space for `size` elements in the list. + void reserve(unsigned size) { results.reserve(size); } + + /// Iterators over the list. + auto begin() { return results.begin(); } + auto end() { return results.end(); } + auto begin() const { return results.begin(); } + auto end() const { return results.end(); } + + /// Returns the number of elements in the list. + size_t size() const { return results.size(); } + + /// Element access. Expects the index to be in bounds. + ApplyToEachResult &operator[](size_t index) { return results[index]; } + const ApplyToEachResult &operator[](size_t index) const { + return results[index]; + } + +private: + /// Underlying storage. + SmallVector results; +}; + +namespace detail { + +/// Check that the contents of `partialResult` matches the number, kind (payload +/// op or parameter) and nullity (either all or none) requirements of +/// `transformOp`. Report errors and return failure otherwise. +LogicalResult checkApplyToOne(Operation *transformOp, Location payloadOpLoc, + const ApplyToEachResultList &partialResult); + +/// "Transpose" the results produced by individual applications, arranging them +/// per result value of the transform op, and populate `transformResults` with +/// that. The number, kind and nullity of per-application results are assumed to +/// have been verified. +void setApplyToOneResults(Operation *transformOp, + TransformResults &transformResults, + ArrayRef results); + +/// Applies a one-to-one or a one-to-many transform to each of the given +/// targets. Puts the results of transforms, if any, in `results` in the same +/// order. Fails if any of the application fails. Individual transforms must be +/// callable with the following signature: +/// - DiagnosedSilenceableFailure(OpTy, +/// SmallVector &results, state) +/// where OpTy is either +/// - Operation *, in which case the transform is always applied; +/// - a concrete Op class, in which case a check is performed whether +/// `targets` contains operations of the same class and a silenceable failure +/// is reported if it does not. +template +DiagnosedSilenceableFailure applyTransformToEach( + TransformOpTy transformOp, TransformRewriter &rewriter, Range &&targets, + SmallVectorImpl &results, TransformState &state) { + using OpTy = typename llvm::function_traits< + decltype(&TransformOpTy::applyToOne)>::template arg_t<1>; + static_assert(std::is_convertible::value, + "expected transform function to take an operation"); + OpBuilder::InsertionGuard g(rewriter); + + SmallVector silenceableStack; + unsigned expectedNumResults = transformOp->getNumResults(); + for (Operation *target : targets) { + auto specificOp = dyn_cast(target); + if (!specificOp) { + Diagnostic diag(transformOp->getLoc(), DiagnosticSeverity::Error); + diag << "transform applied to the wrong op kind"; + diag.attachNote(target->getLoc()) << "when applied to this op"; + silenceableStack.push_back(std::move(diag)); + continue; + } + + ApplyToEachResultList partialResults; + partialResults.reserve(expectedNumResults); + Location specificOpLoc = specificOp->getLoc(); + rewriter.setInsertionPoint(specificOp); + DiagnosedSilenceableFailure res = + transformOp.applyToOne(rewriter, specificOp, partialResults, state); + if (res.isDefiniteFailure()) + return DiagnosedSilenceableFailure::definiteFailure(); + + if (res.isSilenceableFailure()) { + res.takeDiagnostics(silenceableStack); + continue; + } + + if (failed(detail::checkApplyToOne(transformOp, specificOpLoc, + partialResults))) { + return DiagnosedSilenceableFailure::definiteFailure(); + } + results.push_back(std::move(partialResults)); + } + if (!silenceableStack.empty()) { + return DiagnosedSilenceableFailure::silenceableFailure( + std::move(silenceableStack)); + } + return DiagnosedSilenceableFailure::success(); +} + +/// Reports an error and returns failure if `targets` contains an ancestor +/// operation before its descendant (or a copy of itself). Implementation detail +/// for expensive checks during `TransformEachOpTrait::apply`. +LogicalResult checkNestedConsumption(Location loc, + ArrayRef targets); + +} // namespace detail +} // namespace transform +} // namespace mlir + +template +mlir::DiagnosedSilenceableFailure +mlir::transform::TransformEachOpTrait::apply( + TransformRewriter &rewriter, TransformResults &transformResults, + TransformState &state) { + Value handle = this->getOperation()->getOperand(0); + auto targets = state.getPayloadOps(handle); + + // If the operand is consumed, check if it is associated with operations that + // may be erased before their nested operations are. + if (state.getOptions().getExpensiveChecksEnabled() && + isHandleConsumed(handle, cast( + this->getOperation())) && + failed(detail::checkNestedConsumption(this->getOperation()->getLoc(), + llvm::to_vector(targets)))) { + return DiagnosedSilenceableFailure::definiteFailure(); + } + + // Step 1. Handle the corner case where no target is specified. + // This is typically the case when the matcher fails to apply and we need to + // propagate gracefully. + // In this case, we fill all results with an empty vector. + if (std::empty(targets)) { + SmallVector emptyPayload; + SmallVector emptyParams; + for (OpResult r : this->getOperation()->getResults()) { + if (isa(r.getType())) + transformResults.setParams(r, emptyParams); + else if (isa(r.getType())) + transformResults.setValues(r, ValueRange()); + else + transformResults.set(r, emptyPayload); + } + return DiagnosedSilenceableFailure::success(); + } + + // Step 2. Call applyToOne on each target and record newly produced ops in its + // corresponding results entry. + SmallVector results; + DiagnosedSilenceableFailure result = detail::applyTransformToEach( + cast(this->getOperation()), rewriter, targets, results, state); + + // Step 3. Propagate the definite failure if any and bail out. + if (result.isDefiniteFailure()) + return result; + + // Step 4. "Transpose" the results produced by individual applications, + // arranging them per result value of the transform op. The number, kind and + // nullity of per-application results have been verified by the callback + // above. + detail::setApplyToOneResults(this->getOperation(), transformResults, results); + + // Step 5. ApplyToOne may have returned silenceableFailure, propagate it. + return result; +} + +template +mlir::LogicalResult +mlir::transform::TransformEachOpTrait::verifyTrait(Operation *op) { + static_assert(OpTy::template hasTrait(), + "expected single-operand op"); + if (!op->getName().getInterface()) { + return op->emitError() << "TransformEachOpTrait should only be attached to " + "ops that implement TransformOpInterface"; + } + + return success(); +} + +#endif // DIALECT_TRANSFORM_IR_TRANSFORMINTERFACES_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformInterfaces.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformInterfaces.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..691d29dd23c34183be5475913ee7a5807f210dcd --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformInterfaces.h.inc @@ -0,0 +1,569 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Interface Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace transform { +class TransformOpInterface; +namespace detail { +struct TransformOpInterfaceInterfaceTraits { + struct Concept { + /// The methods defined by the interface. + ::mlir::DiagnosedSilenceableFailure (*apply)(const Concept *impl, ::mlir::Operation *, ::mlir::transform::TransformRewriter &, ::mlir::transform::TransformResults &, ::mlir::transform::TransformState &); + bool (*allowsRepeatedHandleOperands)(const Concept *impl, ::mlir::Operation *); + }; + template + class Model : public Concept { + public: + using Interface = ::mlir::transform::TransformOpInterface; + Model() : Concept{apply, allowsRepeatedHandleOperands} {} + + static inline ::mlir::DiagnosedSilenceableFailure apply(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ::mlir::transform::TransformRewriter & rewriter, ::mlir::transform::TransformResults & transformResults, ::mlir::transform::TransformState & state); + static inline bool allowsRepeatedHandleOperands(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); + }; + template + class FallbackModel : public Concept { + public: + using Interface = ::mlir::transform::TransformOpInterface; + FallbackModel() : Concept{apply, allowsRepeatedHandleOperands} {} + + static inline ::mlir::DiagnosedSilenceableFailure apply(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ::mlir::transform::TransformRewriter & rewriter, ::mlir::transform::TransformResults & transformResults, ::mlir::transform::TransformState & state); + static inline bool allowsRepeatedHandleOperands(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); + }; + template + class ExternalModel : public FallbackModel { + public: + using ConcreteEntity = ConcreteOp; + bool allowsRepeatedHandleOperands(::mlir::Operation *tablegen_opaque_val) const; + }; +};template +struct TransformOpInterfaceTrait; + +} // namespace detail +class TransformOpInterface : public ::mlir::OpInterface { +public: + using ::mlir::OpInterface::OpInterface; + template + struct Trait : public detail::TransformOpInterfaceTrait {}; + /// Applies the transformation represented by the current operation. This + /// accepts as arguments the object that must be populated with results of + /// the current transformation and a transformation state object that can be + /// used for queries, e.g., to obtain the list of operations on which the + /// transformation represented by the current op is targeted. Returns a + /// special status object indicating whether the transformation succeeded + /// or failed, and, if it failed, whether the failure is recoverable or not. + /// + /// IR must be created, modified and deleted with the provided rewriter. + /// implementations are responsible for setting the insertion point of the + /// rewriter to the desired location. + ::mlir::DiagnosedSilenceableFailure apply(::mlir::transform::TransformRewriter & rewriter, ::mlir::transform::TransformResults & transformResults, ::mlir::transform::TransformState & state); + /// Indicates whether the op instance allows its handle operands to be + /// associated with the same payload operations. + bool allowsRepeatedHandleOperands(); + + /// Creates the silenceable failure object with a diagnostic located at the + /// current operation. Silenceable failure must be suppressed or reported + /// explicitly at some later time. + DiagnosedSilenceableFailure + emitSilenceableError(const ::llvm::Twine &message = {}) { + return ::mlir::emitSilenceableFailure((*this), message); + } + + /// Creates the definite failure object with a diagnostic located at the + /// current operation. Definite failure will be reported when the object + /// is destroyed or converted. + DiagnosedDefiniteFailure + emitDefiniteFailure(const ::llvm::Twine &message = {}) { + return ::mlir::emitDefiniteFailure((*this), message); + } + + /// Emits a generic definite failure for the current transform operation + /// targeting the given Payload IR operation and returns failure. Should + /// be only used as a last resort when the transformation itself provides + /// no further indication as to the reason of the failure. + DiagnosedDefiniteFailure emitDefaultDefiniteFailure( + ::mlir::Operation *target) { + auto diag = ::mlir::emitDefiniteFailure((*this), "failed to apply"); + diag.attachNote(target->getLoc()) << "attempted to apply to this op"; + return diag; + } + + /// Creates the default silenceable failure for a transform op that failed + /// to properly apply to a target. + DiagnosedSilenceableFailure emitDefaultSilenceableFailure( + Operation *target) { + DiagnosedSilenceableFailure diag = emitSilenceableFailure((*this)->getLoc()); + diag << (*this)->getName() << " failed to apply"; + diag.attachNote(target->getLoc()) << "when applied to this op"; + return diag; + } + + /// Returns all operands that are handles and being consumed by this op. + ::llvm::SmallVector getConsumedHandleOpOperands() { + return ::mlir::transform::detail::getConsumedHandleOpOperands((*this)); + } +}; +namespace detail { + template + struct TransformOpInterfaceTrait : public ::mlir::OpInterface::Trait { + /// Indicates whether the op instance allows its handle operands to be + /// associated with the same payload operations. + bool allowsRepeatedHandleOperands() { + return false; + } + static ::mlir::LogicalResult verifyTrait(::mlir::Operation *op) { + return ::mlir::transform::detail::verifyTransformOpInterface(op); + } + + /// Creates the silenceable failure object with a diagnostic located at the + /// current operation. Silenceable failure must be suppressed or reported + /// explicitly at some later time. + DiagnosedSilenceableFailure + emitSilenceableError(const ::llvm::Twine &message = {}) { + return ::mlir::emitSilenceableFailure((*static_cast(this)), message); + } + + /// Creates the definite failure object with a diagnostic located at the + /// current operation. Definite failure will be reported when the object + /// is destroyed or converted. + DiagnosedDefiniteFailure + emitDefiniteFailure(const ::llvm::Twine &message = {}) { + return ::mlir::emitDefiniteFailure((*static_cast(this)), message); + } + + /// Emits a generic definite failure for the current transform operation + /// targeting the given Payload IR operation and returns failure. Should + /// be only used as a last resort when the transformation itself provides + /// no further indication as to the reason of the failure. + DiagnosedDefiniteFailure emitDefaultDefiniteFailure( + ::mlir::Operation *target) { + auto diag = ::mlir::emitDefiniteFailure((*static_cast(this)), "failed to apply"); + diag.attachNote(target->getLoc()) << "attempted to apply to this op"; + return diag; + } + + /// Creates the default silenceable failure for a transform op that failed + /// to properly apply to a target. + DiagnosedSilenceableFailure emitDefaultSilenceableFailure( + Operation *target) { + DiagnosedSilenceableFailure diag = emitSilenceableFailure((*static_cast(this))->getLoc()); + diag << (*static_cast(this))->getName() << " failed to apply"; + diag.attachNote(target->getLoc()) << "when applied to this op"; + return diag; + } + + /// Returns all operands that are handles and being consumed by this op. + ::llvm::SmallVector getConsumedHandleOpOperands() { + return ::mlir::transform::detail::getConsumedHandleOpOperands((*static_cast(this))); + } + + }; +}// namespace detail +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class FindPayloadReplacementOpInterface; +namespace detail { +struct FindPayloadReplacementOpInterfaceInterfaceTraits { + struct Concept { + /// The methods defined by the interface. + ::llvm::SmallVector<::mlir::Value> (*getNextOperands)(const Concept *impl, ::mlir::Operation *); + }; + template + class Model : public Concept { + public: + using Interface = ::mlir::transform::FindPayloadReplacementOpInterface; + Model() : Concept{getNextOperands} {} + + static inline ::llvm::SmallVector<::mlir::Value> getNextOperands(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); + }; + template + class FallbackModel : public Concept { + public: + using Interface = ::mlir::transform::FindPayloadReplacementOpInterface; + FallbackModel() : Concept{getNextOperands} {} + + static inline ::llvm::SmallVector<::mlir::Value> getNextOperands(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); + }; + template + class ExternalModel : public FallbackModel { + public: + using ConcreteEntity = ConcreteOp; + }; +};template +struct FindPayloadReplacementOpInterfaceTrait; + +} // namespace detail +class FindPayloadReplacementOpInterface : public ::mlir::OpInterface { +public: + using ::mlir::OpInterface::OpInterface; + template + struct Trait : public detail::FindPayloadReplacementOpInterfaceTrait {}; + /// Return the operands at which the lookup for replacement payload ops + /// should continue. + ::llvm::SmallVector<::mlir::Value> getNextOperands(); +}; +namespace detail { + template + struct FindPayloadReplacementOpInterfaceTrait : public ::mlir::OpInterface::Trait { + }; +}// namespace detail +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class PatternDescriptorOpInterface; +namespace detail { +struct PatternDescriptorOpInterfaceInterfaceTraits { + struct Concept { + /// The methods defined by the interface. + void (*populatePatterns)(const Concept *impl, ::mlir::Operation *, ::mlir::RewritePatternSet &); + void (*populatePatternsWithState)(const Concept *impl, ::mlir::Operation *, ::mlir::RewritePatternSet &, ::mlir::transform::TransformState &); + }; + template + class Model : public Concept { + public: + using Interface = ::mlir::transform::PatternDescriptorOpInterface; + Model() : Concept{populatePatterns, populatePatternsWithState} {} + + static inline void populatePatterns(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ::mlir::RewritePatternSet & patterns); + static inline void populatePatternsWithState(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ::mlir::RewritePatternSet & patterns, ::mlir::transform::TransformState & state); + }; + template + class FallbackModel : public Concept { + public: + using Interface = ::mlir::transform::PatternDescriptorOpInterface; + FallbackModel() : Concept{populatePatterns, populatePatternsWithState} {} + + static inline void populatePatterns(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ::mlir::RewritePatternSet & patterns); + static inline void populatePatternsWithState(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ::mlir::RewritePatternSet & patterns, ::mlir::transform::TransformState & state); + }; + template + class ExternalModel : public FallbackModel { + public: + using ConcreteEntity = ConcreteOp; + void populatePatternsWithState(::mlir::Operation *tablegen_opaque_val, ::mlir::RewritePatternSet &patterns, ::mlir::transform::TransformState &state) const; + }; +};template +struct PatternDescriptorOpInterfaceTrait; + +} // namespace detail +class PatternDescriptorOpInterface : public ::mlir::OpInterface { +public: + using ::mlir::OpInterface::OpInterface; + template + struct Trait : public detail::PatternDescriptorOpInterfaceTrait {}; + /// Populate rewrite patterns into the given pattern set. + void populatePatterns(::mlir::RewritePatternSet & patterns); + /// Populate rewrite patterns into the given pattern set taking into account + /// the transform state. + void populatePatternsWithState(::mlir::RewritePatternSet & patterns, ::mlir::transform::TransformState & state); +}; +namespace detail { + template + struct PatternDescriptorOpInterfaceTrait : public ::mlir::OpInterface::Trait { + /// Populate rewrite patterns into the given pattern set taking into account + /// the transform state. + void populatePatternsWithState(::mlir::RewritePatternSet & patterns, ::mlir::transform::TransformState & state) { + (*static_cast(this)).populatePatterns(patterns); + } + }; +}// namespace detail +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class TypeConverterBuilderOpInterface; +namespace detail { +struct TypeConverterBuilderOpInterfaceInterfaceTraits { + struct Concept { + /// The methods defined by the interface. + std::unique_ptr<::mlir::TypeConverter> (*getTypeConverter)(const Concept *impl, ::mlir::Operation *); + StringRef (*getTypeConverterType)(); + }; + template + class Model : public Concept { + public: + using Interface = ::mlir::transform::TypeConverterBuilderOpInterface; + Model() : Concept{getTypeConverter, getTypeConverterType} {} + + static inline std::unique_ptr<::mlir::TypeConverter> getTypeConverter(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); + static inline StringRef getTypeConverterType(); + }; + template + class FallbackModel : public Concept { + public: + using Interface = ::mlir::transform::TypeConverterBuilderOpInterface; + FallbackModel() : Concept{getTypeConverter, getTypeConverterType} {} + + static inline std::unique_ptr<::mlir::TypeConverter> getTypeConverter(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); + static inline StringRef getTypeConverterType(); + }; + template + class ExternalModel : public FallbackModel { + public: + using ConcreteEntity = ConcreteOp; + static StringRef getTypeConverterType(); + }; +};template +struct TypeConverterBuilderOpInterfaceTrait; + +} // namespace detail +class TypeConverterBuilderOpInterface : public ::mlir::OpInterface { +public: + using ::mlir::OpInterface::OpInterface; + template + struct Trait : public detail::TypeConverterBuilderOpInterfaceTrait {}; + /// Return the type converter to be used with a dialect conversion. + std::unique_ptr<::mlir::TypeConverter> getTypeConverter(); + /// Return the type of type converter that this `getTypeConverter` returns. + /// This function is used for op verification. + StringRef getTypeConverterType(); +}; +namespace detail { + template + struct TypeConverterBuilderOpInterfaceTrait : public ::mlir::OpInterface::Trait { + /// Return the type of type converter that this `getTypeConverter` returns. + /// This function is used for op verification. + static StringRef getTypeConverterType() { + return "TypeConverter"; + } + }; +}// namespace detail +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class ConversionPatternDescriptorOpInterface; +namespace detail { +struct ConversionPatternDescriptorOpInterfaceInterfaceTraits { + struct Concept { + /// The methods defined by the interface. + void (*populatePatterns)(const Concept *impl, ::mlir::Operation *, ::mlir::TypeConverter &, ::mlir::RewritePatternSet &); + void (*populateConversionTargetRules)(const Concept *impl, ::mlir::Operation *, const ::mlir::TypeConverter &, ::mlir::ConversionTarget &); + std::unique_ptr<::mlir::TypeConverter> (*getTypeConverter)(const Concept *impl, ::mlir::Operation *); + ::mlir::LogicalResult (*verifyTypeConverter)(const Concept *impl, ::mlir::Operation *, TypeConverterBuilderOpInterface); + }; + template + class Model : public Concept { + public: + using Interface = ::mlir::transform::ConversionPatternDescriptorOpInterface; + Model() : Concept{populatePatterns, populateConversionTargetRules, getTypeConverter, verifyTypeConverter} {} + + static inline void populatePatterns(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ::mlir::TypeConverter & typeConverter, ::mlir::RewritePatternSet & patterns); + static inline void populateConversionTargetRules(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, const ::mlir::TypeConverter & typeConverter, ::mlir::ConversionTarget & conversionTarget); + static inline std::unique_ptr<::mlir::TypeConverter> getTypeConverter(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); + static inline ::mlir::LogicalResult verifyTypeConverter(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, TypeConverterBuilderOpInterface builder); + }; + template + class FallbackModel : public Concept { + public: + using Interface = ::mlir::transform::ConversionPatternDescriptorOpInterface; + FallbackModel() : Concept{populatePatterns, populateConversionTargetRules, getTypeConverter, verifyTypeConverter} {} + + static inline void populatePatterns(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ::mlir::TypeConverter & typeConverter, ::mlir::RewritePatternSet & patterns); + static inline void populateConversionTargetRules(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, const ::mlir::TypeConverter & typeConverter, ::mlir::ConversionTarget & conversionTarget); + static inline std::unique_ptr<::mlir::TypeConverter> getTypeConverter(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); + static inline ::mlir::LogicalResult verifyTypeConverter(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, TypeConverterBuilderOpInterface builder); + }; + template + class ExternalModel : public FallbackModel { + public: + using ConcreteEntity = ConcreteOp; + void populateConversionTargetRules(::mlir::Operation *tablegen_opaque_val, const ::mlir::TypeConverter &typeConverter, ::mlir::ConversionTarget &conversionTarget) const; + std::unique_ptr<::mlir::TypeConverter> getTypeConverter(::mlir::Operation *tablegen_opaque_val) const; + ::mlir::LogicalResult verifyTypeConverter(::mlir::Operation *tablegen_opaque_val, TypeConverterBuilderOpInterface builder) const; + }; +};template +struct ConversionPatternDescriptorOpInterfaceTrait; + +} // namespace detail +class ConversionPatternDescriptorOpInterface : public ::mlir::OpInterface { +public: + using ::mlir::OpInterface::OpInterface; + template + struct Trait : public detail::ConversionPatternDescriptorOpInterfaceTrait {}; + /// Populate conversion patterns into the given pattern set with the + /// given type converter. + void populatePatterns(::mlir::TypeConverter & typeConverter, ::mlir::RewritePatternSet & patterns); + /// Populate the ConversionTarget using the final TypeConverter. The default + /// implementation is to do nothing. Overriding this method can be useful + /// in order to setup the ConversionTarget for structural type conversions. + /// In such a situation, an op's legality depends on using the TypeConverter + /// to determine whether the op's operand and result types are legal + /// (defined as converting to themselves). + /// + void populateConversionTargetRules(const ::mlir::TypeConverter & typeConverter, ::mlir::ConversionTarget & conversionTarget); + /// Return the type converter to be used with this pattern set. If no + /// type converter is specified, the default type converter of the enclosing + /// "apply_conversion_patterns" op is used. + std::unique_ptr<::mlir::TypeConverter> getTypeConverter(); + /// Verify the default type converter that is provided by the enclosing + /// "apply_conversion_patterns" op. + ::mlir::LogicalResult verifyTypeConverter(TypeConverterBuilderOpInterface builder); +}; +namespace detail { + template + struct ConversionPatternDescriptorOpInterfaceTrait : public ::mlir::OpInterface::Trait { + /// Populate the ConversionTarget using the final TypeConverter. The default + /// implementation is to do nothing. Overriding this method can be useful + /// in order to setup the ConversionTarget for structural type conversions. + /// In such a situation, an op's legality depends on using the TypeConverter + /// to determine whether the op's operand and result types are legal + /// (defined as converting to themselves). + /// + void populateConversionTargetRules(const ::mlir::TypeConverter & typeConverter, ::mlir::ConversionTarget & conversionTarget) { + return; + } + /// Return the type converter to be used with this pattern set. If no + /// type converter is specified, the default type converter of the enclosing + /// "apply_conversion_patterns" op is used. + std::unique_ptr<::mlir::TypeConverter> getTypeConverter() { + return nullptr; + } + /// Verify the default type converter that is provided by the enclosing + /// "apply_conversion_patterns" op. + ::mlir::LogicalResult verifyTypeConverter(TypeConverterBuilderOpInterface builder) { + return success(); + } + }; +}// namespace detail +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +template +::mlir::DiagnosedSilenceableFailure detail::TransformOpInterfaceInterfaceTraits::Model::apply(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ::mlir::transform::TransformRewriter & rewriter, ::mlir::transform::TransformResults & transformResults, ::mlir::transform::TransformState & state) { + return (llvm::cast(tablegen_opaque_val)).apply(rewriter, transformResults, state); +} +template +bool detail::TransformOpInterfaceInterfaceTraits::Model::allowsRepeatedHandleOperands(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { + return (llvm::cast(tablegen_opaque_val)).allowsRepeatedHandleOperands(); +} +template +::mlir::DiagnosedSilenceableFailure detail::TransformOpInterfaceInterfaceTraits::FallbackModel::apply(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ::mlir::transform::TransformRewriter & rewriter, ::mlir::transform::TransformResults & transformResults, ::mlir::transform::TransformState & state) { + return static_cast(impl)->apply(tablegen_opaque_val, rewriter, transformResults, state); +} +template +bool detail::TransformOpInterfaceInterfaceTraits::FallbackModel::allowsRepeatedHandleOperands(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { + return static_cast(impl)->allowsRepeatedHandleOperands(tablegen_opaque_val); +} +template +bool detail::TransformOpInterfaceInterfaceTraits::ExternalModel::allowsRepeatedHandleOperands(::mlir::Operation *tablegen_opaque_val) const { +return false; +} +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +template +::llvm::SmallVector<::mlir::Value> detail::FindPayloadReplacementOpInterfaceInterfaceTraits::Model::getNextOperands(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { + return (llvm::cast(tablegen_opaque_val)).getNextOperands(); +} +template +::llvm::SmallVector<::mlir::Value> detail::FindPayloadReplacementOpInterfaceInterfaceTraits::FallbackModel::getNextOperands(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { + return static_cast(impl)->getNextOperands(tablegen_opaque_val); +} +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +template +void detail::PatternDescriptorOpInterfaceInterfaceTraits::Model::populatePatterns(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ::mlir::RewritePatternSet & patterns) { + return (llvm::cast(tablegen_opaque_val)).populatePatterns(patterns); +} +template +void detail::PatternDescriptorOpInterfaceInterfaceTraits::Model::populatePatternsWithState(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ::mlir::RewritePatternSet & patterns, ::mlir::transform::TransformState & state) { + return (llvm::cast(tablegen_opaque_val)).populatePatternsWithState(patterns, state); +} +template +void detail::PatternDescriptorOpInterfaceInterfaceTraits::FallbackModel::populatePatterns(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ::mlir::RewritePatternSet & patterns) { + return static_cast(impl)->populatePatterns(tablegen_opaque_val, patterns); +} +template +void detail::PatternDescriptorOpInterfaceInterfaceTraits::FallbackModel::populatePatternsWithState(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ::mlir::RewritePatternSet & patterns, ::mlir::transform::TransformState & state) { + return static_cast(impl)->populatePatternsWithState(tablegen_opaque_val, patterns, state); +} +template +void detail::PatternDescriptorOpInterfaceInterfaceTraits::ExternalModel::populatePatternsWithState(::mlir::Operation *tablegen_opaque_val, ::mlir::RewritePatternSet &patterns, ::mlir::transform::TransformState &state) const { +(llvm::cast(tablegen_opaque_val)).populatePatterns(patterns); +} +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +template +std::unique_ptr<::mlir::TypeConverter> detail::TypeConverterBuilderOpInterfaceInterfaceTraits::Model::getTypeConverter(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { + return (llvm::cast(tablegen_opaque_val)).getTypeConverter(); +} +template +StringRef detail::TypeConverterBuilderOpInterfaceInterfaceTraits::Model::getTypeConverterType() { + return ConcreteOp::getTypeConverterType(); +} +template +std::unique_ptr<::mlir::TypeConverter> detail::TypeConverterBuilderOpInterfaceInterfaceTraits::FallbackModel::getTypeConverter(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { + return static_cast(impl)->getTypeConverter(tablegen_opaque_val); +} +template +StringRef detail::TypeConverterBuilderOpInterfaceInterfaceTraits::FallbackModel::getTypeConverterType() { + return ConcreteOp::getTypeConverterType(); +} +template +StringRef detail::TypeConverterBuilderOpInterfaceInterfaceTraits::ExternalModel::getTypeConverterType() { +return "TypeConverter"; +} +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +template +void detail::ConversionPatternDescriptorOpInterfaceInterfaceTraits::Model::populatePatterns(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ::mlir::TypeConverter & typeConverter, ::mlir::RewritePatternSet & patterns) { + return (llvm::cast(tablegen_opaque_val)).populatePatterns(typeConverter, patterns); +} +template +void detail::ConversionPatternDescriptorOpInterfaceInterfaceTraits::Model::populateConversionTargetRules(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, const ::mlir::TypeConverter & typeConverter, ::mlir::ConversionTarget & conversionTarget) { + return (llvm::cast(tablegen_opaque_val)).populateConversionTargetRules(typeConverter, conversionTarget); +} +template +std::unique_ptr<::mlir::TypeConverter> detail::ConversionPatternDescriptorOpInterfaceInterfaceTraits::Model::getTypeConverter(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { + return (llvm::cast(tablegen_opaque_val)).getTypeConverter(); +} +template +::mlir::LogicalResult detail::ConversionPatternDescriptorOpInterfaceInterfaceTraits::Model::verifyTypeConverter(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, TypeConverterBuilderOpInterface builder) { + return (llvm::cast(tablegen_opaque_val)).verifyTypeConverter(builder); +} +template +void detail::ConversionPatternDescriptorOpInterfaceInterfaceTraits::FallbackModel::populatePatterns(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, ::mlir::TypeConverter & typeConverter, ::mlir::RewritePatternSet & patterns) { + return static_cast(impl)->populatePatterns(tablegen_opaque_val, typeConverter, patterns); +} +template +void detail::ConversionPatternDescriptorOpInterfaceInterfaceTraits::FallbackModel::populateConversionTargetRules(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, const ::mlir::TypeConverter & typeConverter, ::mlir::ConversionTarget & conversionTarget) { + return static_cast(impl)->populateConversionTargetRules(tablegen_opaque_val, typeConverter, conversionTarget); +} +template +std::unique_ptr<::mlir::TypeConverter> detail::ConversionPatternDescriptorOpInterfaceInterfaceTraits::FallbackModel::getTypeConverter(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { + return static_cast(impl)->getTypeConverter(tablegen_opaque_val); +} +template +::mlir::LogicalResult detail::ConversionPatternDescriptorOpInterfaceInterfaceTraits::FallbackModel::verifyTypeConverter(const Concept *impl, ::mlir::Operation *tablegen_opaque_val, TypeConverterBuilderOpInterface builder) { + return static_cast(impl)->verifyTypeConverter(tablegen_opaque_val, builder); +} +template +void detail::ConversionPatternDescriptorOpInterfaceInterfaceTraits::ExternalModel::populateConversionTargetRules(::mlir::Operation *tablegen_opaque_val, const ::mlir::TypeConverter &typeConverter, ::mlir::ConversionTarget &conversionTarget) const { +return; +} +template +std::unique_ptr<::mlir::TypeConverter> detail::ConversionPatternDescriptorOpInterfaceInterfaceTraits::ExternalModel::getTypeConverter(::mlir::Operation *tablegen_opaque_val) const { +return nullptr; +} +template +::mlir::LogicalResult detail::ConversionPatternDescriptorOpInterfaceInterfaceTraits::ExternalModel::verifyTypeConverter(::mlir::Operation *tablegen_opaque_val, TypeConverterBuilderOpInterface builder) const { +return success(); +} +} // namespace transform +} // namespace mlir diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformOps.cpp.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformOps.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..10648ac7eb2bae54bd42b9b139d210010d6354d4 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformOps.cpp.inc @@ -0,0 +1,10652 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Op Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: TransformOps.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifdef GET_OP_LIST +#undef GET_OP_LIST + +::mlir::transform::AlternativesOp, +::mlir::transform::AnnotateOp, +::mlir::transform::ApplyCanonicalizationPatternsOp, +::mlir::transform::ApplyCommonSubexpressionEliminationOp, +::mlir::transform::ApplyConversionPatternsOp, +::mlir::transform::ApplyDeadCodeEliminationOp, +::mlir::transform::ApplyLoopInvariantCodeMotionOp, +::mlir::transform::ApplyPatternsOp, +::mlir::transform::ApplyRegisteredPassOp, +::mlir::transform::ApplyToLLVMConversionPatternsOp, +::mlir::transform::CastOp, +::mlir::transform::ForeachMatchOp, +::mlir::transform::ForeachOp, +::mlir::transform::GetConsumersOfResult, +::mlir::transform::GetDefiningOp, +::mlir::transform::GetParentOp, +::mlir::transform::GetProducerOfOperand, +::mlir::transform::GetResultOp, +::mlir::transform::GetTypeOp, +::mlir::transform::IncludeOp, +::mlir::transform::MatchOperationEmptyOp, +::mlir::transform::MatchOperationNameOp, +::mlir::transform::MatchParamCmpIOp, +::mlir::transform::MergeHandlesOp, +::mlir::transform::NamedSequenceOp, +::mlir::transform::ParamConstantOp, +::mlir::transform::PrintOp, +::mlir::transform::ReplicateOp, +::mlir::transform::SelectOp, +::mlir::transform::SequenceOp, +::mlir::transform::SplitHandleOp, +::mlir::transform::VerifyOp, +::mlir::transform::YieldOp +#endif // GET_OP_LIST + +#ifdef GET_OP_CLASSES +#undef GET_OP_CLASSES + + +//===----------------------------------------------------------------------===// +// Local Utility Method Definitions +//===----------------------------------------------------------------------===// + +namespace mlir { +namespace transform { + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_TransformOps0( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((::llvm::isa<::mlir::transform::TransformHandleTypeInterface>(type)))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be TransformHandleTypeInterface instance, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_TransformOps1( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((::llvm::isa<::mlir::transform::TransformParamTypeInterface>(type)))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be TransformParamTypeInterface instance, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_TransformOps2( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((::llvm::isa<::mlir::transform::TransformValueHandleTypeInterface>(type)))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be TransformValueHandleTypeInterface instance, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_TransformOps3( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::transform::TransformParamTypeInterface>(type))) || ((::llvm::isa<::mlir::transform::TransformHandleTypeInterface>(type))) || ((::llvm::isa<::mlir::transform::TransformValueHandleTypeInterface>(type))))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be any transform handle or parameter, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_TransformOps0( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::StringAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: string attribute"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_TransformOps0( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_TransformOps0(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_TransformOps1( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !(((::llvm::isa<::mlir::ArrayAttr>(attr))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(attr), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::StringAttr>(attr))); })))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: string array attribute"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_TransformOps1( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_TransformOps1(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_TransformOps2( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::UnitAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: unit attribute"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_TransformOps2( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_TransformOps2(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_TransformOps3( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !(((::llvm::isa<::mlir::ArrayAttr>(attr))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(attr), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::SymbolRefAttr>(attr))); })))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: symbol ref array attribute"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_TransformOps3( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_TransformOps3(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_TransformOps4( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !(((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(64))))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: 64-bit signless integer attribute"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_TransformOps4( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_TransformOps4(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_TransformOps5( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::SymbolRefAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: symbol reference attribute"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_TransformOps5( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_TransformOps5(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_TransformOps6( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::transform::FailurePropagationModeAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: Silenceable error propagation policy"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_TransformOps6( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_TransformOps6(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_TransformOps7( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::transform::MatchCmpIPredicateAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: allowed 32-bit signless integer cases: 0, 1, 2, 3, 4, 5"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_TransformOps7( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_TransformOps7(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_TransformOps8( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !(((::llvm::isa<::mlir::TypeAttr>(attr))) && ((::llvm::isa<::mlir::FunctionType>(::llvm::cast<::mlir::TypeAttr>(attr).getValue()))) && ((true)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: function type attribute"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_TransformOps8( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_TransformOps8(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_TransformOps9( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !(((::llvm::isa<::mlir::ArrayAttr>(attr))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(attr), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::DictionaryAttr>(attr))); })))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: Array of dictionary attributes"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_TransformOps9( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_TransformOps9(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_TransformOps10( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((true))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: any attribute"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_TransformOps10( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_TransformOps10(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_TransformOps11( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::BoolAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: bool attribute"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_TransformOps11( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_TransformOps11(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_region_constraint_TransformOps0( + ::mlir::Operation *op, ::mlir::Region ®ion, ::llvm::StringRef regionName, + unsigned regionIndex) { + if (!((::llvm::hasNItems(region, 1)))) { + return op->emitOpError("region #") << regionIndex + << (regionName.empty() ? " " : " ('" + regionName + "') ") + << "failed to verify constraint: region with 1 blocks"; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_region_constraint_TransformOps1( + ::mlir::Operation *op, ::mlir::Region ®ion, ::llvm::StringRef regionName, + unsigned regionIndex) { + if (!((::llvm::hasNItemsOrLess(region, 1)))) { + return op->emitOpError("region #") << regionIndex + << (regionName.empty() ? " " : " ('" + regionName + "') ") + << "failed to verify constraint: region with at most 1 blocks"; + } + return ::mlir::success(); +} +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::AlternativesOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +AlternativesOpGenericAdaptorBase::AlternativesOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("transform.alternatives", odsAttrs.getContext()); +} + +AlternativesOpGenericAdaptorBase::AlternativesOpGenericAdaptorBase(AlternativesOp op) : AlternativesOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair AlternativesOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr AlternativesOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::RegionRange AlternativesOpGenericAdaptorBase::getAlternatives() { + return odsRegions.drop_front(0); +} + +::mlir::RegionRange AlternativesOpGenericAdaptorBase::getRegions() { + return odsRegions; +} + +} // namespace detail +AlternativesOpAdaptor::AlternativesOpAdaptor(AlternativesOp op) : AlternativesOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult AlternativesOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair AlternativesOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range AlternativesOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> AlternativesOp::getScope() { + auto operands = getODSOperands(0); + return operands.empty() ? ::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface>{} : ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface>>(*operands.begin()); +} + +::mlir::MutableOperandRange AlternativesOp::getScopeMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair AlternativesOp::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::result_range AlternativesOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::result_range AlternativesOp::getResults() { + return getODSResults(0); +} + +::mlir::MutableArrayRef<::mlir::Region> AlternativesOp::getAlternatives() { + return (*this)->getRegions().drop_front(0); +} + +void AlternativesOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, /*optional*/::mlir::Value scope, unsigned alternativesCount) { + if (scope) + odsState.addOperands(scope); + for (unsigned i = 0; i < alternativesCount; ++i) + (void)odsState.addRegion(); + odsState.addTypes(results); +} + +void AlternativesOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes, unsigned numRegions) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != numRegions; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult AlternativesOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + if (valueGroup0.size() > 1) { + return emitOpError("operand group starting at #") << index + << " requires 0 or 1 element, but found " << valueGroup0.size(); + } + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps0(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : getAlternatives()) + if (::mlir::failed(__mlir_ods_local_region_constraint_TransformOps0(*this, region, "alternatives", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult AlternativesOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult AlternativesOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> scopeOperands; + ::llvm::SMLoc scopeOperandsLoc; + (void)scopeOperandsLoc; + ::llvm::SmallVector<::mlir::Type, 1> scopeTypes; + ::llvm::SmallVector<::mlir::Type, 1> resultsTypes; + ::llvm::SmallVector, 2> fullRegions; + + { + scopeOperandsLoc = parser.getCurrentLocation(); + ::mlir::OpAsmParser::UnresolvedOperand operand; + ::mlir::OptionalParseResult parseResult = + parser.parseOptionalOperand(operand); + if (parseResult.has_value()) { + if (failed(*parseResult)) + return ::mlir::failure(); + scopeOperands.push_back(operand); + } + } + if (!scopeOperands.empty()) { + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::Type optionalType; + ::mlir::OptionalParseResult parseResult = + parser.parseOptionalType(optionalType); + if (parseResult.has_value()) { + if (failed(*parseResult)) + return ::mlir::failure(); + scopeTypes.push_back(optionalType); + } + } + } + if (::mlir::succeeded(parser.parseOptionalArrow())) { + + if (parser.parseTypeList(resultsTypes)) + return ::mlir::failure(); + } + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDictWithKeyword(result.attributes)) + return ::mlir::failure(); + } + + { + std::unique_ptr<::mlir::Region> region; + auto firstRegionResult = parser.parseOptionalRegion(region); + if (firstRegionResult.has_value()) { + if (failed(*firstRegionResult)) + return ::mlir::failure(); + fullRegions.emplace_back(std::move(region)); + + // Parse any trailing regions. + while (succeeded(parser.parseOptionalComma())) { + region = std::make_unique<::mlir::Region>(); + if (parser.parseRegion(*region)) + return ::mlir::failure(); + fullRegions.emplace_back(std::move(region)); + } + } + } + + for (auto ®ion : fullRegions) + ensureTerminator(*region, parser.getBuilder(), result.location); + result.addRegions(fullRegions); + result.addTypes(resultsTypes); + if (parser.resolveOperands(scopeOperands, scopeTypes, scopeOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void AlternativesOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + if (getScope()) { + _odsPrinter << ' '; + if (::mlir::Value value = getScope()) + _odsPrinter << value; + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter << (getScope() ? ::llvm::ArrayRef<::mlir::Type>(getScope().getType()) : ::llvm::ArrayRef<::mlir::Type>()); + } + if (!getResults().empty()) { + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + _odsPrinter << getResults().getTypes(); + } + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDictWithKeyword((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' '; + llvm::interleaveComma(getOperation()->getRegions(), _odsPrinter, [&](::mlir::Region ®ion) { + + { + bool printTerminator = true; + if (auto *term = region.empty() ? nullptr : region.begin()->getTerminator()) { + printTerminator = !term->getAttrDictionary().empty() || + term->getNumOperands() != 0 || + term->getNumResults() != 0; + } + _odsPrinter.printRegion(region, /*printEntryBlockArgs=*/true, + /*printBlockTerminators=*/printTerminator); + } + }); +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::AlternativesOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::AnnotateOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +AnnotateOpGenericAdaptorBase::AnnotateOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("transform.annotate", odsAttrs.getContext()); +} + +AnnotateOpGenericAdaptorBase::AnnotateOpGenericAdaptorBase(AnnotateOp op) : AnnotateOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair AnnotateOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr AnnotateOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::StringAttr AnnotateOpGenericAdaptorBase::getNameAttr() { + auto attr = ::llvm::cast<::mlir::StringAttr>(getProperties().name); + return attr; +} + +::llvm::StringRef AnnotateOpGenericAdaptorBase::getName() { + auto attr = getNameAttr(); + return attr.getValue(); +} + +} // namespace detail +AnnotateOpAdaptor::AnnotateOpAdaptor(AnnotateOp op) : AnnotateOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult AnnotateOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_name = getProperties().name; (void)tblgen_name; + if (!tblgen_name) return emitError(loc, "'transform.annotate' op ""requires attribute 'name'"); + + if (tblgen_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_name)))) + return emitError(loc, "'transform.annotate' op ""attribute 'name' failed to satisfy constraint: string attribute"); + return ::mlir::success(); +} + +std::pair AnnotateOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range AnnotateOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> AnnotateOp::getTarget() { + return ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::transform::TransformParamTypeInterface> AnnotateOp::getParam() { + auto operands = getODSOperands(1); + return operands.empty() ? ::mlir::TypedValue<::mlir::transform::TransformParamTypeInterface>{} : ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformParamTypeInterface>>(*operands.begin()); +} + +::mlir::OpOperand &AnnotateOp::getTargetMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange AnnotateOp::getParamMutable() { + auto range = getODSOperandIndexAndLength(1); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair AnnotateOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range AnnotateOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::LogicalResult AnnotateOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.name; + auto attr = dict.get("name"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for name in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `name` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute AnnotateOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.name; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("name", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code AnnotateOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.name.getAsOpaquePointer())); +} + +std::optional AnnotateOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "name") + return prop.name; + return std::nullopt; +} + +void AnnotateOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "name") { + prop.name = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void AnnotateOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.name) attrs.append("name", prop.name); +} + +::mlir::LogicalResult AnnotateOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getNameAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps0(attr, "name", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult AnnotateOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.name))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void AnnotateOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.name); +} + +::mlir::StringAttr AnnotateOp::getNameAttr() { + return ::llvm::cast<::mlir::StringAttr>(getProperties().name); +} + +::llvm::StringRef AnnotateOp::getName() { + auto attr = getNameAttr(); + return attr.getValue(); +} + +void AnnotateOp::setNameAttr(::mlir::StringAttr attr) { + (*this)->setAttr(getNameAttrName(), attr); +} + +void AnnotateOp::setName(::llvm::StringRef attrValue) { + (*this)->setAttr(getNameAttrName(), ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue)); +} + +void AnnotateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value target, ::mlir::StringAttr name, /*optional*/::mlir::Value param) { + odsState.addOperands(target); + if (param) + odsState.addOperands(param); + odsState.getOrAddProperties().name = name; +} + +void AnnotateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target, ::mlir::StringAttr name, /*optional*/::mlir::Value param) { + odsState.addOperands(target); + if (param) + odsState.addOperands(param); + odsState.getOrAddProperties().name = name; + assert(resultTypes.size() == 0u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void AnnotateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value target, ::llvm::StringRef name, /*optional*/::mlir::Value param) { + odsState.addOperands(target); + if (param) + odsState.addOperands(param); + odsState.getOrAddProperties().name = odsBuilder.getStringAttr(name); +} + +void AnnotateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target, ::llvm::StringRef name, /*optional*/::mlir::Value param) { + odsState.addOperands(target); + if (param) + odsState.addOperands(param); + odsState.getOrAddProperties().name = odsBuilder.getStringAttr(name); + assert(resultTypes.size() == 0u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void AnnotateOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult AnnotateOp::verifyInvariantsImpl() { + auto tblgen_name = getProperties().name; (void)tblgen_name; + if (!tblgen_name) return emitOpError("requires attribute 'name'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps0(*this, tblgen_name, "name"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + if (valueGroup1.size() > 1) { + return emitOpError("operand group starting at #") << index + << " requires 0 or 1 element, but found " << valueGroup1.size(); + } + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult AnnotateOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult AnnotateOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand targetRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> targetOperands(targetRawOperands); ::llvm::SMLoc targetOperandsLoc; + (void)targetOperandsLoc; + ::mlir::StringAttr nameAttr; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> paramOperands; + ::llvm::SMLoc paramOperandsLoc; + (void)paramOperandsLoc; + ::mlir::Type targetRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> targetTypes(targetRawTypes); + ::llvm::SmallVector<::mlir::Type, 1> paramTypes; + + targetOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(targetRawOperands[0])) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(nameAttr, parser.getBuilder().getType<::mlir::NoneType>())) { + return ::mlir::failure(); + } + if (nameAttr) result.getOrAddProperties().name = nameAttr; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (::mlir::succeeded(parser.parseOptionalEqual())) { + + { + paramOperandsLoc = parser.getCurrentLocation(); + ::mlir::OpAsmParser::UnresolvedOperand operand; + ::mlir::OptionalParseResult parseResult = + parser.parseOptionalOperand(operand); + if (parseResult.has_value()) { + if (failed(*parseResult)) + return ::mlir::failure(); + paramOperands.push_back(operand); + } + } + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::transform::TransformHandleTypeInterface type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + targetRawTypes[0] = type; + } + if (::mlir::succeeded(parser.parseOptionalComma())) { + + { + ::mlir::Type optionalType; + ::mlir::OptionalParseResult parseResult = + parser.parseOptionalType(optionalType); + if (parseResult.has_value()) { + if (failed(*parseResult)) + return ::mlir::failure(); + paramTypes.push_back(optionalType); + } + } + } + if (parser.resolveOperands(targetOperands, targetTypes, targetOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(paramOperands, paramTypes, paramOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void AnnotateOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getTarget(); + _odsPrinter << ' '; + _odsPrinter.printAttributeWithoutType(getNameAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("name"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + if (getParam()) { + _odsPrinter << ' ' << "="; + _odsPrinter << ' '; + if (::mlir::Value value = getParam()) + _odsPrinter << value; + } + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getTarget().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::transform::TransformHandleTypeInterface>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + if (getParam()) { + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << (getParam() ? ::llvm::ArrayRef<::mlir::Type>(getParam().getType()) : ::llvm::ArrayRef<::mlir::Type>()); + } +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::AnnotateOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::ApplyCanonicalizationPatternsOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ApplyCanonicalizationPatternsOpGenericAdaptorBase::ApplyCanonicalizationPatternsOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("transform.apply_patterns.canonicalization", odsAttrs.getContext()); +} + +ApplyCanonicalizationPatternsOpGenericAdaptorBase::ApplyCanonicalizationPatternsOpGenericAdaptorBase(ApplyCanonicalizationPatternsOp op) : ApplyCanonicalizationPatternsOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ApplyCanonicalizationPatternsOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ApplyCanonicalizationPatternsOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +ApplyCanonicalizationPatternsOpAdaptor::ApplyCanonicalizationPatternsOpAdaptor(ApplyCanonicalizationPatternsOp op) : ApplyCanonicalizationPatternsOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ApplyCanonicalizationPatternsOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair ApplyCanonicalizationPatternsOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ApplyCanonicalizationPatternsOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +std::pair ApplyCanonicalizationPatternsOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ApplyCanonicalizationPatternsOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +void ApplyCanonicalizationPatternsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { +} + +void ApplyCanonicalizationPatternsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { + assert(resultTypes.size() == 0u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ApplyCanonicalizationPatternsOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ApplyCanonicalizationPatternsOp::verifyInvariantsImpl() { + return ::mlir::success(); +} + +::mlir::LogicalResult ApplyCanonicalizationPatternsOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult ApplyCanonicalizationPatternsOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +void ApplyCanonicalizationPatternsOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::ApplyCanonicalizationPatternsOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::ApplyCommonSubexpressionEliminationOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ApplyCommonSubexpressionEliminationOpGenericAdaptorBase::ApplyCommonSubexpressionEliminationOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("transform.apply_cse", odsAttrs.getContext()); +} + +ApplyCommonSubexpressionEliminationOpGenericAdaptorBase::ApplyCommonSubexpressionEliminationOpGenericAdaptorBase(ApplyCommonSubexpressionEliminationOp op) : ApplyCommonSubexpressionEliminationOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ApplyCommonSubexpressionEliminationOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ApplyCommonSubexpressionEliminationOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +ApplyCommonSubexpressionEliminationOpAdaptor::ApplyCommonSubexpressionEliminationOpAdaptor(ApplyCommonSubexpressionEliminationOp op) : ApplyCommonSubexpressionEliminationOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ApplyCommonSubexpressionEliminationOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair ApplyCommonSubexpressionEliminationOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ApplyCommonSubexpressionEliminationOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> ApplyCommonSubexpressionEliminationOp::getTarget() { + return ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &ApplyCommonSubexpressionEliminationOp::getTargetMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair ApplyCommonSubexpressionEliminationOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ApplyCommonSubexpressionEliminationOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +void ApplyCommonSubexpressionEliminationOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value target) { + odsState.addOperands(target); +} + +void ApplyCommonSubexpressionEliminationOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target) { + odsState.addOperands(target); + assert(resultTypes.size() == 0u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ApplyCommonSubexpressionEliminationOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ApplyCommonSubexpressionEliminationOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ApplyCommonSubexpressionEliminationOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult ApplyCommonSubexpressionEliminationOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand targetRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> targetOperands(targetRawOperands); ::llvm::SMLoc targetOperandsLoc; + (void)targetOperandsLoc; + ::mlir::Type targetRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> targetTypes(targetRawTypes); + if (parser.parseKeyword("to")) + return ::mlir::failure(); + + targetOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(targetRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::transform::TransformHandleTypeInterface type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + targetRawTypes[0] = type; + } + if (parser.resolveOperands(targetOperands, targetTypes, targetOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ApplyCommonSubexpressionEliminationOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' ' << "to"; + _odsPrinter << ' '; + _odsPrinter << getTarget(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getTarget().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::transform::TransformHandleTypeInterface>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::ApplyCommonSubexpressionEliminationOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::ApplyConversionPatternsOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ApplyConversionPatternsOpGenericAdaptorBase::ApplyConversionPatternsOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("transform.apply_conversion_patterns", odsAttrs.getContext()); +} + +ApplyConversionPatternsOpGenericAdaptorBase::ApplyConversionPatternsOpGenericAdaptorBase(ApplyConversionPatternsOp op) : ApplyConversionPatternsOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ApplyConversionPatternsOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ApplyConversionPatternsOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::ArrayAttr ApplyConversionPatternsOpGenericAdaptorBase::getLegalOpsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().legal_ops); + return attr; +} + +::std::optional< ::mlir::ArrayAttr > ApplyConversionPatternsOpGenericAdaptorBase::getLegalOps() { + auto attr = getLegalOpsAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +::mlir::ArrayAttr ApplyConversionPatternsOpGenericAdaptorBase::getIllegalOpsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().illegal_ops); + return attr; +} + +::std::optional< ::mlir::ArrayAttr > ApplyConversionPatternsOpGenericAdaptorBase::getIllegalOps() { + auto attr = getIllegalOpsAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +::mlir::ArrayAttr ApplyConversionPatternsOpGenericAdaptorBase::getLegalDialectsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().legal_dialects); + return attr; +} + +::std::optional< ::mlir::ArrayAttr > ApplyConversionPatternsOpGenericAdaptorBase::getLegalDialects() { + auto attr = getLegalDialectsAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +::mlir::ArrayAttr ApplyConversionPatternsOpGenericAdaptorBase::getIllegalDialectsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().illegal_dialects); + return attr; +} + +::std::optional< ::mlir::ArrayAttr > ApplyConversionPatternsOpGenericAdaptorBase::getIllegalDialects() { + auto attr = getIllegalDialectsAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +::mlir::UnitAttr ApplyConversionPatternsOpGenericAdaptorBase::getPartialConversionAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().partial_conversion); + if (!attr) + attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); + return attr; +} + +bool ApplyConversionPatternsOpGenericAdaptorBase::getPartialConversion() { + auto attr = getPartialConversionAttr(); + if (!attr) + return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; + return attr != nullptr; +} + +::mlir::Region &ApplyConversionPatternsOpGenericAdaptorBase::getPatterns() { + return *odsRegions[0]; +} + +::mlir::RegionRange ApplyConversionPatternsOpGenericAdaptorBase::getDefaultTypeConverterRegion() { + return odsRegions.drop_front(1); +} + +::mlir::RegionRange ApplyConversionPatternsOpGenericAdaptorBase::getRegions() { + return odsRegions; +} + +} // namespace detail +ApplyConversionPatternsOpAdaptor::ApplyConversionPatternsOpAdaptor(ApplyConversionPatternsOp op) : ApplyConversionPatternsOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ApplyConversionPatternsOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_illegal_dialects = getProperties().illegal_dialects; (void)tblgen_illegal_dialects; + auto tblgen_illegal_ops = getProperties().illegal_ops; (void)tblgen_illegal_ops; + auto tblgen_legal_dialects = getProperties().legal_dialects; (void)tblgen_legal_dialects; + auto tblgen_legal_ops = getProperties().legal_ops; (void)tblgen_legal_ops; + auto tblgen_partial_conversion = getProperties().partial_conversion; (void)tblgen_partial_conversion; + + if (tblgen_legal_ops && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_legal_ops))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_legal_ops), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::StringAttr>(attr))); })))) + return emitError(loc, "'transform.apply_conversion_patterns' op ""attribute 'legal_ops' failed to satisfy constraint: string array attribute"); + + if (tblgen_illegal_ops && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_illegal_ops))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_illegal_ops), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::StringAttr>(attr))); })))) + return emitError(loc, "'transform.apply_conversion_patterns' op ""attribute 'illegal_ops' failed to satisfy constraint: string array attribute"); + + if (tblgen_legal_dialects && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_legal_dialects))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_legal_dialects), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::StringAttr>(attr))); })))) + return emitError(loc, "'transform.apply_conversion_patterns' op ""attribute 'legal_dialects' failed to satisfy constraint: string array attribute"); + + if (tblgen_illegal_dialects && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_illegal_dialects))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_illegal_dialects), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::StringAttr>(attr))); })))) + return emitError(loc, "'transform.apply_conversion_patterns' op ""attribute 'illegal_dialects' failed to satisfy constraint: string array attribute"); + + if (tblgen_partial_conversion && !((::llvm::isa<::mlir::UnitAttr>(tblgen_partial_conversion)))) + return emitError(loc, "'transform.apply_conversion_patterns' op ""attribute 'partial_conversion' failed to satisfy constraint: unit attribute"); + return ::mlir::success(); +} + +std::pair ApplyConversionPatternsOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ApplyConversionPatternsOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> ApplyConversionPatternsOp::getTarget() { + return ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &ApplyConversionPatternsOp::getTargetMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair ApplyConversionPatternsOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ApplyConversionPatternsOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Region &ApplyConversionPatternsOp::getPatterns() { + return (*this)->getRegion(0); +} + +::mlir::MutableArrayRef<::mlir::Region> ApplyConversionPatternsOp::getDefaultTypeConverterRegion() { + return (*this)->getRegions().drop_front(1); +} + +::mlir::LogicalResult ApplyConversionPatternsOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.illegal_dialects; + auto attr = dict.get("illegal_dialects"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for illegal_dialects in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `illegal_dialects` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.illegal_ops; + auto attr = dict.get("illegal_ops"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for illegal_ops in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `illegal_ops` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.legal_dialects; + auto attr = dict.get("legal_dialects"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for legal_dialects in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `legal_dialects` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.legal_ops; + auto attr = dict.get("legal_ops"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for legal_ops in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `legal_ops` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.partial_conversion; + auto attr = dict.get("partial_conversion"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for partial_conversion in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `partial_conversion` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ApplyConversionPatternsOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.illegal_dialects; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("illegal_dialects", + propStorage)); + } + + { + const auto &propStorage = prop.illegal_ops; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("illegal_ops", + propStorage)); + } + + { + const auto &propStorage = prop.legal_dialects; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("legal_dialects", + propStorage)); + } + + { + const auto &propStorage = prop.legal_ops; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("legal_ops", + propStorage)); + } + + { + const auto &propStorage = prop.partial_conversion; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("partial_conversion", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ApplyConversionPatternsOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.illegal_dialects.getAsOpaquePointer()), + llvm::hash_value(prop.illegal_ops.getAsOpaquePointer()), + llvm::hash_value(prop.legal_dialects.getAsOpaquePointer()), + llvm::hash_value(prop.legal_ops.getAsOpaquePointer()), + llvm::hash_value(prop.partial_conversion.getAsOpaquePointer())); +} + +std::optional ApplyConversionPatternsOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "illegal_dialects") + return prop.illegal_dialects; + + if (name == "illegal_ops") + return prop.illegal_ops; + + if (name == "legal_dialects") + return prop.legal_dialects; + + if (name == "legal_ops") + return prop.legal_ops; + + if (name == "partial_conversion") + return prop.partial_conversion; + return std::nullopt; +} + +void ApplyConversionPatternsOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "illegal_dialects") { + prop.illegal_dialects = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "illegal_ops") { + prop.illegal_ops = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "legal_dialects") { + prop.legal_dialects = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "legal_ops") { + prop.legal_ops = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "partial_conversion") { + prop.partial_conversion = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ApplyConversionPatternsOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.illegal_dialects) attrs.append("illegal_dialects", prop.illegal_dialects); + + if (prop.illegal_ops) attrs.append("illegal_ops", prop.illegal_ops); + + if (prop.legal_dialects) attrs.append("legal_dialects", prop.legal_dialects); + + if (prop.legal_ops) attrs.append("legal_ops", prop.legal_ops); + + if (prop.partial_conversion) attrs.append("partial_conversion", prop.partial_conversion); +} + +::mlir::LogicalResult ApplyConversionPatternsOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getIllegalDialectsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps1(attr, "illegal_dialects", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getIllegalOpsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps1(attr, "illegal_ops", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getLegalDialectsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps1(attr, "legal_dialects", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getLegalOpsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps1(attr, "legal_ops", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getPartialConversionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps2(attr, "partial_conversion", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ApplyConversionPatternsOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.illegal_dialects))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.illegal_ops))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.legal_dialects))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.legal_ops))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.partial_conversion))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ApplyConversionPatternsOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.illegal_dialects); + + writer.writeOptionalAttribute(prop.illegal_ops); + + writer.writeOptionalAttribute(prop.legal_dialects); + + writer.writeOptionalAttribute(prop.legal_ops); + + writer.writeOptionalAttribute(prop.partial_conversion); +} + +::mlir::ArrayAttr ApplyConversionPatternsOp::getLegalOpsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().legal_ops); +} + +::std::optional< ::mlir::ArrayAttr > ApplyConversionPatternsOp::getLegalOps() { + auto attr = getLegalOpsAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +::mlir::ArrayAttr ApplyConversionPatternsOp::getIllegalOpsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().illegal_ops); +} + +::std::optional< ::mlir::ArrayAttr > ApplyConversionPatternsOp::getIllegalOps() { + auto attr = getIllegalOpsAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +::mlir::ArrayAttr ApplyConversionPatternsOp::getLegalDialectsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().legal_dialects); +} + +::std::optional< ::mlir::ArrayAttr > ApplyConversionPatternsOp::getLegalDialects() { + auto attr = getLegalDialectsAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +::mlir::ArrayAttr ApplyConversionPatternsOp::getIllegalDialectsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().illegal_dialects); +} + +::std::optional< ::mlir::ArrayAttr > ApplyConversionPatternsOp::getIllegalDialects() { + auto attr = getIllegalDialectsAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +::mlir::UnitAttr ApplyConversionPatternsOp::getPartialConversionAttr() { + return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().partial_conversion); +} + +bool ApplyConversionPatternsOp::getPartialConversion() { + auto attr = getPartialConversionAttr(); + if (!attr) + return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; + return attr != nullptr; +} + +void ApplyConversionPatternsOp::setLegalOpsAttr(::mlir::ArrayAttr attr) { + (*this)->setAttr(getLegalOpsAttrName(), attr); +} + +void ApplyConversionPatternsOp::setIllegalOpsAttr(::mlir::ArrayAttr attr) { + (*this)->setAttr(getIllegalOpsAttrName(), attr); +} + +void ApplyConversionPatternsOp::setLegalDialectsAttr(::mlir::ArrayAttr attr) { + (*this)->setAttr(getLegalDialectsAttrName(), attr); +} + +void ApplyConversionPatternsOp::setIllegalDialectsAttr(::mlir::ArrayAttr attr) { + (*this)->setAttr(getIllegalDialectsAttrName(), attr); +} + +void ApplyConversionPatternsOp::setPartialConversionAttr(::mlir::UnitAttr attr) { + (*this)->setAttr(getPartialConversionAttrName(), attr); +} + +void ApplyConversionPatternsOp::setPartialConversion(bool attrValue) { + if (attrValue) + return (*this)->setAttr(getPartialConversionAttrName(), ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr)); + (*this)->removeAttr(getPartialConversionAttrName()); +} + +::mlir::Attribute ApplyConversionPatternsOp::removeLegalOpsAttr() { + auto &attr = getProperties().legal_ops; + attr = {}; + return attr; +} + +::mlir::Attribute ApplyConversionPatternsOp::removeIllegalOpsAttr() { + auto &attr = getProperties().illegal_ops; + attr = {}; + return attr; +} + +::mlir::Attribute ApplyConversionPatternsOp::removeLegalDialectsAttr() { + auto &attr = getProperties().legal_dialects; + attr = {}; + return attr; +} + +::mlir::Attribute ApplyConversionPatternsOp::removeIllegalDialectsAttr() { + auto &attr = getProperties().illegal_dialects; + attr = {}; + return attr; +} + +::mlir::Attribute ApplyConversionPatternsOp::removePartialConversionAttr() { + auto &attr = getProperties().partial_conversion; + attr = {}; + return attr; +} + +::mlir::LogicalResult ApplyConversionPatternsOp::verifyInvariantsImpl() { + auto tblgen_illegal_dialects = getProperties().illegal_dialects; (void)tblgen_illegal_dialects; + auto tblgen_illegal_ops = getProperties().illegal_ops; (void)tblgen_illegal_ops; + auto tblgen_legal_dialects = getProperties().legal_dialects; (void)tblgen_legal_dialects; + auto tblgen_legal_ops = getProperties().legal_ops; (void)tblgen_legal_ops; + auto tblgen_partial_conversion = getProperties().partial_conversion; (void)tblgen_partial_conversion; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps1(*this, tblgen_legal_ops, "legal_ops"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps1(*this, tblgen_illegal_ops, "illegal_ops"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps1(*this, tblgen_legal_dialects, "legal_dialects"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps1(*this, tblgen_illegal_dialects, "illegal_dialects"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps2(*this, tblgen_partial_conversion, "partial_conversion"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_TransformOps1(*this, region, "patterns", index++))) + return ::mlir::failure(); + + for (auto ®ion : getDefaultTypeConverterRegion()) + if (::mlir::failed(__mlir_ods_local_region_constraint_TransformOps1(*this, region, "default_type_converter_region", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ApplyConversionPatternsOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult ApplyConversionPatternsOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand targetRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> targetOperands(targetRawOperands); ::llvm::SMLoc targetOperandsLoc; + (void)targetOperandsLoc; + std::unique_ptr<::mlir::Region> patternsRegion = std::make_unique<::mlir::Region>(); + ::llvm::SmallVector, 2> default_type_converter_regionRegions; + ::mlir::Type targetRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> targetTypes(targetRawTypes); + if (parser.parseKeyword("to")) + return ::mlir::failure(); + + targetOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(targetRawOperands[0])) + return ::mlir::failure(); + + if (parser.parseRegion(*patternsRegion)) + return ::mlir::failure(); + + if (patternsRegion->empty()) patternsRegion->emplaceBlock(); + if (::mlir::succeeded(parser.parseOptionalKeyword("with"))) { + if (parser.parseKeyword("type_converter")) + return ::mlir::failure(); + + { + std::unique_ptr<::mlir::Region> region; + auto firstRegionResult = parser.parseOptionalRegion(region); + if (firstRegionResult.has_value()) { + if (failed(*firstRegionResult)) + return ::mlir::failure(); + default_type_converter_regionRegions.emplace_back(std::move(region)); + + // Parse any trailing regions. + while (succeeded(parser.parseOptionalComma())) { + region = std::make_unique<::mlir::Region>(); + if (parser.parseRegion(*region)) + return ::mlir::failure(); + default_type_converter_regionRegions.emplace_back(std::move(region)); + } + } + } + + for (auto ®ion : default_type_converter_regionRegions) + if (region->empty()) region->emplaceBlock(); + } + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::transform::TransformHandleTypeInterface type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + targetRawTypes[0] = type; + } + result.addRegion(std::move(patternsRegion)); + result.addRegions(default_type_converter_regionRegions); + if (parser.resolveOperands(targetOperands, targetTypes, targetOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ApplyConversionPatternsOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' ' << "to"; + _odsPrinter << ' '; + _odsPrinter << getTarget(); + _odsPrinter << ' '; + _odsPrinter.printRegion(getPatterns()); + if (!getDefaultTypeConverterRegion().empty()) { + _odsPrinter << ' ' << "with"; + _odsPrinter << ' ' << "type_converter"; + _odsPrinter << ' '; + llvm::interleaveComma(getDefaultTypeConverterRegion(), _odsPrinter, [&](::mlir::Region ®ion) { + _odsPrinter.printRegion(region); + }); + } + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getPartialConversionAttr(); + if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) + elidedAttrs.push_back("partial_conversion"); + } + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getTarget().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::transform::TransformHandleTypeInterface>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::ApplyConversionPatternsOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::ApplyDeadCodeEliminationOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ApplyDeadCodeEliminationOpGenericAdaptorBase::ApplyDeadCodeEliminationOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("transform.apply_dce", odsAttrs.getContext()); +} + +ApplyDeadCodeEliminationOpGenericAdaptorBase::ApplyDeadCodeEliminationOpGenericAdaptorBase(ApplyDeadCodeEliminationOp op) : ApplyDeadCodeEliminationOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ApplyDeadCodeEliminationOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ApplyDeadCodeEliminationOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +ApplyDeadCodeEliminationOpAdaptor::ApplyDeadCodeEliminationOpAdaptor(ApplyDeadCodeEliminationOp op) : ApplyDeadCodeEliminationOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ApplyDeadCodeEliminationOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair ApplyDeadCodeEliminationOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ApplyDeadCodeEliminationOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> ApplyDeadCodeEliminationOp::getTarget() { + return ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &ApplyDeadCodeEliminationOp::getTargetMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair ApplyDeadCodeEliminationOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ApplyDeadCodeEliminationOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +void ApplyDeadCodeEliminationOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value target) { + odsState.addOperands(target); +} + +void ApplyDeadCodeEliminationOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target) { + odsState.addOperands(target); + assert(resultTypes.size() == 0u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ApplyDeadCodeEliminationOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ApplyDeadCodeEliminationOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ApplyDeadCodeEliminationOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult ApplyDeadCodeEliminationOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand targetRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> targetOperands(targetRawOperands); ::llvm::SMLoc targetOperandsLoc; + (void)targetOperandsLoc; + ::mlir::Type targetRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> targetTypes(targetRawTypes); + if (parser.parseKeyword("to")) + return ::mlir::failure(); + + targetOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(targetRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::transform::TransformHandleTypeInterface type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + targetRawTypes[0] = type; + } + if (parser.resolveOperands(targetOperands, targetTypes, targetOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ApplyDeadCodeEliminationOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' ' << "to"; + _odsPrinter << ' '; + _odsPrinter << getTarget(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getTarget().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::transform::TransformHandleTypeInterface>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::ApplyDeadCodeEliminationOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::ApplyLoopInvariantCodeMotionOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ApplyLoopInvariantCodeMotionOpGenericAdaptorBase::ApplyLoopInvariantCodeMotionOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("transform.apply_licm", odsAttrs.getContext()); +} + +ApplyLoopInvariantCodeMotionOpGenericAdaptorBase::ApplyLoopInvariantCodeMotionOpGenericAdaptorBase(ApplyLoopInvariantCodeMotionOp op) : ApplyLoopInvariantCodeMotionOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ApplyLoopInvariantCodeMotionOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ApplyLoopInvariantCodeMotionOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +ApplyLoopInvariantCodeMotionOpAdaptor::ApplyLoopInvariantCodeMotionOpAdaptor(ApplyLoopInvariantCodeMotionOp op) : ApplyLoopInvariantCodeMotionOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ApplyLoopInvariantCodeMotionOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair ApplyLoopInvariantCodeMotionOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ApplyLoopInvariantCodeMotionOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> ApplyLoopInvariantCodeMotionOp::getTarget() { + return ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &ApplyLoopInvariantCodeMotionOp::getTargetMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair ApplyLoopInvariantCodeMotionOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ApplyLoopInvariantCodeMotionOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +void ApplyLoopInvariantCodeMotionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value target) { + odsState.addOperands(target); +} + +void ApplyLoopInvariantCodeMotionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target) { + odsState.addOperands(target); + assert(resultTypes.size() == 0u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ApplyLoopInvariantCodeMotionOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ApplyLoopInvariantCodeMotionOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ApplyLoopInvariantCodeMotionOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult ApplyLoopInvariantCodeMotionOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand targetRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> targetOperands(targetRawOperands); ::llvm::SMLoc targetOperandsLoc; + (void)targetOperandsLoc; + ::mlir::Type targetRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> targetTypes(targetRawTypes); + if (parser.parseKeyword("to")) + return ::mlir::failure(); + + targetOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(targetRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::transform::TransformHandleTypeInterface type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + targetRawTypes[0] = type; + } + if (parser.resolveOperands(targetOperands, targetTypes, targetOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ApplyLoopInvariantCodeMotionOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' ' << "to"; + _odsPrinter << ' '; + _odsPrinter << getTarget(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getTarget().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::transform::TransformHandleTypeInterface>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::ApplyLoopInvariantCodeMotionOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::ApplyPatternsOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ApplyPatternsOpGenericAdaptorBase::ApplyPatternsOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("transform.apply_patterns", odsAttrs.getContext()); +} + +ApplyPatternsOpGenericAdaptorBase::ApplyPatternsOpGenericAdaptorBase(ApplyPatternsOp op) : ApplyPatternsOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ApplyPatternsOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ApplyPatternsOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::UnitAttr ApplyPatternsOpGenericAdaptorBase::getApplyCseAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().apply_cse); + if (!attr) + attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); + return attr; +} + +bool ApplyPatternsOpGenericAdaptorBase::getApplyCse() { + auto attr = getApplyCseAttr(); + if (!attr) + return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; + return attr != nullptr; +} + +::mlir::Region &ApplyPatternsOpGenericAdaptorBase::getPatterns() { + return *odsRegions[0]; +} + +::mlir::RegionRange ApplyPatternsOpGenericAdaptorBase::getRegions() { + return odsRegions; +} + +} // namespace detail +ApplyPatternsOpAdaptor::ApplyPatternsOpAdaptor(ApplyPatternsOp op) : ApplyPatternsOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ApplyPatternsOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_apply_cse = getProperties().apply_cse; (void)tblgen_apply_cse; + + if (tblgen_apply_cse && !((::llvm::isa<::mlir::UnitAttr>(tblgen_apply_cse)))) + return emitError(loc, "'transform.apply_patterns' op ""attribute 'apply_cse' failed to satisfy constraint: unit attribute"); + return ::mlir::success(); +} + +std::pair ApplyPatternsOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ApplyPatternsOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> ApplyPatternsOp::getTarget() { + return ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &ApplyPatternsOp::getTargetMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair ApplyPatternsOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ApplyPatternsOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Region &ApplyPatternsOp::getPatterns() { + return (*this)->getRegion(0); +} + +::mlir::LogicalResult ApplyPatternsOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.apply_cse; + auto attr = dict.get("apply_cse"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for apply_cse in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `apply_cse` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ApplyPatternsOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.apply_cse; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("apply_cse", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ApplyPatternsOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.apply_cse.getAsOpaquePointer())); +} + +std::optional ApplyPatternsOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "apply_cse") + return prop.apply_cse; + return std::nullopt; +} + +void ApplyPatternsOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "apply_cse") { + prop.apply_cse = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ApplyPatternsOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.apply_cse) attrs.append("apply_cse", prop.apply_cse); +} + +::mlir::LogicalResult ApplyPatternsOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getApplyCseAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps2(attr, "apply_cse", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ApplyPatternsOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.apply_cse))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ApplyPatternsOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.apply_cse); +} + +::mlir::UnitAttr ApplyPatternsOp::getApplyCseAttr() { + return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().apply_cse); +} + +bool ApplyPatternsOp::getApplyCse() { + auto attr = getApplyCseAttr(); + if (!attr) + return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; + return attr != nullptr; +} + +void ApplyPatternsOp::setApplyCseAttr(::mlir::UnitAttr attr) { + (*this)->setAttr(getApplyCseAttrName(), attr); +} + +void ApplyPatternsOp::setApplyCse(bool attrValue) { + if (attrValue) + return (*this)->setAttr(getApplyCseAttrName(), ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr)); + (*this)->removeAttr(getApplyCseAttrName()); +} + +::mlir::Attribute ApplyPatternsOp::removeApplyCseAttr() { + auto &attr = getProperties().apply_cse; + attr = {}; + return attr; +} + +::mlir::LogicalResult ApplyPatternsOp::verifyInvariantsImpl() { + auto tblgen_apply_cse = getProperties().apply_cse; (void)tblgen_apply_cse; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps2(*this, tblgen_apply_cse, "apply_cse"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_TransformOps1(*this, region, "patterns", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ApplyPatternsOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult ApplyPatternsOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand targetRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> targetOperands(targetRawOperands); ::llvm::SMLoc targetOperandsLoc; + (void)targetOperandsLoc; + std::unique_ptr<::mlir::Region> patternsRegion = std::make_unique<::mlir::Region>(); + ::mlir::Type targetRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> targetTypes(targetRawTypes); + if (parser.parseKeyword("to")) + return ::mlir::failure(); + + targetOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(targetRawOperands[0])) + return ::mlir::failure(); + + if (parser.parseRegion(*patternsRegion)) + return ::mlir::failure(); + + if (patternsRegion->empty()) patternsRegion->emplaceBlock(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::transform::TransformHandleTypeInterface type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + targetRawTypes[0] = type; + } + result.addRegion(std::move(patternsRegion)); + if (parser.resolveOperands(targetOperands, targetTypes, targetOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ApplyPatternsOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' ' << "to"; + _odsPrinter << ' '; + _odsPrinter << getTarget(); + _odsPrinter << ' '; + _odsPrinter.printRegion(getPatterns()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getApplyCseAttr(); + if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) + elidedAttrs.push_back("apply_cse"); + } + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getTarget().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::transform::TransformHandleTypeInterface>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::ApplyPatternsOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::ApplyRegisteredPassOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ApplyRegisteredPassOpGenericAdaptorBase::ApplyRegisteredPassOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("transform.apply_registered_pass", odsAttrs.getContext()); +} + +ApplyRegisteredPassOpGenericAdaptorBase::ApplyRegisteredPassOpGenericAdaptorBase(ApplyRegisteredPassOp op) : ApplyRegisteredPassOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ApplyRegisteredPassOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ApplyRegisteredPassOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::StringAttr ApplyRegisteredPassOpGenericAdaptorBase::getPassNameAttr() { + auto attr = ::llvm::cast<::mlir::StringAttr>(getProperties().pass_name); + return attr; +} + +::llvm::StringRef ApplyRegisteredPassOpGenericAdaptorBase::getPassName() { + auto attr = getPassNameAttr(); + return attr.getValue(); +} + +::mlir::StringAttr ApplyRegisteredPassOpGenericAdaptorBase::getOptionsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::StringAttr>(getProperties().options); + return attr; +} + +::llvm::StringRef ApplyRegisteredPassOpGenericAdaptorBase::getOptions() { + auto attr = getOptionsAttr(); + return attr.getValue(); +} + +} // namespace detail +ApplyRegisteredPassOpAdaptor::ApplyRegisteredPassOpAdaptor(ApplyRegisteredPassOp op) : ApplyRegisteredPassOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ApplyRegisteredPassOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_options = getProperties().options; (void)tblgen_options; + auto tblgen_pass_name = getProperties().pass_name; (void)tblgen_pass_name; + if (!tblgen_pass_name) return emitError(loc, "'transform.apply_registered_pass' op ""requires attribute 'pass_name'"); + + if (tblgen_pass_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_pass_name)))) + return emitError(loc, "'transform.apply_registered_pass' op ""attribute 'pass_name' failed to satisfy constraint: string attribute"); + + if (tblgen_options && !((::llvm::isa<::mlir::StringAttr>(tblgen_options)))) + return emitError(loc, "'transform.apply_registered_pass' op ""attribute 'options' failed to satisfy constraint: string attribute"); + return ::mlir::success(); +} + +std::pair ApplyRegisteredPassOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ApplyRegisteredPassOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> ApplyRegisteredPassOp::getTarget() { + return ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &ApplyRegisteredPassOp::getTargetMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair ApplyRegisteredPassOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ApplyRegisteredPassOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> ApplyRegisteredPassOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult ApplyRegisteredPassOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.options; + auto attr = dict.get("options"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for options in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `options` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.pass_name; + auto attr = dict.get("pass_name"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for pass_name in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `pass_name` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ApplyRegisteredPassOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.options; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("options", + propStorage)); + } + + { + const auto &propStorage = prop.pass_name; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("pass_name", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ApplyRegisteredPassOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.options.getAsOpaquePointer()), + llvm::hash_value(prop.pass_name.getAsOpaquePointer())); +} + +std::optional ApplyRegisteredPassOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "options") + return prop.options; + + if (name == "pass_name") + return prop.pass_name; + return std::nullopt; +} + +void ApplyRegisteredPassOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "options") { + prop.options = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "pass_name") { + prop.pass_name = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ApplyRegisteredPassOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.options) attrs.append("options", prop.options); + + if (prop.pass_name) attrs.append("pass_name", prop.pass_name); +} + +::mlir::LogicalResult ApplyRegisteredPassOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getOptionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps0(attr, "options", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getPassNameAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps0(attr, "pass_name", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ApplyRegisteredPassOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.options))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.pass_name))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ApplyRegisteredPassOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.options); + writer.writeAttribute(prop.pass_name); +} + +::mlir::StringAttr ApplyRegisteredPassOp::getPassNameAttr() { + return ::llvm::cast<::mlir::StringAttr>(getProperties().pass_name); +} + +::llvm::StringRef ApplyRegisteredPassOp::getPassName() { + auto attr = getPassNameAttr(); + return attr.getValue(); +} + +::mlir::StringAttr ApplyRegisteredPassOp::getOptionsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::StringAttr>(getProperties().options); +} + +::llvm::StringRef ApplyRegisteredPassOp::getOptions() { + auto attr = getOptionsAttr(); + return attr.getValue(); +} + +void ApplyRegisteredPassOp::setPassNameAttr(::mlir::StringAttr attr) { + (*this)->setAttr(getPassNameAttrName(), attr); +} + +void ApplyRegisteredPassOp::setPassName(::llvm::StringRef attrValue) { + (*this)->setAttr(getPassNameAttrName(), ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue)); +} + +void ApplyRegisteredPassOp::setOptionsAttr(::mlir::StringAttr attr) { + (*this)->setAttr(getOptionsAttrName(), attr); +} + +void ApplyRegisteredPassOp::setOptions(::llvm::StringRef attrValue) { + (*this)->setAttr(getOptionsAttrName(), ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue)); +} + +void ApplyRegisteredPassOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value target, ::mlir::StringAttr pass_name, ::mlir::StringAttr options) { + odsState.addOperands(target); + odsState.getOrAddProperties().pass_name = pass_name; + if (options) { + odsState.getOrAddProperties().options = options; + } + odsState.addTypes(result); +} + +void ApplyRegisteredPassOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target, ::mlir::StringAttr pass_name, ::mlir::StringAttr options) { + odsState.addOperands(target); + odsState.getOrAddProperties().pass_name = pass_name; + if (options) { + odsState.getOrAddProperties().options = options; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ApplyRegisteredPassOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value target, ::llvm::StringRef pass_name, ::llvm::StringRef options) { + odsState.addOperands(target); + odsState.getOrAddProperties().pass_name = odsBuilder.getStringAttr(pass_name); + odsState.getOrAddProperties().options = odsBuilder.getStringAttr(options); + odsState.addTypes(result); +} + +void ApplyRegisteredPassOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target, ::llvm::StringRef pass_name, ::llvm::StringRef options) { + odsState.addOperands(target); + odsState.getOrAddProperties().pass_name = odsBuilder.getStringAttr(pass_name); + odsState.getOrAddProperties().options = odsBuilder.getStringAttr(options); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ApplyRegisteredPassOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ApplyRegisteredPassOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { + ::mlir::Builder odsBuilder(opName.getContext()); + if (!properties.options) + properties.options = odsBuilder.getStringAttr(""); +} + +::mlir::LogicalResult ApplyRegisteredPassOp::verifyInvariantsImpl() { + auto tblgen_options = getProperties().options; (void)tblgen_options; + auto tblgen_pass_name = getProperties().pass_name; (void)tblgen_pass_name; + if (!tblgen_pass_name) return emitOpError("requires attribute 'pass_name'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps0(*this, tblgen_pass_name, "pass_name"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps0(*this, tblgen_options, "options"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps0(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ApplyRegisteredPassOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult ApplyRegisteredPassOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::StringAttr pass_nameAttr; + ::mlir::OpAsmParser::UnresolvedOperand targetRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> targetOperands(targetRawOperands); ::llvm::SMLoc targetOperandsLoc; + (void)targetOperandsLoc; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + + if (parser.parseCustomAttributeWithFallback(pass_nameAttr, parser.getBuilder().getType<::mlir::NoneType>())) { + return ::mlir::failure(); + } + if (pass_nameAttr) result.getOrAddProperties().pass_name = pass_nameAttr; + if (parser.parseKeyword("to")) + return ::mlir::failure(); + + targetOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(targetRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(targetOperands, allOperandTypes, parser.getNameLoc(), result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ApplyRegisteredPassOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter.printAttributeWithoutType(getPassNameAttr()); + _odsPrinter << ' ' << "to"; + _odsPrinter << ' '; + _odsPrinter << getTarget(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("pass_name"); + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getOptionsAttr(); + if(attr && (attr == odsBuilder.getStringAttr(""))) + elidedAttrs.push_back("options"); + } + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::ApplyRegisteredPassOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::ApplyToLLVMConversionPatternsOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ApplyToLLVMConversionPatternsOpGenericAdaptorBase::ApplyToLLVMConversionPatternsOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("transform.apply_conversion_patterns.dialect_to_llvm", odsAttrs.getContext()); +} + +ApplyToLLVMConversionPatternsOpGenericAdaptorBase::ApplyToLLVMConversionPatternsOpGenericAdaptorBase(ApplyToLLVMConversionPatternsOp op) : ApplyToLLVMConversionPatternsOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ApplyToLLVMConversionPatternsOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ApplyToLLVMConversionPatternsOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::StringAttr ApplyToLLVMConversionPatternsOpGenericAdaptorBase::getDialectNameAttr() { + auto attr = ::llvm::cast<::mlir::StringAttr>(getProperties().dialect_name); + return attr; +} + +::llvm::StringRef ApplyToLLVMConversionPatternsOpGenericAdaptorBase::getDialectName() { + auto attr = getDialectNameAttr(); + return attr.getValue(); +} + +} // namespace detail +ApplyToLLVMConversionPatternsOpAdaptor::ApplyToLLVMConversionPatternsOpAdaptor(ApplyToLLVMConversionPatternsOp op) : ApplyToLLVMConversionPatternsOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ApplyToLLVMConversionPatternsOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_dialect_name = getProperties().dialect_name; (void)tblgen_dialect_name; + if (!tblgen_dialect_name) return emitError(loc, "'transform.apply_conversion_patterns.dialect_to_llvm' op ""requires attribute 'dialect_name'"); + + if (tblgen_dialect_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_dialect_name)))) + return emitError(loc, "'transform.apply_conversion_patterns.dialect_to_llvm' op ""attribute 'dialect_name' failed to satisfy constraint: string attribute"); + return ::mlir::success(); +} + +std::pair ApplyToLLVMConversionPatternsOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ApplyToLLVMConversionPatternsOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +std::pair ApplyToLLVMConversionPatternsOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ApplyToLLVMConversionPatternsOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::LogicalResult ApplyToLLVMConversionPatternsOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.dialect_name; + auto attr = dict.get("dialect_name"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for dialect_name in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `dialect_name` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ApplyToLLVMConversionPatternsOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.dialect_name; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("dialect_name", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ApplyToLLVMConversionPatternsOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.dialect_name.getAsOpaquePointer())); +} + +std::optional ApplyToLLVMConversionPatternsOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "dialect_name") + return prop.dialect_name; + return std::nullopt; +} + +void ApplyToLLVMConversionPatternsOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "dialect_name") { + prop.dialect_name = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ApplyToLLVMConversionPatternsOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.dialect_name) attrs.append("dialect_name", prop.dialect_name); +} + +::mlir::LogicalResult ApplyToLLVMConversionPatternsOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getDialectNameAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps0(attr, "dialect_name", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ApplyToLLVMConversionPatternsOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.dialect_name))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ApplyToLLVMConversionPatternsOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.dialect_name); +} + +::mlir::StringAttr ApplyToLLVMConversionPatternsOp::getDialectNameAttr() { + return ::llvm::cast<::mlir::StringAttr>(getProperties().dialect_name); +} + +::llvm::StringRef ApplyToLLVMConversionPatternsOp::getDialectName() { + auto attr = getDialectNameAttr(); + return attr.getValue(); +} + +void ApplyToLLVMConversionPatternsOp::setDialectNameAttr(::mlir::StringAttr attr) { + (*this)->setAttr(getDialectNameAttrName(), attr); +} + +void ApplyToLLVMConversionPatternsOp::setDialectName(::llvm::StringRef attrValue) { + (*this)->setAttr(getDialectNameAttrName(), ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue)); +} + +void ApplyToLLVMConversionPatternsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::StringAttr dialect_name) { + odsState.getOrAddProperties().dialect_name = dialect_name; +} + +void ApplyToLLVMConversionPatternsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::StringAttr dialect_name) { + odsState.getOrAddProperties().dialect_name = dialect_name; + assert(resultTypes.size() == 0u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ApplyToLLVMConversionPatternsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llvm::StringRef dialect_name) { + odsState.getOrAddProperties().dialect_name = odsBuilder.getStringAttr(dialect_name); +} + +void ApplyToLLVMConversionPatternsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::llvm::StringRef dialect_name) { + odsState.getOrAddProperties().dialect_name = odsBuilder.getStringAttr(dialect_name); + assert(resultTypes.size() == 0u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ApplyToLLVMConversionPatternsOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ApplyToLLVMConversionPatternsOp::verifyInvariantsImpl() { + auto tblgen_dialect_name = getProperties().dialect_name; (void)tblgen_dialect_name; + if (!tblgen_dialect_name) return emitOpError("requires attribute 'dialect_name'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps0(*this, tblgen_dialect_name, "dialect_name"))) + return ::mlir::failure(); + return ::mlir::success(); +} + +::mlir::LogicalResult ApplyToLLVMConversionPatternsOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult ApplyToLLVMConversionPatternsOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::StringAttr dialect_nameAttr; + + if (parser.parseCustomAttributeWithFallback(dialect_nameAttr, parser.getBuilder().getType<::mlir::NoneType>())) { + return ::mlir::failure(); + } + if (dialect_nameAttr) result.getOrAddProperties().dialect_name = dialect_nameAttr; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +void ApplyToLLVMConversionPatternsOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter.printAttributeWithoutType(getDialectNameAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("dialect_name"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::ApplyToLLVMConversionPatternsOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::CastOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CastOpGenericAdaptorBase::CastOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("transform.cast", odsAttrs.getContext()); +} + +CastOpGenericAdaptorBase::CastOpGenericAdaptorBase(CastOp op) : CastOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair CastOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr CastOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +CastOpAdaptor::CastOpAdaptor(CastOp op) : CastOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult CastOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair CastOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range CastOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> CastOp::getInput() { + return ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &CastOp::getInputMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair CastOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range CastOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> CastOp::getOutput() { + return ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface>>(*getODSResults(0).begin()); +} + +void CastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input) { + odsState.addOperands(input); + odsState.addTypes(output); +} + +void CastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input) { + odsState.addOperands(input); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void CastOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult CastOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps0(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult CastOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult CastOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand inputRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> inputOperands(inputRawOperands); ::llvm::SMLoc inputOperandsLoc; + (void)inputOperandsLoc; + ::mlir::Type inputRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> inputTypes(inputRawTypes); + ::mlir::Type outputRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> outputTypes(outputRawTypes); + + inputOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(inputRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::transform::TransformHandleTypeInterface type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + inputRawTypes[0] = type; + } + if (parser.parseKeyword("to")) + return ::mlir::failure(); + + { + ::mlir::transform::TransformHandleTypeInterface type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + outputRawTypes[0] = type; + } + result.addTypes(outputTypes); + if (parser.resolveOperands(inputOperands, inputTypes, inputOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CastOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getInput(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getInput().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::transform::TransformHandleTypeInterface>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "to"; + _odsPrinter << ' '; + { + auto type = getOutput().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::transform::TransformHandleTypeInterface>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::CastOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::ForeachMatchOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ForeachMatchOpGenericAdaptorBase::ForeachMatchOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("transform.foreach_match", odsAttrs.getContext()); +} + +ForeachMatchOpGenericAdaptorBase::ForeachMatchOpGenericAdaptorBase(ForeachMatchOp op) : ForeachMatchOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ForeachMatchOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ForeachMatchOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::ArrayAttr ForeachMatchOpGenericAdaptorBase::getMatchersAttr() { + auto attr = ::llvm::cast<::mlir::ArrayAttr>(getProperties().matchers); + return attr; +} + +::mlir::ArrayAttr ForeachMatchOpGenericAdaptorBase::getMatchers() { + auto attr = getMatchersAttr(); + return attr; +} + +::mlir::ArrayAttr ForeachMatchOpGenericAdaptorBase::getActionsAttr() { + auto attr = ::llvm::cast<::mlir::ArrayAttr>(getProperties().actions); + return attr; +} + +::mlir::ArrayAttr ForeachMatchOpGenericAdaptorBase::getActions() { + auto attr = getActionsAttr(); + return attr; +} + +} // namespace detail +ForeachMatchOpAdaptor::ForeachMatchOpAdaptor(ForeachMatchOp op) : ForeachMatchOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ForeachMatchOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_actions = getProperties().actions; (void)tblgen_actions; + if (!tblgen_actions) return emitError(loc, "'transform.foreach_match' op ""requires attribute 'actions'"); + auto tblgen_matchers = getProperties().matchers; (void)tblgen_matchers; + if (!tblgen_matchers) return emitError(loc, "'transform.foreach_match' op ""requires attribute 'matchers'"); + + if (tblgen_matchers && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_matchers))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_matchers), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::SymbolRefAttr>(attr))); })))) + return emitError(loc, "'transform.foreach_match' op ""attribute 'matchers' failed to satisfy constraint: symbol ref array attribute"); + + if (tblgen_actions && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_actions))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_actions), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::SymbolRefAttr>(attr))); })))) + return emitError(loc, "'transform.foreach_match' op ""attribute 'actions' failed to satisfy constraint: symbol ref array attribute"); + return ::mlir::success(); +} + +std::pair ForeachMatchOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ForeachMatchOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> ForeachMatchOp::getRoot() { + return ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &ForeachMatchOp::getRootMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair ForeachMatchOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ForeachMatchOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> ForeachMatchOp::getUpdated() { + return ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult ForeachMatchOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.actions; + auto attr = dict.get("actions"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for actions in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `actions` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.matchers; + auto attr = dict.get("matchers"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for matchers in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `matchers` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ForeachMatchOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.actions; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("actions", + propStorage)); + } + + { + const auto &propStorage = prop.matchers; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("matchers", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ForeachMatchOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.actions.getAsOpaquePointer()), + llvm::hash_value(prop.matchers.getAsOpaquePointer())); +} + +std::optional ForeachMatchOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "actions") + return prop.actions; + + if (name == "matchers") + return prop.matchers; + return std::nullopt; +} + +void ForeachMatchOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "actions") { + prop.actions = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "matchers") { + prop.matchers = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ForeachMatchOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.actions) attrs.append("actions", prop.actions); + + if (prop.matchers) attrs.append("matchers", prop.matchers); +} + +::mlir::LogicalResult ForeachMatchOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getActionsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps3(attr, "actions", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getMatchersAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps3(attr, "matchers", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ForeachMatchOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.actions))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.matchers))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ForeachMatchOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.actions); + writer.writeAttribute(prop.matchers); +} + +::mlir::ArrayAttr ForeachMatchOp::getMatchersAttr() { + return ::llvm::cast<::mlir::ArrayAttr>(getProperties().matchers); +} + +::mlir::ArrayAttr ForeachMatchOp::getMatchers() { + auto attr = getMatchersAttr(); + return attr; +} + +::mlir::ArrayAttr ForeachMatchOp::getActionsAttr() { + return ::llvm::cast<::mlir::ArrayAttr>(getProperties().actions); +} + +::mlir::ArrayAttr ForeachMatchOp::getActions() { + auto attr = getActionsAttr(); + return attr; +} + +void ForeachMatchOp::setMatchersAttr(::mlir::ArrayAttr attr) { + (*this)->setAttr(getMatchersAttrName(), attr); +} + +void ForeachMatchOp::setActionsAttr(::mlir::ArrayAttr attr) { + (*this)->setAttr(getActionsAttrName(), attr); +} + +void ForeachMatchOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type updated, ::mlir::Value root, ::mlir::ArrayAttr matchers, ::mlir::ArrayAttr actions) { + odsState.addOperands(root); + odsState.getOrAddProperties().matchers = matchers; + odsState.getOrAddProperties().actions = actions; + odsState.addTypes(updated); +} + +void ForeachMatchOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value root, ::mlir::ArrayAttr matchers, ::mlir::ArrayAttr actions) { + odsState.addOperands(root); + odsState.getOrAddProperties().matchers = matchers; + odsState.getOrAddProperties().actions = actions; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ForeachMatchOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ForeachMatchOp::verifyInvariantsImpl() { + auto tblgen_actions = getProperties().actions; (void)tblgen_actions; + if (!tblgen_actions) return emitOpError("requires attribute 'actions'"); + auto tblgen_matchers = getProperties().matchers; (void)tblgen_matchers; + if (!tblgen_matchers) return emitOpError("requires attribute 'matchers'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps3(*this, tblgen_matchers, "matchers"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps3(*this, tblgen_actions, "actions"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps0(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ForeachMatchOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult ForeachMatchOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand rootRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rootOperands(rootRawOperands); ::llvm::SMLoc rootOperandsLoc; + (void)rootOperandsLoc; + ::mlir::ArrayAttr matchersAttr; + ::mlir::ArrayAttr actionsAttr; + ::llvm::ArrayRef<::mlir::Type> rootTypes; + ::llvm::ArrayRef<::mlir::Type> updatedTypes; + if (parser.parseKeyword("in")) + return ::mlir::failure(); + + rootOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rootRawOperands[0])) + return ::mlir::failure(); + { + auto odsResult = parseForeachMatchSymbols(parser, matchersAttr, actionsAttr); + if (odsResult) return ::mlir::failure(); + result.getOrAddProperties().matchers = matchersAttr; + result.getOrAddProperties().actions = actionsAttr; + } + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType root__updated_functionType; + if (parser.parseType(root__updated_functionType)) + return ::mlir::failure(); + rootTypes = root__updated_functionType.getInputs(); + updatedTypes = root__updated_functionType.getResults(); + result.addTypes(updatedTypes); + if (parser.resolveOperands(rootOperands, rootTypes, rootOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ForeachMatchOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' ' << "in"; + _odsPrinter << ' '; + _odsPrinter << getRoot(); + _odsPrinter << ' '; + printForeachMatchSymbols(_odsPrinter, *this, getMatchersAttr(), getActionsAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("matchers"); + elidedAttrs.push_back("actions"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(::llvm::ArrayRef<::mlir::Type>(getRoot().getType()), ::llvm::ArrayRef<::mlir::Type>(getUpdated().getType())); +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::ForeachMatchOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::ForeachOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ForeachOpGenericAdaptorBase::ForeachOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("transform.foreach", odsAttrs.getContext()); +} + +ForeachOpGenericAdaptorBase::ForeachOpGenericAdaptorBase(ForeachOp op) : ForeachOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ForeachOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ForeachOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::Region &ForeachOpGenericAdaptorBase::getBody() { + return *odsRegions[0]; +} + +::mlir::RegionRange ForeachOpGenericAdaptorBase::getRegions() { + return odsRegions; +} + +} // namespace detail +ForeachOpAdaptor::ForeachOpAdaptor(ForeachOp op) : ForeachOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ForeachOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair ForeachOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ForeachOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> ForeachOp::getTarget() { + return ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &ForeachOp::getTargetMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair ForeachOp::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::result_range ForeachOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::result_range ForeachOp::getResults() { + return getODSResults(0); +} + +::mlir::Region &ForeachOp::getBody() { + return (*this)->getRegion(0); +} + +void ForeachOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::Value target) { + odsState.addOperands(target); + (void)odsState.addRegion(); + odsState.addTypes(results); +} + +void ForeachOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ForeachOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps0(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_TransformOps0(*this, region, "body", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ForeachOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult ForeachOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand targetRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> targetOperands(targetRawOperands); ::llvm::SMLoc targetOperandsLoc; + (void)targetOperandsLoc; + ::mlir::Type targetRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> targetTypes(targetRawTypes); + ::llvm::SmallVector<::mlir::Type, 1> resultsTypes; + std::unique_ptr<::mlir::Region> bodyRegion = std::make_unique<::mlir::Region>(); + + targetOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(targetRawOperands[0])) + return ::mlir::failure(); + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::transform::TransformHandleTypeInterface type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + targetRawTypes[0] = type; + } + if (::mlir::succeeded(parser.parseOptionalArrow())) { + + if (parser.parseTypeList(resultsTypes)) + return ::mlir::failure(); + } + + if (parser.parseRegion(*bodyRegion)) + return ::mlir::failure(); + + ensureTerminator(*bodyRegion, parser.getBuilder(), result.location); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + result.addRegion(std::move(bodyRegion)); + result.addTypes(resultsTypes); + if (parser.resolveOperands(targetOperands, targetTypes, targetOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ForeachOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getTarget(); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getTarget().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::transform::TransformHandleTypeInterface>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + if (!getResults().empty()) { + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + _odsPrinter << getResults().getTypes(); + } + _odsPrinter << ' '; + + { + bool printTerminator = true; + if (auto *term = getBody().empty() ? nullptr : getBody().begin()->getTerminator()) { + printTerminator = !term->getAttrDictionary().empty() || + term->getNumOperands() != 0 || + term->getNumResults() != 0; + } + _odsPrinter.printRegion(getBody(), /*printEntryBlockArgs=*/true, + /*printBlockTerminators=*/printTerminator); + } + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::ForeachOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::GetConsumersOfResult definitions +//===----------------------------------------------------------------------===// + +namespace detail { +GetConsumersOfResultGenericAdaptorBase::GetConsumersOfResultGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("transform.get_consumers_of_result", odsAttrs.getContext()); +} + +GetConsumersOfResultGenericAdaptorBase::GetConsumersOfResultGenericAdaptorBase(GetConsumersOfResult op) : GetConsumersOfResultGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair GetConsumersOfResultGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr GetConsumersOfResultGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::IntegerAttr GetConsumersOfResultGenericAdaptorBase::getResultNumberAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().result_number); + return attr; +} + +uint64_t GetConsumersOfResultGenericAdaptorBase::getResultNumber() { + auto attr = getResultNumberAttr(); + return attr.getValue().getZExtValue(); +} + +} // namespace detail +GetConsumersOfResultAdaptor::GetConsumersOfResultAdaptor(GetConsumersOfResult op) : GetConsumersOfResultGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult GetConsumersOfResultAdaptor::verify(::mlir::Location loc) { + auto tblgen_result_number = getProperties().result_number; (void)tblgen_result_number; + if (!tblgen_result_number) return emitError(loc, "'transform.get_consumers_of_result' op ""requires attribute 'result_number'"); + + if (tblgen_result_number && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_result_number))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_result_number).getType().isSignlessInteger(64))))) + return emitError(loc, "'transform.get_consumers_of_result' op ""attribute 'result_number' failed to satisfy constraint: 64-bit signless integer attribute"); + return ::mlir::success(); +} + +std::pair GetConsumersOfResult::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range GetConsumersOfResult::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> GetConsumersOfResult::getTarget() { + return ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &GetConsumersOfResult::getTargetMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair GetConsumersOfResult::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range GetConsumersOfResult::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> GetConsumersOfResult::getConsumers() { + return ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult GetConsumersOfResult::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.result_number; + auto attr = dict.get("result_number"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for result_number in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `result_number` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute GetConsumersOfResult::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.result_number; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("result_number", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code GetConsumersOfResult::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.result_number.getAsOpaquePointer())); +} + +std::optional GetConsumersOfResult::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "result_number") + return prop.result_number; + return std::nullopt; +} + +void GetConsumersOfResult::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "result_number") { + prop.result_number = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void GetConsumersOfResult::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.result_number) attrs.append("result_number", prop.result_number); +} + +::mlir::LogicalResult GetConsumersOfResult::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getResultNumberAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps4(attr, "result_number", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult GetConsumersOfResult::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.result_number))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void GetConsumersOfResult::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.result_number); +} + +::mlir::IntegerAttr GetConsumersOfResult::getResultNumberAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().result_number); +} + +uint64_t GetConsumersOfResult::getResultNumber() { + auto attr = getResultNumberAttr(); + return attr.getValue().getZExtValue(); +} + +void GetConsumersOfResult::setResultNumberAttr(::mlir::IntegerAttr attr) { + (*this)->setAttr(getResultNumberAttrName(), attr); +} + +void GetConsumersOfResult::setResultNumber(uint64_t attrValue) { + (*this)->setAttr(getResultNumberAttrName(), ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), attrValue)); +} + +void GetConsumersOfResult::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type consumers, ::mlir::Value target, ::mlir::IntegerAttr result_number) { + odsState.addOperands(target); + odsState.getOrAddProperties().result_number = result_number; + odsState.addTypes(consumers); +} + +void GetConsumersOfResult::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target, ::mlir::IntegerAttr result_number) { + odsState.addOperands(target); + odsState.getOrAddProperties().result_number = result_number; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void GetConsumersOfResult::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type consumers, ::mlir::Value target, uint64_t result_number) { + odsState.addOperands(target); + odsState.getOrAddProperties().result_number = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), result_number); + odsState.addTypes(consumers); +} + +void GetConsumersOfResult::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target, uint64_t result_number) { + odsState.addOperands(target); + odsState.getOrAddProperties().result_number = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), result_number); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void GetConsumersOfResult::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult GetConsumersOfResult::verifyInvariantsImpl() { + auto tblgen_result_number = getProperties().result_number; (void)tblgen_result_number; + if (!tblgen_result_number) return emitOpError("requires attribute 'result_number'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps4(*this, tblgen_result_number, "result_number"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps0(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult GetConsumersOfResult::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult GetConsumersOfResult::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand targetRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> targetOperands(targetRawOperands); ::llvm::SMLoc targetOperandsLoc; + (void)targetOperandsLoc; + ::mlir::IntegerAttr result_numberAttr; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + + targetOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(targetRawOperands[0])) + return ::mlir::failure(); + if (parser.parseLSquare()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(result_numberAttr, parser.getBuilder().getIntegerType(64))) { + return ::mlir::failure(); + } + if (result_numberAttr) result.getOrAddProperties().result_number = result_numberAttr; + if (parser.parseRSquare()) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(targetOperands, allOperandTypes, parser.getNameLoc(), result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void GetConsumersOfResult::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getTarget(); + _odsPrinter << "["; + _odsPrinter.printAttributeWithoutType(getResultNumberAttr()); + _odsPrinter << "]"; + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("result_number"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::GetConsumersOfResult) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::GetDefiningOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +GetDefiningOpGenericAdaptorBase::GetDefiningOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("transform.get_defining_op", odsAttrs.getContext()); +} + +GetDefiningOpGenericAdaptorBase::GetDefiningOpGenericAdaptorBase(GetDefiningOp op) : GetDefiningOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair GetDefiningOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr GetDefiningOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +GetDefiningOpAdaptor::GetDefiningOpAdaptor(GetDefiningOp op) : GetDefiningOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult GetDefiningOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair GetDefiningOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range GetDefiningOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformValueHandleTypeInterface> GetDefiningOp::getTarget() { + return ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformValueHandleTypeInterface>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &GetDefiningOp::getTargetMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair GetDefiningOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range GetDefiningOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> GetDefiningOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface>>(*getODSResults(0).begin()); +} + +void GetDefiningOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value target) { + odsState.addOperands(target); + odsState.addTypes(result); +} + +void GetDefiningOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target) { + odsState.addOperands(target); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void GetDefiningOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult GetDefiningOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps0(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult GetDefiningOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult GetDefiningOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand targetRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> targetOperands(targetRawOperands); ::llvm::SMLoc targetOperandsLoc; + (void)targetOperandsLoc; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + + targetOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(targetRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(targetOperands, allOperandTypes, parser.getNameLoc(), result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void GetDefiningOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getTarget(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::GetDefiningOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::GetParentOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +GetParentOpGenericAdaptorBase::GetParentOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("transform.get_parent_op", odsAttrs.getContext()); +} + +GetParentOpGenericAdaptorBase::GetParentOpGenericAdaptorBase(GetParentOp op) : GetParentOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair GetParentOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr GetParentOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::UnitAttr GetParentOpGenericAdaptorBase::getIsolatedFromAboveAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().isolated_from_above); + if (!attr) + attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); + return attr; +} + +bool GetParentOpGenericAdaptorBase::getIsolatedFromAbove() { + auto attr = getIsolatedFromAboveAttr(); + if (!attr) + return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; + return attr != nullptr; +} + +::mlir::UnitAttr GetParentOpGenericAdaptorBase::getAllowEmptyResultsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().allow_empty_results); + if (!attr) + attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); + return attr; +} + +bool GetParentOpGenericAdaptorBase::getAllowEmptyResults() { + auto attr = getAllowEmptyResultsAttr(); + if (!attr) + return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; + return attr != nullptr; +} + +::mlir::StringAttr GetParentOpGenericAdaptorBase::getOpNameAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::StringAttr>(getProperties().op_name); + return attr; +} + +::std::optional< ::llvm::StringRef > GetParentOpGenericAdaptorBase::getOpName() { + auto attr = getOpNameAttr(); + return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); +} + +::mlir::UnitAttr GetParentOpGenericAdaptorBase::getDeduplicateAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().deduplicate); + if (!attr) + attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); + return attr; +} + +bool GetParentOpGenericAdaptorBase::getDeduplicate() { + auto attr = getDeduplicateAttr(); + if (!attr) + return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; + return attr != nullptr; +} + +} // namespace detail +GetParentOpAdaptor::GetParentOpAdaptor(GetParentOp op) : GetParentOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult GetParentOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_allow_empty_results = getProperties().allow_empty_results; (void)tblgen_allow_empty_results; + auto tblgen_deduplicate = getProperties().deduplicate; (void)tblgen_deduplicate; + auto tblgen_isolated_from_above = getProperties().isolated_from_above; (void)tblgen_isolated_from_above; + auto tblgen_op_name = getProperties().op_name; (void)tblgen_op_name; + + if (tblgen_isolated_from_above && !((::llvm::isa<::mlir::UnitAttr>(tblgen_isolated_from_above)))) + return emitError(loc, "'transform.get_parent_op' op ""attribute 'isolated_from_above' failed to satisfy constraint: unit attribute"); + + if (tblgen_allow_empty_results && !((::llvm::isa<::mlir::UnitAttr>(tblgen_allow_empty_results)))) + return emitError(loc, "'transform.get_parent_op' op ""attribute 'allow_empty_results' failed to satisfy constraint: unit attribute"); + + if (tblgen_op_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_op_name)))) + return emitError(loc, "'transform.get_parent_op' op ""attribute 'op_name' failed to satisfy constraint: string attribute"); + + if (tblgen_deduplicate && !((::llvm::isa<::mlir::UnitAttr>(tblgen_deduplicate)))) + return emitError(loc, "'transform.get_parent_op' op ""attribute 'deduplicate' failed to satisfy constraint: unit attribute"); + return ::mlir::success(); +} + +std::pair GetParentOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range GetParentOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> GetParentOp::getTarget() { + return ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &GetParentOp::getTargetMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair GetParentOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range GetParentOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> GetParentOp::getParent() { + return ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult GetParentOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.allow_empty_results; + auto attr = dict.get("allow_empty_results"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for allow_empty_results in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `allow_empty_results` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.deduplicate; + auto attr = dict.get("deduplicate"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for deduplicate in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `deduplicate` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.isolated_from_above; + auto attr = dict.get("isolated_from_above"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for isolated_from_above in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `isolated_from_above` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.op_name; + auto attr = dict.get("op_name"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for op_name in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `op_name` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute GetParentOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.allow_empty_results; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("allow_empty_results", + propStorage)); + } + + { + const auto &propStorage = prop.deduplicate; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("deduplicate", + propStorage)); + } + + { + const auto &propStorage = prop.isolated_from_above; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("isolated_from_above", + propStorage)); + } + + { + const auto &propStorage = prop.op_name; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("op_name", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code GetParentOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.allow_empty_results.getAsOpaquePointer()), + llvm::hash_value(prop.deduplicate.getAsOpaquePointer()), + llvm::hash_value(prop.isolated_from_above.getAsOpaquePointer()), + llvm::hash_value(prop.op_name.getAsOpaquePointer())); +} + +std::optional GetParentOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "allow_empty_results") + return prop.allow_empty_results; + + if (name == "deduplicate") + return prop.deduplicate; + + if (name == "isolated_from_above") + return prop.isolated_from_above; + + if (name == "op_name") + return prop.op_name; + return std::nullopt; +} + +void GetParentOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "allow_empty_results") { + prop.allow_empty_results = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "deduplicate") { + prop.deduplicate = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "isolated_from_above") { + prop.isolated_from_above = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "op_name") { + prop.op_name = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void GetParentOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.allow_empty_results) attrs.append("allow_empty_results", prop.allow_empty_results); + + if (prop.deduplicate) attrs.append("deduplicate", prop.deduplicate); + + if (prop.isolated_from_above) attrs.append("isolated_from_above", prop.isolated_from_above); + + if (prop.op_name) attrs.append("op_name", prop.op_name); +} + +::mlir::LogicalResult GetParentOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getAllowEmptyResultsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps2(attr, "allow_empty_results", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getDeduplicateAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps2(attr, "deduplicate", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getIsolatedFromAboveAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps2(attr, "isolated_from_above", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getOpNameAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps0(attr, "op_name", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult GetParentOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.allow_empty_results))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.deduplicate))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.isolated_from_above))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.op_name))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void GetParentOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.allow_empty_results); + + writer.writeOptionalAttribute(prop.deduplicate); + + writer.writeOptionalAttribute(prop.isolated_from_above); + + writer.writeOptionalAttribute(prop.op_name); +} + +::mlir::UnitAttr GetParentOp::getIsolatedFromAboveAttr() { + return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().isolated_from_above); +} + +bool GetParentOp::getIsolatedFromAbove() { + auto attr = getIsolatedFromAboveAttr(); + if (!attr) + return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; + return attr != nullptr; +} + +::mlir::UnitAttr GetParentOp::getAllowEmptyResultsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().allow_empty_results); +} + +bool GetParentOp::getAllowEmptyResults() { + auto attr = getAllowEmptyResultsAttr(); + if (!attr) + return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; + return attr != nullptr; +} + +::mlir::StringAttr GetParentOp::getOpNameAttr() { + return ::llvm::dyn_cast_or_null<::mlir::StringAttr>(getProperties().op_name); +} + +::std::optional< ::llvm::StringRef > GetParentOp::getOpName() { + auto attr = getOpNameAttr(); + return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); +} + +::mlir::UnitAttr GetParentOp::getDeduplicateAttr() { + return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().deduplicate); +} + +bool GetParentOp::getDeduplicate() { + auto attr = getDeduplicateAttr(); + if (!attr) + return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; + return attr != nullptr; +} + +void GetParentOp::setIsolatedFromAboveAttr(::mlir::UnitAttr attr) { + (*this)->setAttr(getIsolatedFromAboveAttrName(), attr); +} + +void GetParentOp::setIsolatedFromAbove(bool attrValue) { + if (attrValue) + return (*this)->setAttr(getIsolatedFromAboveAttrName(), ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr)); + (*this)->removeAttr(getIsolatedFromAboveAttrName()); +} + +void GetParentOp::setAllowEmptyResultsAttr(::mlir::UnitAttr attr) { + (*this)->setAttr(getAllowEmptyResultsAttrName(), attr); +} + +void GetParentOp::setAllowEmptyResults(bool attrValue) { + if (attrValue) + return (*this)->setAttr(getAllowEmptyResultsAttrName(), ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr)); + (*this)->removeAttr(getAllowEmptyResultsAttrName()); +} + +void GetParentOp::setOpNameAttr(::mlir::StringAttr attr) { + (*this)->setAttr(getOpNameAttrName(), attr); +} + +void GetParentOp::setOpName(::std::optional<::llvm::StringRef> attrValue) { + if (attrValue) + return (*this)->setAttr(getOpNameAttrName(), ::mlir::Builder((*this)->getContext()).getStringAttr(*attrValue)); + (*this)->removeAttr(getOpNameAttrName()); +} + +void GetParentOp::setDeduplicateAttr(::mlir::UnitAttr attr) { + (*this)->setAttr(getDeduplicateAttrName(), attr); +} + +void GetParentOp::setDeduplicate(bool attrValue) { + if (attrValue) + return (*this)->setAttr(getDeduplicateAttrName(), ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr)); + (*this)->removeAttr(getDeduplicateAttrName()); +} + +::mlir::Attribute GetParentOp::removeIsolatedFromAboveAttr() { + auto &attr = getProperties().isolated_from_above; + attr = {}; + return attr; +} + +::mlir::Attribute GetParentOp::removeAllowEmptyResultsAttr() { + auto &attr = getProperties().allow_empty_results; + attr = {}; + return attr; +} + +::mlir::Attribute GetParentOp::removeOpNameAttr() { + auto &attr = getProperties().op_name; + attr = {}; + return attr; +} + +::mlir::Attribute GetParentOp::removeDeduplicateAttr() { + auto &attr = getProperties().deduplicate; + attr = {}; + return attr; +} + +void GetParentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type parent, ::mlir::Value target, /*optional*/::mlir::UnitAttr isolated_from_above, /*optional*/::mlir::UnitAttr allow_empty_results, /*optional*/::mlir::StringAttr op_name, /*optional*/::mlir::UnitAttr deduplicate) { + odsState.addOperands(target); + if (isolated_from_above) { + odsState.getOrAddProperties().isolated_from_above = isolated_from_above; + } + if (allow_empty_results) { + odsState.getOrAddProperties().allow_empty_results = allow_empty_results; + } + if (op_name) { + odsState.getOrAddProperties().op_name = op_name; + } + if (deduplicate) { + odsState.getOrAddProperties().deduplicate = deduplicate; + } + odsState.addTypes(parent); +} + +void GetParentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target, /*optional*/::mlir::UnitAttr isolated_from_above, /*optional*/::mlir::UnitAttr allow_empty_results, /*optional*/::mlir::StringAttr op_name, /*optional*/::mlir::UnitAttr deduplicate) { + odsState.addOperands(target); + if (isolated_from_above) { + odsState.getOrAddProperties().isolated_from_above = isolated_from_above; + } + if (allow_empty_results) { + odsState.getOrAddProperties().allow_empty_results = allow_empty_results; + } + if (op_name) { + odsState.getOrAddProperties().op_name = op_name; + } + if (deduplicate) { + odsState.getOrAddProperties().deduplicate = deduplicate; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void GetParentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type parent, ::mlir::Value target, /*optional*/bool isolated_from_above, /*optional*/bool allow_empty_results, /*optional*/::mlir::StringAttr op_name, /*optional*/bool deduplicate) { + odsState.addOperands(target); + if (isolated_from_above) { + odsState.getOrAddProperties().isolated_from_above = ((isolated_from_above) ? odsBuilder.getUnitAttr() : nullptr); + } + if (allow_empty_results) { + odsState.getOrAddProperties().allow_empty_results = ((allow_empty_results) ? odsBuilder.getUnitAttr() : nullptr); + } + if (op_name) { + odsState.getOrAddProperties().op_name = op_name; + } + if (deduplicate) { + odsState.getOrAddProperties().deduplicate = ((deduplicate) ? odsBuilder.getUnitAttr() : nullptr); + } + odsState.addTypes(parent); +} + +void GetParentOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target, /*optional*/bool isolated_from_above, /*optional*/bool allow_empty_results, /*optional*/::mlir::StringAttr op_name, /*optional*/bool deduplicate) { + odsState.addOperands(target); + if (isolated_from_above) { + odsState.getOrAddProperties().isolated_from_above = ((isolated_from_above) ? odsBuilder.getUnitAttr() : nullptr); + } + if (allow_empty_results) { + odsState.getOrAddProperties().allow_empty_results = ((allow_empty_results) ? odsBuilder.getUnitAttr() : nullptr); + } + if (op_name) { + odsState.getOrAddProperties().op_name = op_name; + } + if (deduplicate) { + odsState.getOrAddProperties().deduplicate = ((deduplicate) ? odsBuilder.getUnitAttr() : nullptr); + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void GetParentOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult GetParentOp::verifyInvariantsImpl() { + auto tblgen_allow_empty_results = getProperties().allow_empty_results; (void)tblgen_allow_empty_results; + auto tblgen_deduplicate = getProperties().deduplicate; (void)tblgen_deduplicate; + auto tblgen_isolated_from_above = getProperties().isolated_from_above; (void)tblgen_isolated_from_above; + auto tblgen_op_name = getProperties().op_name; (void)tblgen_op_name; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps2(*this, tblgen_isolated_from_above, "isolated_from_above"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps2(*this, tblgen_allow_empty_results, "allow_empty_results"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps0(*this, tblgen_op_name, "op_name"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps2(*this, tblgen_deduplicate, "deduplicate"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps0(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult GetParentOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult GetParentOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand targetRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> targetOperands(targetRawOperands); ::llvm::SMLoc targetOperandsLoc; + (void)targetOperandsLoc; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + + targetOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(targetRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(targetOperands, allOperandTypes, parser.getNameLoc(), result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void GetParentOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getTarget(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getIsolatedFromAboveAttr(); + if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) + elidedAttrs.push_back("isolated_from_above"); + } + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getAllowEmptyResultsAttr(); + if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) + elidedAttrs.push_back("allow_empty_results"); + } + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getDeduplicateAttr(); + if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) + elidedAttrs.push_back("deduplicate"); + } + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::GetParentOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::GetProducerOfOperand definitions +//===----------------------------------------------------------------------===// + +namespace detail { +GetProducerOfOperandGenericAdaptorBase::GetProducerOfOperandGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("transform.get_producer_of_operand", odsAttrs.getContext()); +} + +GetProducerOfOperandGenericAdaptorBase::GetProducerOfOperandGenericAdaptorBase(GetProducerOfOperand op) : GetProducerOfOperandGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair GetProducerOfOperandGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr GetProducerOfOperandGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::IntegerAttr GetProducerOfOperandGenericAdaptorBase::getOperandNumberAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().operand_number); + return attr; +} + +uint64_t GetProducerOfOperandGenericAdaptorBase::getOperandNumber() { + auto attr = getOperandNumberAttr(); + return attr.getValue().getZExtValue(); +} + +} // namespace detail +GetProducerOfOperandAdaptor::GetProducerOfOperandAdaptor(GetProducerOfOperand op) : GetProducerOfOperandGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult GetProducerOfOperandAdaptor::verify(::mlir::Location loc) { + auto tblgen_operand_number = getProperties().operand_number; (void)tblgen_operand_number; + if (!tblgen_operand_number) return emitError(loc, "'transform.get_producer_of_operand' op ""requires attribute 'operand_number'"); + + if (tblgen_operand_number && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_operand_number))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_operand_number).getType().isSignlessInteger(64))))) + return emitError(loc, "'transform.get_producer_of_operand' op ""attribute 'operand_number' failed to satisfy constraint: 64-bit signless integer attribute"); + return ::mlir::success(); +} + +std::pair GetProducerOfOperand::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range GetProducerOfOperand::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> GetProducerOfOperand::getTarget() { + return ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &GetProducerOfOperand::getTargetMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair GetProducerOfOperand::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range GetProducerOfOperand::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> GetProducerOfOperand::getProducer() { + return ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult GetProducerOfOperand::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.operand_number; + auto attr = dict.get("operand_number"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for operand_number in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `operand_number` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute GetProducerOfOperand::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.operand_number; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("operand_number", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code GetProducerOfOperand::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.operand_number.getAsOpaquePointer())); +} + +std::optional GetProducerOfOperand::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "operand_number") + return prop.operand_number; + return std::nullopt; +} + +void GetProducerOfOperand::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "operand_number") { + prop.operand_number = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void GetProducerOfOperand::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.operand_number) attrs.append("operand_number", prop.operand_number); +} + +::mlir::LogicalResult GetProducerOfOperand::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getOperandNumberAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps4(attr, "operand_number", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult GetProducerOfOperand::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.operand_number))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void GetProducerOfOperand::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.operand_number); +} + +::mlir::IntegerAttr GetProducerOfOperand::getOperandNumberAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().operand_number); +} + +uint64_t GetProducerOfOperand::getOperandNumber() { + auto attr = getOperandNumberAttr(); + return attr.getValue().getZExtValue(); +} + +void GetProducerOfOperand::setOperandNumberAttr(::mlir::IntegerAttr attr) { + (*this)->setAttr(getOperandNumberAttrName(), attr); +} + +void GetProducerOfOperand::setOperandNumber(uint64_t attrValue) { + (*this)->setAttr(getOperandNumberAttrName(), ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), attrValue)); +} + +void GetProducerOfOperand::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type producer, ::mlir::Value target, ::mlir::IntegerAttr operand_number) { + odsState.addOperands(target); + odsState.getOrAddProperties().operand_number = operand_number; + odsState.addTypes(producer); +} + +void GetProducerOfOperand::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target, ::mlir::IntegerAttr operand_number) { + odsState.addOperands(target); + odsState.getOrAddProperties().operand_number = operand_number; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void GetProducerOfOperand::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type producer, ::mlir::Value target, uint64_t operand_number) { + odsState.addOperands(target); + odsState.getOrAddProperties().operand_number = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), operand_number); + odsState.addTypes(producer); +} + +void GetProducerOfOperand::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target, uint64_t operand_number) { + odsState.addOperands(target); + odsState.getOrAddProperties().operand_number = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), operand_number); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void GetProducerOfOperand::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult GetProducerOfOperand::verifyInvariantsImpl() { + auto tblgen_operand_number = getProperties().operand_number; (void)tblgen_operand_number; + if (!tblgen_operand_number) return emitOpError("requires attribute 'operand_number'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps4(*this, tblgen_operand_number, "operand_number"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps0(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult GetProducerOfOperand::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult GetProducerOfOperand::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand targetRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> targetOperands(targetRawOperands); ::llvm::SMLoc targetOperandsLoc; + (void)targetOperandsLoc; + ::mlir::IntegerAttr operand_numberAttr; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + + targetOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(targetRawOperands[0])) + return ::mlir::failure(); + if (parser.parseLSquare()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(operand_numberAttr, parser.getBuilder().getIntegerType(64))) { + return ::mlir::failure(); + } + if (operand_numberAttr) result.getOrAddProperties().operand_number = operand_numberAttr; + if (parser.parseRSquare()) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(targetOperands, allOperandTypes, parser.getNameLoc(), result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void GetProducerOfOperand::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getTarget(); + _odsPrinter << "["; + _odsPrinter.printAttributeWithoutType(getOperandNumberAttr()); + _odsPrinter << "]"; + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("operand_number"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::GetProducerOfOperand) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::GetResultOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +GetResultOpGenericAdaptorBase::GetResultOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("transform.get_result", odsAttrs.getContext()); +} + +GetResultOpGenericAdaptorBase::GetResultOpGenericAdaptorBase(GetResultOp op) : GetResultOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair GetResultOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr GetResultOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::IntegerAttr GetResultOpGenericAdaptorBase::getResultNumberAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().result_number); + return attr; +} + +uint64_t GetResultOpGenericAdaptorBase::getResultNumber() { + auto attr = getResultNumberAttr(); + return attr.getValue().getZExtValue(); +} + +} // namespace detail +GetResultOpAdaptor::GetResultOpAdaptor(GetResultOp op) : GetResultOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult GetResultOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_result_number = getProperties().result_number; (void)tblgen_result_number; + if (!tblgen_result_number) return emitError(loc, "'transform.get_result' op ""requires attribute 'result_number'"); + + if (tblgen_result_number && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_result_number))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_result_number).getType().isSignlessInteger(64))))) + return emitError(loc, "'transform.get_result' op ""attribute 'result_number' failed to satisfy constraint: 64-bit signless integer attribute"); + return ::mlir::success(); +} + +std::pair GetResultOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range GetResultOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> GetResultOp::getTarget() { + return ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &GetResultOp::getTargetMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair GetResultOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range GetResultOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformValueHandleTypeInterface> GetResultOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformValueHandleTypeInterface>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult GetResultOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.result_number; + auto attr = dict.get("result_number"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for result_number in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `result_number` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute GetResultOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.result_number; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("result_number", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code GetResultOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.result_number.getAsOpaquePointer())); +} + +std::optional GetResultOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "result_number") + return prop.result_number; + return std::nullopt; +} + +void GetResultOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "result_number") { + prop.result_number = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void GetResultOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.result_number) attrs.append("result_number", prop.result_number); +} + +::mlir::LogicalResult GetResultOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getResultNumberAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps4(attr, "result_number", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult GetResultOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.result_number))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void GetResultOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.result_number); +} + +::mlir::IntegerAttr GetResultOp::getResultNumberAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().result_number); +} + +uint64_t GetResultOp::getResultNumber() { + auto attr = getResultNumberAttr(); + return attr.getValue().getZExtValue(); +} + +void GetResultOp::setResultNumberAttr(::mlir::IntegerAttr attr) { + (*this)->setAttr(getResultNumberAttrName(), attr); +} + +void GetResultOp::setResultNumber(uint64_t attrValue) { + (*this)->setAttr(getResultNumberAttrName(), ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), attrValue)); +} + +void GetResultOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value target, ::mlir::IntegerAttr result_number) { + odsState.addOperands(target); + odsState.getOrAddProperties().result_number = result_number; + odsState.addTypes(result); +} + +void GetResultOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target, ::mlir::IntegerAttr result_number) { + odsState.addOperands(target); + odsState.getOrAddProperties().result_number = result_number; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void GetResultOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value target, uint64_t result_number) { + odsState.addOperands(target); + odsState.getOrAddProperties().result_number = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), result_number); + odsState.addTypes(result); +} + +void GetResultOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target, uint64_t result_number) { + odsState.addOperands(target); + odsState.getOrAddProperties().result_number = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), result_number); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void GetResultOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult GetResultOp::verifyInvariantsImpl() { + auto tblgen_result_number = getProperties().result_number; (void)tblgen_result_number; + if (!tblgen_result_number) return emitOpError("requires attribute 'result_number'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps4(*this, tblgen_result_number, "result_number"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult GetResultOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult GetResultOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand targetRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> targetOperands(targetRawOperands); ::llvm::SMLoc targetOperandsLoc; + (void)targetOperandsLoc; + ::mlir::IntegerAttr result_numberAttr; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + + targetOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(targetRawOperands[0])) + return ::mlir::failure(); + if (parser.parseLSquare()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(result_numberAttr, parser.getBuilder().getIntegerType(64))) { + return ::mlir::failure(); + } + if (result_numberAttr) result.getOrAddProperties().result_number = result_numberAttr; + if (parser.parseRSquare()) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(targetOperands, allOperandTypes, parser.getNameLoc(), result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void GetResultOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getTarget(); + _odsPrinter << "["; + _odsPrinter.printAttributeWithoutType(getResultNumberAttr()); + _odsPrinter << "]"; + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("result_number"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::GetResultOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::GetTypeOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +GetTypeOpGenericAdaptorBase::GetTypeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("transform.get_type", odsAttrs.getContext()); +} + +GetTypeOpGenericAdaptorBase::GetTypeOpGenericAdaptorBase(GetTypeOp op) : GetTypeOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair GetTypeOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr GetTypeOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::UnitAttr GetTypeOpGenericAdaptorBase::getElementalAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().elemental); + if (!attr) + attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); + return attr; +} + +bool GetTypeOpGenericAdaptorBase::getElemental() { + auto attr = getElementalAttr(); + if (!attr) + return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; + return attr != nullptr; +} + +} // namespace detail +GetTypeOpAdaptor::GetTypeOpAdaptor(GetTypeOp op) : GetTypeOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult GetTypeOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_elemental = getProperties().elemental; (void)tblgen_elemental; + + if (tblgen_elemental && !((::llvm::isa<::mlir::UnitAttr>(tblgen_elemental)))) + return emitError(loc, "'transform.get_type' op ""attribute 'elemental' failed to satisfy constraint: unit attribute"); + return ::mlir::success(); +} + +std::pair GetTypeOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range GetTypeOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformValueHandleTypeInterface> GetTypeOp::getValue() { + return ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformValueHandleTypeInterface>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &GetTypeOp::getValueMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair GetTypeOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range GetTypeOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformParamTypeInterface> GetTypeOp::getTypeParam() { + return ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformParamTypeInterface>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult GetTypeOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.elemental; + auto attr = dict.get("elemental"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for elemental in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `elemental` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute GetTypeOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.elemental; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("elemental", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code GetTypeOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.elemental.getAsOpaquePointer())); +} + +std::optional GetTypeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "elemental") + return prop.elemental; + return std::nullopt; +} + +void GetTypeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "elemental") { + prop.elemental = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void GetTypeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.elemental) attrs.append("elemental", prop.elemental); +} + +::mlir::LogicalResult GetTypeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getElementalAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps2(attr, "elemental", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult GetTypeOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.elemental))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void GetTypeOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.elemental); +} + +::mlir::UnitAttr GetTypeOp::getElementalAttr() { + return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().elemental); +} + +bool GetTypeOp::getElemental() { + auto attr = getElementalAttr(); + if (!attr) + return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; + return attr != nullptr; +} + +void GetTypeOp::setElementalAttr(::mlir::UnitAttr attr) { + (*this)->setAttr(getElementalAttrName(), attr); +} + +void GetTypeOp::setElemental(bool attrValue) { + if (attrValue) + return (*this)->setAttr(getElementalAttrName(), ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr)); + (*this)->removeAttr(getElementalAttrName()); +} + +::mlir::Attribute GetTypeOp::removeElementalAttr() { + auto &attr = getProperties().elemental; + attr = {}; + return attr; +} + +void GetTypeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type type_param, ::mlir::Value value, /*optional*/::mlir::UnitAttr elemental) { + odsState.addOperands(value); + if (elemental) { + odsState.getOrAddProperties().elemental = elemental; + } + odsState.addTypes(type_param); +} + +void GetTypeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value value, /*optional*/::mlir::UnitAttr elemental) { + odsState.addOperands(value); + if (elemental) { + odsState.getOrAddProperties().elemental = elemental; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void GetTypeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type type_param, ::mlir::Value value, /*optional*/bool elemental) { + odsState.addOperands(value); + if (elemental) { + odsState.getOrAddProperties().elemental = ((elemental) ? odsBuilder.getUnitAttr() : nullptr); + } + odsState.addTypes(type_param); +} + +void GetTypeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value value, /*optional*/bool elemental) { + odsState.addOperands(value); + if (elemental) { + odsState.getOrAddProperties().elemental = ((elemental) ? odsBuilder.getUnitAttr() : nullptr); + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void GetTypeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult GetTypeOp::verifyInvariantsImpl() { + auto tblgen_elemental = getProperties().elemental; (void)tblgen_elemental; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps2(*this, tblgen_elemental, "elemental"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult GetTypeOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult GetTypeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand valueRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> valueOperands(valueRawOperands); ::llvm::SMLoc valueOperandsLoc; + (void)valueOperandsLoc; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + if (::mlir::succeeded(parser.parseOptionalKeyword("elemental"))) { + result.getOrAddProperties().elemental = parser.getBuilder().getUnitAttr(); } + + valueOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(valueRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(valueOperands, allOperandTypes, parser.getNameLoc(), result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void GetTypeOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + if (getElementalAttr()) { + _odsPrinter << ' ' << "elemental"; + } + _odsPrinter << ' '; + _odsPrinter << getValue(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("elemental"); + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getElementalAttr(); + if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) + elidedAttrs.push_back("elemental"); + } + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::GetTypeOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::IncludeOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +IncludeOpGenericAdaptorBase::IncludeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("transform.include", odsAttrs.getContext()); +} + +IncludeOpGenericAdaptorBase::IncludeOpGenericAdaptorBase(IncludeOp op) : IncludeOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair IncludeOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr IncludeOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::SymbolRefAttr IncludeOpGenericAdaptorBase::getTargetAttr() { + auto attr = ::llvm::cast<::mlir::SymbolRefAttr>(getProperties().target); + return attr; +} + +::mlir::SymbolRefAttr IncludeOpGenericAdaptorBase::getTarget() { + auto attr = getTargetAttr(); + return attr; +} + +::mlir::transform::FailurePropagationModeAttr IncludeOpGenericAdaptorBase::getFailurePropagationModeAttr() { + auto attr = ::llvm::cast<::mlir::transform::FailurePropagationModeAttr>(getProperties().failure_propagation_mode); + return attr; +} + +::mlir::transform::FailurePropagationMode IncludeOpGenericAdaptorBase::getFailurePropagationMode() { + auto attr = getFailurePropagationModeAttr(); + return attr.getValue(); +} + +} // namespace detail +IncludeOpAdaptor::IncludeOpAdaptor(IncludeOp op) : IncludeOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult IncludeOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_failure_propagation_mode = getProperties().failure_propagation_mode; (void)tblgen_failure_propagation_mode; + if (!tblgen_failure_propagation_mode) return emitError(loc, "'transform.include' op ""requires attribute 'failure_propagation_mode'"); + auto tblgen_target = getProperties().target; (void)tblgen_target; + if (!tblgen_target) return emitError(loc, "'transform.include' op ""requires attribute 'target'"); + + if (tblgen_target && !((::llvm::isa<::mlir::SymbolRefAttr>(tblgen_target)))) + return emitError(loc, "'transform.include' op ""attribute 'target' failed to satisfy constraint: symbol reference attribute"); + + if (tblgen_failure_propagation_mode && !((::llvm::isa<::mlir::transform::FailurePropagationModeAttr>(tblgen_failure_propagation_mode)))) + return emitError(loc, "'transform.include' op ""attribute 'failure_propagation_mode' failed to satisfy constraint: Silenceable error propagation policy"); + return ::mlir::success(); +} + +std::pair IncludeOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range IncludeOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::operand_range IncludeOp::getOperands() { + return getODSOperands(0); +} + +::mlir::MutableOperandRange IncludeOp::getOperandsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair IncludeOp::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::result_range IncludeOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::result_range IncludeOp::getResults() { + return getODSResults(0); +} + +::mlir::LogicalResult IncludeOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.failure_propagation_mode; + auto attr = dict.get("failure_propagation_mode"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for failure_propagation_mode in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `failure_propagation_mode` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.target; + auto attr = dict.get("target"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for target in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `target` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute IncludeOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.failure_propagation_mode; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("failure_propagation_mode", + propStorage)); + } + + { + const auto &propStorage = prop.target; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("target", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code IncludeOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.failure_propagation_mode.getAsOpaquePointer()), + llvm::hash_value(prop.target.getAsOpaquePointer())); +} + +std::optional IncludeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "failure_propagation_mode") + return prop.failure_propagation_mode; + + if (name == "target") + return prop.target; + return std::nullopt; +} + +void IncludeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "failure_propagation_mode") { + prop.failure_propagation_mode = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "target") { + prop.target = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void IncludeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.failure_propagation_mode) attrs.append("failure_propagation_mode", prop.failure_propagation_mode); + + if (prop.target) attrs.append("target", prop.target); +} + +::mlir::LogicalResult IncludeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getFailurePropagationModeAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps6(attr, "failure_propagation_mode", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getTargetAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps5(attr, "target", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult IncludeOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.failure_propagation_mode))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.target))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void IncludeOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.failure_propagation_mode); + writer.writeAttribute(prop.target); +} + +::mlir::SymbolRefAttr IncludeOp::getTargetAttr() { + return ::llvm::cast<::mlir::SymbolRefAttr>(getProperties().target); +} + +::mlir::SymbolRefAttr IncludeOp::getTarget() { + auto attr = getTargetAttr(); + return attr; +} + +::mlir::transform::FailurePropagationModeAttr IncludeOp::getFailurePropagationModeAttr() { + return ::llvm::cast<::mlir::transform::FailurePropagationModeAttr>(getProperties().failure_propagation_mode); +} + +::mlir::transform::FailurePropagationMode IncludeOp::getFailurePropagationMode() { + auto attr = getFailurePropagationModeAttr(); + return attr.getValue(); +} + +void IncludeOp::setTargetAttr(::mlir::SymbolRefAttr attr) { + (*this)->setAttr(getTargetAttrName(), attr); +} + +void IncludeOp::setFailurePropagationModeAttr(::mlir::transform::FailurePropagationModeAttr attr) { + (*this)->setAttr(getFailurePropagationModeAttrName(), attr); +} + +void IncludeOp::setFailurePropagationMode(::mlir::transform::FailurePropagationMode attrValue) { + (*this)->setAttr(getFailurePropagationModeAttrName(), ::mlir::transform::FailurePropagationModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue)); +} + +void IncludeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::SymbolRefAttr target, ::mlir::transform::FailurePropagationModeAttr failure_propagation_mode, ::mlir::ValueRange operands) { + odsState.addOperands(operands); + odsState.getOrAddProperties().target = target; + odsState.getOrAddProperties().failure_propagation_mode = failure_propagation_mode; + odsState.addTypes(results); +} + +void IncludeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::SymbolRefAttr target, ::mlir::transform::FailurePropagationMode failure_propagation_mode, ::mlir::ValueRange operands) { + odsState.addOperands(operands); + odsState.getOrAddProperties().target = target; + odsState.getOrAddProperties().failure_propagation_mode = ::mlir::transform::FailurePropagationModeAttr::get(odsBuilder.getContext(), failure_propagation_mode); + odsState.addTypes(results); +} + +void IncludeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult IncludeOp::verifyInvariantsImpl() { + auto tblgen_failure_propagation_mode = getProperties().failure_propagation_mode; (void)tblgen_failure_propagation_mode; + if (!tblgen_failure_propagation_mode) return emitOpError("requires attribute 'failure_propagation_mode'"); + auto tblgen_target = getProperties().target; (void)tblgen_target; + if (!tblgen_target) return emitOpError("requires attribute 'target'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps5(*this, tblgen_target, "target"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps6(*this, tblgen_failure_propagation_mode, "failure_propagation_mode"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult IncludeOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult IncludeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::SymbolRefAttr targetAttr; + ::mlir::transform::FailurePropagationModeAttr failure_propagation_modeAttr; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> operandsOperands; + ::llvm::SMLoc operandsOperandsLoc; + (void)operandsOperandsLoc; + ::llvm::ArrayRef<::mlir::Type> operandsTypes; + ::llvm::ArrayRef<::mlir::Type> resultsTypes; + + if (parser.parseCustomAttributeWithFallback(targetAttr, parser.getBuilder().getType<::mlir::NoneType>())) { + return ::mlir::failure(); + } + if (targetAttr) result.getOrAddProperties().target = targetAttr; + if (parser.parseKeyword("failures")) + return ::mlir::failure(); + if (parser.parseLParen()) + return ::mlir::failure(); + + { + ::llvm::StringRef attrStr; + ::mlir::NamedAttrList attrStorage; + auto loc = parser.getCurrentLocation(); + if (parser.parseOptionalKeyword(&attrStr, {"propagate","suppress"})) { + ::mlir::StringAttr attrVal; + ::mlir::OptionalParseResult parseResult = + parser.parseOptionalAttribute(attrVal, + parser.getBuilder().getNoneType(), + "failure_propagation_mode", attrStorage); + if (parseResult.has_value()) { + if (failed(*parseResult)) + return ::mlir::failure(); + attrStr = attrVal.getValue(); + } else { + return parser.emitError(loc, "expected string or keyword containing one of the following enum values for attribute 'failure_propagation_mode' [propagate, suppress]"); + } + } + if (!attrStr.empty()) { + auto attrOptional = ::mlir::transform::symbolizeFailurePropagationMode(attrStr); + if (!attrOptional) + return parser.emitError(loc, "invalid ") + << "failure_propagation_mode attribute specification: \"" << attrStr << '"';; + + failure_propagation_modeAttr = ::mlir::transform::FailurePropagationModeAttr::get(parser.getBuilder().getContext(), *attrOptional); + result.getOrAddProperties().failure_propagation_mode = failure_propagation_modeAttr; + } + } + if (parser.parseRParen()) + return ::mlir::failure(); + if (parser.parseLParen()) + return ::mlir::failure(); + + operandsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(operandsOperands)) + return ::mlir::failure(); + if (parser.parseRParen()) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType operands__results_functionType; + if (parser.parseType(operands__results_functionType)) + return ::mlir::failure(); + operandsTypes = operands__results_functionType.getInputs(); + resultsTypes = operands__results_functionType.getResults(); + result.addTypes(resultsTypes); + if (parser.resolveOperands(operandsOperands, operandsTypes, operandsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void IncludeOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter.printAttributeWithoutType(getTargetAttr()); + _odsPrinter << ' ' << "failures"; + _odsPrinter << "("; + + { + auto caseValue = getFailurePropagationMode(); + auto caseValueStr = stringifyFailurePropagationMode(caseValue); + _odsPrinter << caseValueStr; + } + _odsPrinter << ")"; + _odsPrinter << ' ' << "("; + _odsPrinter << getOperands(); + _odsPrinter << ")"; + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("target"); + elidedAttrs.push_back("failure_propagation_mode"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperands().getTypes(), getResults().getTypes()); +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::IncludeOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::MatchOperationEmptyOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +MatchOperationEmptyOpGenericAdaptorBase::MatchOperationEmptyOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("transform.match.operation_empty", odsAttrs.getContext()); +} + +MatchOperationEmptyOpGenericAdaptorBase::MatchOperationEmptyOpGenericAdaptorBase(MatchOperationEmptyOp op) : MatchOperationEmptyOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair MatchOperationEmptyOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr MatchOperationEmptyOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +MatchOperationEmptyOpAdaptor::MatchOperationEmptyOpAdaptor(MatchOperationEmptyOp op) : MatchOperationEmptyOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult MatchOperationEmptyOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair MatchOperationEmptyOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range MatchOperationEmptyOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> MatchOperationEmptyOp::getOperandHandle() { + return ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &MatchOperationEmptyOp::getOperandHandleMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair MatchOperationEmptyOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range MatchOperationEmptyOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +void MatchOperationEmptyOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand_handle) { + odsState.addOperands(operand_handle); +} + +void MatchOperationEmptyOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand_handle) { + odsState.addOperands(operand_handle); + assert(resultTypes.size() == 0u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void MatchOperationEmptyOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult MatchOperationEmptyOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult MatchOperationEmptyOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult MatchOperationEmptyOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operand_handleRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operand_handleOperands(operand_handleRawOperands); ::llvm::SMLoc operand_handleOperandsLoc; + (void)operand_handleOperandsLoc; + ::mlir::Type operand_handleRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> operand_handleTypes(operand_handleRawTypes); + + operand_handleOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operand_handleRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::transform::TransformHandleTypeInterface type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + operand_handleRawTypes[0] = type; + } + if (parser.resolveOperands(operand_handleOperands, operand_handleTypes, operand_handleOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void MatchOperationEmptyOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperandHandle(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getOperandHandle().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::transform::TransformHandleTypeInterface>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::MatchOperationEmptyOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::MatchOperationNameOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +MatchOperationNameOpGenericAdaptorBase::MatchOperationNameOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("transform.match.operation_name", odsAttrs.getContext()); +} + +MatchOperationNameOpGenericAdaptorBase::MatchOperationNameOpGenericAdaptorBase(MatchOperationNameOp op) : MatchOperationNameOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair MatchOperationNameOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr MatchOperationNameOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::ArrayAttr MatchOperationNameOpGenericAdaptorBase::getOpNamesAttr() { + auto attr = ::llvm::cast<::mlir::ArrayAttr>(getProperties().op_names); + return attr; +} + +::mlir::ArrayAttr MatchOperationNameOpGenericAdaptorBase::getOpNames() { + auto attr = getOpNamesAttr(); + return attr; +} + +} // namespace detail +MatchOperationNameOpAdaptor::MatchOperationNameOpAdaptor(MatchOperationNameOp op) : MatchOperationNameOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult MatchOperationNameOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_op_names = getProperties().op_names; (void)tblgen_op_names; + if (!tblgen_op_names) return emitError(loc, "'transform.match.operation_name' op ""requires attribute 'op_names'"); + + if (tblgen_op_names && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_op_names))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_op_names), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::StringAttr>(attr))); })))) + return emitError(loc, "'transform.match.operation_name' op ""attribute 'op_names' failed to satisfy constraint: string array attribute"); + return ::mlir::success(); +} + +std::pair MatchOperationNameOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range MatchOperationNameOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> MatchOperationNameOp::getOperandHandle() { + return ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &MatchOperationNameOp::getOperandHandleMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair MatchOperationNameOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range MatchOperationNameOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::LogicalResult MatchOperationNameOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.op_names; + auto attr = dict.get("op_names"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for op_names in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `op_names` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute MatchOperationNameOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.op_names; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("op_names", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code MatchOperationNameOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.op_names.getAsOpaquePointer())); +} + +std::optional MatchOperationNameOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "op_names") + return prop.op_names; + return std::nullopt; +} + +void MatchOperationNameOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "op_names") { + prop.op_names = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void MatchOperationNameOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.op_names) attrs.append("op_names", prop.op_names); +} + +::mlir::LogicalResult MatchOperationNameOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getOpNamesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps1(attr, "op_names", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult MatchOperationNameOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.op_names))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void MatchOperationNameOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.op_names); +} + +::mlir::ArrayAttr MatchOperationNameOp::getOpNamesAttr() { + return ::llvm::cast<::mlir::ArrayAttr>(getProperties().op_names); +} + +::mlir::ArrayAttr MatchOperationNameOp::getOpNames() { + auto attr = getOpNamesAttr(); + return attr; +} + +void MatchOperationNameOp::setOpNamesAttr(::mlir::ArrayAttr attr) { + (*this)->setAttr(getOpNamesAttrName(), attr); +} + +void MatchOperationNameOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand_handle, ::mlir::ArrayAttr op_names) { + odsState.addOperands(operand_handle); + odsState.getOrAddProperties().op_names = op_names; +} + +void MatchOperationNameOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand_handle, ::mlir::ArrayAttr op_names) { + odsState.addOperands(operand_handle); + odsState.getOrAddProperties().op_names = op_names; + assert(resultTypes.size() == 0u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void MatchOperationNameOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult MatchOperationNameOp::verifyInvariantsImpl() { + auto tblgen_op_names = getProperties().op_names; (void)tblgen_op_names; + if (!tblgen_op_names) return emitOpError("requires attribute 'op_names'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps1(*this, tblgen_op_names, "op_names"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult MatchOperationNameOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult MatchOperationNameOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand operand_handleRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> operand_handleOperands(operand_handleRawOperands); ::llvm::SMLoc operand_handleOperandsLoc; + (void)operand_handleOperandsLoc; + ::mlir::ArrayAttr op_namesAttr; + ::mlir::Type operand_handleRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> operand_handleTypes(operand_handleRawTypes); + + operand_handleOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(operand_handleRawOperands[0])) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(op_namesAttr, parser.getBuilder().getType<::mlir::NoneType>())) { + return ::mlir::failure(); + } + if (op_namesAttr) result.getOrAddProperties().op_names = op_namesAttr; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::transform::TransformHandleTypeInterface type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + operand_handleRawTypes[0] = type; + } + if (parser.resolveOperands(operand_handleOperands, operand_handleTypes, operand_handleOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void MatchOperationNameOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperandHandle(); + _odsPrinter << ' '; + _odsPrinter.printAttributeWithoutType(getOpNamesAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("op_names"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getOperandHandle().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::transform::TransformHandleTypeInterface>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::MatchOperationNameOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::MatchParamCmpIOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +MatchParamCmpIOpGenericAdaptorBase::MatchParamCmpIOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("transform.match.param.cmpi", odsAttrs.getContext()); +} + +MatchParamCmpIOpGenericAdaptorBase::MatchParamCmpIOpGenericAdaptorBase(MatchParamCmpIOp op) : MatchParamCmpIOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair MatchParamCmpIOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr MatchParamCmpIOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::transform::MatchCmpIPredicateAttr MatchParamCmpIOpGenericAdaptorBase::getPredicateAttr() { + auto attr = ::llvm::cast<::mlir::transform::MatchCmpIPredicateAttr>(getProperties().predicate); + return attr; +} + +::mlir::transform::MatchCmpIPredicate MatchParamCmpIOpGenericAdaptorBase::getPredicate() { + auto attr = getPredicateAttr(); + return attr.getValue(); +} + +} // namespace detail +MatchParamCmpIOpAdaptor::MatchParamCmpIOpAdaptor(MatchParamCmpIOp op) : MatchParamCmpIOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult MatchParamCmpIOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_predicate = getProperties().predicate; (void)tblgen_predicate; + if (!tblgen_predicate) return emitError(loc, "'transform.match.param.cmpi' op ""requires attribute 'predicate'"); + + if (tblgen_predicate && !((::llvm::isa<::mlir::transform::MatchCmpIPredicateAttr>(tblgen_predicate)))) + return emitError(loc, "'transform.match.param.cmpi' op ""attribute 'predicate' failed to satisfy constraint: allowed 32-bit signless integer cases: 0, 1, 2, 3, 4, 5"); + return ::mlir::success(); +} + +std::pair MatchParamCmpIOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range MatchParamCmpIOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformParamTypeInterface> MatchParamCmpIOp::getParam() { + return ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformParamTypeInterface>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::transform::TransformParamTypeInterface> MatchParamCmpIOp::getReference() { + return ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformParamTypeInterface>>(*getODSOperands(1).begin()); +} + +::mlir::OpOperand &MatchParamCmpIOp::getParamMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MatchParamCmpIOp::getReferenceMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +std::pair MatchParamCmpIOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range MatchParamCmpIOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::LogicalResult MatchParamCmpIOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.predicate; + auto attr = dict.get("predicate"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for predicate in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `predicate` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute MatchParamCmpIOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.predicate; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("predicate", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code MatchParamCmpIOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.predicate.getAsOpaquePointer())); +} + +std::optional MatchParamCmpIOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "predicate") + return prop.predicate; + return std::nullopt; +} + +void MatchParamCmpIOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "predicate") { + prop.predicate = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void MatchParamCmpIOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.predicate) attrs.append("predicate", prop.predicate); +} + +::mlir::LogicalResult MatchParamCmpIOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getPredicateAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps7(attr, "predicate", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult MatchParamCmpIOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.predicate))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void MatchParamCmpIOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.predicate); +} + +::mlir::transform::MatchCmpIPredicateAttr MatchParamCmpIOp::getPredicateAttr() { + return ::llvm::cast<::mlir::transform::MatchCmpIPredicateAttr>(getProperties().predicate); +} + +::mlir::transform::MatchCmpIPredicate MatchParamCmpIOp::getPredicate() { + auto attr = getPredicateAttr(); + return attr.getValue(); +} + +void MatchParamCmpIOp::setPredicateAttr(::mlir::transform::MatchCmpIPredicateAttr attr) { + (*this)->setAttr(getPredicateAttrName(), attr); +} + +void MatchParamCmpIOp::setPredicate(::mlir::transform::MatchCmpIPredicate attrValue) { + (*this)->setAttr(getPredicateAttrName(), ::mlir::transform::MatchCmpIPredicateAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue)); +} + +void MatchParamCmpIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value param, ::mlir::Value reference, ::mlir::transform::MatchCmpIPredicateAttr predicate) { + odsState.addOperands(param); + odsState.addOperands(reference); + odsState.getOrAddProperties().predicate = predicate; +} + +void MatchParamCmpIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value param, ::mlir::Value reference, ::mlir::transform::MatchCmpIPredicateAttr predicate) { + odsState.addOperands(param); + odsState.addOperands(reference); + odsState.getOrAddProperties().predicate = predicate; + assert(resultTypes.size() == 0u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void MatchParamCmpIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value param, ::mlir::Value reference, ::mlir::transform::MatchCmpIPredicate predicate) { + odsState.addOperands(param); + odsState.addOperands(reference); + odsState.getOrAddProperties().predicate = ::mlir::transform::MatchCmpIPredicateAttr::get(odsBuilder.getContext(), predicate); +} + +void MatchParamCmpIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value param, ::mlir::Value reference, ::mlir::transform::MatchCmpIPredicate predicate) { + odsState.addOperands(param); + odsState.addOperands(reference); + odsState.getOrAddProperties().predicate = ::mlir::transform::MatchCmpIPredicateAttr::get(odsBuilder.getContext(), predicate); + assert(resultTypes.size() == 0u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void MatchParamCmpIOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult MatchParamCmpIOp::verifyInvariantsImpl() { + auto tblgen_predicate = getProperties().predicate; (void)tblgen_predicate; + if (!tblgen_predicate) return emitOpError("requires attribute 'predicate'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps7(*this, tblgen_predicate, "predicate"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult MatchParamCmpIOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult MatchParamCmpIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::transform::MatchCmpIPredicateAttr predicateAttr; + ::mlir::OpAsmParser::UnresolvedOperand paramRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> paramOperands(paramRawOperands); ::llvm::SMLoc paramOperandsLoc; + (void)paramOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand referenceRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> referenceOperands(referenceRawOperands); ::llvm::SMLoc referenceOperandsLoc; + (void)referenceOperandsLoc; + ::mlir::Type paramRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> paramTypes(paramRawTypes); + + { + ::llvm::StringRef attrStr; + ::mlir::NamedAttrList attrStorage; + auto loc = parser.getCurrentLocation(); + if (parser.parseOptionalKeyword(&attrStr, {"eq","ne","lt","le","gt","ge"})) { + ::mlir::StringAttr attrVal; + ::mlir::OptionalParseResult parseResult = + parser.parseOptionalAttribute(attrVal, + parser.getBuilder().getNoneType(), + "predicate", attrStorage); + if (parseResult.has_value()) { + if (failed(*parseResult)) + return ::mlir::failure(); + attrStr = attrVal.getValue(); + } else { + return parser.emitError(loc, "expected string or keyword containing one of the following enum values for attribute 'predicate' [eq, ne, lt, le, gt, ge]"); + } + } + if (!attrStr.empty()) { + auto attrOptional = ::mlir::transform::symbolizeMatchCmpIPredicate(attrStr); + if (!attrOptional) + return parser.emitError(loc, "invalid ") + << "predicate attribute specification: \"" << attrStr << '"';; + + predicateAttr = ::mlir::transform::MatchCmpIPredicateAttr::get(parser.getBuilder().getContext(), *attrOptional); + result.getOrAddProperties().predicate = predicateAttr; + } + } + + paramOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(paramRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + referenceOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(referenceRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::transform::TransformParamTypeInterface type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + paramRawTypes[0] = type; + } + if (parser.resolveOperands(paramOperands, paramTypes, paramOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(referenceOperands, paramTypes[0], referenceOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void MatchParamCmpIOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + + { + auto caseValue = getPredicate(); + auto caseValueStr = stringifyMatchCmpIPredicate(caseValue); + _odsPrinter << caseValueStr; + } + _odsPrinter << ' '; + _odsPrinter << getParam(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getReference(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("predicate"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getParam().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::transform::TransformParamTypeInterface>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::MatchParamCmpIOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::MergeHandlesOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +MergeHandlesOpGenericAdaptorBase::MergeHandlesOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("transform.merge_handles", odsAttrs.getContext()); +} + +MergeHandlesOpGenericAdaptorBase::MergeHandlesOpGenericAdaptorBase(MergeHandlesOp op) : MergeHandlesOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair MergeHandlesOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr MergeHandlesOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::UnitAttr MergeHandlesOpGenericAdaptorBase::getDeduplicateAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().deduplicate); + if (!attr) + attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr); + return attr; +} + +bool MergeHandlesOpGenericAdaptorBase::getDeduplicate() { + auto attr = getDeduplicateAttr(); + if (!attr) + return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr; + return attr != nullptr; +} + +} // namespace detail +MergeHandlesOpAdaptor::MergeHandlesOpAdaptor(MergeHandlesOp op) : MergeHandlesOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult MergeHandlesOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_deduplicate = getProperties().deduplicate; (void)tblgen_deduplicate; + + if (tblgen_deduplicate && !((::llvm::isa<::mlir::UnitAttr>(tblgen_deduplicate)))) + return emitError(loc, "'transform.merge_handles' op ""attribute 'deduplicate' failed to satisfy constraint: unit attribute"); + return ::mlir::success(); +} + +std::pair MergeHandlesOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range MergeHandlesOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::operand_range MergeHandlesOp::getHandles() { + return getODSOperands(0); +} + +::mlir::MutableOperandRange MergeHandlesOp::getHandlesMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair MergeHandlesOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range MergeHandlesOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value MergeHandlesOp::getResult() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult MergeHandlesOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.deduplicate; + auto attr = dict.get("deduplicate"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for deduplicate in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `deduplicate` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute MergeHandlesOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.deduplicate; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("deduplicate", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code MergeHandlesOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.deduplicate.getAsOpaquePointer())); +} + +std::optional MergeHandlesOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "deduplicate") + return prop.deduplicate; + return std::nullopt; +} + +void MergeHandlesOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "deduplicate") { + prop.deduplicate = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void MergeHandlesOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.deduplicate) attrs.append("deduplicate", prop.deduplicate); +} + +::mlir::LogicalResult MergeHandlesOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getDeduplicateAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps2(attr, "deduplicate", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult MergeHandlesOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.deduplicate))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void MergeHandlesOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.deduplicate); +} + +::mlir::UnitAttr MergeHandlesOp::getDeduplicateAttr() { + return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().deduplicate); +} + +bool MergeHandlesOp::getDeduplicate() { + auto attr = getDeduplicateAttr(); + if (!attr) + return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr; + return attr != nullptr; +} + +void MergeHandlesOp::setDeduplicateAttr(::mlir::UnitAttr attr) { + (*this)->setAttr(getDeduplicateAttrName(), attr); +} + +void MergeHandlesOp::setDeduplicate(bool attrValue) { + if (attrValue) + return (*this)->setAttr(getDeduplicateAttrName(), ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr)); + (*this)->removeAttr(getDeduplicateAttrName()); +} + +::mlir::Attribute MergeHandlesOp::removeDeduplicateAttr() { + auto &attr = getProperties().deduplicate; + attr = {}; + return attr; +} + +void MergeHandlesOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange handles, /*optional*/::mlir::UnitAttr deduplicate) { + odsState.addOperands(handles); + if (deduplicate) { + odsState.getOrAddProperties().deduplicate = deduplicate; + } + odsState.addTypes(result); +} + +void MergeHandlesOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange handles, /*optional*/::mlir::UnitAttr deduplicate) { + odsState.addOperands(handles); + if (deduplicate) { + odsState.getOrAddProperties().deduplicate = deduplicate; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void MergeHandlesOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange handles, /*optional*/bool deduplicate) { + odsState.addOperands(handles); + if (deduplicate) { + odsState.getOrAddProperties().deduplicate = ((deduplicate) ? odsBuilder.getUnitAttr() : nullptr); + } + odsState.addTypes(result); +} + +void MergeHandlesOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange handles, /*optional*/bool deduplicate) { + odsState.addOperands(handles); + if (deduplicate) { + odsState.getOrAddProperties().deduplicate = ((deduplicate) ? odsBuilder.getUnitAttr() : nullptr); + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void MergeHandlesOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void MergeHandlesOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange handles, /*optional*/::mlir::UnitAttr deduplicate) { + odsState.addOperands(handles); + if (deduplicate) { + odsState.getOrAddProperties().deduplicate = deduplicate; + } + odsState.addTypes({handles.front().getType()}); + +} + +void MergeHandlesOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange handles, /*optional*/bool deduplicate) { + odsState.addOperands(handles); + if (deduplicate) { + odsState.getOrAddProperties().deduplicate = ((deduplicate) ? odsBuilder.getUnitAttr() : nullptr); + } + odsState.addTypes({handles.front().getType()}); + +} + +void MergeHandlesOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + odsState.addTypes({operands[0].getType()}); + +} + +::mlir::LogicalResult MergeHandlesOp::verifyInvariantsImpl() { + auto tblgen_deduplicate = getProperties().deduplicate; (void)tblgen_deduplicate; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps2(*this, tblgen_deduplicate, "deduplicate"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult MergeHandlesOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult MergeHandlesOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> handlesOperands; + ::llvm::SMLoc handlesOperandsLoc; + (void)handlesOperandsLoc; + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + if (::mlir::succeeded(parser.parseOptionalKeyword("deduplicate"))) { + result.getOrAddProperties().deduplicate = parser.getBuilder().getUnitAttr(); } + + handlesOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(handlesOperands)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(handlesOperands, resultTypes[0], handlesOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void MergeHandlesOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + if (getDeduplicateAttr()) { + _odsPrinter << ' ' << "deduplicate"; + } + _odsPrinter << ' '; + _odsPrinter << getHandles(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("deduplicate"); + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getDeduplicateAttr(); + if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr))) + elidedAttrs.push_back("deduplicate"); + } + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::MergeHandlesOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::NamedSequenceOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +NamedSequenceOpGenericAdaptorBase::NamedSequenceOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("transform.named_sequence", odsAttrs.getContext()); +} + +NamedSequenceOpGenericAdaptorBase::NamedSequenceOpGenericAdaptorBase(NamedSequenceOp op) : NamedSequenceOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair NamedSequenceOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr NamedSequenceOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::StringAttr NamedSequenceOpGenericAdaptorBase::getSymNameAttr() { + auto attr = ::llvm::cast<::mlir::StringAttr>(getProperties().sym_name); + return attr; +} + +::llvm::StringRef NamedSequenceOpGenericAdaptorBase::getSymName() { + auto attr = getSymNameAttr(); + return attr.getValue(); +} + +::mlir::TypeAttr NamedSequenceOpGenericAdaptorBase::getFunctionTypeAttr() { + auto attr = ::llvm::cast<::mlir::TypeAttr>(getProperties().function_type); + return attr; +} + +::mlir::FunctionType NamedSequenceOpGenericAdaptorBase::getFunctionType() { + auto attr = getFunctionTypeAttr(); + return ::llvm::cast<::mlir::FunctionType>(attr.getValue()); +} + +::mlir::StringAttr NamedSequenceOpGenericAdaptorBase::getSymVisibilityAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::StringAttr>(getProperties().sym_visibility); + return attr; +} + +::std::optional< ::llvm::StringRef > NamedSequenceOpGenericAdaptorBase::getSymVisibility() { + auto attr = getSymVisibilityAttr(); + return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); +} + +::mlir::ArrayAttr NamedSequenceOpGenericAdaptorBase::getArgAttrsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().arg_attrs); + return attr; +} + +::std::optional< ::mlir::ArrayAttr > NamedSequenceOpGenericAdaptorBase::getArgAttrs() { + auto attr = getArgAttrsAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +::mlir::ArrayAttr NamedSequenceOpGenericAdaptorBase::getResAttrsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().res_attrs); + return attr; +} + +::std::optional< ::mlir::ArrayAttr > NamedSequenceOpGenericAdaptorBase::getResAttrs() { + auto attr = getResAttrsAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +::mlir::Region &NamedSequenceOpGenericAdaptorBase::getBody() { + return *odsRegions[0]; +} + +::mlir::RegionRange NamedSequenceOpGenericAdaptorBase::getRegions() { + return odsRegions; +} + +} // namespace detail +NamedSequenceOpAdaptor::NamedSequenceOpAdaptor(NamedSequenceOp op) : NamedSequenceOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult NamedSequenceOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_arg_attrs = getProperties().arg_attrs; (void)tblgen_arg_attrs; + auto tblgen_function_type = getProperties().function_type; (void)tblgen_function_type; + if (!tblgen_function_type) return emitError(loc, "'transform.named_sequence' op ""requires attribute 'function_type'"); + auto tblgen_res_attrs = getProperties().res_attrs; (void)tblgen_res_attrs; + auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name; + if (!tblgen_sym_name) return emitError(loc, "'transform.named_sequence' op ""requires attribute 'sym_name'"); + auto tblgen_sym_visibility = getProperties().sym_visibility; (void)tblgen_sym_visibility; + + if (tblgen_sym_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_sym_name)))) + return emitError(loc, "'transform.named_sequence' op ""attribute 'sym_name' failed to satisfy constraint: string attribute"); + + if (tblgen_function_type && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_function_type))) && ((::llvm::isa<::mlir::FunctionType>(::llvm::cast<::mlir::TypeAttr>(tblgen_function_type).getValue()))) && ((true)))) + return emitError(loc, "'transform.named_sequence' op ""attribute 'function_type' failed to satisfy constraint: function type attribute"); + + if (tblgen_sym_visibility && !((::llvm::isa<::mlir::StringAttr>(tblgen_sym_visibility)))) + return emitError(loc, "'transform.named_sequence' op ""attribute 'sym_visibility' failed to satisfy constraint: string attribute"); + + if (tblgen_arg_attrs && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_arg_attrs))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_arg_attrs), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::DictionaryAttr>(attr))); })))) + return emitError(loc, "'transform.named_sequence' op ""attribute 'arg_attrs' failed to satisfy constraint: Array of dictionary attributes"); + + if (tblgen_res_attrs && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_res_attrs))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_res_attrs), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::DictionaryAttr>(attr))); })))) + return emitError(loc, "'transform.named_sequence' op ""attribute 'res_attrs' failed to satisfy constraint: Array of dictionary attributes"); + return ::mlir::success(); +} + +std::pair NamedSequenceOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range NamedSequenceOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +std::pair NamedSequenceOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range NamedSequenceOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Region &NamedSequenceOp::getBody() { + return (*this)->getRegion(0); +} + +::mlir::LogicalResult NamedSequenceOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.arg_attrs; + auto attr = dict.get("arg_attrs"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for arg_attrs in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `arg_attrs` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.function_type; + auto attr = dict.get("function_type"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for function_type in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `function_type` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.res_attrs; + auto attr = dict.get("res_attrs"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for res_attrs in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `res_attrs` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.sym_name; + auto attr = dict.get("sym_name"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for sym_name in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `sym_name` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.sym_visibility; + auto attr = dict.get("sym_visibility"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for sym_visibility in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `sym_visibility` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute NamedSequenceOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.arg_attrs; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("arg_attrs", + propStorage)); + } + + { + const auto &propStorage = prop.function_type; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("function_type", + propStorage)); + } + + { + const auto &propStorage = prop.res_attrs; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("res_attrs", + propStorage)); + } + + { + const auto &propStorage = prop.sym_name; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("sym_name", + propStorage)); + } + + { + const auto &propStorage = prop.sym_visibility; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("sym_visibility", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code NamedSequenceOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.arg_attrs.getAsOpaquePointer()), + llvm::hash_value(prop.function_type.getAsOpaquePointer()), + llvm::hash_value(prop.res_attrs.getAsOpaquePointer()), + llvm::hash_value(prop.sym_name.getAsOpaquePointer()), + llvm::hash_value(prop.sym_visibility.getAsOpaquePointer())); +} + +std::optional NamedSequenceOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "arg_attrs") + return prop.arg_attrs; + + if (name == "function_type") + return prop.function_type; + + if (name == "res_attrs") + return prop.res_attrs; + + if (name == "sym_name") + return prop.sym_name; + + if (name == "sym_visibility") + return prop.sym_visibility; + return std::nullopt; +} + +void NamedSequenceOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "arg_attrs") { + prop.arg_attrs = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "function_type") { + prop.function_type = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "res_attrs") { + prop.res_attrs = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "sym_name") { + prop.sym_name = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "sym_visibility") { + prop.sym_visibility = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void NamedSequenceOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.arg_attrs) attrs.append("arg_attrs", prop.arg_attrs); + + if (prop.function_type) attrs.append("function_type", prop.function_type); + + if (prop.res_attrs) attrs.append("res_attrs", prop.res_attrs); + + if (prop.sym_name) attrs.append("sym_name", prop.sym_name); + + if (prop.sym_visibility) attrs.append("sym_visibility", prop.sym_visibility); +} + +::mlir::LogicalResult NamedSequenceOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getArgAttrsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps9(attr, "arg_attrs", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getFunctionTypeAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps8(attr, "function_type", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getResAttrsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps9(attr, "res_attrs", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getSymNameAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps0(attr, "sym_name", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getSymVisibilityAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps0(attr, "sym_visibility", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult NamedSequenceOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.arg_attrs))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.function_type))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.res_attrs))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.sym_name))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.sym_visibility))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void NamedSequenceOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.arg_attrs); + writer.writeAttribute(prop.function_type); + + writer.writeOptionalAttribute(prop.res_attrs); + writer.writeAttribute(prop.sym_name); + + writer.writeOptionalAttribute(prop.sym_visibility); +} + +::mlir::StringAttr NamedSequenceOp::getSymNameAttr() { + return ::llvm::cast<::mlir::StringAttr>(getProperties().sym_name); +} + +::llvm::StringRef NamedSequenceOp::getSymName() { + auto attr = getSymNameAttr(); + return attr.getValue(); +} + +::mlir::TypeAttr NamedSequenceOp::getFunctionTypeAttr() { + return ::llvm::cast<::mlir::TypeAttr>(getProperties().function_type); +} + +::mlir::FunctionType NamedSequenceOp::getFunctionType() { + auto attr = getFunctionTypeAttr(); + return ::llvm::cast<::mlir::FunctionType>(attr.getValue()); +} + +::mlir::StringAttr NamedSequenceOp::getSymVisibilityAttr() { + return ::llvm::dyn_cast_or_null<::mlir::StringAttr>(getProperties().sym_visibility); +} + +::std::optional< ::llvm::StringRef > NamedSequenceOp::getSymVisibility() { + auto attr = getSymVisibilityAttr(); + return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); +} + +::mlir::ArrayAttr NamedSequenceOp::getArgAttrsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().arg_attrs); +} + +::std::optional< ::mlir::ArrayAttr > NamedSequenceOp::getArgAttrs() { + auto attr = getArgAttrsAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +::mlir::ArrayAttr NamedSequenceOp::getResAttrsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().res_attrs); +} + +::std::optional< ::mlir::ArrayAttr > NamedSequenceOp::getResAttrs() { + auto attr = getResAttrsAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +void NamedSequenceOp::setSymNameAttr(::mlir::StringAttr attr) { + (*this)->setAttr(getSymNameAttrName(), attr); +} + +void NamedSequenceOp::setSymName(::llvm::StringRef attrValue) { + (*this)->setAttr(getSymNameAttrName(), ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue)); +} + +void NamedSequenceOp::setFunctionTypeAttr(::mlir::TypeAttr attr) { + (*this)->setAttr(getFunctionTypeAttrName(), attr); +} + +void NamedSequenceOp::setSymVisibilityAttr(::mlir::StringAttr attr) { + (*this)->setAttr(getSymVisibilityAttrName(), attr); +} + +void NamedSequenceOp::setSymVisibility(::std::optional<::llvm::StringRef> attrValue) { + if (attrValue) + return (*this)->setAttr(getSymVisibilityAttrName(), ::mlir::Builder((*this)->getContext()).getStringAttr(*attrValue)); + (*this)->removeAttr(getSymVisibilityAttrName()); +} + +void NamedSequenceOp::setArgAttrsAttr(::mlir::ArrayAttr attr) { + (*this)->setAttr(getArgAttrsAttrName(), attr); +} + +void NamedSequenceOp::setResAttrsAttr(::mlir::ArrayAttr attr) { + (*this)->setAttr(getResAttrsAttrName(), attr); +} + +::mlir::Attribute NamedSequenceOp::removeSymVisibilityAttr() { + auto &attr = getProperties().sym_visibility; + attr = {}; + return attr; +} + +::mlir::Attribute NamedSequenceOp::removeArgAttrsAttr() { + auto &attr = getProperties().arg_attrs; + attr = {}; + return attr; +} + +::mlir::Attribute NamedSequenceOp::removeResAttrsAttr() { + auto &attr = getProperties().res_attrs; + attr = {}; + return attr; +} + +void NamedSequenceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::StringAttr sym_name, ::mlir::TypeAttr function_type, /*optional*/::mlir::StringAttr sym_visibility, /*optional*/::mlir::ArrayAttr arg_attrs, /*optional*/::mlir::ArrayAttr res_attrs) { + odsState.getOrAddProperties().sym_name = sym_name; + odsState.getOrAddProperties().function_type = function_type; + if (sym_visibility) { + odsState.getOrAddProperties().sym_visibility = sym_visibility; + } + if (arg_attrs) { + odsState.getOrAddProperties().arg_attrs = arg_attrs; + } + if (res_attrs) { + odsState.getOrAddProperties().res_attrs = res_attrs; + } + (void)odsState.addRegion(); +} + +void NamedSequenceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, ::mlir::TypeAttr function_type, /*optional*/::mlir::StringAttr sym_visibility, /*optional*/::mlir::ArrayAttr arg_attrs, /*optional*/::mlir::ArrayAttr res_attrs) { + odsState.getOrAddProperties().sym_name = sym_name; + odsState.getOrAddProperties().function_type = function_type; + if (sym_visibility) { + odsState.getOrAddProperties().sym_visibility = sym_visibility; + } + if (arg_attrs) { + odsState.getOrAddProperties().arg_attrs = arg_attrs; + } + if (res_attrs) { + odsState.getOrAddProperties().res_attrs = res_attrs; + } + (void)odsState.addRegion(); + assert(resultTypes.size() == 0u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void NamedSequenceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llvm::StringRef sym_name, ::mlir::TypeAttr function_type, /*optional*/::mlir::StringAttr sym_visibility, /*optional*/::mlir::ArrayAttr arg_attrs, /*optional*/::mlir::ArrayAttr res_attrs) { + odsState.getOrAddProperties().sym_name = odsBuilder.getStringAttr(sym_name); + odsState.getOrAddProperties().function_type = function_type; + if (sym_visibility) { + odsState.getOrAddProperties().sym_visibility = sym_visibility; + } + if (arg_attrs) { + odsState.getOrAddProperties().arg_attrs = arg_attrs; + } + if (res_attrs) { + odsState.getOrAddProperties().res_attrs = res_attrs; + } + (void)odsState.addRegion(); +} + +void NamedSequenceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, ::mlir::TypeAttr function_type, /*optional*/::mlir::StringAttr sym_visibility, /*optional*/::mlir::ArrayAttr arg_attrs, /*optional*/::mlir::ArrayAttr res_attrs) { + odsState.getOrAddProperties().sym_name = odsBuilder.getStringAttr(sym_name); + odsState.getOrAddProperties().function_type = function_type; + if (sym_visibility) { + odsState.getOrAddProperties().sym_visibility = sym_visibility; + } + if (arg_attrs) { + odsState.getOrAddProperties().arg_attrs = arg_attrs; + } + if (res_attrs) { + odsState.getOrAddProperties().res_attrs = res_attrs; + } + (void)odsState.addRegion(); + assert(resultTypes.size() == 0u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void NamedSequenceOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult NamedSequenceOp::verifyInvariantsImpl() { + auto tblgen_arg_attrs = getProperties().arg_attrs; (void)tblgen_arg_attrs; + auto tblgen_function_type = getProperties().function_type; (void)tblgen_function_type; + if (!tblgen_function_type) return emitOpError("requires attribute 'function_type'"); + auto tblgen_res_attrs = getProperties().res_attrs; (void)tblgen_res_attrs; + auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name; + if (!tblgen_sym_name) return emitOpError("requires attribute 'sym_name'"); + auto tblgen_sym_visibility = getProperties().sym_visibility; (void)tblgen_sym_visibility; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps0(*this, tblgen_sym_name, "sym_name"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps8(*this, tblgen_function_type, "function_type"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps0(*this, tblgen_sym_visibility, "sym_visibility"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps9(*this, tblgen_arg_attrs, "arg_attrs"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps9(*this, tblgen_res_attrs, "res_attrs"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_TransformOps1(*this, region, "body", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult NamedSequenceOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::NamedSequenceOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::ParamConstantOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ParamConstantOpGenericAdaptorBase::ParamConstantOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("transform.param.constant", odsAttrs.getContext()); +} + +ParamConstantOpGenericAdaptorBase::ParamConstantOpGenericAdaptorBase(ParamConstantOp op) : ParamConstantOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ParamConstantOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ParamConstantOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::Attribute ParamConstantOpGenericAdaptorBase::getValueAttr() { + auto attr = ::llvm::cast<::mlir::Attribute>(getProperties().value); + return attr; +} + +::mlir::Attribute ParamConstantOpGenericAdaptorBase::getValue() { + auto attr = getValueAttr(); + return attr; +} + +} // namespace detail +ParamConstantOpAdaptor::ParamConstantOpAdaptor(ParamConstantOp op) : ParamConstantOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ParamConstantOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_value = getProperties().value; (void)tblgen_value; + if (!tblgen_value) return emitError(loc, "'transform.param.constant' op ""requires attribute 'value'"); + + if (tblgen_value && !((true))) + return emitError(loc, "'transform.param.constant' op ""attribute 'value' failed to satisfy constraint: any attribute"); + return ::mlir::success(); +} + +std::pair ParamConstantOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ParamConstantOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +std::pair ParamConstantOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ParamConstantOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformParamTypeInterface> ParamConstantOp::getParam() { + return ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformParamTypeInterface>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult ParamConstantOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.value; + auto attr = dict.get("value"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for value in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `value` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ParamConstantOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.value; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("value", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ParamConstantOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.value.getAsOpaquePointer())); +} + +std::optional ParamConstantOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "value") + return prop.value; + return std::nullopt; +} + +void ParamConstantOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "value") { + prop.value = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ParamConstantOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.value) attrs.append("value", prop.value); +} + +::mlir::LogicalResult ParamConstantOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getValueAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps10(attr, "value", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ParamConstantOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.value))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ParamConstantOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.value); +} + +::mlir::Attribute ParamConstantOp::getValueAttr() { + return ::llvm::cast<::mlir::Attribute>(getProperties().value); +} + +::mlir::Attribute ParamConstantOp::getValue() { + auto attr = getValueAttr(); + return attr; +} + +void ParamConstantOp::setValueAttr(::mlir::Attribute attr) { + (*this)->setAttr(getValueAttrName(), attr); +} + +void ParamConstantOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type param, ::mlir::Attribute value) { + odsState.getOrAddProperties().value = value; + odsState.addTypes(param); +} + +void ParamConstantOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Attribute value) { + odsState.getOrAddProperties().value = value; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ParamConstantOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ParamConstantOp::verifyInvariantsImpl() { + auto tblgen_value = getProperties().value; (void)tblgen_value; + if (!tblgen_value) return emitOpError("requires attribute 'value'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps10(*this, tblgen_value, "value"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ParamConstantOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult ParamConstantOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::Attribute valueAttr; + ::mlir::Type paramRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> paramTypes(paramRawTypes); + + if (parser.parseAttribute(valueAttr, ::mlir::Type{})) + return ::mlir::failure(); + if (valueAttr) result.getOrAddProperties().value = valueAttr; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::transform::TransformParamTypeInterface type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + paramRawTypes[0] = type; + } + result.addTypes(paramTypes); + return ::mlir::success(); +} + +void ParamConstantOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter.printAttribute(getValueAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("value"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getParam().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::transform::TransformParamTypeInterface>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::ParamConstantOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::PrintOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +PrintOpGenericAdaptorBase::PrintOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("transform.print", odsAttrs.getContext()); +} + +PrintOpGenericAdaptorBase::PrintOpGenericAdaptorBase(PrintOp op) : PrintOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair PrintOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr PrintOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::StringAttr PrintOpGenericAdaptorBase::getNameAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::StringAttr>(getProperties().name); + return attr; +} + +::std::optional< ::llvm::StringRef > PrintOpGenericAdaptorBase::getName() { + auto attr = getNameAttr(); + return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); +} + +} // namespace detail +PrintOpAdaptor::PrintOpAdaptor(PrintOp op) : PrintOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult PrintOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_name = getProperties().name; (void)tblgen_name; + + if (tblgen_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_name)))) + return emitError(loc, "'transform.print' op ""attribute 'name' failed to satisfy constraint: string attribute"); + return ::mlir::success(); +} + +std::pair PrintOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range PrintOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> PrintOp::getTarget() { + auto operands = getODSOperands(0); + return operands.empty() ? ::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface>{} : ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface>>(*operands.begin()); +} + +::mlir::MutableOperandRange PrintOp::getTargetMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair PrintOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range PrintOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::LogicalResult PrintOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.name; + auto attr = dict.get("name"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for name in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `name` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute PrintOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.name; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("name", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code PrintOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.name.getAsOpaquePointer())); +} + +std::optional PrintOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "name") + return prop.name; + return std::nullopt; +} + +void PrintOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "name") { + prop.name = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void PrintOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.name) attrs.append("name", prop.name); +} + +::mlir::LogicalResult PrintOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getNameAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps0(attr, "name", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult PrintOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.name))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void PrintOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.name); +} + +::mlir::StringAttr PrintOp::getNameAttr() { + return ::llvm::dyn_cast_or_null<::mlir::StringAttr>(getProperties().name); +} + +::std::optional< ::llvm::StringRef > PrintOp::getName() { + auto attr = getNameAttr(); + return attr ? ::std::optional< ::llvm::StringRef >(attr.getValue()) : (::std::nullopt); +} + +void PrintOp::setNameAttr(::mlir::StringAttr attr) { + (*this)->setAttr(getNameAttrName(), attr); +} + +void PrintOp::setName(::std::optional<::llvm::StringRef> attrValue) { + if (attrValue) + return (*this)->setAttr(getNameAttrName(), ::mlir::Builder((*this)->getContext()).getStringAttr(*attrValue)); + (*this)->removeAttr(getNameAttrName()); +} + +::mlir::Attribute PrintOp::removeNameAttr() { + auto &attr = getProperties().name; + attr = {}; + return attr; +} + +void PrintOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Value target, /*optional*/::mlir::StringAttr name) { + if (target) + odsState.addOperands(target); + if (name) { + odsState.getOrAddProperties().name = name; + } +} + +void PrintOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value target, /*optional*/::mlir::StringAttr name) { + if (target) + odsState.addOperands(target); + if (name) { + odsState.getOrAddProperties().name = name; + } + assert(resultTypes.size() == 0u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void PrintOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult PrintOp::verifyInvariantsImpl() { + auto tblgen_name = getProperties().name; (void)tblgen_name; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps0(*this, tblgen_name, "name"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + if (valueGroup0.size() > 1) { + return emitOpError("operand group starting at #") << index + << " requires 0 or 1 element, but found " << valueGroup0.size(); + } + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult PrintOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult PrintOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> targetOperands; + ::llvm::SMLoc targetOperandsLoc; + (void)targetOperandsLoc; + ::llvm::SmallVector<::mlir::Type, 1> targetTypes; + + { + targetOperandsLoc = parser.getCurrentLocation(); + ::mlir::OpAsmParser::UnresolvedOperand operand; + ::mlir::OptionalParseResult parseResult = + parser.parseOptionalOperand(operand); + if (parseResult.has_value()) { + if (failed(*parseResult)) + return ::mlir::failure(); + targetOperands.push_back(operand); + } + } + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (::mlir::succeeded(parser.parseOptionalColon())) { + + { + ::mlir::Type optionalType; + ::mlir::OptionalParseResult parseResult = + parser.parseOptionalType(optionalType); + if (parseResult.has_value()) { + if (failed(*parseResult)) + return ::mlir::failure(); + targetTypes.push_back(optionalType); + } + } + } + if (parser.resolveOperands(targetOperands, targetTypes, targetOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void PrintOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + if (::mlir::Value value = getTarget()) + _odsPrinter << value; + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + if (getTarget()) { + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter << (getTarget() ? ::llvm::ArrayRef<::mlir::Type>(getTarget().getType()) : ::llvm::ArrayRef<::mlir::Type>()); + } +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::PrintOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::ReplicateOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ReplicateOpGenericAdaptorBase::ReplicateOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("transform.replicate", odsAttrs.getContext()); +} + +ReplicateOpGenericAdaptorBase::ReplicateOpGenericAdaptorBase(ReplicateOp op) : ReplicateOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ReplicateOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr ReplicateOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +ReplicateOpAdaptor::ReplicateOpAdaptor(ReplicateOp op) : ReplicateOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ReplicateOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair ReplicateOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range ReplicateOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> ReplicateOp::getPattern() { + return ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface>>(*getODSOperands(0).begin()); +} + +::mlir::Operation::operand_range ReplicateOp::getHandles() { + return getODSOperands(1); +} + +::mlir::OpOperand &ReplicateOp::getPatternMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange ReplicateOp::getHandlesMutable() { + auto range = getODSOperandIndexAndLength(1); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair ReplicateOp::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::result_range ReplicateOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::result_range ReplicateOp::getReplicated() { + return getODSResults(0); +} + +void ReplicateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange replicated, ::mlir::Value pattern, ::mlir::ValueRange handles) { + odsState.addOperands(pattern); + odsState.addOperands(handles); + odsState.addTypes(replicated); +} + +void ReplicateOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ReplicateOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!(((this->getODSOperands(1).getType()) == (this->getODSResults(0).getType()) && (this->getODSResults(0).getType()) == (this->getODSOperands(1).getType())))) + return emitOpError("failed to verify that all of {handles, replicated} have same type"); + return ::mlir::success(); +} + +::mlir::LogicalResult ReplicateOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult ReplicateOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand patternRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> patternOperands(patternRawOperands); ::llvm::SMLoc patternOperandsLoc; + (void)patternOperandsLoc; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> handlesOperands; + ::llvm::SMLoc handlesOperandsLoc; + (void)handlesOperandsLoc; + ::mlir::Type patternRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> patternTypes(patternRawTypes); + ::llvm::SmallVector<::mlir::Type, 1> handlesTypes; + if (parser.parseKeyword("num")) + return ::mlir::failure(); + if (parser.parseLParen()) + return ::mlir::failure(); + + patternOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(patternRawOperands[0])) + return ::mlir::failure(); + if (parser.parseRParen()) + return ::mlir::failure(); + + handlesOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(handlesOperands)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::transform::TransformHandleTypeInterface type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + patternRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + if (parser.parseTypeList(handlesTypes)) + return ::mlir::failure(); + result.addTypes(handlesTypes); + if (parser.resolveOperands(patternOperands, patternTypes, patternOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(handlesOperands, handlesTypes, handlesOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ReplicateOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' ' << "num"; + _odsPrinter << "("; + _odsPrinter << getPattern(); + _odsPrinter << ")"; + _odsPrinter << ' '; + _odsPrinter << getHandles(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getPattern().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::transform::TransformHandleTypeInterface>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getHandles().getTypes(); +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::ReplicateOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::SelectOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +SelectOpGenericAdaptorBase::SelectOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("transform.select", odsAttrs.getContext()); +} + +SelectOpGenericAdaptorBase::SelectOpGenericAdaptorBase(SelectOp op) : SelectOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair SelectOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr SelectOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::StringAttr SelectOpGenericAdaptorBase::getOpNameAttr() { + auto attr = ::llvm::cast<::mlir::StringAttr>(getProperties().op_name); + return attr; +} + +::llvm::StringRef SelectOpGenericAdaptorBase::getOpName() { + auto attr = getOpNameAttr(); + return attr.getValue(); +} + +} // namespace detail +SelectOpAdaptor::SelectOpAdaptor(SelectOp op) : SelectOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult SelectOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_op_name = getProperties().op_name; (void)tblgen_op_name; + if (!tblgen_op_name) return emitError(loc, "'transform.select' op ""requires attribute 'op_name'"); + + if (tblgen_op_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_op_name)))) + return emitError(loc, "'transform.select' op ""attribute 'op_name' failed to satisfy constraint: string attribute"); + return ::mlir::success(); +} + +std::pair SelectOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range SelectOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> SelectOp::getTarget() { + return ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &SelectOp::getTargetMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair SelectOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range SelectOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> SelectOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult SelectOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.op_name; + auto attr = dict.get("op_name"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for op_name in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `op_name` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute SelectOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.op_name; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("op_name", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code SelectOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.op_name.getAsOpaquePointer())); +} + +std::optional SelectOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "op_name") + return prop.op_name; + return std::nullopt; +} + +void SelectOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "op_name") { + prop.op_name = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void SelectOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.op_name) attrs.append("op_name", prop.op_name); +} + +::mlir::LogicalResult SelectOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getOpNameAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps0(attr, "op_name", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult SelectOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.op_name))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SelectOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.op_name); +} + +::mlir::StringAttr SelectOp::getOpNameAttr() { + return ::llvm::cast<::mlir::StringAttr>(getProperties().op_name); +} + +::llvm::StringRef SelectOp::getOpName() { + auto attr = getOpNameAttr(); + return attr.getValue(); +} + +void SelectOp::setOpNameAttr(::mlir::StringAttr attr) { + (*this)->setAttr(getOpNameAttrName(), attr); +} + +void SelectOp::setOpName(::llvm::StringRef attrValue) { + (*this)->setAttr(getOpNameAttrName(), ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue)); +} + +void SelectOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value target, ::mlir::StringAttr op_name) { + odsState.addOperands(target); + odsState.getOrAddProperties().op_name = op_name; + odsState.addTypes(result); +} + +void SelectOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target, ::mlir::StringAttr op_name) { + odsState.addOperands(target); + odsState.getOrAddProperties().op_name = op_name; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SelectOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value target, ::llvm::StringRef op_name) { + odsState.addOperands(target); + odsState.getOrAddProperties().op_name = odsBuilder.getStringAttr(op_name); + odsState.addTypes(result); +} + +void SelectOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target, ::llvm::StringRef op_name) { + odsState.addOperands(target); + odsState.getOrAddProperties().op_name = odsBuilder.getStringAttr(op_name); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SelectOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult SelectOp::verifyInvariantsImpl() { + auto tblgen_op_name = getProperties().op_name; (void)tblgen_op_name; + if (!tblgen_op_name) return emitOpError("requires attribute 'op_name'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps0(*this, tblgen_op_name, "op_name"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps0(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult SelectOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult SelectOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::StringAttr op_nameAttr; + ::mlir::OpAsmParser::UnresolvedOperand targetRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> targetOperands(targetRawOperands); ::llvm::SMLoc targetOperandsLoc; + (void)targetOperandsLoc; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + + if (parser.parseCustomAttributeWithFallback(op_nameAttr, parser.getBuilder().getType<::mlir::NoneType>())) { + return ::mlir::failure(); + } + if (op_nameAttr) result.getOrAddProperties().op_name = op_nameAttr; + if (parser.parseKeyword("in")) + return ::mlir::failure(); + + targetOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(targetRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(targetOperands, allOperandTypes, parser.getNameLoc(), result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SelectOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter.printAttributeWithoutType(getOpNameAttr()); + _odsPrinter << ' ' << "in"; + _odsPrinter << ' '; + _odsPrinter << getTarget(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("op_name"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::SelectOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::SequenceOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +SequenceOpGenericAdaptorBase::SequenceOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("transform.sequence", odsAttrs.getContext()); +} + +SequenceOpGenericAdaptorBase::SequenceOpGenericAdaptorBase(SequenceOp op) : SequenceOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair SequenceOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; + + unsigned start = 0; + for (unsigned i = 0; i < index; ++i) + start += sizeAttr[i]; + return {start, sizeAttr[index]}; +} + +::mlir::DictionaryAttr SequenceOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::transform::FailurePropagationModeAttr SequenceOpGenericAdaptorBase::getFailurePropagationModeAttr() { + auto attr = ::llvm::cast<::mlir::transform::FailurePropagationModeAttr>(getProperties().failure_propagation_mode); + return attr; +} + +::mlir::transform::FailurePropagationMode SequenceOpGenericAdaptorBase::getFailurePropagationMode() { + auto attr = getFailurePropagationModeAttr(); + return attr.getValue(); +} + +::mlir::Region &SequenceOpGenericAdaptorBase::getBody() { + return *odsRegions[0]; +} + +::mlir::RegionRange SequenceOpGenericAdaptorBase::getRegions() { + return odsRegions; +} + +} // namespace detail +SequenceOpAdaptor::SequenceOpAdaptor(SequenceOp op) : SequenceOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult SequenceOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_failure_propagation_mode = getProperties().failure_propagation_mode; (void)tblgen_failure_propagation_mode; + if (!tblgen_failure_propagation_mode) return emitError(loc, "'transform.sequence' op ""requires attribute 'failure_propagation_mode'"); + + if (tblgen_failure_propagation_mode && !((::llvm::isa<::mlir::transform::FailurePropagationModeAttr>(tblgen_failure_propagation_mode)))) + return emitError(loc, "'transform.sequence' op ""attribute 'failure_propagation_mode' failed to satisfy constraint: Silenceable error propagation policy"); + return ::mlir::success(); +} + +std::pair SequenceOp::getODSOperandIndexAndLength(unsigned index) { + ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; + + unsigned start = 0; + for (unsigned i = 0; i < index; ++i) + start += sizeAttr[i]; + return {start, sizeAttr[index]}; +} + +::mlir::Operation::operand_range SequenceOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> SequenceOp::getRoot() { + auto operands = getODSOperands(0); + return operands.empty() ? ::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface>{} : ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface>>(*operands.begin()); +} + +::mlir::Operation::operand_range SequenceOp::getExtraBindings() { + return getODSOperands(1); +} + +::mlir::MutableOperandRange SequenceOp::getRootMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(0u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); + return mutableRange; +} + +::mlir::MutableOperandRange SequenceOp::getExtraBindingsMutable() { + auto range = getODSOperandIndexAndLength(1); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); + return mutableRange; +} + +std::pair SequenceOp::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::result_range SequenceOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::result_range SequenceOp::getResults() { + return getODSResults(0); +} + +::mlir::Region &SequenceOp::getBody() { + return (*this)->getRegion(0); +} + +::mlir::LogicalResult SequenceOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.failure_propagation_mode; + auto attr = dict.get("failure_propagation_mode"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for failure_propagation_mode in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `failure_propagation_mode` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } +; + { + auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, + ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return convertFromAttribute(propStorage, propAttr, emitError);; + }; + auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; + if (!attr) { + emitError() << "expected key entry for operandSegmentSizes in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + if (::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute SequenceOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.failure_propagation_mode; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("failure_propagation_mode", + propStorage)); + } + + { + const auto &propStorage = prop.operandSegmentSizes; + attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", + ::mlir::DenseI32ArrayAttr::get(ctx, propStorage))); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code SequenceOp::computePropertiesHash(const Properties &prop) { + auto hash_operandSegmentSizes = [] (const auto &propStorage) -> llvm::hash_code { + return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; + }; + return llvm::hash_combine( + llvm::hash_value(prop.failure_propagation_mode.getAsOpaquePointer()), + hash_operandSegmentSizes(prop.operandSegmentSizes)); +} + +std::optional SequenceOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "failure_propagation_mode") + return prop.failure_propagation_mode; + if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); + return std::nullopt; +} + +void SequenceOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "failure_propagation_mode") { + prop.failure_propagation_mode = ::llvm::dyn_cast_or_null>(value); + return; + } + if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { + auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); + if (!arrAttr) return; + if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) + return; + llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); + return; + } +} + +void SequenceOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.failure_propagation_mode) attrs.append("failure_propagation_mode", prop.failure_propagation_mode); + attrs.append("operandSegmentSizes", ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes)); +} + +::mlir::LogicalResult SequenceOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getFailurePropagationModeAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps6(attr, "failure_propagation_mode", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult SequenceOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.failure_propagation_mode))) + return ::mlir::failure(); + + { + auto &propStorage = prop.operandSegmentSizes; + auto readProp = [&]() { + +if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { + ::mlir::DenseI32ArrayAttr attr; + if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); + if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { + reader.emitError("size mismatch for operand/result_segment_size"); + return ::mlir::failure(); + } + ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); +} else { + return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); +} +; + return ::mlir::success(); + }; + if (::mlir::failed(readProp())) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +void SequenceOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.failure_propagation_mode); + + { + auto &propStorage = prop.operandSegmentSizes; + +if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) + writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(getContext(), propStorage)); +else + writer.writeSparseArray(::llvm::ArrayRef(propStorage)); +; + } +} + +::mlir::transform::FailurePropagationModeAttr SequenceOp::getFailurePropagationModeAttr() { + return ::llvm::cast<::mlir::transform::FailurePropagationModeAttr>(getProperties().failure_propagation_mode); +} + +::mlir::transform::FailurePropagationMode SequenceOp::getFailurePropagationMode() { + auto attr = getFailurePropagationModeAttr(); + return attr.getValue(); +} + +void SequenceOp::setFailurePropagationModeAttr(::mlir::transform::FailurePropagationModeAttr attr) { + (*this)->setAttr(getFailurePropagationModeAttrName(), attr); +} + +void SequenceOp::setFailurePropagationMode(::mlir::transform::FailurePropagationMode attrValue) { + (*this)->setAttr(getFailurePropagationModeAttrName(), ::mlir::transform::FailurePropagationModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue)); +} + +void SequenceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::transform::FailurePropagationModeAttr failure_propagation_mode, /*optional*/::mlir::Value root, ::mlir::ValueRange extra_bindings) { + if (root) + odsState.addOperands(root); + odsState.addOperands(extra_bindings); + ::llvm::copy(::llvm::ArrayRef({(root ? 1 : 0), static_cast(extra_bindings.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + odsState.getOrAddProperties().failure_propagation_mode = failure_propagation_mode; + (void)odsState.addRegion(); + odsState.addTypes(results); +} + +void SequenceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::transform::FailurePropagationMode failure_propagation_mode, /*optional*/::mlir::Value root, ::mlir::ValueRange extra_bindings) { + if (root) + odsState.addOperands(root); + odsState.addOperands(extra_bindings); + ::llvm::copy(::llvm::ArrayRef({(root ? 1 : 0), static_cast(extra_bindings.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + odsState.getOrAddProperties().failure_propagation_mode = ::mlir::transform::FailurePropagationModeAttr::get(odsBuilder.getContext(), failure_propagation_mode); + (void)odsState.addRegion(); + odsState.addTypes(results); +} + +void SequenceOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + for (unsigned i = 0; i != 1; ++i) + (void)odsState.addRegion(); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult SequenceOp::verifyInvariantsImpl() { + auto tblgen_failure_propagation_mode = getProperties().failure_propagation_mode; (void)tblgen_failure_propagation_mode; + if (!tblgen_failure_propagation_mode) return emitOpError("requires attribute 'failure_propagation_mode'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps6(*this, tblgen_failure_propagation_mode, "failure_propagation_mode"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + if (valueGroup0.size() > 1) { + return emitOpError("operand group starting at #") << index + << " requires 0 or 1 element, but found " << valueGroup0.size(); + } + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps0(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_TransformOps0(*this, region, "body", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult SequenceOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult SequenceOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> rootOperands; + ::llvm::SMLoc rootOperandsLoc; + (void)rootOperandsLoc; + ::llvm::SmallVector<::mlir::Type, 1> rootTypes; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> extra_bindingsOperands; + ::llvm::SMLoc extra_bindingsOperandsLoc; + (void)extra_bindingsOperandsLoc; + ::llvm::SmallVector<::mlir::Type, 1> extra_bindingsTypes; + ::llvm::SmallVector<::mlir::Type, 1> resultsTypes; + ::mlir::transform::FailurePropagationModeAttr failure_propagation_modeAttr; + ::llvm::SmallVector, 2> fullRegions; + { + rootOperandsLoc = parser.getCurrentLocation(); + ::std::optional<::mlir::OpAsmParser::UnresolvedOperand> rootOperand; + ::mlir::Type rootType; + extra_bindingsOperandsLoc = parser.getCurrentLocation(); + auto odsResult = parseSequenceOpOperands(parser, rootOperand, rootType, extra_bindingsOperands, extra_bindingsTypes); + if (odsResult) return ::mlir::failure(); + if (rootOperand.has_value()) + rootOperands.push_back(*rootOperand); + if (rootType) + rootTypes.push_back(rootType); + } + if (::mlir::succeeded(parser.parseOptionalArrow())) { + + if (parser.parseTypeList(resultsTypes)) + return ::mlir::failure(); + } + if (parser.parseKeyword("failures")) + return ::mlir::failure(); + if (parser.parseLParen()) + return ::mlir::failure(); + + { + ::llvm::StringRef attrStr; + ::mlir::NamedAttrList attrStorage; + auto loc = parser.getCurrentLocation(); + if (parser.parseOptionalKeyword(&attrStr, {"propagate","suppress"})) { + ::mlir::StringAttr attrVal; + ::mlir::OptionalParseResult parseResult = + parser.parseOptionalAttribute(attrVal, + parser.getBuilder().getNoneType(), + "failure_propagation_mode", attrStorage); + if (parseResult.has_value()) { + if (failed(*parseResult)) + return ::mlir::failure(); + attrStr = attrVal.getValue(); + } else { + return parser.emitError(loc, "expected string or keyword containing one of the following enum values for attribute 'failure_propagation_mode' [propagate, suppress]"); + } + } + if (!attrStr.empty()) { + auto attrOptional = ::mlir::transform::symbolizeFailurePropagationMode(attrStr); + if (!attrOptional) + return parser.emitError(loc, "invalid ") + << "failure_propagation_mode attribute specification: \"" << attrStr << '"';; + + failure_propagation_modeAttr = ::mlir::transform::FailurePropagationModeAttr::get(parser.getBuilder().getContext(), *attrOptional); + result.getOrAddProperties().failure_propagation_mode = failure_propagation_modeAttr; + } + } + if (parser.parseRParen()) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDictWithKeyword(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + + { + std::unique_ptr<::mlir::Region> region; + auto firstRegionResult = parser.parseOptionalRegion(region); + if (firstRegionResult.has_value()) { + if (failed(*firstRegionResult)) + return ::mlir::failure(); + fullRegions.emplace_back(std::move(region)); + + // Parse any trailing regions. + while (succeeded(parser.parseOptionalComma())) { + region = std::make_unique<::mlir::Region>(); + if (parser.parseRegion(*region)) + return ::mlir::failure(); + fullRegions.emplace_back(std::move(region)); + } + } + } + + for (auto ®ion : fullRegions) + ensureTerminator(*region, parser.getBuilder(), result.location); + result.addRegions(fullRegions); +::llvm::copy(::llvm::ArrayRef({static_cast(rootOperands.size()), static_cast(extra_bindingsOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); + result.addTypes(resultsTypes); + if (parser.resolveOperands(rootOperands, rootTypes, rootOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(extra_bindingsOperands, extra_bindingsTypes, extra_bindingsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SequenceOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + printSequenceOpOperands(_odsPrinter, *this, getRoot(), (getRoot() ? getRoot().getType() : ::mlir::Type()), getExtraBindings(), getExtraBindings().getTypes()); + if (!getResults().empty()) { + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + _odsPrinter << getResults().getTypes(); + } + _odsPrinter << ' ' << "failures"; + _odsPrinter << "("; + + { + auto caseValue = getFailurePropagationMode(); + auto caseValueStr = stringifyFailurePropagationMode(caseValue); + _odsPrinter << caseValueStr; + } + _odsPrinter << ")"; + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("operandSegmentSizes"); + elidedAttrs.push_back("failure_propagation_mode"); + _odsPrinter.printOptionalAttrDictWithKeyword((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' '; + llvm::interleaveComma(getOperation()->getRegions(), _odsPrinter, [&](::mlir::Region ®ion) { + + { + bool printTerminator = true; + if (auto *term = region.empty() ? nullptr : region.begin()->getTerminator()) { + printTerminator = !term->getAttrDictionary().empty() || + term->getNumOperands() != 0 || + term->getNumResults() != 0; + } + _odsPrinter.printRegion(region, /*printEntryBlockArgs=*/true, + /*printBlockTerminators=*/printTerminator); + } + }); +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::SequenceOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::SplitHandleOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +SplitHandleOpGenericAdaptorBase::SplitHandleOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("transform.split_handle", odsAttrs.getContext()); +} + +SplitHandleOpGenericAdaptorBase::SplitHandleOpGenericAdaptorBase(SplitHandleOp op) : SplitHandleOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair SplitHandleOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr SplitHandleOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::BoolAttr SplitHandleOpGenericAdaptorBase::getPassThroughEmptyHandleAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().pass_through_empty_handle); + return attr; +} + +bool SplitHandleOpGenericAdaptorBase::getPassThroughEmptyHandle() { + auto attr = getPassThroughEmptyHandleAttr(); + return attr.getValue(); +} + +::mlir::BoolAttr SplitHandleOpGenericAdaptorBase::getFailOnPayloadTooSmallAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().fail_on_payload_too_small); + return attr; +} + +bool SplitHandleOpGenericAdaptorBase::getFailOnPayloadTooSmall() { + auto attr = getFailOnPayloadTooSmallAttr(); + return attr.getValue(); +} + +::mlir::IntegerAttr SplitHandleOpGenericAdaptorBase::getOverflowResultAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::IntegerAttr>(getProperties().overflow_result); + return attr; +} + +::std::optional SplitHandleOpGenericAdaptorBase::getOverflowResult() { + auto attr = getOverflowResultAttr(); + return attr ? ::std::optional(attr.getValue().getZExtValue()) : (::std::nullopt); +} + +} // namespace detail +SplitHandleOpAdaptor::SplitHandleOpAdaptor(SplitHandleOp op) : SplitHandleOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult SplitHandleOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_fail_on_payload_too_small = getProperties().fail_on_payload_too_small; (void)tblgen_fail_on_payload_too_small; + auto tblgen_overflow_result = getProperties().overflow_result; (void)tblgen_overflow_result; + auto tblgen_pass_through_empty_handle = getProperties().pass_through_empty_handle; (void)tblgen_pass_through_empty_handle; + + if (tblgen_pass_through_empty_handle && !((::llvm::isa<::mlir::BoolAttr>(tblgen_pass_through_empty_handle)))) + return emitError(loc, "'transform.split_handle' op ""attribute 'pass_through_empty_handle' failed to satisfy constraint: bool attribute"); + + if (tblgen_fail_on_payload_too_small && !((::llvm::isa<::mlir::BoolAttr>(tblgen_fail_on_payload_too_small)))) + return emitError(loc, "'transform.split_handle' op ""attribute 'fail_on_payload_too_small' failed to satisfy constraint: bool attribute"); + + if (tblgen_overflow_result && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_overflow_result))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_overflow_result).getType().isSignlessInteger(64))))) + return emitError(loc, "'transform.split_handle' op ""attribute 'overflow_result' failed to satisfy constraint: 64-bit signless integer attribute"); + return ::mlir::success(); +} + +std::pair SplitHandleOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range SplitHandleOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> SplitHandleOp::getHandle() { + return ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &SplitHandleOp::getHandleMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair SplitHandleOp::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::result_range SplitHandleOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::result_range SplitHandleOp::getResults() { + return getODSResults(0); +} + +::mlir::LogicalResult SplitHandleOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.fail_on_payload_too_small; + auto attr = dict.get("fail_on_payload_too_small"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for fail_on_payload_too_small in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `fail_on_payload_too_small` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.overflow_result; + auto attr = dict.get("overflow_result"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for overflow_result in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `overflow_result` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.pass_through_empty_handle; + auto attr = dict.get("pass_through_empty_handle"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for pass_through_empty_handle in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `pass_through_empty_handle` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute SplitHandleOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.fail_on_payload_too_small; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("fail_on_payload_too_small", + propStorage)); + } + + { + const auto &propStorage = prop.overflow_result; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("overflow_result", + propStorage)); + } + + { + const auto &propStorage = prop.pass_through_empty_handle; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("pass_through_empty_handle", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code SplitHandleOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.fail_on_payload_too_small.getAsOpaquePointer()), + llvm::hash_value(prop.overflow_result.getAsOpaquePointer()), + llvm::hash_value(prop.pass_through_empty_handle.getAsOpaquePointer())); +} + +std::optional SplitHandleOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "fail_on_payload_too_small") + return prop.fail_on_payload_too_small; + + if (name == "overflow_result") + return prop.overflow_result; + + if (name == "pass_through_empty_handle") + return prop.pass_through_empty_handle; + return std::nullopt; +} + +void SplitHandleOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "fail_on_payload_too_small") { + prop.fail_on_payload_too_small = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "overflow_result") { + prop.overflow_result = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "pass_through_empty_handle") { + prop.pass_through_empty_handle = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void SplitHandleOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.fail_on_payload_too_small) attrs.append("fail_on_payload_too_small", prop.fail_on_payload_too_small); + + if (prop.overflow_result) attrs.append("overflow_result", prop.overflow_result); + + if (prop.pass_through_empty_handle) attrs.append("pass_through_empty_handle", prop.pass_through_empty_handle); +} + +::mlir::LogicalResult SplitHandleOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getFailOnPayloadTooSmallAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps11(attr, "fail_on_payload_too_small", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getOverflowResultAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps4(attr, "overflow_result", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getPassThroughEmptyHandleAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps11(attr, "pass_through_empty_handle", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult SplitHandleOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.fail_on_payload_too_small))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.overflow_result))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.pass_through_empty_handle))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SplitHandleOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.fail_on_payload_too_small); + + writer.writeOptionalAttribute(prop.overflow_result); + + writer.writeOptionalAttribute(prop.pass_through_empty_handle); +} + +::mlir::BoolAttr SplitHandleOp::getPassThroughEmptyHandleAttr() { + return ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().pass_through_empty_handle); +} + +bool SplitHandleOp::getPassThroughEmptyHandle() { + auto attr = getPassThroughEmptyHandleAttr(); + return attr.getValue(); +} + +::mlir::BoolAttr SplitHandleOp::getFailOnPayloadTooSmallAttr() { + return ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().fail_on_payload_too_small); +} + +bool SplitHandleOp::getFailOnPayloadTooSmall() { + auto attr = getFailOnPayloadTooSmallAttr(); + return attr.getValue(); +} + +::mlir::IntegerAttr SplitHandleOp::getOverflowResultAttr() { + return ::llvm::dyn_cast_or_null<::mlir::IntegerAttr>(getProperties().overflow_result); +} + +::std::optional SplitHandleOp::getOverflowResult() { + auto attr = getOverflowResultAttr(); + return attr ? ::std::optional(attr.getValue().getZExtValue()) : (::std::nullopt); +} + +void SplitHandleOp::setPassThroughEmptyHandleAttr(::mlir::BoolAttr attr) { + (*this)->setAttr(getPassThroughEmptyHandleAttrName(), attr); +} + +void SplitHandleOp::setPassThroughEmptyHandle(bool attrValue) { + (*this)->setAttr(getPassThroughEmptyHandleAttrName(), ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue)); +} + +void SplitHandleOp::setFailOnPayloadTooSmallAttr(::mlir::BoolAttr attr) { + (*this)->setAttr(getFailOnPayloadTooSmallAttrName(), attr); +} + +void SplitHandleOp::setFailOnPayloadTooSmall(bool attrValue) { + (*this)->setAttr(getFailOnPayloadTooSmallAttrName(), ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue)); +} + +void SplitHandleOp::setOverflowResultAttr(::mlir::IntegerAttr attr) { + (*this)->setAttr(getOverflowResultAttrName(), attr); +} + +void SplitHandleOp::setOverflowResult(::std::optional attrValue) { + if (attrValue) + return (*this)->setAttr(getOverflowResultAttrName(), ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), *attrValue)); + (*this)->removeAttr(getOverflowResultAttrName()); +} + +::mlir::Attribute SplitHandleOp::removeOverflowResultAttr() { + auto &attr = getProperties().overflow_result; + attr = {}; + return attr; +} + +void SplitHandleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::Value handle, ::mlir::BoolAttr pass_through_empty_handle, ::mlir::BoolAttr fail_on_payload_too_small, /*optional*/::mlir::IntegerAttr overflow_result) { + odsState.addOperands(handle); + if (pass_through_empty_handle) { + odsState.getOrAddProperties().pass_through_empty_handle = pass_through_empty_handle; + } + if (fail_on_payload_too_small) { + odsState.getOrAddProperties().fail_on_payload_too_small = fail_on_payload_too_small; + } + if (overflow_result) { + odsState.getOrAddProperties().overflow_result = overflow_result; + } + odsState.addTypes(results); +} + +void SplitHandleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::Value handle, bool pass_through_empty_handle, bool fail_on_payload_too_small, /*optional*/::mlir::IntegerAttr overflow_result) { + odsState.addOperands(handle); + odsState.getOrAddProperties().pass_through_empty_handle = odsBuilder.getBoolAttr(pass_through_empty_handle); + odsState.getOrAddProperties().fail_on_payload_too_small = odsBuilder.getBoolAttr(fail_on_payload_too_small); + if (overflow_result) { + odsState.getOrAddProperties().overflow_result = overflow_result; + } + odsState.addTypes(results); +} + +void SplitHandleOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + odsState.addTypes(resultTypes); +} + +void SplitHandleOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { + ::mlir::Builder odsBuilder(opName.getContext()); + if (!properties.pass_through_empty_handle) + properties.pass_through_empty_handle = odsBuilder.getBoolAttr(true); + if (!properties.fail_on_payload_too_small) + properties.fail_on_payload_too_small = odsBuilder.getBoolAttr(true); +} + +::mlir::LogicalResult SplitHandleOp::verifyInvariantsImpl() { + auto tblgen_fail_on_payload_too_small = getProperties().fail_on_payload_too_small; (void)tblgen_fail_on_payload_too_small; + auto tblgen_overflow_result = getProperties().overflow_result; (void)tblgen_overflow_result; + auto tblgen_pass_through_empty_handle = getProperties().pass_through_empty_handle; (void)tblgen_pass_through_empty_handle; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps11(*this, tblgen_pass_through_empty_handle, "pass_through_empty_handle"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps11(*this, tblgen_fail_on_payload_too_small, "fail_on_payload_too_small"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_TransformOps4(*this, tblgen_overflow_result, "overflow_result"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps0(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult SplitHandleOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult SplitHandleOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand handleRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> handleOperands(handleRawOperands); ::llvm::SMLoc handleOperandsLoc; + (void)handleOperandsLoc; + ::llvm::ArrayRef<::mlir::Type> allOperandTypes; + ::llvm::ArrayRef<::mlir::Type> allResultTypes; + + handleOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(handleRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + ::mlir::FunctionType allOperand__allResult_functionType; + if (parser.parseType(allOperand__allResult_functionType)) + return ::mlir::failure(); + allOperandTypes = allOperand__allResult_functionType.getInputs(); + allResultTypes = allOperand__allResult_functionType.getResults(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(handleOperands, allOperandTypes, parser.getNameLoc(), result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SplitHandleOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getHandle(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getPassThroughEmptyHandleAttr(); + if(attr && (attr == odsBuilder.getBoolAttr(true))) + elidedAttrs.push_back("pass_through_empty_handle"); + } + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getFailOnPayloadTooSmallAttr(); + if(attr && (attr == odsBuilder.getBoolAttr(true))) + elidedAttrs.push_back("fail_on_payload_too_small"); + } + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes()); +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::SplitHandleOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::VerifyOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +VerifyOpGenericAdaptorBase::VerifyOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("transform.verify", odsAttrs.getContext()); +} + +VerifyOpGenericAdaptorBase::VerifyOpGenericAdaptorBase(VerifyOp op) : VerifyOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair VerifyOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr VerifyOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +VerifyOpAdaptor::VerifyOpAdaptor(VerifyOp op) : VerifyOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult VerifyOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair VerifyOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range VerifyOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> VerifyOp::getTarget() { + return ::llvm::cast<::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &VerifyOp::getTargetMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair VerifyOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range VerifyOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +void VerifyOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value target) { + odsState.addOperands(target); +} + +void VerifyOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target) { + odsState.addOperands(target); + assert(resultTypes.size() == 0u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void VerifyOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult VerifyOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult VerifyOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult VerifyOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand targetRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> targetOperands(targetRawOperands); ::llvm::SMLoc targetOperandsLoc; + (void)targetOperandsLoc; + ::mlir::Type targetRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> targetTypes(targetRawTypes); + + targetOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(targetRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::transform::TransformHandleTypeInterface type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + targetRawTypes[0] = type; + } + if (parser.resolveOperands(targetOperands, targetTypes, targetOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void VerifyOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getTarget(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getTarget().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::transform::TransformHandleTypeInterface>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::VerifyOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::YieldOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +YieldOpGenericAdaptorBase::YieldOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("transform.yield", odsAttrs.getContext()); +} + +YieldOpGenericAdaptorBase::YieldOpGenericAdaptorBase(YieldOp op) : YieldOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair YieldOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr YieldOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +YieldOpAdaptor::YieldOpAdaptor(YieldOp op) : YieldOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult YieldOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair YieldOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range YieldOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::operand_range YieldOp::getOperands() { + return getODSOperands(0); +} + +::mlir::MutableOperandRange YieldOp::getOperandsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair YieldOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range YieldOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +void YieldOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { + return build(odsBuilder, odsState, ::mlir::ValueRange()); + +} + +void YieldOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands) { + odsState.addOperands(operands); +} + +void YieldOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult YieldOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_TransformOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult YieldOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult YieldOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands; + ::llvm::SmallVector<::mlir::Type, 1> operandsTypes; + ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(allOperands)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (::mlir::succeeded(parser.parseOptionalColon())) { + + if (parser.parseTypeList(operandsTypes)) + return ::mlir::failure(); + } + if (parser.resolveOperands(allOperands, operandsTypes, allOperandLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void YieldOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperation()->getOperands(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + if (!getOperands().empty()) { + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter << getOperands().getTypes(); + } +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::YieldOp) + + +#endif // GET_OP_CLASSES + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformOps.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformOps.h new file mode 100644 index 0000000000000000000000000000000000000000..1f46e34171b8ddcd185084e3adfe6b50cbb4a482 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformOps.h @@ -0,0 +1,47 @@ +//===- TransformDialect.h - Transform dialect operations --------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_TRANSFORM_IR_TRANSFORMOPS_H +#define MLIR_DIALECT_TRANSFORM_IR_TRANSFORMOPS_H + +#include "mlir/Bytecode/BytecodeOpInterface.h" +#include "mlir/Dialect/Transform/IR/MatchInterfaces.h" +#include "mlir/Dialect/Transform/IR/TransformAttrs.h" +#include "mlir/Dialect/Transform/IR/TransformDialect.h" +#include "mlir/Dialect/Transform/IR/TransformInterfaces.h" +#include "mlir/Dialect/Transform/IR/TransformTypes.h" +#include "mlir/IR/OpDefinition.h" +#include "mlir/IR/OpImplementation.h" +#include "mlir/IR/PatternMatch.h" +#include "mlir/IR/SymbolTable.h" +#include "mlir/Interfaces/CallInterfaces.h" +#include "mlir/Interfaces/CastInterfaces.h" +#include "mlir/Interfaces/ControlFlowInterfaces.h" +#include "mlir/Interfaces/FunctionInterfaces.h" +#include "mlir/Interfaces/LoopLikeInterface.h" + +namespace mlir { +namespace transform { + +enum class FailurePropagationMode : uint32_t; +class FailurePropagationModeAttr; + +/// A builder function that populates the body of a SequenceOp. +using SequenceBodyBuilderFn = ::llvm::function_ref; +using SequenceBodyBuilderArgsFn = + ::llvm::function_ref; + +} // namespace transform +} // namespace mlir + +#define GET_OP_CLASSES +#include "mlir/Dialect/Transform/IR/TransformOps.h.inc" + +#endif // MLIR_DIALECT_TRANSFORM_IR_TRANSFORMOPS_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformOps.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformOps.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..aa1d22274144c185d53bcd727ee283953d1bc668 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformOps.h.inc @@ -0,0 +1,5341 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Op Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: TransformOps.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#if defined(GET_OP_CLASSES) || defined(GET_OP_FWD_DEFINES) +#undef GET_OP_FWD_DEFINES +namespace mlir { +namespace transform { +class AlternativesOp; +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class AnnotateOp; +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class ApplyCanonicalizationPatternsOp; +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class ApplyCommonSubexpressionEliminationOp; +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class ApplyConversionPatternsOp; +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class ApplyDeadCodeEliminationOp; +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class ApplyLoopInvariantCodeMotionOp; +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class ApplyPatternsOp; +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class ApplyRegisteredPassOp; +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class ApplyToLLVMConversionPatternsOp; +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class CastOp; +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class ForeachMatchOp; +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class ForeachOp; +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class GetConsumersOfResult; +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class GetDefiningOp; +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class GetParentOp; +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class GetProducerOfOperand; +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class GetResultOp; +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class GetTypeOp; +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class IncludeOp; +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class MatchOperationEmptyOp; +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class MatchOperationNameOp; +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class MatchParamCmpIOp; +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class MergeHandlesOp; +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class NamedSequenceOp; +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class ParamConstantOp; +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class PrintOp; +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class ReplicateOp; +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class SelectOp; +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class SequenceOp; +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class SplitHandleOp; +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class VerifyOp; +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class YieldOp; +} // namespace transform +} // namespace mlir +#endif + +#ifdef GET_OP_CLASSES +#undef GET_OP_CLASSES + + +//===----------------------------------------------------------------------===// +// Local Utility Method Definitions +//===----------------------------------------------------------------------===// + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::AlternativesOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class AlternativesOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + AlternativesOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + AlternativesOpGenericAdaptorBase(AlternativesOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); + ::mlir::RegionRange getAlternatives(); + ::mlir::RegionRange getRegions(); +}; +} // namespace detail +template +class AlternativesOpGenericAdaptor : public detail::AlternativesOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::AlternativesOpGenericAdaptorBase; +public: + AlternativesOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + AlternativesOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : AlternativesOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + AlternativesOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getScope() { + auto operands = getODSOperands(0); + return operands.empty() ? ValueT{} : (*operands.begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class AlternativesOpAdaptor : public AlternativesOpGenericAdaptor<::mlir::ValueRange> { +public: + using AlternativesOpGenericAdaptor::AlternativesOpGenericAdaptor; + AlternativesOpAdaptor(AlternativesOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class AlternativesOp : public ::mlir::Op::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::RegionBranchOpInterface::Trait, ::mlir::transform::TransformOpInterface::Trait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::IsIsolatedFromAbove, ::mlir::transform::PossibleTopLevelTransformOpTrait> { +public: + using Op::Op; + using Op::print; + using Adaptor = AlternativesOpAdaptor; + template + using GenericAdaptor = AlternativesOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("transform.alternatives"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> getScope(); + ::mlir::MutableOperandRange getScopeMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Operation::result_range getResults(); + ::mlir::MutableArrayRef<::mlir::Region> getAlternatives(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, /*optional*/::mlir::Value scope, unsigned alternativesCount); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes, unsigned numRegions); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + ::mlir::OperandRange getEntrySuccessorOperands(::mlir::RegionBranchPoint point); + void getSuccessorRegions(::mlir::RegionBranchPoint point, ::llvm::SmallVectorImpl<::mlir::RegionSuccessor> ®ions); + void getRegionInvocationBounds(::llvm::ArrayRef<::mlir::Attribute> operands, ::llvm::SmallVectorImpl<::mlir::InvocationBounds> &invocationBounds); + ::mlir::DiagnosedSilenceableFailure apply(::mlir::transform::TransformRewriter &rewriter, ::mlir::transform::TransformResults &transformResults, ::mlir::transform::TransformState &state); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +public: +}; +} // namespace transform +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::AlternativesOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::AnnotateOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class AnnotateOpGenericAdaptorBase { +public: + struct Properties { + using nameTy = ::mlir::StringAttr; + nameTy name; + + auto getName() { + auto &propStorage = this->name; + return ::llvm::cast<::mlir::StringAttr>(propStorage); + } + void setName(const ::mlir::StringAttr &propValue) { + this->name = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.name == this->name && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + AnnotateOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + AnnotateOpGenericAdaptorBase(AnnotateOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::StringAttr getNameAttr(); + ::llvm::StringRef getName(); +}; +} // namespace detail +template +class AnnotateOpGenericAdaptor : public detail::AnnotateOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::AnnotateOpGenericAdaptorBase; +public: + AnnotateOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + AnnotateOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : AnnotateOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + AnnotateOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getTarget() { + return (*getODSOperands(0).begin()); + } + + ValueT getParam() { + auto operands = getODSOperands(1); + return operands.empty() ? ValueT{} : (*operands.begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class AnnotateOpAdaptor : public AnnotateOpGenericAdaptor<::mlir::ValueRange> { +public: + using AnnotateOpGenericAdaptor::AnnotateOpGenericAdaptor; + AnnotateOpAdaptor(AnnotateOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class AnnotateOp : public ::mlir::Op::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::transform::TransformOpInterface::Trait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = AnnotateOpAdaptor; + template + using GenericAdaptor = AnnotateOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("name")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getNameAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getNameAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("transform.annotate"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> getTarget(); + ::mlir::TypedValue<::mlir::transform::TransformParamTypeInterface> getParam(); + ::mlir::OpOperand &getTargetMutable(); + ::mlir::MutableOperandRange getParamMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::StringAttr getNameAttr(); + ::llvm::StringRef getName(); + void setNameAttr(::mlir::StringAttr attr); + void setName(::llvm::StringRef attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value target, ::mlir::StringAttr name, /*optional*/::mlir::Value param); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target, ::mlir::StringAttr name, /*optional*/::mlir::Value param); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value target, ::llvm::StringRef name, /*optional*/::mlir::Value param); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target, ::llvm::StringRef name, /*optional*/::mlir::Value param); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::DiagnosedSilenceableFailure apply(::mlir::transform::TransformRewriter &rewriter, ::mlir::transform::TransformResults &transformResults, ::mlir::transform::TransformState &state); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace transform +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::AnnotateOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::ApplyCanonicalizationPatternsOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ApplyCanonicalizationPatternsOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + ApplyCanonicalizationPatternsOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + ApplyCanonicalizationPatternsOpGenericAdaptorBase(ApplyCanonicalizationPatternsOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class ApplyCanonicalizationPatternsOpGenericAdaptor : public detail::ApplyCanonicalizationPatternsOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ApplyCanonicalizationPatternsOpGenericAdaptorBase; +public: + ApplyCanonicalizationPatternsOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ApplyCanonicalizationPatternsOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ApplyCanonicalizationPatternsOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + ApplyCanonicalizationPatternsOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ApplyCanonicalizationPatternsOpAdaptor : public ApplyCanonicalizationPatternsOpGenericAdaptor<::mlir::ValueRange> { +public: + using ApplyCanonicalizationPatternsOpGenericAdaptor::ApplyCanonicalizationPatternsOpGenericAdaptor; + ApplyCanonicalizationPatternsOpAdaptor(ApplyCanonicalizationPatternsOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ApplyCanonicalizationPatternsOp : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = ApplyCanonicalizationPatternsOpAdaptor; + template + using GenericAdaptor = ApplyCanonicalizationPatternsOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("transform.apply_patterns.canonicalization"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + void populatePatterns(::mlir::RewritePatternSet &patterns); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +public: +}; +} // namespace transform +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::ApplyCanonicalizationPatternsOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::ApplyCommonSubexpressionEliminationOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ApplyCommonSubexpressionEliminationOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + ApplyCommonSubexpressionEliminationOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + ApplyCommonSubexpressionEliminationOpGenericAdaptorBase(ApplyCommonSubexpressionEliminationOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class ApplyCommonSubexpressionEliminationOpGenericAdaptor : public detail::ApplyCommonSubexpressionEliminationOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ApplyCommonSubexpressionEliminationOpGenericAdaptorBase; +public: + ApplyCommonSubexpressionEliminationOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ApplyCommonSubexpressionEliminationOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ApplyCommonSubexpressionEliminationOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + ApplyCommonSubexpressionEliminationOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getTarget() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ApplyCommonSubexpressionEliminationOpAdaptor : public ApplyCommonSubexpressionEliminationOpGenericAdaptor<::mlir::ValueRange> { +public: + using ApplyCommonSubexpressionEliminationOpGenericAdaptor::ApplyCommonSubexpressionEliminationOpGenericAdaptor; + ApplyCommonSubexpressionEliminationOpAdaptor(ApplyCommonSubexpressionEliminationOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ApplyCommonSubexpressionEliminationOp : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = ApplyCommonSubexpressionEliminationOpAdaptor; + template + using GenericAdaptor = ApplyCommonSubexpressionEliminationOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("transform.apply_cse"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> getTarget(); + ::mlir::OpOperand &getTargetMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value target); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +public: + ::mlir::DiagnosedSilenceableFailure applyToOne( + ::mlir::transform::TransformRewriter &rewriter, + ::mlir::Operation *target, + ::mlir::transform::ApplyToEachResultList &results, + ::mlir::transform::TransformState &state); +}; +} // namespace transform +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::ApplyCommonSubexpressionEliminationOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::ApplyConversionPatternsOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ApplyConversionPatternsOpGenericAdaptorBase { +public: + struct Properties { + using illegal_dialectsTy = ::mlir::ArrayAttr; + illegal_dialectsTy illegal_dialects; + + auto getIllegalDialects() { + auto &propStorage = this->illegal_dialects; + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(propStorage); + } + void setIllegalDialects(const ::mlir::ArrayAttr &propValue) { + this->illegal_dialects = propValue; + } + using illegal_opsTy = ::mlir::ArrayAttr; + illegal_opsTy illegal_ops; + + auto getIllegalOps() { + auto &propStorage = this->illegal_ops; + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(propStorage); + } + void setIllegalOps(const ::mlir::ArrayAttr &propValue) { + this->illegal_ops = propValue; + } + using legal_dialectsTy = ::mlir::ArrayAttr; + legal_dialectsTy legal_dialects; + + auto getLegalDialects() { + auto &propStorage = this->legal_dialects; + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(propStorage); + } + void setLegalDialects(const ::mlir::ArrayAttr &propValue) { + this->legal_dialects = propValue; + } + using legal_opsTy = ::mlir::ArrayAttr; + legal_opsTy legal_ops; + + auto getLegalOps() { + auto &propStorage = this->legal_ops; + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(propStorage); + } + void setLegalOps(const ::mlir::ArrayAttr &propValue) { + this->legal_ops = propValue; + } + using partial_conversionTy = ::mlir::UnitAttr; + partial_conversionTy partial_conversion; + + auto getPartialConversion() { + auto &propStorage = this->partial_conversion; + return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(propStorage); + } + void setPartialConversion(const ::mlir::UnitAttr &propValue) { + this->partial_conversion = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.illegal_dialects == this->illegal_dialects && + rhs.illegal_ops == this->illegal_ops && + rhs.legal_dialects == this->legal_dialects && + rhs.legal_ops == this->legal_ops && + rhs.partial_conversion == this->partial_conversion && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ApplyConversionPatternsOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + ApplyConversionPatternsOpGenericAdaptorBase(ApplyConversionPatternsOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::ArrayAttr getLegalOpsAttr(); + ::std::optional< ::mlir::ArrayAttr > getLegalOps(); + ::mlir::ArrayAttr getIllegalOpsAttr(); + ::std::optional< ::mlir::ArrayAttr > getIllegalOps(); + ::mlir::ArrayAttr getLegalDialectsAttr(); + ::std::optional< ::mlir::ArrayAttr > getLegalDialects(); + ::mlir::ArrayAttr getIllegalDialectsAttr(); + ::std::optional< ::mlir::ArrayAttr > getIllegalDialects(); + ::mlir::UnitAttr getPartialConversionAttr(); + bool getPartialConversion(); + ::mlir::Region &getPatterns(); + ::mlir::RegionRange getDefaultTypeConverterRegion(); + ::mlir::RegionRange getRegions(); +}; +} // namespace detail +template +class ApplyConversionPatternsOpGenericAdaptor : public detail::ApplyConversionPatternsOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ApplyConversionPatternsOpGenericAdaptorBase; +public: + ApplyConversionPatternsOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ApplyConversionPatternsOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ApplyConversionPatternsOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + ApplyConversionPatternsOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getTarget() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ApplyConversionPatternsOpAdaptor : public ApplyConversionPatternsOpGenericAdaptor<::mlir::ValueRange> { +public: + using ApplyConversionPatternsOpGenericAdaptor::ApplyConversionPatternsOpGenericAdaptor; + ApplyConversionPatternsOpAdaptor(ApplyConversionPatternsOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ApplyConversionPatternsOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroResults, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::NoTerminator, ::mlir::OpTrait::SingleBlock, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::transform::TransformOpInterface::Trait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::transform::ReportTrackingListenerFailuresOpTrait, ::mlir::RegionKindInterface::Trait, ::mlir::OpTrait::HasOnlyGraphRegion> { +public: + using Op::Op; + using Op::print; + using Adaptor = ApplyConversionPatternsOpAdaptor; + template + using GenericAdaptor = ApplyConversionPatternsOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("illegal_dialects"), ::llvm::StringRef("illegal_ops"), ::llvm::StringRef("legal_dialects"), ::llvm::StringRef("legal_ops"), ::llvm::StringRef("partial_conversion")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getIllegalDialectsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getIllegalDialectsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getIllegalOpsAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getIllegalOpsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getLegalDialectsAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getLegalDialectsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getLegalOpsAttrName() { + return getAttributeNameForIndex(3); + } + + static ::mlir::StringAttr getLegalOpsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 3); + } + + ::mlir::StringAttr getPartialConversionAttrName() { + return getAttributeNameForIndex(4); + } + + static ::mlir::StringAttr getPartialConversionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 4); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("transform.apply_conversion_patterns"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> getTarget(); + ::mlir::OpOperand &getTargetMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Region &getPatterns(); + ::mlir::MutableArrayRef<::mlir::Region> getDefaultTypeConverterRegion(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::ArrayAttr getLegalOpsAttr(); + ::std::optional< ::mlir::ArrayAttr > getLegalOps(); + ::mlir::ArrayAttr getIllegalOpsAttr(); + ::std::optional< ::mlir::ArrayAttr > getIllegalOps(); + ::mlir::ArrayAttr getLegalDialectsAttr(); + ::std::optional< ::mlir::ArrayAttr > getLegalDialects(); + ::mlir::ArrayAttr getIllegalDialectsAttr(); + ::std::optional< ::mlir::ArrayAttr > getIllegalDialects(); + ::mlir::UnitAttr getPartialConversionAttr(); + bool getPartialConversion(); + void setLegalOpsAttr(::mlir::ArrayAttr attr); + void setIllegalOpsAttr(::mlir::ArrayAttr attr); + void setLegalDialectsAttr(::mlir::ArrayAttr attr); + void setIllegalDialectsAttr(::mlir::ArrayAttr attr); + void setPartialConversionAttr(::mlir::UnitAttr attr); + void setPartialConversion(bool attrValue); + ::mlir::Attribute removeLegalOpsAttr(); + ::mlir::Attribute removeIllegalOpsAttr(); + ::mlir::Attribute removeLegalDialectsAttr(); + ::mlir::Attribute removeIllegalDialectsAttr(); + ::mlir::Attribute removePartialConversionAttr(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value target, function_ref patternsBodyBuilder = nullptr, function_ref typeConverterBodyBuilder = nullptr); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + ::mlir::DiagnosedSilenceableFailure apply(::mlir::transform::TransformRewriter &rewriter, ::mlir::transform::TransformResults &transformResults, ::mlir::transform::TransformState &state); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 5 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + ::mlir::transform::TypeConverterBuilderOpInterface getDefaultTypeConverter() { + if (getDefaultTypeConverterRegion().size() == 0) + return {}; + return ::llvm::cast<::mlir::transform::TypeConverterBuilderOpInterface>( + &getDefaultTypeConverterRegion()[0].front().front()); + } +}; +} // namespace transform +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::ApplyConversionPatternsOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::ApplyDeadCodeEliminationOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ApplyDeadCodeEliminationOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + ApplyDeadCodeEliminationOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + ApplyDeadCodeEliminationOpGenericAdaptorBase(ApplyDeadCodeEliminationOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class ApplyDeadCodeEliminationOpGenericAdaptor : public detail::ApplyDeadCodeEliminationOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ApplyDeadCodeEliminationOpGenericAdaptorBase; +public: + ApplyDeadCodeEliminationOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ApplyDeadCodeEliminationOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ApplyDeadCodeEliminationOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + ApplyDeadCodeEliminationOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getTarget() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ApplyDeadCodeEliminationOpAdaptor : public ApplyDeadCodeEliminationOpGenericAdaptor<::mlir::ValueRange> { +public: + using ApplyDeadCodeEliminationOpGenericAdaptor::ApplyDeadCodeEliminationOpGenericAdaptor; + ApplyDeadCodeEliminationOpAdaptor(ApplyDeadCodeEliminationOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ApplyDeadCodeEliminationOp : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = ApplyDeadCodeEliminationOpAdaptor; + template + using GenericAdaptor = ApplyDeadCodeEliminationOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("transform.apply_dce"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> getTarget(); + ::mlir::OpOperand &getTargetMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value target); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +public: + ::mlir::DiagnosedSilenceableFailure applyToOne( + ::mlir::transform::TransformRewriter &rewriter, + ::mlir::Operation *target, + ::mlir::transform::ApplyToEachResultList &results, + ::mlir::transform::TransformState &state); +}; +} // namespace transform +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::ApplyDeadCodeEliminationOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::ApplyLoopInvariantCodeMotionOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ApplyLoopInvariantCodeMotionOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + ApplyLoopInvariantCodeMotionOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + ApplyLoopInvariantCodeMotionOpGenericAdaptorBase(ApplyLoopInvariantCodeMotionOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class ApplyLoopInvariantCodeMotionOpGenericAdaptor : public detail::ApplyLoopInvariantCodeMotionOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ApplyLoopInvariantCodeMotionOpGenericAdaptorBase; +public: + ApplyLoopInvariantCodeMotionOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ApplyLoopInvariantCodeMotionOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ApplyLoopInvariantCodeMotionOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + ApplyLoopInvariantCodeMotionOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getTarget() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ApplyLoopInvariantCodeMotionOpAdaptor : public ApplyLoopInvariantCodeMotionOpGenericAdaptor<::mlir::ValueRange> { +public: + using ApplyLoopInvariantCodeMotionOpGenericAdaptor::ApplyLoopInvariantCodeMotionOpGenericAdaptor; + ApplyLoopInvariantCodeMotionOpAdaptor(ApplyLoopInvariantCodeMotionOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ApplyLoopInvariantCodeMotionOp : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = ApplyLoopInvariantCodeMotionOpAdaptor; + template + using GenericAdaptor = ApplyLoopInvariantCodeMotionOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("transform.apply_licm"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> getTarget(); + ::mlir::OpOperand &getTargetMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value target); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +public: + ::mlir::DiagnosedSilenceableFailure applyToOne( + ::mlir::transform::TransformRewriter &rewriter, + ::mlir::LoopLikeOpInterface target, + ::mlir::transform::ApplyToEachResultList &results, + ::mlir::transform::TransformState &state); +}; +} // namespace transform +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::ApplyLoopInvariantCodeMotionOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::ApplyPatternsOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ApplyPatternsOpGenericAdaptorBase { +public: + struct Properties { + using apply_cseTy = ::mlir::UnitAttr; + apply_cseTy apply_cse; + + auto getApplyCse() { + auto &propStorage = this->apply_cse; + return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(propStorage); + } + void setApplyCse(const ::mlir::UnitAttr &propValue) { + this->apply_cse = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.apply_cse == this->apply_cse && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ApplyPatternsOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + ApplyPatternsOpGenericAdaptorBase(ApplyPatternsOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::UnitAttr getApplyCseAttr(); + bool getApplyCse(); + ::mlir::Region &getPatterns(); + ::mlir::RegionRange getRegions(); +}; +} // namespace detail +template +class ApplyPatternsOpGenericAdaptor : public detail::ApplyPatternsOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ApplyPatternsOpGenericAdaptorBase; +public: + ApplyPatternsOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ApplyPatternsOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ApplyPatternsOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + ApplyPatternsOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getTarget() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ApplyPatternsOpAdaptor : public ApplyPatternsOpGenericAdaptor<::mlir::ValueRange> { +public: + using ApplyPatternsOpGenericAdaptor::ApplyPatternsOpGenericAdaptor; + ApplyPatternsOpAdaptor(ApplyPatternsOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ApplyPatternsOp : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = ApplyPatternsOpAdaptor; + template + using GenericAdaptor = ApplyPatternsOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("apply_cse")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getApplyCseAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getApplyCseAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("transform.apply_patterns"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> getTarget(); + ::mlir::OpOperand &getTargetMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Region &getPatterns(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::UnitAttr getApplyCseAttr(); + bool getApplyCse(); + void setApplyCseAttr(::mlir::UnitAttr attr); + void setApplyCse(bool attrValue); + ::mlir::Attribute removeApplyCseAttr(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value target, function_ref bodyBuilder = nullptr); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + ::mlir::DiagnosedSilenceableFailure applyToOne( + ::mlir::transform::TransformRewriter &rewriter, + ::mlir::Operation *target, + ::mlir::transform::ApplyToEachResultList &results, + ::mlir::transform::TransformState &state); +}; +} // namespace transform +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::ApplyPatternsOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::ApplyRegisteredPassOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ApplyRegisteredPassOpGenericAdaptorBase { +public: + struct Properties { + using optionsTy = ::mlir::StringAttr; + optionsTy options; + + auto getOptions() { + auto &propStorage = this->options; + return ::llvm::dyn_cast_or_null<::mlir::StringAttr>(propStorage); + } + void setOptions(const ::mlir::StringAttr &propValue) { + this->options = propValue; + } + using pass_nameTy = ::mlir::StringAttr; + pass_nameTy pass_name; + + auto getPassName() { + auto &propStorage = this->pass_name; + return ::llvm::cast<::mlir::StringAttr>(propStorage); + } + void setPassName(const ::mlir::StringAttr &propValue) { + this->pass_name = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.options == this->options && + rhs.pass_name == this->pass_name && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ApplyRegisteredPassOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + ApplyRegisteredPassOpGenericAdaptorBase(ApplyRegisteredPassOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::StringAttr getPassNameAttr(); + ::llvm::StringRef getPassName(); + ::mlir::StringAttr getOptionsAttr(); + ::llvm::StringRef getOptions(); +}; +} // namespace detail +template +class ApplyRegisteredPassOpGenericAdaptor : public detail::ApplyRegisteredPassOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ApplyRegisteredPassOpGenericAdaptorBase; +public: + ApplyRegisteredPassOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ApplyRegisteredPassOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ApplyRegisteredPassOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + ApplyRegisteredPassOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getTarget() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ApplyRegisteredPassOpAdaptor : public ApplyRegisteredPassOpGenericAdaptor<::mlir::ValueRange> { +public: + using ApplyRegisteredPassOpGenericAdaptor::ApplyRegisteredPassOpGenericAdaptor; + ApplyRegisteredPassOpAdaptor(ApplyRegisteredPassOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ApplyRegisteredPassOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::transform::TransformOpInterface::Trait, ::mlir::transform::TransformEachOpTrait, ::mlir::transform::FunctionalStyleTransformOpTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ApplyRegisteredPassOpAdaptor; + template + using GenericAdaptor = ApplyRegisteredPassOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("options"), ::llvm::StringRef("pass_name")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getOptionsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getOptionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getPassNameAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getPassNameAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("transform.apply_registered_pass"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> getTarget(); + ::mlir::OpOperand &getTargetMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> getResult(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::StringAttr getPassNameAttr(); + ::llvm::StringRef getPassName(); + ::mlir::StringAttr getOptionsAttr(); + ::llvm::StringRef getOptions(); + void setPassNameAttr(::mlir::StringAttr attr); + void setPassName(::llvm::StringRef attrValue); + void setOptionsAttr(::mlir::StringAttr attr); + void setOptions(::llvm::StringRef attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value target, ::mlir::StringAttr pass_name, ::mlir::StringAttr options); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target, ::mlir::StringAttr pass_name, ::mlir::StringAttr options); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value target, ::llvm::StringRef pass_name, ::llvm::StringRef options = ""); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target, ::llvm::StringRef pass_name, ::llvm::StringRef options = ""); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void populateDefaultProperties(::mlir::OperationName opName, Properties &properties); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + ::mlir::DiagnosedSilenceableFailure applyToOne( + ::mlir::transform::TransformRewriter &rewriter, + ::mlir::Operation *target, + ::mlir::transform::ApplyToEachResultList &results, + ::mlir::transform::TransformState &state); +}; +} // namespace transform +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::ApplyRegisteredPassOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::ApplyToLLVMConversionPatternsOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ApplyToLLVMConversionPatternsOpGenericAdaptorBase { +public: + struct Properties { + using dialect_nameTy = ::mlir::StringAttr; + dialect_nameTy dialect_name; + + auto getDialectName() { + auto &propStorage = this->dialect_name; + return ::llvm::cast<::mlir::StringAttr>(propStorage); + } + void setDialectName(const ::mlir::StringAttr &propValue) { + this->dialect_name = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.dialect_name == this->dialect_name && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ApplyToLLVMConversionPatternsOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + ApplyToLLVMConversionPatternsOpGenericAdaptorBase(ApplyToLLVMConversionPatternsOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::StringAttr getDialectNameAttr(); + ::llvm::StringRef getDialectName(); +}; +} // namespace detail +template +class ApplyToLLVMConversionPatternsOpGenericAdaptor : public detail::ApplyToLLVMConversionPatternsOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ApplyToLLVMConversionPatternsOpGenericAdaptorBase; +public: + ApplyToLLVMConversionPatternsOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ApplyToLLVMConversionPatternsOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ApplyToLLVMConversionPatternsOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + ApplyToLLVMConversionPatternsOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ApplyToLLVMConversionPatternsOpAdaptor : public ApplyToLLVMConversionPatternsOpGenericAdaptor<::mlir::ValueRange> { +public: + using ApplyToLLVMConversionPatternsOpGenericAdaptor::ApplyToLLVMConversionPatternsOpGenericAdaptor; + ApplyToLLVMConversionPatternsOpAdaptor(ApplyToLLVMConversionPatternsOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ApplyToLLVMConversionPatternsOp : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = ApplyToLLVMConversionPatternsOpAdaptor; + template + using GenericAdaptor = ApplyToLLVMConversionPatternsOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("dialect_name")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getDialectNameAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getDialectNameAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("transform.apply_conversion_patterns.dialect_to_llvm"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::StringAttr getDialectNameAttr(); + ::llvm::StringRef getDialectName(); + void setDialectNameAttr(::mlir::StringAttr attr); + void setDialectName(::llvm::StringRef attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::StringAttr dialect_name); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::StringAttr dialect_name); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llvm::StringRef dialect_name); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::llvm::StringRef dialect_name); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + void populatePatterns(::mlir::TypeConverter &typeConverter, ::mlir::RewritePatternSet &patterns); + ::mlir::LogicalResult verifyTypeConverter(TypeConverterBuilderOpInterface builder); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace transform +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::ApplyToLLVMConversionPatternsOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::CastOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CastOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + CastOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + CastOpGenericAdaptorBase(CastOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class CastOpGenericAdaptor : public detail::CastOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CastOpGenericAdaptorBase; +public: + CastOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CastOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CastOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + CastOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getInput() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class CastOpAdaptor : public CastOpGenericAdaptor<::mlir::ValueRange> { +public: + using CastOpGenericAdaptor::CastOpGenericAdaptor; + CastOpAdaptor(CastOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class CastOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::transform::TransformOpInterface::Trait, ::mlir::transform::TransformEachOpTrait, ::mlir::CastOpInterface::Trait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = CastOpAdaptor; + template + using GenericAdaptor = CastOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("transform.cast"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> getInput(); + ::mlir::OpOperand &getInputMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> getOutput(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static bool areCastCompatible(::mlir::TypeRange inputs, ::mlir::TypeRange outputs); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +public: + ::mlir::DiagnosedSilenceableFailure applyToOne( + ::mlir::transform::TransformRewriter &rewriter, + ::mlir::Operation *target, + ::mlir::transform::ApplyToEachResultList &results, + ::mlir::transform::TransformState &state); +}; +} // namespace transform +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::CastOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::ForeachMatchOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ForeachMatchOpGenericAdaptorBase { +public: + struct Properties { + using actionsTy = ::mlir::ArrayAttr; + actionsTy actions; + + auto getActions() { + auto &propStorage = this->actions; + return ::llvm::cast<::mlir::ArrayAttr>(propStorage); + } + void setActions(const ::mlir::ArrayAttr &propValue) { + this->actions = propValue; + } + using matchersTy = ::mlir::ArrayAttr; + matchersTy matchers; + + auto getMatchers() { + auto &propStorage = this->matchers; + return ::llvm::cast<::mlir::ArrayAttr>(propStorage); + } + void setMatchers(const ::mlir::ArrayAttr &propValue) { + this->matchers = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.actions == this->actions && + rhs.matchers == this->matchers && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ForeachMatchOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + ForeachMatchOpGenericAdaptorBase(ForeachMatchOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::ArrayAttr getMatchersAttr(); + ::mlir::ArrayAttr getMatchers(); + ::mlir::ArrayAttr getActionsAttr(); + ::mlir::ArrayAttr getActions(); +}; +} // namespace detail +template +class ForeachMatchOpGenericAdaptor : public detail::ForeachMatchOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ForeachMatchOpGenericAdaptorBase; +public: + ForeachMatchOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ForeachMatchOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ForeachMatchOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + ForeachMatchOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getRoot() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ForeachMatchOpAdaptor : public ForeachMatchOpGenericAdaptor<::mlir::ValueRange> { +public: + using ForeachMatchOpGenericAdaptor::ForeachMatchOpGenericAdaptor; + ForeachMatchOpAdaptor(ForeachMatchOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ForeachMatchOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::SymbolUserOpInterface::Trait, ::mlir::transform::TransformOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ForeachMatchOpAdaptor; + template + using GenericAdaptor = ForeachMatchOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("actions"), ::llvm::StringRef("matchers")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getActionsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getActionsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getMatchersAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getMatchersAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("transform.foreach_match"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> getRoot(); + ::mlir::OpOperand &getRootMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> getUpdated(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::ArrayAttr getMatchersAttr(); + ::mlir::ArrayAttr getMatchers(); + ::mlir::ArrayAttr getActionsAttr(); + ::mlir::ArrayAttr getActions(); + void setMatchersAttr(::mlir::ArrayAttr attr); + void setActionsAttr(::mlir::ArrayAttr attr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type updated, ::mlir::Value root, ::mlir::ArrayAttr matchers, ::mlir::ArrayAttr actions); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value root, ::mlir::ArrayAttr matchers, ::mlir::ArrayAttr actions); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); + ::mlir::LogicalResult verifySymbolUses(::mlir::SymbolTableCollection &symbolTable); + ::mlir::DiagnosedSilenceableFailure apply(::mlir::transform::TransformRewriter &rewriter, ::mlir::transform::TransformResults &transformResults, ::mlir::transform::TransformState &state); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace transform +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::ForeachMatchOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::ForeachOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ForeachOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + ForeachOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + ForeachOpGenericAdaptorBase(ForeachOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); + ::mlir::Region &getBody(); + ::mlir::RegionRange getRegions(); +}; +} // namespace detail +template +class ForeachOpGenericAdaptor : public detail::ForeachOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ForeachOpGenericAdaptorBase; +public: + ForeachOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ForeachOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ForeachOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + ForeachOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getTarget() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ForeachOpAdaptor : public ForeachOpGenericAdaptor<::mlir::ValueRange> { +public: + using ForeachOpGenericAdaptor::ForeachOpGenericAdaptor; + ForeachOpAdaptor(ForeachOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ForeachOp : public ::mlir::Op::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::transform::TransformOpInterface::Trait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::RegionBranchOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ForeachOpAdaptor; + template + using GenericAdaptor = ForeachOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("transform.foreach"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> getTarget(); + ::mlir::OpOperand &getTargetMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Operation::result_range getResults(); + ::mlir::Region &getBody(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::Value target); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + ::mlir::DiagnosedSilenceableFailure apply(::mlir::transform::TransformRewriter &rewriter, ::mlir::transform::TransformResults &transformResults, ::mlir::transform::TransformState &state); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); + ::mlir::OperandRange getEntrySuccessorOperands(::mlir::RegionBranchPoint point); + void getSuccessorRegions(::mlir::RegionBranchPoint point, ::llvm::SmallVectorImpl<::mlir::RegionSuccessor> ®ions); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +public: + /// Allow the dialect prefix to be omitted. + static StringRef getDefaultDialect() { return "transform"; } + + BlockArgument getIterationVariable() { + return getBody().front().getArgument(0); + } + + transform::YieldOp getYieldOp(); +}; +} // namespace transform +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::ForeachOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::GetConsumersOfResult declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class GetConsumersOfResultGenericAdaptorBase { +public: + struct Properties { + using result_numberTy = ::mlir::IntegerAttr; + result_numberTy result_number; + + auto getResultNumber() { + auto &propStorage = this->result_number; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setResultNumber(const ::mlir::IntegerAttr &propValue) { + this->result_number = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.result_number == this->result_number && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + GetConsumersOfResultGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + GetConsumersOfResultGenericAdaptorBase(GetConsumersOfResult op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::IntegerAttr getResultNumberAttr(); + uint64_t getResultNumber(); +}; +} // namespace detail +template +class GetConsumersOfResultGenericAdaptor : public detail::GetConsumersOfResultGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::GetConsumersOfResultGenericAdaptorBase; +public: + GetConsumersOfResultGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + GetConsumersOfResultGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : GetConsumersOfResultGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + GetConsumersOfResultGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getTarget() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class GetConsumersOfResultAdaptor : public GetConsumersOfResultGenericAdaptor<::mlir::ValueRange> { +public: + using GetConsumersOfResultGenericAdaptor::GetConsumersOfResultGenericAdaptor; + GetConsumersOfResultAdaptor(GetConsumersOfResult op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class GetConsumersOfResult : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::transform::TransformOpInterface::Trait, ::mlir::transform::NavigationTransformOpTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = GetConsumersOfResultAdaptor; + template + using GenericAdaptor = GetConsumersOfResultGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("result_number")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getResultNumberAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getResultNumberAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("transform.get_consumers_of_result"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> getTarget(); + ::mlir::OpOperand &getTargetMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> getConsumers(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::IntegerAttr getResultNumberAttr(); + uint64_t getResultNumber(); + void setResultNumberAttr(::mlir::IntegerAttr attr); + void setResultNumber(uint64_t attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type consumers, ::mlir::Value target, ::mlir::IntegerAttr result_number); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target, ::mlir::IntegerAttr result_number); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type consumers, ::mlir::Value target, uint64_t result_number); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target, uint64_t result_number); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::DiagnosedSilenceableFailure apply(::mlir::transform::TransformRewriter &rewriter, ::mlir::transform::TransformResults &transformResults, ::mlir::transform::TransformState &state); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace transform +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::GetConsumersOfResult) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::GetDefiningOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class GetDefiningOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + GetDefiningOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + GetDefiningOpGenericAdaptorBase(GetDefiningOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class GetDefiningOpGenericAdaptor : public detail::GetDefiningOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::GetDefiningOpGenericAdaptorBase; +public: + GetDefiningOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + GetDefiningOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : GetDefiningOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + GetDefiningOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getTarget() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class GetDefiningOpAdaptor : public GetDefiningOpGenericAdaptor<::mlir::ValueRange> { +public: + using GetDefiningOpGenericAdaptor::GetDefiningOpGenericAdaptor; + GetDefiningOpAdaptor(GetDefiningOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class GetDefiningOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::transform::TransformOpInterface::Trait, ::mlir::transform::MatchOpInterface::Trait, ::mlir::transform::NavigationTransformOpTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = GetDefiningOpAdaptor; + template + using GenericAdaptor = GetDefiningOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("transform.get_defining_op"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformValueHandleTypeInterface> getTarget(); + ::mlir::OpOperand &getTargetMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value target); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::DiagnosedSilenceableFailure apply(::mlir::transform::TransformRewriter &rewriter, ::mlir::transform::TransformResults &transformResults, ::mlir::transform::TransformState &state); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +public: +}; +} // namespace transform +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::GetDefiningOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::GetParentOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class GetParentOpGenericAdaptorBase { +public: + struct Properties { + using allow_empty_resultsTy = ::mlir::UnitAttr; + allow_empty_resultsTy allow_empty_results; + + auto getAllowEmptyResults() { + auto &propStorage = this->allow_empty_results; + return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(propStorage); + } + void setAllowEmptyResults(const ::mlir::UnitAttr &propValue) { + this->allow_empty_results = propValue; + } + using deduplicateTy = ::mlir::UnitAttr; + deduplicateTy deduplicate; + + auto getDeduplicate() { + auto &propStorage = this->deduplicate; + return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(propStorage); + } + void setDeduplicate(const ::mlir::UnitAttr &propValue) { + this->deduplicate = propValue; + } + using isolated_from_aboveTy = ::mlir::UnitAttr; + isolated_from_aboveTy isolated_from_above; + + auto getIsolatedFromAbove() { + auto &propStorage = this->isolated_from_above; + return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(propStorage); + } + void setIsolatedFromAbove(const ::mlir::UnitAttr &propValue) { + this->isolated_from_above = propValue; + } + using op_nameTy = ::mlir::StringAttr; + op_nameTy op_name; + + auto getOpName() { + auto &propStorage = this->op_name; + return ::llvm::dyn_cast_or_null<::mlir::StringAttr>(propStorage); + } + void setOpName(const ::mlir::StringAttr &propValue) { + this->op_name = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.allow_empty_results == this->allow_empty_results && + rhs.deduplicate == this->deduplicate && + rhs.isolated_from_above == this->isolated_from_above && + rhs.op_name == this->op_name && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + GetParentOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + GetParentOpGenericAdaptorBase(GetParentOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::UnitAttr getIsolatedFromAboveAttr(); + bool getIsolatedFromAbove(); + ::mlir::UnitAttr getAllowEmptyResultsAttr(); + bool getAllowEmptyResults(); + ::mlir::StringAttr getOpNameAttr(); + ::std::optional< ::llvm::StringRef > getOpName(); + ::mlir::UnitAttr getDeduplicateAttr(); + bool getDeduplicate(); +}; +} // namespace detail +template +class GetParentOpGenericAdaptor : public detail::GetParentOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::GetParentOpGenericAdaptorBase; +public: + GetParentOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + GetParentOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : GetParentOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + GetParentOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getTarget() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class GetParentOpAdaptor : public GetParentOpGenericAdaptor<::mlir::ValueRange> { +public: + using GetParentOpGenericAdaptor::GetParentOpGenericAdaptor; + GetParentOpAdaptor(GetParentOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class GetParentOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::transform::TransformOpInterface::Trait, ::mlir::transform::MatchOpInterface::Trait, ::mlir::transform::NavigationTransformOpTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = GetParentOpAdaptor; + template + using GenericAdaptor = GetParentOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("allow_empty_results"), ::llvm::StringRef("deduplicate"), ::llvm::StringRef("isolated_from_above"), ::llvm::StringRef("op_name")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getAllowEmptyResultsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getAllowEmptyResultsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getDeduplicateAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getDeduplicateAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getIsolatedFromAboveAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getIsolatedFromAboveAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getOpNameAttrName() { + return getAttributeNameForIndex(3); + } + + static ::mlir::StringAttr getOpNameAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 3); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("transform.get_parent_op"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> getTarget(); + ::mlir::OpOperand &getTargetMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> getParent(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::UnitAttr getIsolatedFromAboveAttr(); + bool getIsolatedFromAbove(); + ::mlir::UnitAttr getAllowEmptyResultsAttr(); + bool getAllowEmptyResults(); + ::mlir::StringAttr getOpNameAttr(); + ::std::optional< ::llvm::StringRef > getOpName(); + ::mlir::UnitAttr getDeduplicateAttr(); + bool getDeduplicate(); + void setIsolatedFromAboveAttr(::mlir::UnitAttr attr); + void setIsolatedFromAbove(bool attrValue); + void setAllowEmptyResultsAttr(::mlir::UnitAttr attr); + void setAllowEmptyResults(bool attrValue); + void setOpNameAttr(::mlir::StringAttr attr); + void setOpName(::std::optional<::llvm::StringRef> attrValue); + void setDeduplicateAttr(::mlir::UnitAttr attr); + void setDeduplicate(bool attrValue); + ::mlir::Attribute removeIsolatedFromAboveAttr(); + ::mlir::Attribute removeAllowEmptyResultsAttr(); + ::mlir::Attribute removeOpNameAttr(); + ::mlir::Attribute removeDeduplicateAttr(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type parent, ::mlir::Value target, /*optional*/::mlir::UnitAttr isolated_from_above, /*optional*/::mlir::UnitAttr allow_empty_results, /*optional*/::mlir::StringAttr op_name, /*optional*/::mlir::UnitAttr deduplicate); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target, /*optional*/::mlir::UnitAttr isolated_from_above, /*optional*/::mlir::UnitAttr allow_empty_results, /*optional*/::mlir::StringAttr op_name, /*optional*/::mlir::UnitAttr deduplicate); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type parent, ::mlir::Value target, /*optional*/bool isolated_from_above, /*optional*/bool allow_empty_results, /*optional*/::mlir::StringAttr op_name, /*optional*/bool deduplicate = false); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target, /*optional*/bool isolated_from_above, /*optional*/bool allow_empty_results, /*optional*/::mlir::StringAttr op_name, /*optional*/bool deduplicate = false); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::DiagnosedSilenceableFailure apply(::mlir::transform::TransformRewriter &rewriter, ::mlir::transform::TransformResults &transformResults, ::mlir::transform::TransformState &state); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 4 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace transform +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::GetParentOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::GetProducerOfOperand declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class GetProducerOfOperandGenericAdaptorBase { +public: + struct Properties { + using operand_numberTy = ::mlir::IntegerAttr; + operand_numberTy operand_number; + + auto getOperandNumber() { + auto &propStorage = this->operand_number; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setOperandNumber(const ::mlir::IntegerAttr &propValue) { + this->operand_number = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.operand_number == this->operand_number && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + GetProducerOfOperandGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + GetProducerOfOperandGenericAdaptorBase(GetProducerOfOperand op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::IntegerAttr getOperandNumberAttr(); + uint64_t getOperandNumber(); +}; +} // namespace detail +template +class GetProducerOfOperandGenericAdaptor : public detail::GetProducerOfOperandGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::GetProducerOfOperandGenericAdaptorBase; +public: + GetProducerOfOperandGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + GetProducerOfOperandGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : GetProducerOfOperandGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + GetProducerOfOperandGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getTarget() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class GetProducerOfOperandAdaptor : public GetProducerOfOperandGenericAdaptor<::mlir::ValueRange> { +public: + using GetProducerOfOperandGenericAdaptor::GetProducerOfOperandGenericAdaptor; + GetProducerOfOperandAdaptor(GetProducerOfOperand op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class GetProducerOfOperand : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::transform::TransformOpInterface::Trait, ::mlir::transform::NavigationTransformOpTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = GetProducerOfOperandAdaptor; + template + using GenericAdaptor = GetProducerOfOperandGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("operand_number")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getOperandNumberAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getOperandNumberAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("transform.get_producer_of_operand"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> getTarget(); + ::mlir::OpOperand &getTargetMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> getProducer(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::IntegerAttr getOperandNumberAttr(); + uint64_t getOperandNumber(); + void setOperandNumberAttr(::mlir::IntegerAttr attr); + void setOperandNumber(uint64_t attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type producer, ::mlir::Value target, ::mlir::IntegerAttr operand_number); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target, ::mlir::IntegerAttr operand_number); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type producer, ::mlir::Value target, uint64_t operand_number); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target, uint64_t operand_number); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::DiagnosedSilenceableFailure apply(::mlir::transform::TransformRewriter &rewriter, ::mlir::transform::TransformResults &transformResults, ::mlir::transform::TransformState &state); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace transform +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::GetProducerOfOperand) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::GetResultOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class GetResultOpGenericAdaptorBase { +public: + struct Properties { + using result_numberTy = ::mlir::IntegerAttr; + result_numberTy result_number; + + auto getResultNumber() { + auto &propStorage = this->result_number; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setResultNumber(const ::mlir::IntegerAttr &propValue) { + this->result_number = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.result_number == this->result_number && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + GetResultOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + GetResultOpGenericAdaptorBase(GetResultOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::IntegerAttr getResultNumberAttr(); + uint64_t getResultNumber(); +}; +} // namespace detail +template +class GetResultOpGenericAdaptor : public detail::GetResultOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::GetResultOpGenericAdaptorBase; +public: + GetResultOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + GetResultOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : GetResultOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + GetResultOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getTarget() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class GetResultOpAdaptor : public GetResultOpGenericAdaptor<::mlir::ValueRange> { +public: + using GetResultOpGenericAdaptor::GetResultOpGenericAdaptor; + GetResultOpAdaptor(GetResultOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class GetResultOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::transform::TransformOpInterface::Trait, ::mlir::transform::NavigationTransformOpTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = GetResultOpAdaptor; + template + using GenericAdaptor = GetResultOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("result_number")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getResultNumberAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getResultNumberAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("transform.get_result"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> getTarget(); + ::mlir::OpOperand &getTargetMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformValueHandleTypeInterface> getResult(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::IntegerAttr getResultNumberAttr(); + uint64_t getResultNumber(); + void setResultNumberAttr(::mlir::IntegerAttr attr); + void setResultNumber(uint64_t attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value target, ::mlir::IntegerAttr result_number); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target, ::mlir::IntegerAttr result_number); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value target, uint64_t result_number); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target, uint64_t result_number); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::DiagnosedSilenceableFailure apply(::mlir::transform::TransformRewriter &rewriter, ::mlir::transform::TransformResults &transformResults, ::mlir::transform::TransformState &state); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace transform +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::GetResultOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::GetTypeOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class GetTypeOpGenericAdaptorBase { +public: + struct Properties { + using elementalTy = ::mlir::UnitAttr; + elementalTy elemental; + + auto getElemental() { + auto &propStorage = this->elemental; + return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(propStorage); + } + void setElemental(const ::mlir::UnitAttr &propValue) { + this->elemental = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.elemental == this->elemental && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + GetTypeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + GetTypeOpGenericAdaptorBase(GetTypeOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::UnitAttr getElementalAttr(); + bool getElemental(); +}; +} // namespace detail +template +class GetTypeOpGenericAdaptor : public detail::GetTypeOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::GetTypeOpGenericAdaptorBase; +public: + GetTypeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + GetTypeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : GetTypeOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + GetTypeOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getValue() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class GetTypeOpAdaptor : public GetTypeOpGenericAdaptor<::mlir::ValueRange> { +public: + using GetTypeOpGenericAdaptor::GetTypeOpGenericAdaptor; + GetTypeOpAdaptor(GetTypeOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class GetTypeOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::transform::TransformOpInterface::Trait, ::mlir::transform::MatchOpInterface::Trait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = GetTypeOpAdaptor; + template + using GenericAdaptor = GetTypeOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("elemental")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getElementalAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getElementalAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("transform.get_type"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformValueHandleTypeInterface> getValue(); + ::mlir::OpOperand &getValueMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformParamTypeInterface> getTypeParam(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::UnitAttr getElementalAttr(); + bool getElemental(); + void setElementalAttr(::mlir::UnitAttr attr); + void setElemental(bool attrValue); + ::mlir::Attribute removeElementalAttr(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type type_param, ::mlir::Value value, /*optional*/::mlir::UnitAttr elemental); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value value, /*optional*/::mlir::UnitAttr elemental); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type type_param, ::mlir::Value value, /*optional*/bool elemental = false); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value value, /*optional*/bool elemental = false); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::DiagnosedSilenceableFailure apply(::mlir::transform::TransformRewriter &rewriter, ::mlir::transform::TransformResults &transformResults, ::mlir::transform::TransformState &state); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace transform +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::GetTypeOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::IncludeOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class IncludeOpGenericAdaptorBase { +public: + struct Properties { + using failure_propagation_modeTy = ::mlir::transform::FailurePropagationModeAttr; + failure_propagation_modeTy failure_propagation_mode; + + auto getFailurePropagationMode() { + auto &propStorage = this->failure_propagation_mode; + return ::llvm::cast<::mlir::transform::FailurePropagationModeAttr>(propStorage); + } + void setFailurePropagationMode(const ::mlir::transform::FailurePropagationModeAttr &propValue) { + this->failure_propagation_mode = propValue; + } + using targetTy = ::mlir::SymbolRefAttr; + targetTy target; + + auto getTarget() { + auto &propStorage = this->target; + return ::llvm::cast<::mlir::SymbolRefAttr>(propStorage); + } + void setTarget(const ::mlir::SymbolRefAttr &propValue) { + this->target = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.failure_propagation_mode == this->failure_propagation_mode && + rhs.target == this->target && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + IncludeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + IncludeOpGenericAdaptorBase(IncludeOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::SymbolRefAttr getTargetAttr(); + ::mlir::SymbolRefAttr getTarget(); + ::mlir::transform::FailurePropagationModeAttr getFailurePropagationModeAttr(); + ::mlir::transform::FailurePropagationMode getFailurePropagationMode(); +}; +} // namespace detail +template +class IncludeOpGenericAdaptor : public detail::IncludeOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::IncludeOpGenericAdaptorBase; +public: + IncludeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + IncludeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : IncludeOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + IncludeOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return getODSOperands(0); + } + +private: + RangeT odsOperands; +}; +class IncludeOpAdaptor : public IncludeOpGenericAdaptor<::mlir::ValueRange> { +public: + using IncludeOpGenericAdaptor::IncludeOpGenericAdaptor; + IncludeOpAdaptor(IncludeOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class IncludeOp : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = IncludeOpAdaptor; + template + using GenericAdaptor = IncludeOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("failure_propagation_mode"), ::llvm::StringRef("target")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getFailurePropagationModeAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getFailurePropagationModeAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getTargetAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getTargetAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("transform.include"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Operation::operand_range getOperands(); + ::mlir::MutableOperandRange getOperandsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Operation::result_range getResults(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::SymbolRefAttr getTargetAttr(); + ::mlir::SymbolRefAttr getTarget(); + ::mlir::transform::FailurePropagationModeAttr getFailurePropagationModeAttr(); + ::mlir::transform::FailurePropagationMode getFailurePropagationMode(); + void setTargetAttr(::mlir::SymbolRefAttr attr); + void setFailurePropagationModeAttr(::mlir::transform::FailurePropagationModeAttr attr); + void setFailurePropagationMode(::mlir::transform::FailurePropagationMode attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::SymbolRefAttr target, ::mlir::transform::FailurePropagationModeAttr failure_propagation_mode, ::mlir::ValueRange operands); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::SymbolRefAttr target, ::mlir::transform::FailurePropagationMode failure_propagation_mode, ::mlir::ValueRange operands); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); + ::mlir::LogicalResult verifySymbolUses(::mlir::SymbolTableCollection &symbolTable); + ::mlir::DiagnosedSilenceableFailure apply(::mlir::transform::TransformRewriter &rewriter, ::mlir::transform::TransformResults &transformResults, ::mlir::transform::TransformState &state); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + ::mlir::CallInterfaceCallable getCallableForCallee() { + return getTarget(); + } + + void setCalleeFromCallable(::mlir::CallInterfaceCallable callee) { + setTargetAttr(callee.get()); + } + + ::mlir::Operation::operand_range getArgOperands() { + return getOperands(); + } + + ::mlir::MutableOperandRange getArgOperandsMutable() { + return getOperandsMutable(); + } +}; +} // namespace transform +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::IncludeOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::MatchOperationEmptyOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class MatchOperationEmptyOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + MatchOperationEmptyOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + MatchOperationEmptyOpGenericAdaptorBase(MatchOperationEmptyOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class MatchOperationEmptyOpGenericAdaptor : public detail::MatchOperationEmptyOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::MatchOperationEmptyOpGenericAdaptorBase; +public: + MatchOperationEmptyOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + MatchOperationEmptyOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : MatchOperationEmptyOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + MatchOperationEmptyOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperandHandle() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class MatchOperationEmptyOpAdaptor : public MatchOperationEmptyOpGenericAdaptor<::mlir::ValueRange> { +public: + using MatchOperationEmptyOpGenericAdaptor::MatchOperationEmptyOpGenericAdaptor; + MatchOperationEmptyOpAdaptor(MatchOperationEmptyOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class MatchOperationEmptyOp : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = MatchOperationEmptyOpAdaptor; + template + using GenericAdaptor = MatchOperationEmptyOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("transform.match.operation_empty"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> getOperandHandle(); + ::mlir::OpOperand &getOperandHandleMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand_handle); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand_handle); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +public: + ::mlir::DiagnosedSilenceableFailure matchOperation( + ::std::optional<::mlir::Operation *> maybeCurrent, + ::mlir::transform::TransformResults &results, + ::mlir::transform::TransformState &state); +}; +} // namespace transform +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::MatchOperationEmptyOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::MatchOperationNameOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class MatchOperationNameOpGenericAdaptorBase { +public: + struct Properties { + using op_namesTy = ::mlir::ArrayAttr; + op_namesTy op_names; + + auto getOpNames() { + auto &propStorage = this->op_names; + return ::llvm::cast<::mlir::ArrayAttr>(propStorage); + } + void setOpNames(const ::mlir::ArrayAttr &propValue) { + this->op_names = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.op_names == this->op_names && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + MatchOperationNameOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + MatchOperationNameOpGenericAdaptorBase(MatchOperationNameOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::ArrayAttr getOpNamesAttr(); + ::mlir::ArrayAttr getOpNames(); +}; +} // namespace detail +template +class MatchOperationNameOpGenericAdaptor : public detail::MatchOperationNameOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::MatchOperationNameOpGenericAdaptorBase; +public: + MatchOperationNameOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + MatchOperationNameOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : MatchOperationNameOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + MatchOperationNameOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getOperandHandle() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class MatchOperationNameOpAdaptor : public MatchOperationNameOpGenericAdaptor<::mlir::ValueRange> { +public: + using MatchOperationNameOpGenericAdaptor::MatchOperationNameOpGenericAdaptor; + MatchOperationNameOpAdaptor(MatchOperationNameOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class MatchOperationNameOp : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = MatchOperationNameOpAdaptor; + template + using GenericAdaptor = MatchOperationNameOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("op_names")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getOpNamesAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getOpNamesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("transform.match.operation_name"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> getOperandHandle(); + ::mlir::OpOperand &getOperandHandleMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::ArrayAttr getOpNamesAttr(); + ::mlir::ArrayAttr getOpNames(); + void setOpNamesAttr(::mlir::ArrayAttr attr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value operand_handle, ::mlir::ArrayAttr op_names); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value operand_handle, ::mlir::ArrayAttr op_names); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + ::mlir::DiagnosedSilenceableFailure matchOperation( + ::mlir::Operation *current, + ::mlir::transform::TransformResults &results, + ::mlir::transform::TransformState &state); +}; +} // namespace transform +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::MatchOperationNameOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::MatchParamCmpIOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class MatchParamCmpIOpGenericAdaptorBase { +public: + struct Properties { + using predicateTy = ::mlir::transform::MatchCmpIPredicateAttr; + predicateTy predicate; + + auto getPredicate() { + auto &propStorage = this->predicate; + return ::llvm::cast<::mlir::transform::MatchCmpIPredicateAttr>(propStorage); + } + void setPredicate(const ::mlir::transform::MatchCmpIPredicateAttr &propValue) { + this->predicate = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.predicate == this->predicate && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + MatchParamCmpIOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + MatchParamCmpIOpGenericAdaptorBase(MatchParamCmpIOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::transform::MatchCmpIPredicateAttr getPredicateAttr(); + ::mlir::transform::MatchCmpIPredicate getPredicate(); +}; +} // namespace detail +template +class MatchParamCmpIOpGenericAdaptor : public detail::MatchParamCmpIOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::MatchParamCmpIOpGenericAdaptorBase; +public: + MatchParamCmpIOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + MatchParamCmpIOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : MatchParamCmpIOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + MatchParamCmpIOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getParam() { + return (*getODSOperands(0).begin()); + } + + ValueT getReference() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class MatchParamCmpIOpAdaptor : public MatchParamCmpIOpGenericAdaptor<::mlir::ValueRange> { +public: + using MatchParamCmpIOpGenericAdaptor::MatchParamCmpIOpGenericAdaptor; + MatchParamCmpIOpAdaptor(MatchParamCmpIOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class MatchParamCmpIOp : public ::mlir::Op::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::transform::TransformOpInterface::Trait, ::mlir::transform::MatchOpInterface::Trait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::SameTypeOperands> { +public: + using Op::Op; + using Op::print; + using Adaptor = MatchParamCmpIOpAdaptor; + template + using GenericAdaptor = MatchParamCmpIOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("predicate")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getPredicateAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getPredicateAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("transform.match.param.cmpi"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformParamTypeInterface> getParam(); + ::mlir::TypedValue<::mlir::transform::TransformParamTypeInterface> getReference(); + ::mlir::OpOperand &getParamMutable(); + ::mlir::OpOperand &getReferenceMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::transform::MatchCmpIPredicateAttr getPredicateAttr(); + ::mlir::transform::MatchCmpIPredicate getPredicate(); + void setPredicateAttr(::mlir::transform::MatchCmpIPredicateAttr attr); + void setPredicate(::mlir::transform::MatchCmpIPredicate attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value param, ::mlir::Value reference, ::mlir::transform::MatchCmpIPredicateAttr predicate); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value param, ::mlir::Value reference, ::mlir::transform::MatchCmpIPredicateAttr predicate); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value param, ::mlir::Value reference, ::mlir::transform::MatchCmpIPredicate predicate); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value param, ::mlir::Value reference, ::mlir::transform::MatchCmpIPredicate predicate); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::DiagnosedSilenceableFailure apply(::mlir::transform::TransformRewriter &rewriter, ::mlir::transform::TransformResults &transformResults, ::mlir::transform::TransformState &state); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace transform +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::MatchParamCmpIOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::MergeHandlesOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class MergeHandlesOpGenericAdaptorBase { +public: + struct Properties { + using deduplicateTy = ::mlir::UnitAttr; + deduplicateTy deduplicate; + + auto getDeduplicate() { + auto &propStorage = this->deduplicate; + return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(propStorage); + } + void setDeduplicate(const ::mlir::UnitAttr &propValue) { + this->deduplicate = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.deduplicate == this->deduplicate && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + MergeHandlesOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + MergeHandlesOpGenericAdaptorBase(MergeHandlesOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::UnitAttr getDeduplicateAttr(); + bool getDeduplicate(); +}; +} // namespace detail +template +class MergeHandlesOpGenericAdaptor : public detail::MergeHandlesOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::MergeHandlesOpGenericAdaptorBase; +public: + MergeHandlesOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + MergeHandlesOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : MergeHandlesOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + MergeHandlesOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getHandles() { + return getODSOperands(0); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class MergeHandlesOpAdaptor : public MergeHandlesOpGenericAdaptor<::mlir::ValueRange> { +public: + using MergeHandlesOpGenericAdaptor::MergeHandlesOpGenericAdaptor; + MergeHandlesOpAdaptor(MergeHandlesOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class MergeHandlesOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::transform::TransformOpInterface::Trait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::transform::MatchOpInterface::Trait, ::mlir::OpTrait::SameOperandsAndResultType> { +public: + using Op::Op; + using Op::print; + using Adaptor = MergeHandlesOpAdaptor; + template + using GenericAdaptor = MergeHandlesOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("deduplicate")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getDeduplicateAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getDeduplicateAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("transform.merge_handles"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Operation::operand_range getHandles(); + ::mlir::MutableOperandRange getHandlesMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getResult(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::UnitAttr getDeduplicateAttr(); + bool getDeduplicate(); + void setDeduplicateAttr(::mlir::UnitAttr attr); + void setDeduplicate(bool attrValue); + ::mlir::Attribute removeDeduplicateAttr(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange handles, /*optional*/::mlir::UnitAttr deduplicate); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange handles, /*optional*/::mlir::UnitAttr deduplicate); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange handles, /*optional*/bool deduplicate = false); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange handles, /*optional*/bool deduplicate = false); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange handles, /*optional*/::mlir::UnitAttr deduplicate); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange handles, /*optional*/bool deduplicate = false); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + ::mlir::DiagnosedSilenceableFailure apply(::mlir::transform::TransformRewriter &rewriter, ::mlir::transform::TransformResults &transformResults, ::mlir::transform::TransformState &state); + bool allowsRepeatedHandleOperands(); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace transform +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::MergeHandlesOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::NamedSequenceOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class NamedSequenceOpGenericAdaptorBase { +public: + struct Properties { + using arg_attrsTy = ::mlir::ArrayAttr; + arg_attrsTy arg_attrs; + + auto getArgAttrs() { + auto &propStorage = this->arg_attrs; + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(propStorage); + } + void setArgAttrs(const ::mlir::ArrayAttr &propValue) { + this->arg_attrs = propValue; + } + using function_typeTy = ::mlir::TypeAttr; + function_typeTy function_type; + + auto getFunctionType() { + auto &propStorage = this->function_type; + return ::llvm::cast<::mlir::TypeAttr>(propStorage); + } + void setFunctionType(const ::mlir::TypeAttr &propValue) { + this->function_type = propValue; + } + using res_attrsTy = ::mlir::ArrayAttr; + res_attrsTy res_attrs; + + auto getResAttrs() { + auto &propStorage = this->res_attrs; + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(propStorage); + } + void setResAttrs(const ::mlir::ArrayAttr &propValue) { + this->res_attrs = propValue; + } + using sym_nameTy = ::mlir::StringAttr; + sym_nameTy sym_name; + + auto getSymName() { + auto &propStorage = this->sym_name; + return ::llvm::cast<::mlir::StringAttr>(propStorage); + } + void setSymName(const ::mlir::StringAttr &propValue) { + this->sym_name = propValue; + } + using sym_visibilityTy = ::mlir::StringAttr; + sym_visibilityTy sym_visibility; + + auto getSymVisibility() { + auto &propStorage = this->sym_visibility; + return ::llvm::dyn_cast_or_null<::mlir::StringAttr>(propStorage); + } + void setSymVisibility(const ::mlir::StringAttr &propValue) { + this->sym_visibility = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.arg_attrs == this->arg_attrs && + rhs.function_type == this->function_type && + rhs.res_attrs == this->res_attrs && + rhs.sym_name == this->sym_name && + rhs.sym_visibility == this->sym_visibility && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + NamedSequenceOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + NamedSequenceOpGenericAdaptorBase(NamedSequenceOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::StringAttr getSymNameAttr(); + ::llvm::StringRef getSymName(); + ::mlir::TypeAttr getFunctionTypeAttr(); + ::mlir::FunctionType getFunctionType(); + ::mlir::StringAttr getSymVisibilityAttr(); + ::std::optional< ::llvm::StringRef > getSymVisibility(); + ::mlir::ArrayAttr getArgAttrsAttr(); + ::std::optional< ::mlir::ArrayAttr > getArgAttrs(); + ::mlir::ArrayAttr getResAttrsAttr(); + ::std::optional< ::mlir::ArrayAttr > getResAttrs(); + ::mlir::Region &getBody(); + ::mlir::RegionRange getRegions(); +}; +} // namespace detail +template +class NamedSequenceOpGenericAdaptor : public detail::NamedSequenceOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::NamedSequenceOpGenericAdaptorBase; +public: + NamedSequenceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + NamedSequenceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : NamedSequenceOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + NamedSequenceOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class NamedSequenceOpAdaptor : public NamedSequenceOpGenericAdaptor<::mlir::ValueRange> { +public: + using NamedSequenceOpGenericAdaptor::NamedSequenceOpGenericAdaptor; + NamedSequenceOpAdaptor(NamedSequenceOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class NamedSequenceOp : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = NamedSequenceOpAdaptor; + template + using GenericAdaptor = NamedSequenceOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("arg_attrs"), ::llvm::StringRef("function_type"), ::llvm::StringRef("res_attrs"), ::llvm::StringRef("sym_name"), ::llvm::StringRef("sym_visibility")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getArgAttrsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getArgAttrsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getFunctionTypeAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getFunctionTypeAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getResAttrsAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getResAttrsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + ::mlir::StringAttr getSymNameAttrName() { + return getAttributeNameForIndex(3); + } + + static ::mlir::StringAttr getSymNameAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 3); + } + + ::mlir::StringAttr getSymVisibilityAttrName() { + return getAttributeNameForIndex(4); + } + + static ::mlir::StringAttr getSymVisibilityAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 4); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("transform.named_sequence"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Region &getBody(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::StringAttr getSymNameAttr(); + ::llvm::StringRef getSymName(); + ::mlir::TypeAttr getFunctionTypeAttr(); + ::mlir::FunctionType getFunctionType(); + ::mlir::StringAttr getSymVisibilityAttr(); + ::std::optional< ::llvm::StringRef > getSymVisibility(); + ::mlir::ArrayAttr getArgAttrsAttr(); + ::std::optional< ::mlir::ArrayAttr > getArgAttrs(); + ::mlir::ArrayAttr getResAttrsAttr(); + ::std::optional< ::mlir::ArrayAttr > getResAttrs(); + void setSymNameAttr(::mlir::StringAttr attr); + void setSymName(::llvm::StringRef attrValue); + void setFunctionTypeAttr(::mlir::TypeAttr attr); + void setSymVisibilityAttr(::mlir::StringAttr attr); + void setSymVisibility(::std::optional<::llvm::StringRef> attrValue); + void setArgAttrsAttr(::mlir::ArrayAttr attr); + void setResAttrsAttr(::mlir::ArrayAttr attr); + ::mlir::Attribute removeSymVisibilityAttr(); + ::mlir::Attribute removeArgAttrsAttr(); + ::mlir::Attribute removeResAttrsAttr(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::StringAttr sym_name, ::mlir::TypeAttr function_type, /*optional*/::mlir::StringAttr sym_visibility, /*optional*/::mlir::ArrayAttr arg_attrs, /*optional*/::mlir::ArrayAttr res_attrs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, ::mlir::TypeAttr function_type, /*optional*/::mlir::StringAttr sym_visibility, /*optional*/::mlir::ArrayAttr arg_attrs, /*optional*/::mlir::ArrayAttr res_attrs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llvm::StringRef sym_name, ::mlir::TypeAttr function_type, /*optional*/::mlir::StringAttr sym_visibility, /*optional*/::mlir::ArrayAttr arg_attrs, /*optional*/::mlir::ArrayAttr res_attrs); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, ::mlir::TypeAttr function_type, /*optional*/::mlir::StringAttr sym_visibility, /*optional*/::mlir::ArrayAttr arg_attrs, /*optional*/::mlir::ArrayAttr res_attrs); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &p); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); + ::mlir::DiagnosedSilenceableFailure apply(::mlir::transform::TransformRewriter &rewriter, ::mlir::transform::TransformResults &transformResults, ::mlir::transform::TransformState &state); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 5 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + ::llvm::ArrayRef<::mlir::Type> getArgumentTypes() { + return getFunctionType().getInputs(); + } + ::llvm::ArrayRef<::mlir::Type> getResultTypes() { + return getFunctionType().getResults(); + } + ::mlir::Region *getCallableRegion() { + return &getBody(); + } +}; +} // namespace transform +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::NamedSequenceOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::ParamConstantOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ParamConstantOpGenericAdaptorBase { +public: + struct Properties { + using valueTy = ::mlir::Attribute; + valueTy value; + + auto getValue() { + auto &propStorage = this->value; + return ::llvm::cast<::mlir::Attribute>(propStorage); + } + void setValue(const ::mlir::Attribute &propValue) { + this->value = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.value == this->value && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ParamConstantOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + ParamConstantOpGenericAdaptorBase(ParamConstantOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::Attribute getValueAttr(); + ::mlir::Attribute getValue(); +}; +} // namespace detail +template +class ParamConstantOpGenericAdaptor : public detail::ParamConstantOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ParamConstantOpGenericAdaptorBase; +public: + ParamConstantOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ParamConstantOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ParamConstantOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + ParamConstantOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ParamConstantOpAdaptor : public ParamConstantOpGenericAdaptor<::mlir::ValueRange> { +public: + using ParamConstantOpGenericAdaptor::ParamConstantOpGenericAdaptor; + ParamConstantOpAdaptor(ParamConstantOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ParamConstantOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::ZeroOperands, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::transform::TransformOpInterface::Trait, ::mlir::transform::MatchOpInterface::Trait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::transform::ParamProducerTransformOpTrait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ParamConstantOpAdaptor; + template + using GenericAdaptor = ParamConstantOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("value")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getValueAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getValueAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("transform.param.constant"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformParamTypeInterface> getParam(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::Attribute getValueAttr(); + ::mlir::Attribute getValue(); + void setValueAttr(::mlir::Attribute attr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type param, ::mlir::Attribute value); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Attribute value); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::DiagnosedSilenceableFailure apply(::mlir::transform::TransformRewriter &rewriter, ::mlir::transform::TransformResults &transformResults, ::mlir::transform::TransformState &state); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace transform +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::ParamConstantOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::PrintOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class PrintOpGenericAdaptorBase { +public: + struct Properties { + using nameTy = ::mlir::StringAttr; + nameTy name; + + auto getName() { + auto &propStorage = this->name; + return ::llvm::dyn_cast_or_null<::mlir::StringAttr>(propStorage); + } + void setName(const ::mlir::StringAttr &propValue) { + this->name = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.name == this->name && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + PrintOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + PrintOpGenericAdaptorBase(PrintOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::StringAttr getNameAttr(); + ::std::optional< ::llvm::StringRef > getName(); +}; +} // namespace detail +template +class PrintOpGenericAdaptor : public detail::PrintOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::PrintOpGenericAdaptorBase; +public: + PrintOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + PrintOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : PrintOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + PrintOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getTarget() { + auto operands = getODSOperands(0); + return operands.empty() ? ValueT{} : (*operands.begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class PrintOpAdaptor : public PrintOpGenericAdaptor<::mlir::ValueRange> { +public: + using PrintOpGenericAdaptor::PrintOpGenericAdaptor; + PrintOpAdaptor(PrintOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class PrintOp : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = PrintOpAdaptor; + template + using GenericAdaptor = PrintOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("name")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getNameAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getNameAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("transform.print"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> getTarget(); + ::mlir::MutableOperandRange getTargetMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::StringAttr getNameAttr(); + ::std::optional< ::llvm::StringRef > getName(); + void setNameAttr(::mlir::StringAttr attr); + void setName(::std::optional<::llvm::StringRef> attrValue); + ::mlir::Attribute removeNameAttr(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, StringRef name = StringRef()); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value target, StringRef name = StringRef()); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Value target, /*optional*/::mlir::StringAttr name); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value target, /*optional*/::mlir::StringAttr name); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::DiagnosedSilenceableFailure apply(::mlir::transform::TransformRewriter &rewriter, ::mlir::transform::TransformResults &transformResults, ::mlir::transform::TransformState &state); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace transform +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::PrintOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::ReplicateOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ReplicateOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + ReplicateOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + ReplicateOpGenericAdaptorBase(ReplicateOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class ReplicateOpGenericAdaptor : public detail::ReplicateOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ReplicateOpGenericAdaptorBase; +public: + ReplicateOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ReplicateOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ReplicateOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + ReplicateOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getPattern() { + return (*getODSOperands(0).begin()); + } + + RangeT getHandles() { + return getODSOperands(1); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ReplicateOpAdaptor : public ReplicateOpGenericAdaptor<::mlir::ValueRange> { +public: + using ReplicateOpGenericAdaptor::ReplicateOpGenericAdaptor; + ReplicateOpAdaptor(ReplicateOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ReplicateOp : public ::mlir::Op::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::transform::TransformOpInterface::Trait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ReplicateOpAdaptor; + template + using GenericAdaptor = ReplicateOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("transform.replicate"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> getPattern(); + ::mlir::Operation::operand_range getHandles(); + ::mlir::OpOperand &getPatternMutable(); + ::mlir::MutableOperandRange getHandlesMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Operation::result_range getReplicated(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange replicated, ::mlir::Value pattern, ::mlir::ValueRange handles); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::DiagnosedSilenceableFailure apply(::mlir::transform::TransformRewriter &rewriter, ::mlir::transform::TransformResults &transformResults, ::mlir::transform::TransformState &state); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +public: +}; +} // namespace transform +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::ReplicateOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::SelectOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class SelectOpGenericAdaptorBase { +public: + struct Properties { + using op_nameTy = ::mlir::StringAttr; + op_nameTy op_name; + + auto getOpName() { + auto &propStorage = this->op_name; + return ::llvm::cast<::mlir::StringAttr>(propStorage); + } + void setOpName(const ::mlir::StringAttr &propValue) { + this->op_name = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.op_name == this->op_name && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + SelectOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + SelectOpGenericAdaptorBase(SelectOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::StringAttr getOpNameAttr(); + ::llvm::StringRef getOpName(); +}; +} // namespace detail +template +class SelectOpGenericAdaptor : public detail::SelectOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::SelectOpGenericAdaptorBase; +public: + SelectOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + SelectOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : SelectOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + SelectOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getTarget() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class SelectOpAdaptor : public SelectOpGenericAdaptor<::mlir::ValueRange> { +public: + using SelectOpGenericAdaptor::SelectOpGenericAdaptor; + SelectOpAdaptor(SelectOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class SelectOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::transform::TransformOpInterface::Trait, ::mlir::transform::NavigationTransformOpTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = SelectOpAdaptor; + template + using GenericAdaptor = SelectOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("op_name")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getOpNameAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getOpNameAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("transform.select"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> getTarget(); + ::mlir::OpOperand &getTargetMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> getResult(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::StringAttr getOpNameAttr(); + ::llvm::StringRef getOpName(); + void setOpNameAttr(::mlir::StringAttr attr); + void setOpName(::llvm::StringRef attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value target, ::mlir::StringAttr op_name); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target, ::mlir::StringAttr op_name); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value target, ::llvm::StringRef op_name); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target, ::llvm::StringRef op_name); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::DiagnosedSilenceableFailure apply(::mlir::transform::TransformRewriter &rewriter, ::mlir::transform::TransformResults &transformResults, ::mlir::transform::TransformState &state); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace transform +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::SelectOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::SequenceOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class SequenceOpGenericAdaptorBase { +public: + struct Properties { + using failure_propagation_modeTy = ::mlir::transform::FailurePropagationModeAttr; + failure_propagation_modeTy failure_propagation_mode; + + auto getFailurePropagationMode() { + auto &propStorage = this->failure_propagation_mode; + return ::llvm::cast<::mlir::transform::FailurePropagationModeAttr>(propStorage); + } + void setFailurePropagationMode(const ::mlir::transform::FailurePropagationModeAttr &propValue) { + this->failure_propagation_mode = propValue; + } + using operandSegmentSizesTy = std::array; + operandSegmentSizesTy operandSegmentSizes; + ::llvm::ArrayRef getOperandSegmentSizes() { + auto &propStorage = this->operandSegmentSizes; + return propStorage; + } + void setOperandSegmentSizes(const ::llvm::ArrayRef &propValue) { + auto &propStorage = this->operandSegmentSizes; + ::llvm::copy(propValue, propStorage.begin()); + } + bool operator==(const Properties &rhs) const { + return + rhs.failure_propagation_mode == this->failure_propagation_mode && + rhs.operandSegmentSizes == this->operandSegmentSizes && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + SequenceOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + SequenceOpGenericAdaptorBase(SequenceOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::transform::FailurePropagationModeAttr getFailurePropagationModeAttr(); + ::mlir::transform::FailurePropagationMode getFailurePropagationMode(); + ::mlir::Region &getBody(); + ::mlir::RegionRange getRegions(); +}; +} // namespace detail +template +class SequenceOpGenericAdaptor : public detail::SequenceOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::SequenceOpGenericAdaptorBase; +public: + SequenceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + SequenceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : SequenceOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + SequenceOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getRoot() { + auto operands = getODSOperands(0); + return operands.empty() ? ValueT{} : (*operands.begin()); + } + + RangeT getExtraBindings() { + return getODSOperands(1); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class SequenceOpAdaptor : public SequenceOpGenericAdaptor<::mlir::ValueRange> { +public: + using SequenceOpGenericAdaptor::SequenceOpGenericAdaptor; + SequenceOpAdaptor(SequenceOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class SequenceOp : public ::mlir::Op::Impl, ::mlir::OpTrait::AttrSizedOperandSegments, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::RegionBranchOpInterface::Trait, ::mlir::transform::TransformOpInterface::Trait, ::mlir::transform::MatchOpInterface::Trait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpAsmOpInterface::Trait, ::mlir::transform::PossibleTopLevelTransformOpTrait> { +public: + using Op::Op; + using Op::print; + using Adaptor = SequenceOpAdaptor; + template + using GenericAdaptor = SequenceOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("failure_propagation_mode"), ::llvm::StringRef("operandSegmentSizes")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getFailurePropagationModeAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getFailurePropagationModeAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getOperandSegmentSizesAttrName() { + return (*this)->getName().getAttributeNames().back(); + } + + static ::mlir::StringAttr getOperandSegmentSizesAttrName(::mlir::OperationName name) { + return name.getAttributeNames().back(); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("transform.sequence"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> getRoot(); + ::mlir::Operation::operand_range getExtraBindings(); + ::mlir::MutableOperandRange getRootMutable(); + ::mlir::MutableOperandRange getExtraBindingsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Operation::result_range getResults(); + ::mlir::Region &getBody(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::transform::FailurePropagationModeAttr getFailurePropagationModeAttr(); + ::mlir::transform::FailurePropagationMode getFailurePropagationMode(); + void setFailurePropagationModeAttr(::mlir::transform::FailurePropagationModeAttr attr); + void setFailurePropagationMode(::mlir::transform::FailurePropagationMode attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::transform::FailurePropagationMode failure_propagation_mode, ::mlir::Value root, SequenceBodyBuilderFn bodyBuilder); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::transform::FailurePropagationMode failure_propagation_mode, ::mlir::Value root, ::mlir::ValueRange extraBindings, SequenceBodyBuilderArgsFn bodyBuilder); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::transform::FailurePropagationMode failure_propagation_mode, ::mlir::Type bbArgType, SequenceBodyBuilderFn bodyBuilder); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::transform::FailurePropagationMode failure_propagation_mode, ::mlir::Type bbArgType, ::mlir::TypeRange extraBindingTypes, SequenceBodyBuilderArgsFn bodyBuilder); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::transform::FailurePropagationModeAttr failure_propagation_mode, /*optional*/::mlir::Value root, ::mlir::ValueRange extra_bindings); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::transform::FailurePropagationMode failure_propagation_mode, /*optional*/::mlir::Value root, ::mlir::ValueRange extra_bindings); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + ::mlir::OperandRange getEntrySuccessorOperands(::mlir::RegionBranchPoint point); + void getSuccessorRegions(::mlir::RegionBranchPoint point, ::llvm::SmallVectorImpl<::mlir::RegionSuccessor> ®ions); + void getRegionInvocationBounds(::llvm::ArrayRef<::mlir::Attribute> operands, ::llvm::SmallVectorImpl<::mlir::InvocationBounds> &invocationBounds); + ::mlir::DiagnosedSilenceableFailure apply(::mlir::transform::TransformRewriter &rewriter, ::mlir::transform::TransformResults &transformResults, ::mlir::transform::TransformState &state); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + /// Allow the dialect prefix to be omitted. + static StringRef getDefaultDialect() { return "transform"; } +}; +} // namespace transform +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::SequenceOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::SplitHandleOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class SplitHandleOpGenericAdaptorBase { +public: + struct Properties { + using fail_on_payload_too_smallTy = ::mlir::BoolAttr; + fail_on_payload_too_smallTy fail_on_payload_too_small; + + auto getFailOnPayloadTooSmall() { + auto &propStorage = this->fail_on_payload_too_small; + return ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(propStorage); + } + void setFailOnPayloadTooSmall(const ::mlir::BoolAttr &propValue) { + this->fail_on_payload_too_small = propValue; + } + using overflow_resultTy = ::mlir::IntegerAttr; + overflow_resultTy overflow_result; + + auto getOverflowResult() { + auto &propStorage = this->overflow_result; + return ::llvm::dyn_cast_or_null<::mlir::IntegerAttr>(propStorage); + } + void setOverflowResult(const ::mlir::IntegerAttr &propValue) { + this->overflow_result = propValue; + } + using pass_through_empty_handleTy = ::mlir::BoolAttr; + pass_through_empty_handleTy pass_through_empty_handle; + + auto getPassThroughEmptyHandle() { + auto &propStorage = this->pass_through_empty_handle; + return ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(propStorage); + } + void setPassThroughEmptyHandle(const ::mlir::BoolAttr &propValue) { + this->pass_through_empty_handle = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.fail_on_payload_too_small == this->fail_on_payload_too_small && + rhs.overflow_result == this->overflow_result && + rhs.pass_through_empty_handle == this->pass_through_empty_handle && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + SplitHandleOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + SplitHandleOpGenericAdaptorBase(SplitHandleOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::BoolAttr getPassThroughEmptyHandleAttr(); + bool getPassThroughEmptyHandle(); + ::mlir::BoolAttr getFailOnPayloadTooSmallAttr(); + bool getFailOnPayloadTooSmall(); + ::mlir::IntegerAttr getOverflowResultAttr(); + ::std::optional getOverflowResult(); +}; +} // namespace detail +template +class SplitHandleOpGenericAdaptor : public detail::SplitHandleOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::SplitHandleOpGenericAdaptorBase; +public: + SplitHandleOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + SplitHandleOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : SplitHandleOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + SplitHandleOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getHandle() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class SplitHandleOpAdaptor : public SplitHandleOpGenericAdaptor<::mlir::ValueRange> { +public: + using SplitHandleOpGenericAdaptor::SplitHandleOpGenericAdaptor; + SplitHandleOpAdaptor(SplitHandleOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class SplitHandleOp : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = SplitHandleOpAdaptor; + template + using GenericAdaptor = SplitHandleOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("fail_on_payload_too_small"), ::llvm::StringRef("overflow_result"), ::llvm::StringRef("pass_through_empty_handle")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getFailOnPayloadTooSmallAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getFailOnPayloadTooSmallAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getOverflowResultAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getOverflowResultAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getPassThroughEmptyHandleAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getPassThroughEmptyHandleAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("transform.split_handle"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> getHandle(); + ::mlir::OpOperand &getHandleMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Operation::result_range getResults(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::BoolAttr getPassThroughEmptyHandleAttr(); + bool getPassThroughEmptyHandle(); + ::mlir::BoolAttr getFailOnPayloadTooSmallAttr(); + bool getFailOnPayloadTooSmall(); + ::mlir::IntegerAttr getOverflowResultAttr(); + ::std::optional getOverflowResult(); + void setPassThroughEmptyHandleAttr(::mlir::BoolAttr attr); + void setPassThroughEmptyHandle(bool attrValue); + void setFailOnPayloadTooSmallAttr(::mlir::BoolAttr attr); + void setFailOnPayloadTooSmall(bool attrValue); + void setOverflowResultAttr(::mlir::IntegerAttr attr); + void setOverflowResult(::std::optional attrValue); + ::mlir::Attribute removeOverflowResultAttr(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value handle, int64_t numResultHandles); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::Value handle, ::mlir::BoolAttr pass_through_empty_handle, ::mlir::BoolAttr fail_on_payload_too_small, /*optional*/::mlir::IntegerAttr overflow_result); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::Value handle, bool pass_through_empty_handle, bool fail_on_payload_too_small, /*optional*/::mlir::IntegerAttr overflow_result); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void populateDefaultProperties(::mlir::OperationName opName, Properties &properties); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + ::mlir::DiagnosedSilenceableFailure apply(::mlir::transform::TransformRewriter &rewriter, ::mlir::transform::TransformResults &transformResults, ::mlir::transform::TransformState &state); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 3 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace transform +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::SplitHandleOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::VerifyOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class VerifyOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + VerifyOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + VerifyOpGenericAdaptorBase(VerifyOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class VerifyOpGenericAdaptor : public detail::VerifyOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::VerifyOpGenericAdaptorBase; +public: + VerifyOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + VerifyOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : VerifyOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + VerifyOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getTarget() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class VerifyOpAdaptor : public VerifyOpGenericAdaptor<::mlir::ValueRange> { +public: + using VerifyOpGenericAdaptor::VerifyOpGenericAdaptor; + VerifyOpAdaptor(VerifyOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class VerifyOp : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = VerifyOpAdaptor; + template + using GenericAdaptor = VerifyOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("transform.verify"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::transform::TransformHandleTypeInterface> getTarget(); + ::mlir::OpOperand &getTargetMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value target); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value target); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +public: + ::mlir::DiagnosedSilenceableFailure applyToOne( + ::mlir::transform::TransformRewriter &rewriter, + ::mlir::Operation *target, + ::mlir::transform::ApplyToEachResultList &results, + ::mlir::transform::TransformState &state); +}; +} // namespace transform +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::VerifyOp) + +namespace mlir { +namespace transform { + +//===----------------------------------------------------------------------===// +// ::mlir::transform::YieldOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class YieldOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + YieldOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + YieldOpGenericAdaptorBase(YieldOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class YieldOpGenericAdaptor : public detail::YieldOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::YieldOpGenericAdaptorBase; +public: + YieldOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + YieldOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : YieldOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + YieldOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return getODSOperands(0); + } + +private: + RangeT odsOperands; +}; +class YieldOpAdaptor : public YieldOpGenericAdaptor<::mlir::ValueRange> { +public: + using YieldOpGenericAdaptor::YieldOpGenericAdaptor; + YieldOpAdaptor(YieldOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class YieldOp : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = YieldOpAdaptor; + template + using GenericAdaptor = YieldOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("transform.yield"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Operation::operand_range getOperands(); + ::mlir::MutableOperandRange getOperandsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +public: +}; +} // namespace transform +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::YieldOp) + + +#endif // GET_OP_CLASSES + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformTypeInterfaces.cpp.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformTypeInterfaces.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..18de81e6d7f17ca202116c27295d0259e55b1311 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformTypeInterfaces.cpp.inc @@ -0,0 +1,26 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Interface Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +/// Checks if the given associated objects (Payload IR operations or attributes) +/// satisfy the conditions defined by this type. If not, produces a silenceable +/// error at the specified location. +::mlir::DiagnosedSilenceableFailure mlir::transform::TransformHandleTypeInterface::checkPayload(::mlir::Location loc, ::mlir::ArrayRef<::mlir::Operation *> payload) const { + return getImpl()->checkPayload(getImpl(), *this, loc, payload); + } +/// Checks if the given associated objects (Payload IR operations or attributes) +/// satisfy the conditions defined by this type. If not, produces a silenceable +/// error at the specified location. +::mlir::DiagnosedSilenceableFailure mlir::transform::TransformParamTypeInterface::checkPayload(::mlir::Location loc, ::mlir::ArrayRef<::mlir::Attribute> payload) const { + return getImpl()->checkPayload(getImpl(), *this, loc, payload); + } +/// Checks if the given associated objects (Payload IR operations or attributes) +/// satisfy the conditions defined by this type. If not, produces a silenceable +/// error at the specified location. +::mlir::DiagnosedSilenceableFailure mlir::transform::TransformValueHandleTypeInterface::checkPayload(::mlir::Location loc, ::mlir::ArrayRef<::mlir::Value> payload) const { + return getImpl()->checkPayload(getImpl(), *this, loc, payload); + } diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformTypeInterfaces.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformTypeInterfaces.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..d9dd4c6771a5289b5bb0e6e07051e94b1f6840f9 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformTypeInterfaces.h.inc @@ -0,0 +1,230 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Interface Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace transform { +class TransformHandleTypeInterface; +namespace detail { +struct TransformHandleTypeInterfaceInterfaceTraits { + struct Concept { + /// The methods defined by the interface. + ::mlir::DiagnosedSilenceableFailure (*checkPayload)(const Concept *impl, ::mlir::Type , ::mlir::Location, ::mlir::ArrayRef<::mlir::Operation *>); + }; + template + class Model : public Concept { + public: + using Interface = ::mlir::transform::TransformHandleTypeInterface; + Model() : Concept{checkPayload} {} + + static inline ::mlir::DiagnosedSilenceableFailure checkPayload(const Concept *impl, ::mlir::Type tablegen_opaque_val, ::mlir::Location loc, ::mlir::ArrayRef<::mlir::Operation *> payload); + }; + template + class FallbackModel : public Concept { + public: + using Interface = ::mlir::transform::TransformHandleTypeInterface; + FallbackModel() : Concept{checkPayload} {} + + static inline ::mlir::DiagnosedSilenceableFailure checkPayload(const Concept *impl, ::mlir::Type tablegen_opaque_val, ::mlir::Location loc, ::mlir::ArrayRef<::mlir::Operation *> payload); + }; + template + class ExternalModel : public FallbackModel { + public: + using ConcreteEntity = ConcreteType; + }; +};template +struct TransformHandleTypeInterfaceTrait; + +} // namespace detail +class TransformHandleTypeInterface : public ::mlir::TypeInterface { +public: + using ::mlir::TypeInterface::TypeInterface; + template + struct Trait : public detail::TransformHandleTypeInterfaceTrait {}; + /// Checks if the given associated objects (Payload IR operations or attributes) + /// satisfy the conditions defined by this type. If not, produces a silenceable + /// error at the specified location. + ::mlir::DiagnosedSilenceableFailure checkPayload(::mlir::Location loc, ::mlir::ArrayRef<::mlir::Operation *> payload) const; + + DiagnosedSilenceableFailure emitSilenceableError(Location loc) const { + Diagnostic diag(loc, DiagnosticSeverity::Error); + return DiagnosedSilenceableFailure::silenceableFailure(std::move(diag)); + } +}; +namespace detail { + template + struct TransformHandleTypeInterfaceTrait : public ::mlir::TypeInterface::Trait { + + DiagnosedSilenceableFailure emitSilenceableError(Location loc) const { + Diagnostic diag(loc, DiagnosticSeverity::Error); + return DiagnosedSilenceableFailure::silenceableFailure(std::move(diag)); + } + + }; +}// namespace detail +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class TransformParamTypeInterface; +namespace detail { +struct TransformParamTypeInterfaceInterfaceTraits { + struct Concept { + /// The methods defined by the interface. + ::mlir::DiagnosedSilenceableFailure (*checkPayload)(const Concept *impl, ::mlir::Type , ::mlir::Location, ::mlir::ArrayRef<::mlir::Attribute>); + }; + template + class Model : public Concept { + public: + using Interface = ::mlir::transform::TransformParamTypeInterface; + Model() : Concept{checkPayload} {} + + static inline ::mlir::DiagnosedSilenceableFailure checkPayload(const Concept *impl, ::mlir::Type tablegen_opaque_val, ::mlir::Location loc, ::mlir::ArrayRef<::mlir::Attribute> payload); + }; + template + class FallbackModel : public Concept { + public: + using Interface = ::mlir::transform::TransformParamTypeInterface; + FallbackModel() : Concept{checkPayload} {} + + static inline ::mlir::DiagnosedSilenceableFailure checkPayload(const Concept *impl, ::mlir::Type tablegen_opaque_val, ::mlir::Location loc, ::mlir::ArrayRef<::mlir::Attribute> payload); + }; + template + class ExternalModel : public FallbackModel { + public: + using ConcreteEntity = ConcreteType; + }; +};template +struct TransformParamTypeInterfaceTrait; + +} // namespace detail +class TransformParamTypeInterface : public ::mlir::TypeInterface { +public: + using ::mlir::TypeInterface::TypeInterface; + template + struct Trait : public detail::TransformParamTypeInterfaceTrait {}; + /// Checks if the given associated objects (Payload IR operations or attributes) + /// satisfy the conditions defined by this type. If not, produces a silenceable + /// error at the specified location. + ::mlir::DiagnosedSilenceableFailure checkPayload(::mlir::Location loc, ::mlir::ArrayRef<::mlir::Attribute> payload) const; + + DiagnosedSilenceableFailure emitSilenceableError(Location loc) const { + Diagnostic diag(loc, DiagnosticSeverity::Error); + return DiagnosedSilenceableFailure::silenceableFailure(std::move(diag)); + } +}; +namespace detail { + template + struct TransformParamTypeInterfaceTrait : public ::mlir::TypeInterface::Trait { + + DiagnosedSilenceableFailure emitSilenceableError(Location loc) const { + Diagnostic diag(loc, DiagnosticSeverity::Error); + return DiagnosedSilenceableFailure::silenceableFailure(std::move(diag)); + } + + }; +}// namespace detail +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +class TransformValueHandleTypeInterface; +namespace detail { +struct TransformValueHandleTypeInterfaceInterfaceTraits { + struct Concept { + /// The methods defined by the interface. + ::mlir::DiagnosedSilenceableFailure (*checkPayload)(const Concept *impl, ::mlir::Type , ::mlir::Location, ::mlir::ArrayRef<::mlir::Value>); + }; + template + class Model : public Concept { + public: + using Interface = ::mlir::transform::TransformValueHandleTypeInterface; + Model() : Concept{checkPayload} {} + + static inline ::mlir::DiagnosedSilenceableFailure checkPayload(const Concept *impl, ::mlir::Type tablegen_opaque_val, ::mlir::Location loc, ::mlir::ArrayRef<::mlir::Value> payload); + }; + template + class FallbackModel : public Concept { + public: + using Interface = ::mlir::transform::TransformValueHandleTypeInterface; + FallbackModel() : Concept{checkPayload} {} + + static inline ::mlir::DiagnosedSilenceableFailure checkPayload(const Concept *impl, ::mlir::Type tablegen_opaque_val, ::mlir::Location loc, ::mlir::ArrayRef<::mlir::Value> payload); + }; + template + class ExternalModel : public FallbackModel { + public: + using ConcreteEntity = ConcreteType; + }; +};template +struct TransformValueHandleTypeInterfaceTrait; + +} // namespace detail +class TransformValueHandleTypeInterface : public ::mlir::TypeInterface { +public: + using ::mlir::TypeInterface::TypeInterface; + template + struct Trait : public detail::TransformValueHandleTypeInterfaceTrait {}; + /// Checks if the given associated objects (Payload IR operations or attributes) + /// satisfy the conditions defined by this type. If not, produces a silenceable + /// error at the specified location. + ::mlir::DiagnosedSilenceableFailure checkPayload(::mlir::Location loc, ::mlir::ArrayRef<::mlir::Value> payload) const; + + DiagnosedSilenceableFailure emitSilenceableError(Location loc) const { + Diagnostic diag(loc, DiagnosticSeverity::Error); + return DiagnosedSilenceableFailure::silenceableFailure(std::move(diag)); + } +}; +namespace detail { + template + struct TransformValueHandleTypeInterfaceTrait : public ::mlir::TypeInterface::Trait { + + DiagnosedSilenceableFailure emitSilenceableError(Location loc) const { + Diagnostic diag(loc, DiagnosticSeverity::Error); + return DiagnosedSilenceableFailure::silenceableFailure(std::move(diag)); + } + + }; +}// namespace detail +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +template +::mlir::DiagnosedSilenceableFailure detail::TransformHandleTypeInterfaceInterfaceTraits::Model::checkPayload(const Concept *impl, ::mlir::Type tablegen_opaque_val, ::mlir::Location loc, ::mlir::ArrayRef<::mlir::Operation *> payload) { + return (::llvm::cast(tablegen_opaque_val)).checkPayload(loc, payload); +} +template +::mlir::DiagnosedSilenceableFailure detail::TransformHandleTypeInterfaceInterfaceTraits::FallbackModel::checkPayload(const Concept *impl, ::mlir::Type tablegen_opaque_val, ::mlir::Location loc, ::mlir::ArrayRef<::mlir::Operation *> payload) { + return static_cast(impl)->checkPayload(tablegen_opaque_val, loc, payload); +} +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +template +::mlir::DiagnosedSilenceableFailure detail::TransformParamTypeInterfaceInterfaceTraits::Model::checkPayload(const Concept *impl, ::mlir::Type tablegen_opaque_val, ::mlir::Location loc, ::mlir::ArrayRef<::mlir::Attribute> payload) { + return (::llvm::cast(tablegen_opaque_val)).checkPayload(loc, payload); +} +template +::mlir::DiagnosedSilenceableFailure detail::TransformParamTypeInterfaceInterfaceTraits::FallbackModel::checkPayload(const Concept *impl, ::mlir::Type tablegen_opaque_val, ::mlir::Location loc, ::mlir::ArrayRef<::mlir::Attribute> payload) { + return static_cast(impl)->checkPayload(tablegen_opaque_val, loc, payload); +} +} // namespace transform +} // namespace mlir +namespace mlir { +namespace transform { +template +::mlir::DiagnosedSilenceableFailure detail::TransformValueHandleTypeInterfaceInterfaceTraits::Model::checkPayload(const Concept *impl, ::mlir::Type tablegen_opaque_val, ::mlir::Location loc, ::mlir::ArrayRef<::mlir::Value> payload) { + return (::llvm::cast(tablegen_opaque_val)).checkPayload(loc, payload); +} +template +::mlir::DiagnosedSilenceableFailure detail::TransformValueHandleTypeInterfaceInterfaceTraits::FallbackModel::checkPayload(const Concept *impl, ::mlir::Type tablegen_opaque_val, ::mlir::Location loc, ::mlir::ArrayRef<::mlir::Value> payload) { + return static_cast(impl)->checkPayload(tablegen_opaque_val, loc, payload); +} +} // namespace transform +} // namespace mlir diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformTypes.cpp.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformTypes.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..0ff06087cfa933a595cf87bcbca948d3c15cd35b --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformTypes.cpp.inc @@ -0,0 +1,319 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* TypeDef Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifdef GET_TYPEDEF_LIST +#undef GET_TYPEDEF_LIST + +::mlir::transform::AffineMapParamType, +::mlir::transform::AnyOpType, +::mlir::transform::AnyParamType, +::mlir::transform::AnyValueType, +::mlir::transform::OperationType, +::mlir::transform::ParamType, +::mlir::transform::TypeParamType + +#endif // GET_TYPEDEF_LIST + +#ifdef GET_TYPEDEF_CLASSES +#undef GET_TYPEDEF_CLASSES + +static ::mlir::OptionalParseResult generatedTypeParser(::mlir::AsmParser &parser, ::llvm::StringRef *mnemonic, ::mlir::Type &value) { + return ::mlir::AsmParser::KeywordSwitch<::mlir::OptionalParseResult>(parser) + .Case(::mlir::transform::AffineMapParamType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::transform::AffineMapParamType::parse(parser); + return ::mlir::success(!!value); + }) + .Case(::mlir::transform::AnyOpType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::transform::AnyOpType::parse(parser); + return ::mlir::success(!!value); + }) + .Case(::mlir::transform::AnyParamType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::transform::AnyParamType::parse(parser); + return ::mlir::success(!!value); + }) + .Case(::mlir::transform::AnyValueType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::transform::AnyValueType::parse(parser); + return ::mlir::success(!!value); + }) + .Case(::mlir::transform::OperationType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::transform::OperationType::parse(parser); + return ::mlir::success(!!value); + }) + .Case(::mlir::transform::ParamType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::transform::ParamType::parse(parser); + return ::mlir::success(!!value); + }) + .Case(::mlir::transform::TypeParamType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::transform::TypeParamType::parse(parser); + return ::mlir::success(!!value); + }) + .Default([&](llvm::StringRef keyword, llvm::SMLoc) { + *mnemonic = keyword; + return std::nullopt; + }); +} + +static ::mlir::LogicalResult generatedTypePrinter(::mlir::Type def, ::mlir::AsmPrinter &printer) { + return ::llvm::TypeSwitch<::mlir::Type, ::mlir::LogicalResult>(def) .Case<::mlir::transform::AffineMapParamType>([&](auto t) { + printer << ::mlir::transform::AffineMapParamType::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::transform::AnyOpType>([&](auto t) { + printer << ::mlir::transform::AnyOpType::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::transform::AnyParamType>([&](auto t) { + printer << ::mlir::transform::AnyParamType::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::transform::AnyValueType>([&](auto t) { + printer << ::mlir::transform::AnyValueType::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::transform::OperationType>([&](auto t) { + printer << ::mlir::transform::OperationType::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::transform::ParamType>([&](auto t) { + printer << ::mlir::transform::ParamType::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::transform::TypeParamType>([&](auto t) { + printer << ::mlir::transform::TypeParamType::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Default([](auto) { return ::mlir::failure(); }); +} + +namespace mlir { +namespace transform { +::mlir::Type AffineMapParamType::parse(::mlir::AsmParser &odsParser) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + return AffineMapParamType::get(odsParser.getContext()); +} + +void AffineMapParamType::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::AffineMapParamType) +namespace mlir { +namespace transform { +::mlir::Type AnyOpType::parse(::mlir::AsmParser &odsParser) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + return AnyOpType::get(odsParser.getContext()); +} + +void AnyOpType::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::AnyOpType) +namespace mlir { +namespace transform { +::mlir::Type AnyParamType::parse(::mlir::AsmParser &odsParser) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + return AnyParamType::get(odsParser.getContext()); +} + +void AnyParamType::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::AnyParamType) +namespace mlir { +namespace transform { +::mlir::Type AnyValueType::parse(::mlir::AsmParser &odsParser) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + return AnyValueType::get(odsParser.getContext()); +} + +void AnyValueType::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::AnyValueType) +namespace mlir { +namespace transform { +namespace detail { +struct OperationTypeStorage : public ::mlir::TypeStorage { + using KeyTy = std::tuple<::llvm::StringRef>; + OperationTypeStorage(::llvm::StringRef operation_name) : operation_name(std::move(operation_name)) {} + + KeyTy getAsKey() const { + return KeyTy(operation_name); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (operation_name == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static OperationTypeStorage *construct(::mlir::TypeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto operation_name = std::move(std::get<0>(tblgenKey)); + operation_name = allocator.copyInto(operation_name); + return new (allocator.allocate()) OperationTypeStorage(std::move(operation_name)); + } + + ::llvm::StringRef operation_name; +}; +} // namespace detail +OperationType OperationType::get(::mlir::MLIRContext *context, ::llvm::StringRef operation_name) { + return Base::get(context, std::move(operation_name)); +} + +::mlir::Type OperationType::parse(::mlir::AsmParser &odsParser) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr _result_operation_name; + // Parse literal '<' + if (odsParser.parseLess()) return {}; + + // Parse variable 'operation_name' + _result_operation_name = ::mlir::FieldParser::parse(odsParser); + if (::mlir::failed(_result_operation_name)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse Transform_OperationType parameter 'operation_name' which is to be a `::llvm::StringRef`"); + return {}; + } + // Parse literal '>' + if (odsParser.parseGreater()) return {}; + assert(::mlir::succeeded(_result_operation_name)); + return OperationType::get(odsParser.getContext(), + ::llvm::StringRef((*_result_operation_name))); +} + +void OperationType::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << "<"; + odsPrinter.printString(getOperationName());; + odsPrinter << ">"; +} + +::llvm::StringRef OperationType::getOperationName() const { + return getImpl()->operation_name; +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::OperationType) +namespace mlir { +namespace transform { +namespace detail { +struct ParamTypeStorage : public ::mlir::TypeStorage { + using KeyTy = std::tuple<::mlir::Type>; + ParamTypeStorage(::mlir::Type type) : type(std::move(type)) {} + + KeyTy getAsKey() const { + return KeyTy(type); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (type == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static ParamTypeStorage *construct(::mlir::TypeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto type = std::move(std::get<0>(tblgenKey)); + return new (allocator.allocate()) ParamTypeStorage(std::move(type)); + } + + ::mlir::Type type; +}; +} // namespace detail +ParamType ParamType::get(::mlir::MLIRContext *context, ::mlir::Type type) { + return Base::get(context, std::move(type)); +} + +ParamType ParamType::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, ::mlir::Type type) { + return Base::getChecked(emitError, context, type); +} + +::mlir::Type ParamType::parse(::mlir::AsmParser &odsParser) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::mlir::Type> _result_type; + // Parse literal '<' + if (odsParser.parseLess()) return {}; + + // Parse variable 'type' + _result_type = ::mlir::FieldParser<::mlir::Type>::parse(odsParser); + if (::mlir::failed(_result_type)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse Transform_ParamType parameter 'type' which is to be a `::mlir::Type`"); + return {}; + } + // Parse literal '>' + if (odsParser.parseGreater()) return {}; + assert(::mlir::succeeded(_result_type)); + return odsParser.getChecked(odsLoc, odsParser.getContext(), + ::mlir::Type((*_result_type))); +} + +void ParamType::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << "<"; + odsPrinter.printStrippedAttrOrType(getType()); + odsPrinter << ">"; +} + +::mlir::Type ParamType::getType() const { + return getImpl()->type; +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::ParamType) +namespace mlir { +namespace transform { +::mlir::Type TypeParamType::parse(::mlir::AsmParser &odsParser) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + return TypeParamType::get(odsParser.getContext()); +} + +void TypeParamType::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); +} + +} // namespace transform +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::TypeParamType) + +#endif // GET_TYPEDEF_CLASSES + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformTypes.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformTypes.h new file mode 100644 index 0000000000000000000000000000000000000000..bf0fc208829a7b208790495c333e52fb55c0026a --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformTypes.h @@ -0,0 +1,26 @@ +//===- TransformTypes.h - Transform dialect types ---------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_TRANSFORM_IR_TRANSFORMTYPES_H +#define MLIR_DIALECT_TRANSFORM_IR_TRANSFORMTYPES_H + +#include "mlir/Dialect/Transform/Utils/DiagnosedSilenceableFailure.h" +#include "mlir/IR/Types.h" +#include "mlir/Support/LLVM.h" + +namespace mlir { +class DiagnosedSilenceableFailure; +class Operation; +class Type; +} // namespace mlir + +#include "mlir/Dialect/Transform/IR/TransformTypeInterfaces.h.inc" +#define GET_TYPEDEF_CLASSES +#include "mlir/Dialect/Transform/IR/TransformTypes.h.inc" + +#endif // MLIR_DIALECT_TRANSFORM_IR_TRANSFORMTYPES_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformTypes.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformTypes.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..841528e153f2954d5e71a162ccee2897b4c6301b --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/IR/TransformTypes.h.inc @@ -0,0 +1,127 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* TypeDef Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifdef GET_TYPEDEF_CLASSES +#undef GET_TYPEDEF_CLASSES + + +namespace mlir { +class AsmParser; +class AsmPrinter; +} // namespace mlir +namespace mlir { +namespace transform { +class AffineMapParamType; +class AnyOpType; +class AnyParamType; +class AnyValueType; +class OperationType; +class ParamType; +class TypeParamType; +class AffineMapParamType : public ::mlir::Type::TypeBase { +public: + using Base::Base; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"affine_map"}; + } + + static ::mlir::Type parse(::mlir::AsmParser &odsParser); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::mlir::DiagnosedSilenceableFailure checkPayload(::mlir::Location loc, ::mlir::ArrayRef<::mlir::Attribute> payload) const; +}; +class AnyOpType : public ::mlir::Type::TypeBase { +public: + using Base::Base; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"any_op"}; + } + + static ::mlir::Type parse(::mlir::AsmParser &odsParser); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::mlir::DiagnosedSilenceableFailure checkPayload(::mlir::Location loc, ::mlir::ArrayRef<::mlir::Operation *> payload) const; +}; +class AnyParamType : public ::mlir::Type::TypeBase { +public: + using Base::Base; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"any_param"}; + } + + static ::mlir::Type parse(::mlir::AsmParser &odsParser); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::mlir::DiagnosedSilenceableFailure checkPayload(::mlir::Location loc, ::mlir::ArrayRef<::mlir::Attribute> payload) const; +}; +class AnyValueType : public ::mlir::Type::TypeBase { +public: + using Base::Base; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"any_value"}; + } + + static ::mlir::Type parse(::mlir::AsmParser &odsParser); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::mlir::DiagnosedSilenceableFailure checkPayload(::mlir::Location loc, ::mlir::ArrayRef<::mlir::Value> payload) const; +}; +namespace detail { +struct OperationTypeStorage; +} // namespace detail +class OperationType : public ::mlir::Type::TypeBase { +public: + using Base::Base; + static OperationType get(::mlir::MLIRContext *context, ::llvm::StringRef operation_name); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"op"}; + } + + static ::mlir::Type parse(::mlir::AsmParser &odsParser); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::llvm::StringRef getOperationName() const; + ::mlir::DiagnosedSilenceableFailure checkPayload(::mlir::Location loc, ::mlir::ArrayRef<::mlir::Operation *> payload) const; +}; +namespace detail { +struct ParamTypeStorage; +} // namespace detail +class ParamType : public ::mlir::Type::TypeBase { +public: + using Base::Base; + using Base::getChecked; + static ParamType get(::mlir::MLIRContext *context, ::mlir::Type type); + static ParamType getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, ::mlir::Type type); + static ::mlir::LogicalResult verify(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::Type type); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"param"}; + } + + static ::mlir::Type parse(::mlir::AsmParser &odsParser); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::mlir::Type getType() const; + ::mlir::DiagnosedSilenceableFailure checkPayload(::mlir::Location loc, ::mlir::ArrayRef<::mlir::Attribute> payload) const; +}; +class TypeParamType : public ::mlir::Type::TypeBase { +public: + using Base::Base; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"type"}; + } + + static ::mlir::Type parse(::mlir::AsmParser &odsParser); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::mlir::DiagnosedSilenceableFailure checkPayload(::mlir::Location loc, ::mlir::ArrayRef<::mlir::Attribute> payload) const; +}; +} // namespace transform +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::AffineMapParamType) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::AnyOpType) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::AnyParamType) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::AnyValueType) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::OperationType) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::ParamType) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::transform::TypeParamType) + +#endif // GET_TYPEDEF_CLASSES + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/Transforms/Passes.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/Transforms/Passes.h new file mode 100644 index 0000000000000000000000000000000000000000..7a7dfe4709b229755d36bf2f54f1a766d7caa80c --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/Transforms/Passes.h @@ -0,0 +1,27 @@ +//===- Passes.h - Transform dialect pass entry points -----------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_TRANSFORM_TRANSFORMS_PASSES_H +#define MLIR_DIALECT_TRANSFORM_TRANSFORMS_PASSES_H + +#include "mlir/Pass/Pass.h" +#include + +namespace mlir { +class Pass; + +namespace transform { +#define GEN_PASS_DECL +#include "mlir/Dialect/Transform/Transforms/Passes.h.inc" + +#define GEN_PASS_REGISTRATION +#include "mlir/Dialect/Transform/Transforms/Passes.h.inc" +} // namespace transform +} // namespace mlir + +#endif // MLIR_DIALECT_TRANSFORM_TRANSFORMS_PASSES_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/Transforms/Passes.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/Transforms/Passes.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..04b087259c5f70a622826f0af079acb2ef2bad9c --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/Transforms/Passes.h.inc @@ -0,0 +1,290 @@ +/* Autogenerated by mlir-tblgen; don't manually edit */ + +#ifdef GEN_PASS_DECL +// Generate declarations for all passes. +#define GEN_PASS_DECL_CHECKUSESPASS +#define GEN_PASS_DECL_INFEREFFECTSPASS +#undef GEN_PASS_DECL +#endif // GEN_PASS_DECL + +//===----------------------------------------------------------------------===// +// CheckUsesPass +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_CHECKUSESPASS +std::unique_ptr<::mlir::Pass> createCheckUsesPass(); +#undef GEN_PASS_DECL_CHECKUSESPASS +#endif // GEN_PASS_DECL_CHECKUSESPASS +#ifdef GEN_PASS_DEF_CHECKUSESPASS + +namespace impl { + std::unique_ptr<::mlir::Pass> createCheckUsesPass(); +} // namespace impl +namespace impl { + +template +class CheckUsesPassBase : public ::mlir::OperationPass<> { +public: + using Base = CheckUsesPassBase; + + CheckUsesPassBase() : ::mlir::OperationPass<>(::mlir::TypeID::get()) {} + CheckUsesPassBase(const CheckUsesPassBase &other) : ::mlir::OperationPass<>(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("transform-dialect-check-uses"); + } + ::llvm::StringRef getArgument() const override { return "transform-dialect-check-uses"; } + + ::llvm::StringRef getDescription() const override { return "warn about potential use-after-free in the transform dialect"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("CheckUsesPass"); + } + ::llvm::StringRef getName() const override { return "CheckUsesPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(CheckUsesPassBase) + +protected: +private: + + friend std::unique_ptr<::mlir::Pass> createCheckUsesPass() { + return std::make_unique(); + } +}; +} // namespace impl + +std::unique_ptr<::mlir::Pass> createCheckUsesPass() { + return impl::createCheckUsesPass(); +} +#undef GEN_PASS_DEF_CHECKUSESPASS +#endif // GEN_PASS_DEF_CHECKUSESPASS + +//===----------------------------------------------------------------------===// +// InferEffectsPass +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_INFEREFFECTSPASS +std::unique_ptr<::mlir::Pass> createInferEffectsPass(); +#undef GEN_PASS_DECL_INFEREFFECTSPASS +#endif // GEN_PASS_DECL_INFEREFFECTSPASS +#ifdef GEN_PASS_DEF_INFEREFFECTSPASS + +namespace impl { + std::unique_ptr<::mlir::Pass> createInferEffectsPass(); +} // namespace impl +namespace impl { + +template +class InferEffectsPassBase : public ::mlir::OperationPass<> { +public: + using Base = InferEffectsPassBase; + + InferEffectsPassBase() : ::mlir::OperationPass<>(::mlir::TypeID::get()) {} + InferEffectsPassBase(const InferEffectsPassBase &other) : ::mlir::OperationPass<>(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("transform-infer-effects"); + } + ::llvm::StringRef getArgument() const override { return "transform-infer-effects"; } + + ::llvm::StringRef getDescription() const override { return "infer transform side effects for symbols"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("InferEffectsPass"); + } + ::llvm::StringRef getName() const override { return "InferEffectsPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(InferEffectsPassBase) + +protected: +private: + + friend std::unique_ptr<::mlir::Pass> createInferEffectsPass() { + return std::make_unique(); + } +}; +} // namespace impl + +std::unique_ptr<::mlir::Pass> createInferEffectsPass() { + return impl::createInferEffectsPass(); +} +#undef GEN_PASS_DEF_INFEREFFECTSPASS +#endif // GEN_PASS_DEF_INFEREFFECTSPASS +#ifdef GEN_PASS_REGISTRATION + +//===----------------------------------------------------------------------===// +// CheckUsesPass Registration +//===----------------------------------------------------------------------===// + +inline void registerCheckUsesPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createCheckUsesPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerCheckUsesPassPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createCheckUsesPass(); + }); +} + +//===----------------------------------------------------------------------===// +// InferEffectsPass Registration +//===----------------------------------------------------------------------===// + +inline void registerInferEffectsPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createInferEffectsPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerInferEffectsPassPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return createInferEffectsPass(); + }); +} + +//===----------------------------------------------------------------------===// +// Transform Registration +//===----------------------------------------------------------------------===// + +inline void registerTransformPasses() { + registerCheckUsesPass(); + registerInferEffectsPass(); +} +#undef GEN_PASS_REGISTRATION +#endif // GEN_PASS_REGISTRATION +// Deprecated. Please use the new per-pass macros. +#ifdef GEN_PASS_CLASSES + +template +class CheckUsesPassBase : public ::mlir::OperationPass<> { +public: + using Base = CheckUsesPassBase; + + CheckUsesPassBase() : ::mlir::OperationPass<>(::mlir::TypeID::get()) {} + CheckUsesPassBase(const CheckUsesPassBase &other) : ::mlir::OperationPass<>(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("transform-dialect-check-uses"); + } + ::llvm::StringRef getArgument() const override { return "transform-dialect-check-uses"; } + + ::llvm::StringRef getDescription() const override { return "warn about potential use-after-free in the transform dialect"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("CheckUsesPass"); + } + ::llvm::StringRef getName() const override { return "CheckUsesPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(CheckUsesPassBase) + +protected: +}; + +template +class InferEffectsPassBase : public ::mlir::OperationPass<> { +public: + using Base = InferEffectsPassBase; + + InferEffectsPassBase() : ::mlir::OperationPass<>(::mlir::TypeID::get()) {} + InferEffectsPassBase(const InferEffectsPassBase &other) : ::mlir::OperationPass<>(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("transform-infer-effects"); + } + ::llvm::StringRef getArgument() const override { return "transform-infer-effects"; } + + ::llvm::StringRef getDescription() const override { return "infer transform side effects for symbols"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("InferEffectsPass"); + } + ::llvm::StringRef getName() const override { return "InferEffectsPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(InferEffectsPassBase) + +protected: +}; +#undef GEN_PASS_CLASSES +#endif // GEN_PASS_CLASSES diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/Transforms/TransformInterpreterPassBase.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/Transforms/TransformInterpreterPassBase.h new file mode 100644 index 0000000000000000000000000000000000000000..16ef0bc6a7392001e39267a9f10c96946f85eb8c --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/Transforms/TransformInterpreterPassBase.h @@ -0,0 +1,216 @@ +//===- TransformInterpreterPassBase.h ---------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Base class with shared implementation for transform dialect interpreter +// passes. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_TRANSFORM_TRANSFORMS_TRANSFORMINTERPRETERPASSBASE_H +#define MLIR_DIALECT_TRANSFORM_TRANSFORMS_TRANSFORMINTERPRETERPASSBASE_H + +#include "mlir/Dialect/Transform/IR/TransformInterfaces.h" +#include "mlir/Pass/Pass.h" +#include "mlir/Support/LLVM.h" +#include + +namespace mlir { +struct LogicalResult; +class MLIRContext; +class ModuleOp; +class Operation; +template +class OwningOpRef; +class Region; + +namespace transform { +namespace detail { +/// Template-free implementation of TransformInterpreterPassBase::initialize. +LogicalResult interpreterBaseInitializeImpl( + MLIRContext *context, StringRef transformFileName, + ArrayRef transformLibraryPaths, + std::shared_ptr> &module, + std::shared_ptr> &libraryModule, + function_ref(OpBuilder &, Location)> + moduleBuilder = nullptr); + +/// Template-free implementation of +/// TransformInterpreterPassBase::runOnOperation. +LogicalResult interpreterBaseRunOnOperationImpl( + Operation *target, StringRef passName, + const std::shared_ptr> &sharedTransformModule, + const std::shared_ptr> &libraryModule, + const RaggedArray &extraMappings, + const TransformOptions &options, + const Pass::Option &transformFileName, + const Pass::ListOption &transformLibraryPaths, + const Pass::Option &debugPayloadRootTag, + const Pass::Option &debugTransformRootTag, + StringRef binaryName); +} // namespace detail + +/// Base class for transform dialect interpreter passes that can consume and +/// dump transform dialect scripts in separate files. The pass is controlled by +/// three string options: +/// +/// - transformFileName: if non-empty, the name of the file containing the +/// transform script. If empty, `debugTransformRootTag` is considered or the +/// pass root operation must contain a single top-level transform op that +/// will be interpreted. +/// - transformLibraryPaths: if non-empty, the modules in these files will be +/// merged into the main transform script run by the interpreter before +/// execution. This allows to provide definitions for external functions +/// used in the main script. Other public symbols in the library modules may +/// lead to collisions with public symbols in the main script and among each +/// other. +/// - debugPayloadRootTag: if non-empty, the value of the attribute named +/// `kTransformDialectTagAttrName` indicating the single op that is +/// considered the payload root of the transform interpreter; otherwise, the +/// root operation of the pass is used. +/// - debugTransformRootTag: if non-empty, the value of the attribute named +/// `kTransformDialectTagAttrName` indicating the single top-level transform +/// op contained in the payload root to be used as the entry point by the +/// transform interpreter; mutually exclusive with `transformFileName`. +/// +/// The pass runs the transform dialect interpreter as directed by the options. +/// It also provides the mechanism to dump reproducers into stderr +/// (-debug-only=transform-dialect-dump-repro) or into a temporary file +/// (-debug-only=transform-dialect-save-repro) that can be used with this +/// pass in a standalone mode. +/// +/// Concrete passes must derive from this class instead of their generated base +/// class (or PassWrapper), and supply themselves and the generated base class +/// as template arguments. They are *not* expected to to implement `initialize` +/// or `runOnOperation`. They *are* expected to call the copy constructor of +/// this class in their copy constructors, short of which the file-based +/// transform dialect script injection facility will become non-operational. +/// +/// Concrete passes may implement the `runBeforeInterpreter` and +/// `runAfterInterpreter` to customize the behavior of the pass. +template typename GeneratedBase> +class TransformInterpreterPassBase : public GeneratedBase { +public: + explicit TransformInterpreterPassBase( + const TransformOptions &options = TransformOptions()) + : options(options) {} + + TransformInterpreterPassBase(const TransformInterpreterPassBase &pass) { + sharedTransformModule = pass.sharedTransformModule; + transformLibraryModule = pass.transformLibraryModule; + options = pass.options; + } + + static StringLiteral getBinaryName() { return "mlir-opt"; } + + LogicalResult initialize(MLIRContext *context) override { + +#define REQUIRE_PASS_OPTION(NAME) \ + static_assert( \ + std::is_same_v< \ + std::remove_reference_t().NAME)>, \ + Pass::Option>, \ + "required " #NAME " string pass option is missing") + + REQUIRE_PASS_OPTION(transformFileName); + REQUIRE_PASS_OPTION(debugPayloadRootTag); + REQUIRE_PASS_OPTION(debugTransformRootTag); + +#undef REQUIRE_PASS_OPTION + +#define REQUIRE_PASS_LIST_OPTION(NAME) \ + static_assert( \ + std::is_same_v< \ + std::remove_reference_t().NAME)>, \ + Pass::ListOption>, \ + "required " #NAME " string pass option is missing") + + REQUIRE_PASS_LIST_OPTION(transformLibraryPaths); + +#undef REQUIRE_PASS_LIST_OPTION + + StringRef transformFileName = + static_cast(this)->transformFileName; + ArrayRef transformLibraryPaths = + static_cast(this)->transformLibraryPaths; + return detail::interpreterBaseInitializeImpl( + context, transformFileName, transformLibraryPaths, + sharedTransformModule, transformLibraryModule, + [this](OpBuilder &builder, Location loc) { + return static_cast(this)->constructTransformModule( + builder, loc); + }); + } + + /// Hook for passes to run additional logic in the pass before the + /// interpreter. If failure is returned, the pass fails and the interpreter is + /// not run. + LogicalResult runBeforeInterpreter(Operation *) { return success(); } + + /// Hook for passes to run additional logic in the pass after the interpreter. + /// Only runs if everything succeeded before. If failure is returned, the pass + /// fails. + LogicalResult runAfterInterpreter(Operation *) { return success(); } + + /// Hook for passes to run custom logic to construct the transform module. + /// This will run during initialization. If the external script is provided, + /// it overrides the construction, which will not be called. + std::optional constructTransformModule(OpBuilder &builder, + Location loc) { + return std::nullopt; + } + + void runOnOperation() override { + auto *pass = static_cast(this); + Operation *op = pass->getOperation(); + StringRef binaryName = Concrete::getBinaryName(); + if (failed(pass->runBeforeInterpreter(op)) || + failed(detail::interpreterBaseRunOnOperationImpl( + op, pass->getArgument(), sharedTransformModule, + transformLibraryModule, + /*extraMappings=*/{}, options, pass->transformFileName, + pass->transformLibraryPaths, pass->debugPayloadRootTag, + pass->debugTransformRootTag, binaryName)) || + failed(pass->runAfterInterpreter(op))) { + return pass->signalPassFailure(); + } + } + +protected: + /// Transform interpreter options. + TransformOptions options; + + /// Returns a read-only reference to shared transform module. + const std::shared_ptr> & + getSharedTransformModule() const { + return sharedTransformModule; + } + + /// Returns a read-only reference to the transform library module. + const std::shared_ptr> & + getTransformLibraryModule() const { + return transformLibraryModule; + } + +private: + /// The separate transform module to be used for transformations, shared + /// across multiple instances of the pass if it is applied in parallel to + /// avoid potentially expensive cloning. MUST NOT be modified after the pass + /// has been initialized. + std::shared_ptr> sharedTransformModule = nullptr; + + /// The transform module containing symbol definitions that become available + /// in the transform scripts. Similar to dynamic linking for binaries. This is + /// shared across multiple instances of the pass and therefore MUST NOT be + /// modified after the pass has been initialized. + std::shared_ptr> transformLibraryModule = nullptr; +}; + +} // namespace transform +} // namespace mlir + +#endif // MLIR_DIALECT_TRANSFORM_TRANSFORMS_TRANSFORMINTERPRETERPASSBASE_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/Transforms/TransformInterpreterUtils.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/Transforms/TransformInterpreterUtils.h new file mode 100644 index 0000000000000000000000000000000000000000..36c80e6fd61d3c1d42c37a2fd7d69afe1462e994 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/Transforms/TransformInterpreterUtils.h @@ -0,0 +1,89 @@ +//===- TransformInterpreterUtils.h - Transform Utils ------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_TRANSFORM_TRANSFORMS_TRANSFORMINTERPRETERUTILS_H +#define MLIR_DIALECT_TRANSFORM_TRANSFORMS_TRANSFORMINTERPRETERUTILS_H + +#include "mlir/Dialect/Transform/IR/TransformDialect.h" +#include "mlir/Dialect/Transform/IR/TransformInterfaces.h" +#include "mlir/Pass/Pass.h" +#include "mlir/Support/LLVM.h" +#include + +namespace mlir { +struct LogicalResult; +class MLIRContext; +class ModuleOp; +class Operation; +template +class OwningOpRef; +class Region; + +namespace transform { +namespace detail { +/// Utility to parse and verify the content of a `transformFileName` MLIR file +/// containing a transform dialect specification. +LogicalResult +parseTransformModuleFromFile(MLIRContext *context, + llvm::StringRef transformFileName, + OwningOpRef &transformModule); + +/// Utility to load a transform interpreter `module` from a module that has +/// already been preloaded in the context. +/// This mode is useful in cases where explicit parsing of a transform library +/// from file is expected to be prohibitively expensive. +/// In such cases, the transform module is expected to be found in the preloaded +/// library modules of the transform dialect. +/// Returns null if the module is not found. +ModuleOp getPreloadedTransformModule(MLIRContext *context); + +/// Finds the first TransformOpInterface named `kTransformEntryPointSymbolName` +/// that is either: +/// 1. nested under `root` (takes precedence). +/// 2. nested under `module`, if not found in `root`. +/// Reports errors and returns null if no such operation found. +TransformOpInterface findTransformEntryPoint( + Operation *root, ModuleOp module, + StringRef entryPoint = TransformDialect::kTransformEntryPointSymbolName); + +/// Merge all symbols from `other` into `target`. Both ops need to implement the +/// `SymbolTable` trait. Operations are moved from `other`, i.e., `other` may be +/// modified by this function and might not verify after the function returns. +/// Upon merging, private symbols may be renamed in order to avoid collisions in +/// the result. Public symbols may not collide, with the exception of +/// instances of `SymbolOpInterface`, where collisions are allowed if at least +/// one of the two is external, in which case the other op preserved (or any one +/// of the two if both are external). +// TODO: Reconsider cloning individual ops rather than forcing users of the +// function to clone (or move) `other` in order to improve efficiency. +// This might primarily make sense if we can also prune the symbols that +// are merged to a subset (such as those that are actually used). +LogicalResult mergeSymbolsInto(Operation *target, + OwningOpRef other); +} // namespace detail + +/// Standalone util to apply the named sequence `entryPoint` to the payload. +/// This is done in 3 steps: +/// 1. lookup the `entryPoint` symbol in `{payload, sharedTransformModule}` by +/// calling detail::findTransformEntryPoint. +/// 2. if the entry point is found and not nested under +/// `sharedTransformModule`, call `detail::defineDeclaredSymbols` to "link" in +/// the `sharedTransformModule`. Note: this may modify the transform IR +/// embedded with the payload IR. +/// 3. apply the transform IR to the payload IR, relaxing the requirement that +/// the transform IR is a top-level transform op. We are applying a named +/// sequence anyway. +LogicalResult applyTransformNamedSequence( + Operation *payload, ModuleOp transformModule, + const TransformOptions &options, + StringRef entryPoint = TransformDialect::kTransformEntryPointSymbolName); + +} // namespace transform +} // namespace mlir + +#endif // MLIR_DIALECT_TRANSFORM_TRANSFORMS_TRANSFORMINTERPRETERUTILS_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/Utils/DiagnosedSilenceableFailure.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/Utils/DiagnosedSilenceableFailure.h new file mode 100644 index 0000000000000000000000000000000000000000..fcf422a0b6aa3473a7e555cd8e098014f4bb0bed --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/Utils/DiagnosedSilenceableFailure.h @@ -0,0 +1,267 @@ +//===- DiagnosedSilenceableFailure.h - Tri-state result ----------- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file declares the DiagnosedSilenceableFailure class allowing to store +// a tri-state result (definite failure, recoverable failure, success) with an +// optional associated list of diagnostics. +// +//===----------------------------------------------------------------------===// + +#include "mlir/IR/Diagnostics.h" +#include "mlir/IR/Operation.h" +#include + +#ifndef MLIR_DIALECT_TRANSFORM_UTILS_DIAGNOSEDSILENCEABLEFAILURE_H +#define MLIR_DIALECT_TRANSFORM_UTILS_DIAGNOSEDSILENCEABLEFAILURE_H + +namespace mlir { +/// The result of a transform IR operation application. This can have one of the +/// three states: +/// - success; +/// - silenceable (recoverable) failure with yet-unreported diagnostic; +/// - definite failure. +/// Silenceable failure is intended to communicate information about +/// transformations that did not apply but in a way that supports recovery, +/// for example, they did not modify the payload IR or modified it in some +/// predictable way. They are associated with a Diagnostic that provides more +/// details on the failure. Silenceable failure can be discarded, turning the +/// result into success, or "reported", emitting the diagnostic and turning the +/// result into definite failure. +/// Transform IR operations containing other operations are allowed to do either +/// with the results of the nested transformations, but must propagate definite +/// failures as their diagnostics have been already reported to the user. +class [[nodiscard]] DiagnosedSilenceableFailure { +public: + DiagnosedSilenceableFailure(const DiagnosedSilenceableFailure &) = delete; + DiagnosedSilenceableFailure & + operator=(const DiagnosedSilenceableFailure &) = delete; + DiagnosedSilenceableFailure(DiagnosedSilenceableFailure &&) = default; + DiagnosedSilenceableFailure & + operator=(DiagnosedSilenceableFailure &&) = default; + + /// Constructs a DiagnosedSilenceableFailure in the success state. + static DiagnosedSilenceableFailure success() { + return DiagnosedSilenceableFailure(::mlir::success()); + } + + /// Constructs a DiagnosedSilenceableFailure in the failure state. Typically, + /// a diagnostic has been emitted before this. + static DiagnosedSilenceableFailure definiteFailure() { + return DiagnosedSilenceableFailure(::mlir::failure()); + } + + /// Constructs a DiagnosedSilenceableFailure in the silenceable failure state, + /// ready to emit the given diagnostic. This is considered a failure + /// regardless of the diagnostic severity. + static DiagnosedSilenceableFailure silenceableFailure(Diagnostic &&diag) { + return DiagnosedSilenceableFailure(std::forward(diag)); + } + static DiagnosedSilenceableFailure + silenceableFailure(SmallVector &&diag) { + return DiagnosedSilenceableFailure( + std::forward>(diag)); + } + + /// Converts all kinds of failure into a LogicalResult failure, emitting the + /// diagnostic if necessary. Must not be called more than once. + LogicalResult checkAndReport(); + + /// Returns `true` if this is a success. + bool succeeded() const { + return ::mlir::succeeded(result) && diagnostics.empty(); + } + + /// Returns `true` if this is a definite failure. + bool isDefiniteFailure() const { + return ::mlir::failed(result) && diagnostics.empty(); + } + + /// Returns `true` if this is a silenceable failure. + bool isSilenceableFailure() const { return !diagnostics.empty(); } + + /// Returns the diagnostic message without emitting it. Expects this object + /// to be a silenceable failure. + std::string getMessage() const { + std::string res; + for (auto &diagnostic : diagnostics) { + res.append(diagnostic.str()); + res.append("\n"); + } + return res; + } + + /// Returns a string representation of the failure mode (for error reporting). + std::string getStatusString() const { + if (succeeded()) + return "success"; + if (isSilenceableFailure()) + return "silenceable failure"; + return "definite failure"; + } + + /// Converts silenceable failure into LogicalResult success without reporting + /// the diagnostic, preserves the other states. + LogicalResult silence() { + if (!diagnostics.empty()) { + diagnostics.clear(); + result = ::mlir::success(); + } + return result; + } + + /// Take the diagnostics and silence. + void takeDiagnostics(SmallVectorImpl &diags) { + assert(!diagnostics.empty() && "expected a diagnostic to be present"); + diags.append(std::make_move_iterator(diagnostics.begin()), + std::make_move_iterator(diagnostics.end())); + } + + /// Streams the given values into the last diagnostic. + /// Expects this object to be a silenceable failure. + template + DiagnosedSilenceableFailure &operator<<(T &&value) & { + assert(isSilenceableFailure() && + "can only append output in silenceable failure state"); + diagnostics.back() << std::forward(value); + return *this; + } + template + DiagnosedSilenceableFailure &&operator<<(T &&value) && { + return std::move(this->operator<<(std::forward(value))); + } + + /// Attaches a note to the last diagnostic. + /// Expects this object to be a silenceable failure. + Diagnostic &attachNote(std::optional loc = std::nullopt) { + assert(isSilenceableFailure() && + "can only attach notes to silenceable failures"); + return diagnostics.back().attachNote(loc); + } + +private: + explicit DiagnosedSilenceableFailure(LogicalResult result) : result(result) {} + explicit DiagnosedSilenceableFailure(Diagnostic &&diagnostic) + : result(failure()) { + diagnostics.emplace_back(std::move(diagnostic)); + } + explicit DiagnosedSilenceableFailure(SmallVector &&diagnostics) + : diagnostics(std::move(diagnostics)), result(failure()) {} + + /// The diagnostics associated with this object. If non-empty, the object is + /// considered to be in the silenceable failure state regardless of the + /// `result` field. + SmallVector diagnostics; + + /// The "definite" logical state, either success or failure. + /// Ignored if the diagnostics message is present. + LogicalResult result; + +#if LLVM_ENABLE_ABI_BREAKING_CHECKS + /// Whether the associated diagnostics have been reported. + /// Diagnostics reporting consumes the diagnostics, so we need a mechanism to + /// differentiate reported diagnostics from a state where it was never + /// created. + bool reported = false; +#endif // LLVM_ENABLE_ABI_BREAKING_CHECKS +}; + +class DiagnosedDefiniteFailure; + +DiagnosedDefiniteFailure emitDefiniteFailure(Location loc, + const Twine &message = {}); + +/// A compatibility class connecting `InFlightDiagnostic` to +/// `DiagnosedSilenceableFailure` while providing an interface similar to the +/// former. Implicitly convertible to `DiagnosticSilenceableFailure` in definite +/// failure state and to `LogicalResult` failure. Reports the error on +/// conversion or on destruction. Instances of this class can be created by +/// `emitDefiniteFailure()`. +class DiagnosedDefiniteFailure { + friend DiagnosedDefiniteFailure emitDefiniteFailure(Location loc, + const Twine &message); + +public: + /// Only move-constructible because it carries an in-flight diagnostic. + DiagnosedDefiniteFailure(DiagnosedDefiniteFailure &&) = default; + + /// Forward the message to the diagnostic. + template + DiagnosedDefiniteFailure &operator<<(T &&value) & { + diag << std::forward(value); + return *this; + } + template + DiagnosedDefiniteFailure &&operator<<(T &&value) && { + return std::move(this->operator<<(std::forward(value))); + } + + /// Attaches a note to the error. + Diagnostic &attachNote(std::optional loc = std::nullopt) { + return diag.attachNote(loc); + } + + /// Implicit conversion to DiagnosedSilenceableFailure in the definite failure + /// state. Reports the error. + operator DiagnosedSilenceableFailure() { + diag.report(); + return DiagnosedSilenceableFailure::definiteFailure(); + } + + /// Implicit conversion to LogicalResult in the failure state. Reports the + /// error. + operator LogicalResult() { + diag.report(); + return failure(); + } + +private: + /// Constructs a definite failure at the given location with the given + /// message. + explicit DiagnosedDefiniteFailure(Location loc, const Twine &message) + : diag(emitError(loc, message)) {} + + /// Copy-construction and any assignment is disallowed to prevent repeated + /// error reporting. + DiagnosedDefiniteFailure(const DiagnosedDefiniteFailure &) = delete; + DiagnosedDefiniteFailure & + operator=(const DiagnosedDefiniteFailure &) = delete; + DiagnosedDefiniteFailure &operator=(DiagnosedDefiniteFailure &&) = delete; + + /// The error message. + InFlightDiagnostic diag; +}; + +/// Emits a definite failure with the given message. The returned object allows +/// for last-minute modification to the error message, such as attaching notes +/// and completing the message. It will be reported when the object is +/// destructed or converted. +inline DiagnosedDefiniteFailure emitDefiniteFailure(Location loc, + const Twine &message) { + return DiagnosedDefiniteFailure(loc, message); +} +inline DiagnosedDefiniteFailure emitDefiniteFailure(Operation *op, + const Twine &message = {}) { + return emitDefiniteFailure(op->getLoc(), message); +} + +/// Emits a silenceable failure with the given message. A silenceable failure +/// must be either suppressed or converted into a definite failure and reported +/// to the user. +inline DiagnosedSilenceableFailure +emitSilenceableFailure(Location loc, const Twine &message = {}) { + Diagnostic diag(loc, DiagnosticSeverity::Error); + diag << message; + return DiagnosedSilenceableFailure::silenceableFailure(std::move(diag)); +} +inline DiagnosedSilenceableFailure +emitSilenceableFailure(Operation *op, const Twine &message = {}) { + return emitSilenceableFailure(op->getLoc(), message); +} +} // namespace mlir + +#endif // MLIR_DIALECT_TRANSFORM_UTILS_DIAGNOSEDSILENCEABLEFAILURE_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/Utils/RaggedArray.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/Utils/RaggedArray.h new file mode 100644 index 0000000000000000000000000000000000000000..0ee23914fa4e1d07d489e24ab80389178580061c --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/Utils/RaggedArray.h @@ -0,0 +1,173 @@ +//===- RaggedArray.h - 2D array with different inner lengths ----*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "mlir/Support/LLVM.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/SmallVector.h" +#include + +namespace mlir { +/// A 2D array where each row may have different length. Elements of each row +/// are stored contiguously, but rows don't have a fixed order in the storage. +template +class RaggedArray { +public: + /// Returns the number of rows in the 2D array. + size_t size() const { return slices.size(); } + + /// Returns true if the are no rows in the 2D array. Note that an array with a + /// non-zero number of empty rows is *NOT* empty. + bool empty() const { return slices.empty(); } + + /// Accesses `pos`-th row. + ArrayRef operator[](size_t pos) const { return at(pos); } + ArrayRef at(size_t pos) const { + if (slices[pos].first == static_cast(-1)) + return ArrayRef(); + return ArrayRef(storage).slice(slices[pos].first, slices[pos].second); + } + MutableArrayRef operator[](size_t pos) { return at(pos); } + MutableArrayRef at(size_t pos) { + if (slices[pos].first == static_cast(-1)) + return MutableArrayRef(); + return MutableArrayRef(storage).slice(slices[pos].first, + slices[pos].second); + } + + /// Iterator over the rows. + class iterator + : public llvm::iterator_facade_base< + iterator, std::forward_iterator_tag, MutableArrayRef, + std::ptrdiff_t, MutableArrayRef *, MutableArrayRef> { + public: + /// Creates the start iterator. + explicit iterator(RaggedArray &ragged) : ragged(ragged), pos(0) {} + + /// Creates the end iterator. + iterator(RaggedArray &ragged, size_t pos) : ragged(ragged), pos(pos) {} + + /// Dereferences the current iterator. Assumes in-bounds. + MutableArrayRef operator*() const { return ragged[pos]; } + + /// Increments the iterator. + iterator &operator++() { + if (pos < ragged.slices.size()) + ++pos; + return *this; + } + + /// Compares the two iterators. Iterators into different ragged arrays + /// compare not equal. + bool operator==(const iterator &other) const { + return &ragged == &other.ragged && pos == other.pos; + } + + private: + RaggedArray &ragged; + size_t pos; + }; + + /// Constant iterator over the rows. + class const_iterator + : public llvm::iterator_facade_base< + const_iterator, std::forward_iterator_tag, ArrayRef, + std::ptrdiff_t, ArrayRef *, ArrayRef> { + public: + /// Creates the start iterator. + explicit const_iterator(const RaggedArray &ragged) + : ragged(ragged), pos(0) {} + + /// Creates the end iterator. + const_iterator(const RaggedArray &ragged, size_t pos) + : ragged(ragged), pos(pos) {} + + /// Dereferences the current iterator. Assumes in-bounds. + ArrayRef operator*() const { return ragged[pos]; } + + /// Increments the iterator. + const_iterator &operator++() { + if (pos < ragged.slices.size()) + ++pos; + return *this; + } + + /// Compares the two iterators. Iterators into different ragged arrays + /// compare not equal. + bool operator==(const const_iterator &other) const { + return &ragged == &other.ragged && pos == other.pos; + } + + private: + const RaggedArray &ragged; + size_t pos; + }; + + /// Iterator over rows. + const_iterator begin() const { return const_iterator(*this); } + const_iterator end() const { return const_iterator(*this, slices.size()); } + iterator begin() { return iterator(*this); } + iterator end() { return iterator(*this, slices.size()); } + + /// Reserve space to store `size` rows with `nestedSize` elements each. + void reserve(size_t size, size_t nestedSize = 0) { + slices.reserve(size); + storage.reserve(size * nestedSize); + } + + /// Appends the given range of elements as a new row to the 2D array. May + /// invalidate the end iterator. + template + void push_back(Range &&elements) { + slices.push_back(appendToStorage(std::forward(elements))); + } + + /// Replaces the `pos`-th row in the 2D array with the given range of + /// elements. Invalidates iterators and references to `pos`-th and all + /// succeeding rows. + template + void replace(size_t pos, Range &&elements) { + if (slices[pos].first != static_cast(-1)) { + auto from = std::next(storage.begin(), slices[pos].first); + auto to = std::next(from, slices[pos].second); + auto newFrom = storage.erase(from, to); + // Update the array refs after the underlying storage was shifted. + for (size_t i = pos + 1, e = size(); i < e; ++i) { + slices[i] = std::make_pair(std::distance(storage.begin(), newFrom), + slices[i].second); + std::advance(newFrom, slices[i].second); + } + } + slices[pos] = appendToStorage(std::forward(elements)); + } + + /// Appends `num` empty rows to the array. + void appendEmptyRows(size_t num) { + slices.resize(slices.size() + num, std::pair(-1, 0)); + } + +private: + /// Appends the given elements to the storage and returns an ArrayRef + /// pointing to them in the storage. + template + std::pair appendToStorage(Range &&elements) { + size_t start = storage.size(); + llvm::append_range(storage, std::forward(elements)); + return std::make_pair(start, storage.size() - start); + } + + /// Outer elements of the ragged array. Each entry is an (offset, length) + /// pair identifying a contiguous segment in the `storage` list that + /// contains the actual elements. This allows for elements to be stored + /// contiguously without nested vectors and for different segments to be set + /// or replaced in any order. + SmallVector> slices; + + /// Dense storage for ragged array elements. + SmallVector storage; +}; +} // namespace mlir diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/Utils/Utils.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/Utils/Utils.h new file mode 100644 index 0000000000000000000000000000000000000000..868054e5e2aef4d3cb1b6f1916b9180418acf65a --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Transform/Utils/Utils.h @@ -0,0 +1,54 @@ +//===- Utils.h - Transform dialect utilities --------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_TRANSFORMS_UTILS_UTILS_H +#define MLIR_DIALECT_TRANSFORMS_UTILS_UTILS_H + +#include "mlir/IR/OpImplementation.h" +#include "mlir/IR/Value.h" +#include "mlir/IR/ValueRange.h" +#include "mlir/Support/LLVM.h" + +namespace mlir { +class OpAsmPrinter; + +namespace transform { +class TransformState; + +/// Printer hook for custom directive in assemblyFormat. +/// +/// custom($packed, type($packed), $values, +/// type($values), $integers) +/// +/// where `values` are variadic Index values, `integers` is an `I64ArrayAttr` +/// and `packed` is a single transform dialect handle who's mapped payload ops +/// have a single Index result and represent the index list. Either `packed` +/// or the other two parameters may be specified. +/// +/// This allows idiomatic printing of mixed value and integer attributes in a +/// list or with a single handle. E.g., `[%arg0 : !transform.any_op, 7, 42, +/// %arg42 : !transform.param]` or just `%h : !transform.any_op`. +void printPackedOrDynamicIndexList(OpAsmPrinter &printer, Operation *op, + Value packed, Type packedType, + OperandRange values, TypeRange valueTypes, + DenseI64ArrayAttr integers); + +/// Parser hook for custom directive in assemblyFormat. +/// +/// custom($packed, type($packed), $values, +/// type($values), $integers) +/// +/// See `printPackedOrDynamicIndexList` for details. +ParseResult parsePackedOrDynamicIndexList( + OpAsmParser &parser, std::optional &packed, + Type &packedType, SmallVectorImpl &values, + SmallVectorImpl &valueTypes, DenseI64ArrayAttr &integers); +} // namespace transform +} // namespace mlir + +#endif // MLIR_DIALECT_TRANSFORMS_UTILS_UTILS_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/UB/IR/UBOps.cpp.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/UB/IR/UBOps.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..6cb6b2a664ef66733ec7a487dbf80fbf70938614 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/UB/IR/UBOps.cpp.inc @@ -0,0 +1,340 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Op Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: UBOps.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifdef GET_OP_LIST +#undef GET_OP_LIST + +::mlir::ub::PoisonOp +#endif // GET_OP_LIST + +#ifdef GET_OP_CLASSES +#undef GET_OP_CLASSES + + +//===----------------------------------------------------------------------===// +// Local Utility Method Definitions +//===----------------------------------------------------------------------===// + +namespace mlir { +namespace ub { + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_UBOps0( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((true))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be any type, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_UBOps0( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::ub::PoisonAttrInterface>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: PoisonAttrInterface instance"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_UBOps0( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_UBOps0(attr, attrName, [op]() { + return op->emitOpError(); + }); +} +} // namespace ub +} // namespace mlir +namespace mlir { +namespace ub { + +//===----------------------------------------------------------------------===// +// ::mlir::ub::PoisonOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +PoisonOpGenericAdaptorBase::PoisonOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("ub.poison", odsAttrs.getContext()); +} + +PoisonOpGenericAdaptorBase::PoisonOpGenericAdaptorBase(PoisonOp op) : PoisonOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair PoisonOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr PoisonOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::ub::PoisonAttrInterface PoisonOpGenericAdaptorBase::getValueAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::ub::PoisonAttrInterface>(getProperties().value); + return attr; +} + +::mlir::ub::PoisonAttrInterface PoisonOpGenericAdaptorBase::getValue() { + auto attr = getValueAttr(); + return attr; +} + +} // namespace detail +PoisonOpAdaptor::PoisonOpAdaptor(PoisonOp op) : PoisonOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult PoisonOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_value = getProperties().value; (void)tblgen_value; + + if (tblgen_value && !((::llvm::isa<::mlir::ub::PoisonAttrInterface>(tblgen_value)))) + return emitError(loc, "'ub.poison' op ""attribute 'value' failed to satisfy constraint: PoisonAttrInterface instance"); + return ::mlir::success(); +} + +std::pair PoisonOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range PoisonOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +std::pair PoisonOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range PoisonOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value PoisonOp::getResult() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult PoisonOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.value; + auto attr = dict.get("value"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for value in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `value` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute PoisonOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.value; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("value", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code PoisonOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.value.getAsOpaquePointer())); +} + +std::optional PoisonOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "value") + return prop.value; + return std::nullopt; +} + +void PoisonOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "value") { + prop.value = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void PoisonOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.value) attrs.append("value", prop.value); +} + +::mlir::LogicalResult PoisonOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getValueAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_UBOps0(attr, "value", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult PoisonOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.value))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void PoisonOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.value); +} + +::mlir::ub::PoisonAttrInterface PoisonOp::getValueAttr() { + return ::llvm::dyn_cast_or_null<::mlir::ub::PoisonAttrInterface>(getProperties().value); +} + +::mlir::ub::PoisonAttrInterface PoisonOp::getValue() { + auto attr = getValueAttr(); + return attr; +} + +void PoisonOp::setValueAttr(::mlir::ub::PoisonAttrInterface attr) { + (*this)->setAttr(getValueAttrName(), attr); +} + +void PoisonOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ub::PoisonAttrInterface value) { + if (value) { + odsState.getOrAddProperties().value = value; + } + odsState.addTypes(result); +} + +void PoisonOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ub::PoisonAttrInterface value) { + if (value) { + odsState.getOrAddProperties().value = value; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void PoisonOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void PoisonOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { + ::mlir::Builder odsBuilder(opName.getContext()); + if (!properties.value) + properties.value = ::mlir::ub::PoisonAttr::get(odsBuilder.getContext()); +} + +::mlir::LogicalResult PoisonOp::verifyInvariantsImpl() { + auto tblgen_value = getProperties().value; (void)tblgen_value; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_UBOps0(*this, tblgen_value, "value"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_UBOps0(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult PoisonOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult PoisonOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::ub::PoisonAttrInterface valueAttr; + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (::mlir::succeeded(parser.parseOptionalLess())) { + + if (parser.parseCustomAttributeWithFallback(valueAttr, ::mlir::Type{})) { + return ::mlir::failure(); + } + if (valueAttr) result.getOrAddProperties().value = valueAttr; + if (parser.parseGreater()) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + result.addTypes(resultTypes); + return ::mlir::success(); +} + +void PoisonOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("value"); + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getValueAttr(); + if(attr && (attr == ::mlir::ub::PoisonAttr::get(odsBuilder.getContext()))) + elidedAttrs.push_back("value"); + } + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + if (getValueAttr() && getValueAttr() != ::mlir::ub::PoisonAttr::get(::mlir::OpBuilder((*this)->getContext()).getContext())) { + _odsPrinter << "<"; + _odsPrinter.printStrippedAttrOrType(getValueAttr()); + _odsPrinter << ">"; + } + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void PoisonOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace ub +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::ub::PoisonOp) + + +#endif // GET_OP_CLASSES + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/UB/IR/UBOps.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/UB/IR/UBOps.h new file mode 100644 index 0000000000000000000000000000000000000000..21de5cb0c182adef9da9da1131517ad59166fe8b --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/UB/IR/UBOps.h @@ -0,0 +1,27 @@ +//===- UBOps.h - UB Dialect Operations ------------------------*--- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_UB_IR_OPS_H +#define MLIR_DIALECT_UB_IR_OPS_H + +#include "mlir/Bytecode/BytecodeOpInterface.h" +#include "mlir/IR/Dialect.h" +#include "mlir/IR/OpImplementation.h" +#include "mlir/Interfaces/SideEffectInterfaces.h" + +#include "mlir/Dialect/UB/IR/UBOpsInterfaces.h.inc" + +#define GET_ATTRDEF_CLASSES +#include "mlir/Dialect/UB/IR/UBOpsAttributes.h.inc" + +#define GET_OP_CLASSES +#include "mlir/Dialect/UB/IR/UBOps.h.inc" + +#include "mlir/Dialect/UB/IR/UBOpsDialect.h.inc" + +#endif // MLIR_DIALECT_UB_IR_OPS_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/UB/IR/UBOps.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/UB/IR/UBOps.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..11346f06969a0202303c635ba88157747d1372bf --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/UB/IR/UBOps.h.inc @@ -0,0 +1,185 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Op Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: UBOps.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#if defined(GET_OP_CLASSES) || defined(GET_OP_FWD_DEFINES) +#undef GET_OP_FWD_DEFINES +namespace mlir { +namespace ub { +class PoisonOp; +} // namespace ub +} // namespace mlir +#endif + +#ifdef GET_OP_CLASSES +#undef GET_OP_CLASSES + + +//===----------------------------------------------------------------------===// +// Local Utility Method Definitions +//===----------------------------------------------------------------------===// + +namespace mlir { +namespace ub { + +//===----------------------------------------------------------------------===// +// ::mlir::ub::PoisonOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class PoisonOpGenericAdaptorBase { +public: + struct Properties { + using valueTy = ::mlir::ub::PoisonAttrInterface; + valueTy value; + + auto getValue() { + auto &propStorage = this->value; + return ::llvm::dyn_cast_or_null<::mlir::ub::PoisonAttrInterface>(propStorage); + } + void setValue(const ::mlir::ub::PoisonAttrInterface &propValue) { + this->value = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.value == this->value && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + PoisonOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + PoisonOpGenericAdaptorBase(PoisonOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::ub::PoisonAttrInterface getValueAttr(); + ::mlir::ub::PoisonAttrInterface getValue(); +}; +} // namespace detail +template +class PoisonOpGenericAdaptor : public detail::PoisonOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::PoisonOpGenericAdaptorBase; +public: + PoisonOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + PoisonOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : PoisonOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + PoisonOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class PoisonOpAdaptor : public PoisonOpGenericAdaptor<::mlir::ValueRange> { +public: + using PoisonOpGenericAdaptor::PoisonOpGenericAdaptor; + PoisonOpAdaptor(PoisonOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class PoisonOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::ZeroOperands, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpTrait::ConstantLike, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = PoisonOpAdaptor; + template + using GenericAdaptor = PoisonOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("value")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getValueAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getValueAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("ub.poison"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getResult(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::ub::PoisonAttrInterface getValueAttr(); + ::mlir::ub::PoisonAttrInterface getValue(); + void setValueAttr(::mlir::ub::PoisonAttrInterface attr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ub::PoisonAttrInterface value); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ub::PoisonAttrInterface value); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void populateDefaultProperties(::mlir::OperationName opName, Properties &properties); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace ub +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::ub::PoisonOp) + + +#endif // GET_OP_CLASSES + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/UB/IR/UBOpsAttributes.cpp.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/UB/IR/UBOpsAttributes.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..427da0e301b1f9014178c48d986be3f5494f0a23 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/UB/IR/UBOpsAttributes.cpp.inc @@ -0,0 +1,74 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* AttrDef Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifdef GET_ATTRDEF_LIST +#undef GET_ATTRDEF_LIST + +::mlir::ub::PoisonAttr + +#endif // GET_ATTRDEF_LIST + +#ifdef GET_ATTRDEF_CLASSES +#undef GET_ATTRDEF_CLASSES + +static ::mlir::OptionalParseResult generatedAttributeParser(::mlir::AsmParser &parser, ::llvm::StringRef *mnemonic, ::mlir::Type type, ::mlir::Attribute &value) { + return ::mlir::AsmParser::KeywordSwitch<::mlir::OptionalParseResult>(parser) + .Case(::mlir::ub::PoisonAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::ub::PoisonAttr::get(parser.getContext()); + return ::mlir::success(!!value); + }) + .Default([&](llvm::StringRef keyword, llvm::SMLoc) { + *mnemonic = keyword; + return std::nullopt; + }); +} + +static ::mlir::LogicalResult generatedAttributePrinter(::mlir::Attribute def, ::mlir::AsmPrinter &printer) { + return ::llvm::TypeSwitch<::mlir::Attribute, ::mlir::LogicalResult>(def) .Case<::mlir::ub::PoisonAttr>([&](auto t) { + printer << ::mlir::ub::PoisonAttr::getMnemonic(); + return ::mlir::success(); + }) + .Default([](auto) { return ::mlir::failure(); }); +} + +namespace mlir { +namespace ub { +} // namespace ub +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::ub::PoisonAttr) +namespace mlir { +namespace ub { + +/// Parse an attribute registered to this dialect. +::mlir::Attribute UBDialect::parseAttribute(::mlir::DialectAsmParser &parser, + ::mlir::Type type) const { + ::llvm::SMLoc typeLoc = parser.getCurrentLocation(); + ::llvm::StringRef attrTag; + { + ::mlir::Attribute attr; + auto parseResult = generatedAttributeParser(parser, &attrTag, type, attr); + if (parseResult.has_value()) + return attr; + } + + parser.emitError(typeLoc) << "unknown attribute `" + << attrTag << "` in dialect `" << getNamespace() << "`"; + return {}; +} +/// Print an attribute registered to this dialect. +void UBDialect::printAttribute(::mlir::Attribute attr, + ::mlir::DialectAsmPrinter &printer) const { + if (::mlir::succeeded(generatedAttributePrinter(attr, printer))) + return; + +} +} // namespace ub +} // namespace mlir + +#endif // GET_ATTRDEF_CLASSES + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/UB/IR/UBOpsAttributes.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/UB/IR/UBOpsAttributes.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..298f162b4555ce7858651853e606f2e15b43e349 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/UB/IR/UBOpsAttributes.h.inc @@ -0,0 +1,33 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* AttrDef Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifdef GET_ATTRDEF_CLASSES +#undef GET_ATTRDEF_CLASSES + + +namespace mlir { +class AsmParser; +class AsmPrinter; +} // namespace mlir +namespace mlir { +namespace ub { +class PoisonAttr; +class PoisonAttr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"poison"}; + } + +}; +} // namespace ub +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::ub::PoisonAttr) + +#endif // GET_ATTRDEF_CLASSES + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/UB/IR/UBOpsDialect.cpp.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/UB/IR/UBOpsDialect.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..fdbb58cc6ca9a6e67ce062575be4199c15f4084f --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/UB/IR/UBOpsDialect.cpp.inc @@ -0,0 +1,23 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Dialect Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: UBOps.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::ub::UBDialect) +namespace mlir { +namespace ub { + +UBDialect::UBDialect(::mlir::MLIRContext *context) + : ::mlir::Dialect(getDialectNamespace(), context, ::mlir::TypeID::get()) { + + initialize(); +} + +UBDialect::~UBDialect() = default; + +} // namespace ub +} // namespace mlir diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/UB/IR/UBOpsDialect.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/UB/IR/UBOpsDialect.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..af36182a627c8faa4c91795b0ffb2d794c6ae664 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/UB/IR/UBOpsDialect.h.inc @@ -0,0 +1,41 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Dialect Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: UBOps.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace ub { + +class UBDialect : public ::mlir::Dialect { + explicit UBDialect(::mlir::MLIRContext *context); + + void initialize(); + friend class ::mlir::MLIRContext; +public: + ~UBDialect() override; + static constexpr ::llvm::StringLiteral getDialectNamespace() { + return ::llvm::StringLiteral("ub"); + } + + /// Parse an attribute registered to this dialect. + ::mlir::Attribute parseAttribute(::mlir::DialectAsmParser &parser, + ::mlir::Type type) const override; + + /// Print an attribute registered to this dialect. + void printAttribute(::mlir::Attribute attr, + ::mlir::DialectAsmPrinter &os) const override; + + /// Materialize a single constant operation from a given attribute value with + /// the desired resultant type. + ::mlir::Operation *materializeConstant(::mlir::OpBuilder &builder, + ::mlir::Attribute value, + ::mlir::Type type, + ::mlir::Location loc) override; +}; +} // namespace ub +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::ub::UBDialect) diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/UB/IR/UBOpsInterfaces.cpp.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/UB/IR/UBOpsInterfaces.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..a5fbc8cdb1d57b9573a84ae56e88cdffa91d464f --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/UB/IR/UBOpsInterfaces.cpp.inc @@ -0,0 +1,8 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Interface Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/UB/IR/UBOpsInterfaces.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/UB/IR/UBOpsInterfaces.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..012cfa1b487aebc7a8805b8ab9ff2bd071554c7c --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/UB/IR/UBOpsInterfaces.h.inc @@ -0,0 +1,56 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Interface Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace ub { +class PoisonAttrInterface; +namespace detail { +struct PoisonAttrInterfaceInterfaceTraits { + struct Concept { + /// The methods defined by the interface. + }; + template + class Model : public Concept { + public: + using Interface = ::mlir::ub::PoisonAttrInterface; + Model() : Concept{} {} + + }; + template + class FallbackModel : public Concept { + public: + using Interface = ::mlir::ub::PoisonAttrInterface; + FallbackModel() : Concept{} {} + + }; + template + class ExternalModel : public FallbackModel { + public: + using ConcreteEntity = ConcreteAttr; + }; +};template +struct PoisonAttrInterfaceTrait; + +} // namespace detail +class PoisonAttrInterface : public ::mlir::AttributeInterface { +public: + using ::mlir::AttributeInterface::AttributeInterface; + template + struct Trait : public detail::PoisonAttrInterfaceTrait {}; +}; +namespace detail { + template + struct PoisonAttrInterfaceTrait : public ::mlir::AttributeInterface::Trait { + }; +}// namespace detail +} // namespace ub +} // namespace mlir +namespace mlir { +namespace ub { +} // namespace ub +} // namespace mlir diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Utils/DialectUtilsEnums.cpp.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Utils/DialectUtilsEnums.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..565df3ac1d38e9333290d56a2713feed7961a4d1 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Utils/DialectUtilsEnums.cpp.inc @@ -0,0 +1,36 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Enum Utility Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: StructuredOpsUtils.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace utils { +::llvm::StringRef stringifyIteratorType(IteratorType val) { + switch (val) { + case IteratorType::parallel: return "parallel"; + case IteratorType::reduction: return "reduction"; + } + return ""; +} + +::std::optional symbolizeIteratorType(::llvm::StringRef str) { + return ::llvm::StringSwitch<::std::optional>(str) + .Case("parallel", IteratorType::parallel) + .Case("reduction", IteratorType::reduction) + .Default(::std::nullopt); +} +::std::optional symbolizeIteratorType(uint32_t value) { + switch (value) { + case 0: return IteratorType::parallel; + case 1: return IteratorType::reduction; + default: return ::std::nullopt; + } +} + +} // namespace utils +} // namespace mlir + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Utils/DialectUtilsEnums.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Utils/DialectUtilsEnums.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..2aaa2090354e90baddc243b76103ed01633d5642 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Utils/DialectUtilsEnums.h.inc @@ -0,0 +1,90 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Enum Utility Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: StructuredOpsUtils.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace utils { +// Iterator type +enum class IteratorType : uint32_t { + parallel = 0, + reduction = 1, +}; + +::std::optional symbolizeIteratorType(uint32_t); +::llvm::StringRef stringifyIteratorType(IteratorType); +::std::optional symbolizeIteratorType(::llvm::StringRef); +inline constexpr unsigned getMaxEnumValForIteratorType() { + return 1; +} + + +inline ::llvm::StringRef stringifyEnum(IteratorType enumValue) { + return stringifyIteratorType(enumValue); +} + +template +::std::optional symbolizeEnum(::llvm::StringRef); + +template <> +inline ::std::optional symbolizeEnum(::llvm::StringRef str) { + return symbolizeIteratorType(str); +} +} // namespace utils +} // namespace mlir + +namespace mlir { +template +struct FieldParser; + +template<> +struct FieldParser<::mlir::utils::IteratorType, ::mlir::utils::IteratorType> { + template + static FailureOr<::mlir::utils::IteratorType> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return parser.emitError(loc, "expected keyword for Iterator type"); + + // Symbolize the keyword. + if (::std::optional<::mlir::utils::IteratorType> attr = ::mlir::utils::symbolizeEnum<::mlir::utils::IteratorType>(enumKeyword)) + return *attr; + return parser.emitError(loc, "invalid Iterator type specification: ") << enumKeyword; + } +}; +} // namespace mlir + +namespace llvm { +inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::utils::IteratorType value) { + auto valueStr = stringifyEnum(value); + return p << valueStr; +} +} // namespace llvm + +namespace llvm { +template<> struct DenseMapInfo<::mlir::utils::IteratorType> { + using StorageInfo = ::llvm::DenseMapInfo; + + static inline ::mlir::utils::IteratorType getEmptyKey() { + return static_cast<::mlir::utils::IteratorType>(StorageInfo::getEmptyKey()); + } + + static inline ::mlir::utils::IteratorType getTombstoneKey() { + return static_cast<::mlir::utils::IteratorType>(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const ::mlir::utils::IteratorType &val) { + return StorageInfo::getHashValue(static_cast(val)); + } + + static bool isEqual(const ::mlir::utils::IteratorType &lhs, const ::mlir::utils::IteratorType &rhs) { + return lhs == rhs; + } +}; +} + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Utils/IndexingUtils.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Utils/IndexingUtils.h new file mode 100644 index 0000000000000000000000000000000000000000..f51a8b28b7548ed178784d632317c67f3b61f1a9 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Utils/IndexingUtils.h @@ -0,0 +1,392 @@ +//===- IndexingUtils.h - Helpers related to index computations --*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This header file defines utilities and common canonicalization patterns for +// reshape operations. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_UTILS_INDEXINGUTILS_H +#define MLIR_DIALECT_UTILS_INDEXINGUTILS_H + +#include "mlir/IR/Builders.h" +#include "mlir/Support/LLVM.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/iterator.h" +#include +#include + +namespace mlir { +class ArrayAttr; + +//===----------------------------------------------------------------------===// +// Utils that operate on static integer values. +//===----------------------------------------------------------------------===// + +/// Given a set of sizes, return the suffix product. +/// +/// When applied to slicing, this is the calculation needed to derive the +/// strides (i.e. the number of linear indices to skip along the (k-1) most +/// minor dimensions to get the next k-slice). +/// +/// This is the basis to linearize an n-D offset confined to `[0 ... sizes]`. +/// +/// Assuming `sizes` is `[s0, .. sn]`, return the vector +/// `[s1 * ... * sn, s2 * ... * sn, ..., sn, 1]`. +/// +/// `sizes` elements are asserted to be non-negative. +/// +/// Return an empty vector if `sizes` is empty. +SmallVector computeSuffixProduct(ArrayRef sizes); +inline SmallVector computeStrides(ArrayRef sizes) { + return computeSuffixProduct(sizes); +} + +/// Return a vector containing llvm::zip_equal(v1, v2) multiplied elementwise. +/// +/// Return an empty vector if `v1` and `v2` are empty. +SmallVector computeElementwiseMul(ArrayRef v1, + ArrayRef v2); + +/// Self-explicit. +int64_t computeSum(ArrayRef basis); + +/// Self-explicit. +int64_t computeProduct(ArrayRef basis); + +/// Return the number of elements of basis (i.e. the max linear index). +/// Return `0` if `basis` is empty. +/// +/// `basis` elements are asserted to be non-negative. +/// +/// Return `0` if `basis` is empty. +inline int64_t computeMaxLinearIndex(ArrayRef basis) { + return computeProduct(basis); +} + +/// Return the linearized index of 'offsets' w.r.t. 'basis'. +/// +/// `basis` elements are asserted to be non-negative. +int64_t linearize(ArrayRef offsets, ArrayRef basis); + +/// Given the strides together with a linear index in the dimension space, +/// return the vector-space offsets in each dimension for a de-linearized index. +/// `strides` elements are asserted to be non-negative. +/// +/// Let `li = linearIndex`, assuming `strides` are `[s0, .. sn]`, return the +/// vector of int64_t +/// `[li % s0, (li / s0) % s1, ..., (li / s0 / .. / sn-1) % sn]` +SmallVector delinearize(int64_t linearIndex, + ArrayRef strides); + +/// Return the multi-dimensional integral ratio of `subShape` to the trailing +/// dimensions of `shape`. This represents how many times `subShape` fits +/// within `shape`. If integral division is not possible, return std::nullopt. +/// The trailing `subShape.size()` entries of both shapes are assumed (and +/// enforced) to only contain non-negative values. +/// +/// Examples: +/// - shapeRatio({3, 5, 8}, {2, 5, 2}) returns {3, 2, 1}. +/// - shapeRatio({3, 8}, {2, 5, 2}) returns std::nullopt (subshape has +/// higher +/// rank). +/// - shapeRatio({42, 2, 10, 32}, {2, 5, 2}) returns {42, 1, 2, 16} which is +/// derived as {42(leading shape dim), 2/2, 10/5, 32/2}. +/// - shapeRatio({42, 2, 11, 32}, {2, 5, 2}) returns std::nullopt which is +/// derived as {42(leading shape dim), 2/2, 11/5(not divisible), 32/2}. +std::optional> +computeShapeRatio(ArrayRef shape, ArrayRef subShape); + +//===----------------------------------------------------------------------===// +// Utils that operate on AffineExpr. +//===----------------------------------------------------------------------===// + +/// Given a set of sizes, return the suffix product. +/// +/// When applied to slicing, this is the calculation needed to derive the +/// strides (i.e. the number of linear indices to skip along the (k-1) most +/// minor dimensions to get the next k-slice). +/// +/// This is the basis to linearize an n-D offset confined to `[0 ... sizes]`. +/// +/// Assuming `sizes` is `[s0, .. sn]`, return the vector +/// `[s1 * ... * sn, s2 * ... * sn, ..., sn, 1]`. +/// +/// It is the caller's responsibility to pass proper AffineExpr kind that +/// result in valid AffineExpr (i.e. cannot multiply 2 AffineDimExpr or divide +/// by an AffineDimExpr). +/// +/// `sizes` elements are expected to bind to non-negative values. +/// +/// Return an empty vector if `sizes` is empty. +SmallVector computeSuffixProduct(ArrayRef sizes); +inline SmallVector computeStrides(ArrayRef sizes) { + return computeSuffixProduct(sizes); +} + +/// Return a vector containing llvm::zip_equal(v1, v2) multiplied elementwise. +/// +/// It is the caller's responsibility to pass proper AffineExpr kind that +/// result in valid AffineExpr (i.e. cannot multiply 2 AffineDimExpr or divide +/// by an AffineDimExpr). +/// +/// Return an empty vector if `v1` and `v2` are empty. +SmallVector computeElementwiseMul(ArrayRef v1, + ArrayRef v2); + +/// Self-explicit. +AffineExpr computeSum(MLIRContext *ctx, ArrayRef basis); + +/// Self-explicit. +AffineExpr computeProduct(MLIRContext *ctx, ArrayRef basis); + +/// Return the number of elements of basis (i.e. the max linear index). +/// Return `0` if `basis` is empty. +/// +/// It is the caller's responsibility to pass proper AffineExpr kind that +/// result in valid AffineExpr (i.e. cannot multiply 2 AffineDimExpr or divide +/// by an AffineDimExpr). +/// +/// `basis` elements are expected to bind to non-negative values. +/// +/// Return the `0` AffineConstantExpr if `basis` is empty. +inline AffineExpr computeMaxLinearIndex(MLIRContext *ctx, + ArrayRef basis) { + return computeProduct(ctx, basis); +} + +/// Return the linearized index of 'offsets' w.r.t. 'basis'. +/// +/// Assuming `offsets` is `[o0, .. on]` and `basis` is `[b0, .. bn]`, return the +/// AffineExpr `o0 * b0 + .. + on * bn`. +/// +/// It is the caller's responsibility to pass proper AffineExpr kind that result +/// in valid AffineExpr (i.e. cannot multiply 2 AffineDimExpr or divide by an +/// AffineDimExpr). +/// +/// `basis` elements are expected to bind to non-negative values. +AffineExpr linearize(MLIRContext *ctx, ArrayRef offsets, + ArrayRef basis); +AffineExpr linearize(MLIRContext *ctx, ArrayRef offsets, + ArrayRef basis); + +/// Given the strides together with a linear index in the dimension space, +/// return the vector-space offsets in each dimension for a de-linearized index. +/// +/// Let `li = linearIndex`, assuming `strides` are `[s0, .. sn]`, return the +/// vector of AffineExpr +/// `[li % s0, (li / s0) % s1, ..., (li / s0 / .. / sn-1) % sn]` +/// +/// It is the caller's responsibility to pass proper AffineExpr kind that result +/// in valid AffineExpr (i.e. cannot multiply 2 AffineDimExpr or divide by an +/// AffineDimExpr). +/// +/// `strides` elements are expected to bind to non-negative values. +SmallVector delinearize(AffineExpr linearIndex, + ArrayRef strides); +SmallVector delinearize(AffineExpr linearIndex, + ArrayRef strides); + +//===----------------------------------------------------------------------===// +// Permutation utils. +//===----------------------------------------------------------------------===// + +template +SmallVector applyPermutation(ArrayRef input, + ArrayRef permutation) { + assert(input.size() == permutation.size() && + "expected input rank to equal permutation rank"); + auto permutationRange = llvm::map_range( + llvm::seq(0, input.size()), + [&](int64_t idx) -> T { return input[permutation[idx]]; }); + return llvm::to_vector(permutationRange); +} + +template +SmallVector applyPermutation(const SmallVectorImpl &input, + ArrayRef permutation) { + return applyPermutation(ArrayRef(input), permutation); +} + +/// Apply the permutation defined by `permutation` to `inVec`. +/// Element `i` in `inVec` is mapped to location `j = permutation[i]`. +/// E.g.: for an input vector `inVec = ['a', 'b', 'c']` and a permutation +/// vector `permutation = [2, 0, 1]`, this function leaves `inVec = ['c', 'a', +/// 'b']`. +template +void applyPermutationToVector(SmallVector &inVec, + ArrayRef permutation) { + inVec = applyPermutation(inVec, permutation); +} + +/// Helper method to apply to inverse a permutation. +SmallVector invertPermutationVector(ArrayRef permutation); + +/// Method to check if an interchange vector is a permutation. +bool isPermutationVector(ArrayRef interchange); + +/// Return a permutation vector of size permSize that would result in moving +/// positions into desiredPositions. +/// +/// For example, permSize == 5, positions = {2, 4}, desiredPositions = {1, 0} +/// would result in a {4, 2, 0, 1, 3} permutation vector. +SmallVector +computePermutationVector(int64_t permSize, ArrayRef positions, + ArrayRef desiredPositions); + +/// Helper to return a subset of `arrayAttr` as a vector of int64_t. +// TODO: Port everything relevant to DenseArrayAttr and drop this util. +SmallVector getI64SubArray(ArrayAttr arrayAttr, unsigned dropFront = 0, + unsigned dropBack = 0); + +/// Compute linear index from provided strides and indices, assuming strided +/// layout. +/// Returns AffineExpr and list of values to apply to it, e.g.: +/// +/// auto &&[expr, values] = computeLinearIndex(...); +/// offset = affine::makeComposedFoldedAffineApply(builder, loc, expr, values); +std::pair> +computeLinearIndex(OpFoldResult sourceOffset, ArrayRef strides, + ArrayRef indices); + +//===----------------------------------------------------------------------===// +// Utilities for decomposing larger shapes +//===----------------------------------------------------------------------===// + +namespace detail { +/// Encapsulates the set of parameters that are used to make tile offset +/// calculations in the TileOffsetRangeIterator. +class TileOffsetRangeImpl { +public: + TileOffsetRangeImpl(ArrayRef shape, ArrayRef tileShape, + ArrayRef loopOrder); + + int64_t getMaxLinearIndex() const { return maxLinearIndex; } + + SmallVector getStaticTileOffsets(int64_t linearIndex) const; + + SmallVector getDynamicTileOffsets(AffineExpr linearIndex) const; + + template + SmallVector getTileOffsets(T linearIndex) const { + if constexpr (std::is_same_v) + return getStaticTileOffsets(linearIndex); + else + return getDynamicTileOffsets(linearIndex); + } + +private: + /// The sub-shape that divides the larger outer shape (which is provided to + /// the constructor). + SmallVector tileShape; + /// The inverse permutation to the `loopOrder` permutation provided in the + /// constructor. + SmallVector inverseLoopOrder; + /// The strides for the basis 'div(shape, tileShape)' permuted by `loopOrder`. + SmallVector sliceStrides; + /// The maximum linear index in the iteration space given by basis 'div(shape, + /// tileShape)'. + int64_t maxLinearIndex; +}; + +/// The STL-style iterator implementation for StaticTileOffsetRange. +template +class TileOffsetRangeIterator + : public llvm::iterator_facade_base, + std::forward_iterator_tag, + SmallVector> { +public: + TileOffsetRangeIterator(const TileOffsetRangeImpl ¶ms, ElementType index) + : params(params), index(index) {} + + void operator++() { incrementIndex(1); } + TileOffsetRangeIterator operator++(int) { + const auto copy = *this; + ++*this; + return copy; + } + + bool operator==(const TileOffsetRangeIterator &other) const { + return index == other.index; + } + bool operator!=(const TileOffsetRangeIterator &other) const { + return index != other.index; + } + + SmallVector operator*() const { + return params.getTileOffsets(index); + } + void operator+=(int64_t offset) { incrementIndex(offset); } + +private: + void incrementIndex(int64_t offset) { index = index + offset; } + const TileOffsetRangeImpl params; + int64_t index; +}; +} // namespace detail + +/// A range-style iterator that allows for iterating over the offsets of all +/// potential tiles of size `tileShape` within the larger shape `shape`, using +/// an ordering specified by `loopOrder`. The `loopOrder` specifies the order of +/// unrolling by numbering the dimensions in order from "outer most for loop" +/// (slowest changing) to "inner most for loop" (fastest changing). +/// +/// For example, for `shape = {10, 20, 30}`, `tileShape = {5, 10, 15}`, and +/// `loopOrder={2, 0, 1}`, the iterating over this range will yield offsets: +/// +/// ``` +/// {0, 0, 0}, {0, 10, 0}, {5, 0, 0}, {5, 10, 0}, {0, 0, 15}, +/// {0, 10, 15}, {5, 0, 15}, {0, 10, 15}, {5, 10, 15} +/// ``` +/// +/// This is useful in contexts where a vector computation over a larger shape +/// needs to be unrolled to a set of operations on subsets of the original +/// operands, such as during the "vector unrolling" transformations. +/// +/// The size of `tileShape` must be less-than-or-equal-to the size of `shape`.a +/// If the rank of `tileShape` is smaller than `shape`, then `tileShape` +/// elements correspond to the trailing dimensions of `shape`, and the leading +/// dimensions are considered untiled and `tileShape` is effectively prepended +/// with the leading dims of `shape`. +class StaticTileOffsetRange { +public: + using IteratorTy = detail::TileOffsetRangeIterator; + using ParamsTy = detail::TileOffsetRangeImpl; + + StaticTileOffsetRange(ArrayRef shape, ArrayRef tileShape, + ArrayRef loopOrder) + : params(shape, tileShape, loopOrder), beginValue(params, 0), + pastEndValue(params, params.getMaxLinearIndex()) { + assert(shape.size() >= tileShape.size()); + assert(loopOrder.size() == shape.size()); + } + + /// Create the range with identity loop order. + StaticTileOffsetRange(ArrayRef shape, ArrayRef tileShape) + : params(shape, tileShape, + llvm::to_vector(llvm::seq(0, shape.size()))), + beginValue(params, 0), + pastEndValue(params, params.getMaxLinearIndex()) { + assert(shape.size() >= tileShape.size()); + } + + IteratorTy begin() const { return beginValue; } + IteratorTy end() const { return pastEndValue; } + + /// Returns the total number of tiles that fit in the larger shape. + size_t size() const { return params.getMaxLinearIndex(); } + +private: + const ParamsTy params; + IteratorTy beginValue; + IteratorTy pastEndValue; +}; +} // namespace mlir + +#endif // MLIR_DIALECT_UTILS_INDEXINGUTILS_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Utils/ReshapeOpsUtils.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Utils/ReshapeOpsUtils.h new file mode 100644 index 0000000000000000000000000000000000000000..61c929dee0f272ce6dd459b3856f4d34fb601b1e --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Utils/ReshapeOpsUtils.h @@ -0,0 +1,538 @@ +//===- ReshapeOpsUtils.h - Utilities used by reshape ops --*- C++ -*------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This header file defines utilities and common canonicalization patterns for +// reshape operations. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_UTILS_RESHAPEOPSUTILS_H +#define MLIR_DIALECT_UTILS_RESHAPEOPSUTILS_H + +#include "mlir/Dialect/Utils/StaticValueUtils.h" +#include "mlir/IR/OpImplementation.h" +#include "mlir/IR/PatternMatch.h" +#include "mlir/Support/LLVM.h" +#include "llvm/ADT/StringRef.h" +#include + +namespace mlir { + +using ReassociationIndices = SmallVector; +using ReassociationIndicesRef = ArrayRef; +using ReassociationExprs = SmallVector; + +/// Attribute name for the ArrayAttr which encodes reassociation indices. +constexpr StringRef getReassociationAttrName() { return "reassociation"; } + +/// Compose reassociation maps that are used in pair of reshape ops where one +/// is a producer and other is the consumer. Only valid to use this method when +/// both the producer and consumer are collapsing dimensions or both are +/// expanding dimensions. +/// +/// For example, +/// producerReassociation = [[0, 1], [2], [3, 4]] +/// consumerReassociation = [[0, 1], [2]] +/// +/// is folded into +/// +/// result = [[0, 1, 2], [3, 4]]. +std::optional> composeReassociationIndices( + ArrayRef producerReassociations, + ArrayRef consumerReassociations, + MLIRContext *context); + +/// Convert reassociation indices to affine expressions. +SmallVector, 2> convertReassociationIndicesToExprs( + MLIRContext *context, ArrayRef reassociationIndices); + +/// Constructs affine maps out of Array>. +SmallVector +getSymbolLessAffineMaps(ArrayRef reassociation); + +/// Wraps a list of reassociations in an ArrayAttr. +ArrayAttr +getReassociationIndicesAttribute(OpBuilder &b, + ArrayRef reassociation); + +/// Convert Array> to Array>. +SmallVector convertReassociationMapsToIndices( + OpBuilder &b, ArrayRef reassociationExprs); + +/// Return the reassociations maps to use to reshape given the source type and +/// the target type when possible. Return std::nullopt when this computation +/// failed. +std::optional> +getReassociationIndicesForReshape(ShapedType sourceType, ShapedType targetType); + +/// Returns the reassociation maps to collapse `sourceShape` to `targetShape` if +/// possible. +std::optional> +getReassociationIndicesForCollapse(ArrayRef sourceShape, + ArrayRef targetShape); + +/// Return true if the reassociation specification is valid, false otherwise. +/// When false, the `invalidIndex` integer pointer is optionally filled with the +/// index of the offending reassociation map. +bool isReassociationValid(ArrayRef reassociation, + int *invalidIndex = nullptr); + +template +static OpFoldResult foldReshapeOp(ReshapeOpTy reshapeOp, + ArrayRef operands) { + // Fold producer-consumer reshape ops that where the operand type of the + // producer is same as the return type of the consumer. + auto reshapeSrcOp = + reshapeOp.getSrc().template getDefiningOp(); + if (reshapeSrcOp && reshapeSrcOp.getSrcType() == reshapeOp.getResultType()) + return reshapeSrcOp.getSrc(); + // Reshape of a constant can be replaced with a new constant. + if (auto elements = dyn_cast_or_null(operands.front())) { + return elements.reshape(cast(reshapeOp.getResult().getType())); + } + return nullptr; +} + +/// Common verifier for reshape-like types. Fills `expandedType` and +///`collapsedType` with the proper `src` or `result` type. +template +static LogicalResult verifyReshapeLikeTypes(Op op, T expandedType, + T collapsedType, bool isExpansion) { + unsigned expandedRank = expandedType.getRank(); + unsigned collapsedRank = collapsedType.getRank(); + if (expandedRank < collapsedRank) + return op.emitOpError("expected the type ") + << expandedType + << " to have higher rank than the type = " << collapsedType; + if (expandedRank == 0) + return op.emitOpError("expected non-zero memref ranks"); + if (expandedRank == collapsedRank) + return op.emitOpError("expected to collapse or expand dims"); + + if (collapsedRank == 0) { + // If collapsed rank is 0, then expanded type must be static shaped and of + // sizes 1. + if (llvm::any_of(expandedType.getShape(), + [](int64_t dim) -> bool { return dim != 1; })) + return op.emitOpError("invalid to reshape tensor/memref with non-unit " + "extent dimensions to zero-rank tensor/memref"); + return success(); + } + if (collapsedRank != op.getReassociation().size()) + return op.emitOpError("expected rank of the collapsed type(") + << collapsedRank << ") to be the number of reassociation maps(" + << op.getReassociation().size() << ")"; + auto maps = op.getReassociationMaps(); + for (auto it : llvm::enumerate(maps)) + if (it.value().getNumDims() != expandedRank) + return op.emitOpError("expected reassociation map #") + << it.index() << " of same rank as expanded memref(" + << expandedRank << "), but got " << it.value().getNumDims(); + int invalidIdx = 0; + if (!isReassociationValid(maps, &invalidIdx)) + return op.emitOpError("expected reassociation map #") + << invalidIdx << " to be valid and contiguous"; + return verifyReshapeLikeShapes(op, collapsedType, expandedType, isExpansion); +} + +/// Verify that shapes of the reshaped types using following rules +/// 1) if a dimension in the collapsed type is static, then the corresponding +/// dimensions in the expanded shape should be +/// a) static +/// b) the product should be same as the collaped shape. +/// 2) if a dimension in the collaped type is dynamic, one and only one of the +/// corresponding dimensions in the expanded type should be dynamic. This +/// rule is only needed with reshape operations that are expanding. +LogicalResult reshapeLikeShapesAreCompatible( + function_ref emitError, + ArrayRef collapsedShape, ArrayRef expandedShape, + ArrayRef reassociationMaps, bool isExpandingReshape); + +template +static LogicalResult verifyReshapeLikeShapes(OpTy op, ShapedType collapsedType, + ShapedType expandedType, + bool isExpandingReshape) { + return reshapeLikeShapesAreCompatible( + [&](const Twine &msg) { return op->emitOpError(msg); }, + collapsedType.getShape(), expandedType.getShape(), + op.getReassociationIndices(), isExpandingReshape); +} + +/// Returns true iff the type is a MemRefType and has a non-identity layout. +bool hasNonIdentityLayout(Type type); + +/// Pattern to collapse producer/consumer reshape ops that are both collapsing +/// dimensions or are both expanding dimensions. +template +struct ComposeReassociativeReshapeOps : public OpRewritePattern { + using OpRewritePattern::OpRewritePattern; + LogicalResult matchAndRewrite(ReshapeOpTy reshapeOp, + PatternRewriter &rewriter) const override { + auto srcReshapeOp = + reshapeOp.getSrc().template getDefiningOp(); + if (!srcReshapeOp) + return failure(); + + ShapedType resultType = reshapeOp.getResultType(); + + if (hasNonIdentityLayout(srcReshapeOp.getSrc().getType()) || + hasNonIdentityLayout(reshapeOp.getSrc().getType()) || + hasNonIdentityLayout(reshapeOp.getResult().getType())) + return failure(); + + std::optional> reassociationIndices = + composeReassociationIndices(srcReshapeOp.getReassociationIndices(), + reshapeOp.getReassociationIndices(), + rewriter.getContext()); + if (!reassociationIndices) + return failure(); + rewriter.replaceOpWithNewOp( + reshapeOp, resultType, srcReshapeOp.getSrc(), *reassociationIndices); + return success(); + } +}; + +/// Pattern to compose +/// `collapse_shape(expand_shape(%src, reassociation_1), reassociation_2)`. +/// In that case both `srcType` and `resultType` can be expressed as a function +/// of `intermediateType`. +/// In order to demonstrate the approach, let's assume that `rank(srcType) > +/// `rank(resultType)`, i.e. the resulting operation should be `collapse_shape`. +/// In that case, we can iterate over every set of indices in `reassociation_2` +/// and try to find ids of sets of indices in `reassociation_1` that cover it +/// completely. +/// +/// Example: +/// +/// %0 = tensor.expand_shape %arg [[0], [1], [2, 3]] +/// : tensor into tensor +/// %1 = tensor.collapse_shape %0 [[0, 1], [2, 3]] +/// : tensor into tensor +/// +/// can be canonicalized into +/// +/// %0 = tensor.collapse_shape %arg [[0, 1], [2]] +/// : tensor into tensor +/// +/// because [0] and [1] from `expand_shape` reassociation cover completely +/// `[0, 1]` from `collapse_shape`. If it is impossible to find such union of +/// indices, then we fail. +// +/// When `rank(srcType) < rank(resultType)`, then we just swap `reassociation_1` +/// `reassociation_2` and produce `expand_shape`. +template +struct ComposeCollapseOfExpandOp : public OpRewritePattern { + using OpRewritePattern::OpRewritePattern; + LogicalResult matchAndRewrite(CollapseOpTy collapseOp, + PatternRewriter &rewriter) const override { + auto expandOp = collapseOp.getSrc().template getDefiningOp(); + if (!expandOp) + return failure(); + + ShapedType srcType = expandOp.getSrcType(); + ShapedType resultType = collapseOp.getResultType(); + + if (hasNonIdentityLayout(collapseOp.getSrc().getType()) || + hasNonIdentityLayout(expandOp.getSrc().getType()) || + hasNonIdentityLayout(expandOp.getResult().getType())) + return failure(); + + int64_t srcRank = srcType.getRank(); + int64_t resultRank = resultType.getRank(); + if (srcType == resultType) + return failure(); + + SmallVector higherRankReassociation, + lowerRankReassociation; + + if (srcRank > resultRank) { + higherRankReassociation = expandOp.getReassociationIndices(); + lowerRankReassociation = collapseOp.getReassociationIndices(); + } else { + higherRankReassociation = collapseOp.getReassociationIndices(); + lowerRankReassociation = expandOp.getReassociationIndices(); + } + + size_t higherRankIndicesID = 0; + SmallVector composedReassociation; + for (const auto &lowerRankIndices : lowerRankReassociation) { + ReassociationIndices composedIndices; + while (higherRankIndicesID < higherRankReassociation.size()) { + auto rightmostIndex = + higherRankReassociation[higherRankIndicesID].back(); + if (rightmostIndex > lowerRankIndices.back()) + return failure(); + composedIndices.push_back(higherRankIndicesID++); + if (rightmostIndex == lowerRankIndices.back()) + break; + } + composedReassociation.push_back(composedIndices); + } + if (srcRank > resultRank) { + rewriter.replaceOpWithNewOp( + collapseOp, resultType, expandOp.getSrc(), composedReassociation); + } else if (srcRank < resultRank) { + rewriter.replaceOpWithNewOp( + collapseOp, resultType, expandOp.getSrc(), composedReassociation); + } else { + // Collapses/expansions that do not change the rank are not allowed. Use + // a cast instead. + assert(llvm::equal(srcType.getShape(), resultType.getShape()) && + "expected same shape"); + rewriter.replaceOpWithNewOp(collapseOp, resultType, + expandOp.getSrc()); + } + return success(); + } +}; + +template +struct ComposeExpandOfCollapseOp : public OpRewritePattern { + using OpRewritePattern::OpRewritePattern; + LogicalResult matchAndRewrite(ExpandOpTy expandOp, + PatternRewriter &rewriter) const override { + auto collapseOp = expandOp.getSrc().template getDefiningOp(); + if (!collapseOp) + return failure(); + + ShapedType srcType = collapseOp.getSrcType(); + ShapedType resultType = expandOp.getResultType(); + + if (hasNonIdentityLayout(expandOp.getSrc().getType()) || + hasNonIdentityLayout(collapseOp.getSrc().getType()) || + hasNonIdentityLayout(collapseOp.getResult().getType())) + return failure(); + + int64_t srcRank = srcType.getRank(); + int64_t resultRank = resultType.getRank(); + if (srcType == resultType) + return failure(); + + auto srcReassociation = collapseOp.getReassociationIndices(); + auto resultReassociation = expandOp.getReassociationIndices(); + if (srcRank > resultRank) { + auto composedReassociation = findCollapsingReassociation( + srcReassociation, resultReassociation, srcType.getShape(), + resultType.getShape()); + if (!composedReassociation) + return failure(); + + rewriter.replaceOpWithNewOp( + expandOp, resultType, collapseOp.getSrc(), *composedReassociation); + return success(); + } + auto composedReassociation = + findCollapsingReassociation(resultReassociation, srcReassociation, + resultType.getShape(), srcType.getShape()); + if (!composedReassociation) + return failure(); + + rewriter.replaceOpWithNewOp( + expandOp, resultType, collapseOp.getSrc(), *composedReassociation); + return success(); + } + +private: + // Attempts to find a way to collapse `srcShape` to `resultShape` by + // collapsing subshapes defined by the reassociation indices. + std::optional> findCollapsingReassociation( + ArrayRef srcReassociation, + ArrayRef resultReassociation, + ArrayRef srcShape, ArrayRef resultShape) const { + SmallVector composedReassociation; + + if (srcReassociation.empty()) + return {getReassociationIndicesForCollapse(srcShape, resultShape)}; + + for (auto item : llvm::zip(srcReassociation, resultReassociation)) { + auto &srcIndices = std::get<0>(item); + auto &resultIndices = std::get<1>(item); + auto srcSubShape = srcShape.slice(srcIndices.front(), srcIndices.size()); + auto resultSubShape = + resultShape.slice(resultIndices.front(), resultIndices.size()); + + if (srcSubShape.size() == resultSubShape.size()) { + if (srcSubShape == resultSubShape) + composedReassociation.push_back(srcIndices); + else + return std::nullopt; + } + + // Find reassociation to collapse `srcSubShape` into `resultSubShape`. + auto subShapeReassociation = + getReassociationIndicesForCollapse(srcSubShape, resultSubShape); + if (!subShapeReassociation) + return std::nullopt; + + // Remap the subshape indices back to the original srcShape. + for (auto &subshape_indices : *subShapeReassociation) { + ReassociationIndices shape_indices; + for (int64_t index : subshape_indices) + shape_indices.push_back(srcIndices.front() + index); + composedReassociation.push_back(shape_indices); + } + } + return {std::move(composedReassociation)}; + } +}; + +/// The input parameters `offsets`, `sizes`, `strides` specify a rectangular +/// non rank-reducing slice of the collapse_shape output. Try to find which +/// dimensions have been sliced and which dimensions are not sliced (offset = 0, +/// size = dim, size = 1). Note that this conservative as it cannot detect if a +/// dynamic size corresponds to the full tensor dimension or not. +llvm::SmallBitVector getSlicedDimensions(ArrayRef sliceInputShape, + ArrayRef sliceParams); + +/// Determine which dimensions are linearized by a `tensor.collapse_shape` op by +/// inspecting its reassociation indices. +llvm::SmallBitVector +getLinearizedDimensions(ArrayRef reassociationIndices); + +/// Given the parameters for both operations in a `CollapseShape->ExtractSlice` +/// chain and reified source and result shapes of the CollapseShapeOp, this +/// class provides two functions that assist with directly forming the result +/// of the extract slice by "tiling the CollapseShapeOp by 1". +//// Example: +// clang-format off +/// ``` +/// %0 = linalg.generic ... -> tensor<3x7x11x10xf32> +/// %1 = tensor.collapse_shape %0 [[0, 1, 2], [3]] : ... to tensor<341x10xf32> +/// %2 = tensor.extract_slice %1 [13, 0] [10, 10] [2, 1] : .... tensor<10x10xf32> +/// ``` +/// This class helps build the below IR to replace %2: +/// ``` +/// %dest = tensor.empty() : tensor<10x10xf32> +/// %2 = scf.for %iv = %c0 to %c10 step %c1 iter_args(%arg0) -> tensor<10x10xf32> { +/// %linear_index = affine.apply affine_map<(d0)[]->(d0*2 + 11)>(%iv) +/// %3:3 = arith.delinearize_index %iv into (3, 7, 11) +/// +/// // This function takes %3 (multiIndices) and the parameters for the slice below. +/// %4 = tensor.extract_slice %0 [%3#0, %3#1, %3#2, 0] [1, 1, 1, 10] [1, 1, 1, 1] : +/// tensor<3x7x11x10xf32> to tensor<1x1x1x10xf32> +/// +/// %5 = tensor.collapse_shape %4 [[0, 1, 2], [3]] : +/// tensor<1x1x1x10xf32> into tensor<1x10xf32> +/// %6 = tensor.insert_slice %5 into %arg0 [%iv, 0] [1, 10] [1, 1] : +/// tensor<1x10xf32> into tensor<10x10xf32> +/// scf.yield %6 : tensor<10x10xf32> +/// } +/// ``` +// clang-format on +class SliceFromCollapseHelper { +public: + SliceFromCollapseHelper(ArrayRef reassociationIndices, + ArrayRef collapseShapeInputShape, + ArrayRef collapseShapeOutputShape, + ArrayRef extractSliceParams) + : reassociationIndices(reassociationIndices), + collapseShapeInputShape(collapseShapeInputShape), + collapseShapeOutputShape(collapseShapeOutputShape), + sliceParams(extractSliceParams), + linearizedDimensions(getLinearizedDimensions(reassociationIndices)), + slicedDimensions(getSlicedDimensions(collapseShapeOutputShape, + extractSliceParams)) {} + + /// This function takes multi-indices and maps them to ExtractSlice parameters + /// in the index space of the CollapseShape's source tensor. This function's + /// signature can be described by `(D_0, D_1,.. D_{n-1}) -> (offsets, sizes, + /// strides)` where `n` the number of "tiled dimensions", which are the + /// dimensions of the output that are linearized by the collapse shape op and + /// are also sliced. Each `D_i` is a tuple that must represent a valid + /// multi-index for the `i-th` tiled dimension. In the example above, there is + /// only one tiled dimension (D_0) and `arith.delinearize_index` produces the + /// multi-index (%3) that would be passed to this function to generate the + /// parameters for the `tensor.extract_slice` op (%4). + SmallVector getExtractSliceParams(MLIRContext *ctx, + ArrayRef multiIndices); + + /// This function takes indices in the index space of the "tiled dimensions" + /// described above and returns a set of Range variables that describe how the + /// slice should be inserted into the destination. In the example above, `%iv` + /// would be passed to this function to generate the parameters for the + /// `tensor.insert_slice` op producing %6. + SmallVector getInsertSliceParams(MLIRContext *ctx, + ValueRange tileIndices); + +private: + SmallVector reassociationIndices; + SmallVector collapseShapeInputShape; + SmallVector collapseShapeOutputShape; + SmallVector sliceParams; + llvm::SmallBitVector linearizedDimensions; + llvm::SmallBitVector slicedDimensions; +}; + +/// Parameters required to simplify a collapsing reshape op with a rank-reducing +/// slice operation. See `getSimplifyCollapseShapeWithRankReducingSliceInfo`. +struct CollapseShapeRankReducingSliceSimplificationInfo { + /// The shape of the output of the rank-reducing slice. + RankedTensorType sliceResultType; + /// The reassociation indices for the new collapse shape op, if required. If + /// `std::nullopt`, the slice should replace the collapse shape op. + std::optional> newReassociationIndices; +}; + +/// A collapsing reshape operation can sometimes be simplified or eliminated by +/// inserting a single rank-reducing slice operation between it and the source +/// tensor. The slice op will either take the place of the source, allowing for +/// a new, simpler reshape op to replace the original, or the reshape op will be +/// completely replaced by the slice result. +/// +/// This function returns the parameters required to implement this pattern. If +/// the pattern is not applicable, then failure is returned. +/// +/// ### Example: +/// ``` +/// %result = tensor.collapse_shape %0 [[0, 1], [2, 3]] +/// : tensor to tensor +/// ``` +/// can be transformed to +/// ``` +/// %tmp = tensor.extract_slice %0 [0, 0, 0, 0] +/// [0, %dim1, 30, 30] +/// [1, 1, 1 1] +/// : tensor to tensor +/// %result = tensor.collapse_shape %tmp [[0], [1, 2]] +/// : tensor to tensor +/// ``` +/// +/// ### Example: +/// ``` +/// %result = tensor.collapse_shape %1 [[0, 1], [2]] +/// : tensor to tensor +/// ``` +/// can be transformed to +/// ``` +/// %result = tensor.extract_slice %1 [0, 0, 0] +/// [%dim2, 1, 30] +/// [1, 1, 1] +/// : tensor to tensor +/// ``` +FailureOr +getSimplifyCollapseShapeWithRankReducingSliceInfo( + RankedTensorType sourceType, + ArrayRef reassociationIndices); + +struct PackingMetadata { + SmallVector insertPositions; + SmallVector outerPositions; + SmallVector reassociations; +}; + +/// Given a vector of `positions` indices representing desired packing insertion +/// points into a target vector (i.e. pack/unpack.inner_dim_pos), compute the +/// final positions in the target shape as well as the reshape reassociations. +// Note: This should not be called with a large positions array (or the +// implementation needs to be updated to use an N.log N sort instead of +// repeated N^2 counts). +PackingMetadata computePackingMetadata(int64_t packedRank, + ArrayRef innerDimPos); +} // namespace mlir + +#endif // MLIR_DIALECT_UTILS_RESHAPEOPSUTILS_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Utils/StaticValueUtils.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Utils/StaticValueUtils.h new file mode 100644 index 0000000000000000000000000000000000000000..23a366036b9dd6f17bb8b5f647e69e11657767ad --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Utils/StaticValueUtils.h @@ -0,0 +1,154 @@ +//===- StaticValueUtils.h - Utilities for static values ---------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This header file defines utilities for dealing with static values, e.g., +// converting back and forth between Value and OpFoldResult. Such functionality +// is used in multiple dialects. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_UTILS_STATICVALUEUTILS_H +#define MLIR_DIALECT_UTILS_STATICVALUEUTILS_H + +#include "mlir/IR/BuiltinAttributes.h" +#include "mlir/IR/OpDefinition.h" +#include "mlir/Support/LLVM.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/SmallVectorExtras.h" + +namespace mlir { + +/// Return true if `v` is an IntegerAttr with value `0` of a ConstantIndexOp +/// with attribute with value `0`. +bool isZeroIndex(OpFoldResult v); + +/// Represents a range (offset, size, and stride) where each element of the +/// triple may be dynamic or static. +struct Range { + OpFoldResult offset; + OpFoldResult size; + OpFoldResult stride; +}; + +/// Given an array of Range values, return a tuple of (offset vector, sizes +/// vector, and strides vector) formed by separating out the individual +/// elements of each range. +std::tuple, SmallVector, + SmallVector> +getOffsetsSizesAndStrides(ArrayRef ranges); + +/// Helper function to dispatch an OpFoldResult into `staticVec` if: +/// a) it is an IntegerAttr +/// In other cases, the OpFoldResult is dispached to the `dynamicVec`. +/// In such dynamic cases, ShapedType::kDynamic is also pushed to +/// `staticVec`. This is useful to extract mixed static and dynamic entries +/// that come from an AttrSizedOperandSegments trait. +void dispatchIndexOpFoldResult(OpFoldResult ofr, + SmallVectorImpl &dynamicVec, + SmallVectorImpl &staticVec); + +/// Helper function to dispatch multiple OpFoldResults according to the +/// behavior of `dispatchIndexOpFoldResult(OpFoldResult ofr` for a single +/// OpFoldResult. +void dispatchIndexOpFoldResults(ArrayRef ofrs, + SmallVectorImpl &dynamicVec, + SmallVectorImpl &staticVec); + +/// Extract integer values from the assumed ArrayAttr of IntegerAttr. +template +SmallVector extractFromIntegerArrayAttr(Attribute attr) { + return llvm::to_vector( + llvm::map_range(cast(attr), [](Attribute a) -> IntTy { + return cast(a).getInt(); + })); +} + +/// Given a value, try to extract a constant Attribute. If this fails, return +/// the original value. +OpFoldResult getAsOpFoldResult(Value val); +/// Given an array of values, try to extract a constant Attribute from each +/// value. If this fails, return the original value. +SmallVector getAsOpFoldResult(ValueRange values); +/// Convert `arrayAttr` to a vector of OpFoldResult. +SmallVector getAsOpFoldResult(ArrayAttr arrayAttr); + +/// Convert int64_t to integer attributes of index type and return them as +/// OpFoldResult. +OpFoldResult getAsIndexOpFoldResult(MLIRContext *ctx, int64_t val); +SmallVector getAsIndexOpFoldResult(MLIRContext *ctx, + ArrayRef values); + +/// If ofr is a constant integer or an IntegerAttr, return the integer. +std::optional getConstantIntValue(OpFoldResult ofr); +/// If all ofrs are constant integers or IntegerAttrs, return the integers. +std::optional> +getConstantIntValues(ArrayRef ofrs); + +/// Return true if `ofr` is constant integer equal to `value`. +bool isConstantIntValue(OpFoldResult ofr, int64_t value); + +/// Return true if ofr1 and ofr2 are the same integer constant attribute +/// values or the same SSA value. Ignore integer bitwitdh and type mismatch +/// that come from the fact there is no IndexAttr and that IndexType have no +/// bitwidth. +bool isEqualConstantIntOrValue(OpFoldResult ofr1, OpFoldResult ofr2); +bool isEqualConstantIntOrValueArray(ArrayRef ofrs1, + ArrayRef ofrs2); + +// To convert an OpFoldResult to a Value of index type, see: +// mlir/include/mlir/Dialect/Arith/Utils/Utils.h +// TODO: find a better common landing place. +// +// Value getValueOrCreateConstantIndexOp(OpBuilder &b, Location loc, +// OpFoldResult ofr); + +// To convert an OpFoldResult to a Value of index type, see: +// mlir/include/mlir/Dialect/Arith/Utils/Utils.h +// TODO: find a better common landing place. +// +// SmallVector +// getValueOrCreateConstantIndexOp(OpBuilder &b, Location loc, +// ArrayRef valueOrAttrVec); + +/// Return a vector of OpFoldResults with the same size a staticValues, but +/// all elements for which ShapedType::isDynamic is true, will be replaced by +/// dynamicValues. +SmallVector getMixedValues(ArrayRef staticValues, + ValueRange dynamicValues, Builder &b); + +/// Decompose a vector of mixed static or dynamic values into the +/// corresponding pair of arrays. This is the inverse function of +/// `getMixedValues`. +std::pair> +decomposeMixedValues(Builder &b, + const SmallVectorImpl &mixedValues); + +/// Helper to sort `values` according to matching `keys`. +SmallVector +getValuesSortedByKey(ArrayRef keys, ArrayRef values, + llvm::function_ref compare); +SmallVector +getValuesSortedByKey(ArrayRef keys, ArrayRef values, + llvm::function_ref compare); +SmallVector +getValuesSortedByKey(ArrayRef keys, ArrayRef values, + llvm::function_ref compare); + +/// Returns "success" when any of the elements in `ofrs` is a constant value. In +/// that case the value is replaced by an attribute. Returns "failure" when no +/// folding happened. +LogicalResult foldDynamicIndexList(SmallVectorImpl &ofrs); + +/// Return the number of iterations for a loop with a lower bound `lb`, upper +/// bound `ub` and step `step`. +std::optional constantTripCount(OpFoldResult lb, OpFoldResult ub, + OpFoldResult step); + +} // namespace mlir + +#endif // MLIR_DIALECT_UTILS_STATICVALUEUTILS_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Utils/StructuredOpsUtils.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Utils/StructuredOpsUtils.h new file mode 100644 index 0000000000000000000000000000000000000000..dab24bd930326927590cab0ca8f133913d3fc634 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Utils/StructuredOpsUtils.h @@ -0,0 +1,137 @@ +//===- StructuredOpsUtils.h - Utilities used by structured ops --*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This header file define utilities that operate on builtin types and are +// useful across multiple dialects that use structured ops abstractions. These +// abstractions consist of define custom operations that encode and transport +// information about their semantics (e.g. type of iterators like parallel, +// reduction, etc..) as attributes. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_UTILS_STRUCTUREDOPSUTILS_H +#define MLIR_DIALECT_UTILS_STRUCTUREDOPSUTILS_H + +#include "mlir/IR/AffineMap.h" +#include "mlir/IR/BuiltinAttributes.h" +#include "mlir/IR/Location.h" +#include "mlir/IR/TypeRange.h" +#include "mlir/Support/LLVM.h" + +// Pull in all enum type definitions and utility function declarations. +#include "mlir/Dialect/Utils/DialectUtilsEnums.h.inc" + +namespace mlir { + +class OpBuilder; +class RewriterBase; + +/// Tests whether the given maps describe a row major matmul. The test is +/// permutation-invariant. Note that this only checks the affine maps from an +/// operation, so does not perform any checks on the math being performed within +/// the reduction. +bool isRowMajorMatmul(ArrayAttr indexingMaps); + +/// Tests whether the given maps describe a column major matmul. The test is +/// permutation-invariant. Note that this only checks the affine maps from an +/// operation, so does not perform any checks on the math being performed within +/// the reduction. +bool isColumnMajorMatmul(ArrayAttr indexingMaps); + +/// Tests whether the given maps describe a row major batch matmul. The test is +/// permutation-invariant. Note that this only checks the affine maps from an +/// operation, so does not perform any checks on the math being performed within +/// the reduction. +bool isRowMajorBatchMatmul(ArrayAttr indexingMaps); + +/// Return positions in `iteratorTypes` that match `iteratorTypeName`. +inline void findPositionsOfType(ArrayRef iteratorTypes, + utils::IteratorType iteratorTypeName, + SmallVectorImpl &res) { + for (const auto &en : llvm::enumerate(iteratorTypes)) { + if (en.value() == iteratorTypeName) + res.push_back(en.index()); + } +} + +/// Helper StructuredGenerator class to manipulate and rewrite ops with +/// `StructuredOpInterface`. This is templated for now because VectorOps do not +/// yet implement the StructuredOpInterface itself. +template +class StructuredGenerator { +public: + using MapList = ArrayRef>; + + struct IteratorType { + IteratorType(IteratorTypeT iter) : iter(iter) {} + bool isOfType(IteratorTypeT expectedIter) const { + return expectedIter == iter; + } + IteratorTypeT iter; + }; + struct Par : public IteratorType { + Par() : IteratorType(IteratorTypeT::parallel) {} + }; + struct Red : public IteratorType { + Red() : IteratorType(IteratorTypeT::reduction) {} + }; + + StructuredGenerator(RewriterBase &rewriter, StructuredOpInterface op) + : rewriter(rewriter), ctx(op.getContext()), loc(op.getLoc()), + iterators(op.getIteratorTypesArray()), maps(op.getIndexingMapsArray()), + op(op) {} + + bool iters(ArrayRef its) { + if (its.size() != iterators.size()) + return false; + for (int i = 0, e = its.size(); i != e; ++i) { + if (!its[i].isOfType(iterators[i])) + return false; + } + return true; + } + + bool layout(MapList l) { + auto infer = [](MapList m) { return AffineMap::inferFromExprList(m); }; + return maps == infer(l); + } + +protected: + RewriterBase &rewriter; + MLIRContext *ctx; + Location loc; + SmallVector iterators; + SmallVector maps; + Operation *op; +}; + +// Clone the current operation with the operands. This is used to abstract away +// the optional underlying region creation. +// Note: this is a true builder that notifies the OpBuilder listener. +Operation *clone(OpBuilder &b, Operation *op, TypeRange newResultTypes, + ValueRange newOperands); +template +OpT clone(OpBuilder &b, OpT op, TypeRange newResultTypes, + ValueRange newOperands) { + return cast(clone(b, op.getOperation(), newResultTypes, newOperands)); +} + +// Clone the current operation with the operands but leave the regions empty. +// Note: this is a true builder that notifies the OpBuilder listener. +Operation *cloneWithoutRegions(OpBuilder &b, Operation *op, + TypeRange newResultTypes, + ValueRange newOperands); + +// Get the list of attributes associated with the op, ignoring +// those with the provided name. +SmallVector +getPrunedAttributeList(Operation *op, ArrayRef elidedAttrs); + +} // namespace mlir + +#endif // MLIR_DIALECT_UTILS_STRUCTUREDOPSUTILS_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/IR/VectorAttributes.cpp.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/IR/VectorAttributes.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..9b9ad3b01aa879a296e4882e53428b959103812d --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/IR/VectorAttributes.cpp.inc @@ -0,0 +1,320 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* AttrDef Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifdef GET_ATTRDEF_LIST +#undef GET_ATTRDEF_LIST + +::mlir::vector::CombiningKindAttr, +::mlir::vector::IteratorTypeAttr, +::mlir::vector::PrintPunctuationAttr + +#endif // GET_ATTRDEF_LIST + +#ifdef GET_ATTRDEF_CLASSES +#undef GET_ATTRDEF_CLASSES + +static ::mlir::OptionalParseResult generatedAttributeParser(::mlir::AsmParser &parser, ::llvm::StringRef *mnemonic, ::mlir::Type type, ::mlir::Attribute &value) { + return ::mlir::AsmParser::KeywordSwitch<::mlir::OptionalParseResult>(parser) + .Case(::mlir::vector::CombiningKindAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vector::CombiningKindAttr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::vector::IteratorTypeAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vector::IteratorTypeAttr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Case(::mlir::vector::PrintPunctuationAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) { + value = ::mlir::vector::PrintPunctuationAttr::parse(parser, type); + return ::mlir::success(!!value); + }) + .Default([&](llvm::StringRef keyword, llvm::SMLoc) { + *mnemonic = keyword; + return std::nullopt; + }); +} + +static ::mlir::LogicalResult generatedAttributePrinter(::mlir::Attribute def, ::mlir::AsmPrinter &printer) { + return ::llvm::TypeSwitch<::mlir::Attribute, ::mlir::LogicalResult>(def) .Case<::mlir::vector::CombiningKindAttr>([&](auto t) { + printer << ::mlir::vector::CombiningKindAttr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::vector::IteratorTypeAttr>([&](auto t) { + printer << ::mlir::vector::IteratorTypeAttr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Case<::mlir::vector::PrintPunctuationAttr>([&](auto t) { + printer << ::mlir::vector::PrintPunctuationAttr::getMnemonic(); +t.print(printer); + return ::mlir::success(); + }) + .Default([](auto) { return ::mlir::failure(); }); +} + +namespace mlir { +namespace vector { +namespace detail { +struct CombiningKindAttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::mlir::vector::CombiningKind>; + CombiningKindAttrStorage(::mlir::vector::CombiningKind value) : value(std::move(value)) {} + + KeyTy getAsKey() const { + return KeyTy(value); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (value == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static CombiningKindAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto value = std::move(std::get<0>(tblgenKey)); + return new (allocator.allocate()) CombiningKindAttrStorage(std::move(value)); + } + + ::mlir::vector::CombiningKind value; +}; +} // namespace detail +CombiningKindAttr CombiningKindAttr::get(::mlir::MLIRContext *context, ::mlir::vector::CombiningKind value) { + return Base::get(context, std::move(value)); +} + +::mlir::Attribute CombiningKindAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::mlir::vector::CombiningKind> _result_value; + // Parse literal '<' + if (odsParser.parseLess()) return {}; + + // Parse variable 'value' + _result_value = [&]() -> ::mlir::FailureOr<::mlir::vector::CombiningKind> { + ::mlir::vector::CombiningKind flags = {}; + auto loc = odsParser.getCurrentLocation(); + ::llvm::StringRef enumKeyword; + do { + if (::mlir::failed(odsParser.parseKeyword(&enumKeyword))) + return ::mlir::failure(); + auto maybeEnum = ::mlir::vector::symbolizeCombiningKind(enumKeyword); + if (!maybeEnum) { + return {(::mlir::LogicalResult)(odsParser.emitError(loc) << "expected " << "::mlir::vector::CombiningKind" << " to be one of: " << "add" << ", " << "mul" << ", " << "minui" << ", " << "minsi" << ", " << "minf" << ", " << "maxui" << ", " << "maxsi" << ", " << "maxf" << ", " << "and" << ", " << "or" << ", " << "xor" << ", " << "maximumf" << ", " << "minimumf")}; + } + flags = flags | *maybeEnum; + } while(::mlir::succeeded(odsParser.parseOptionalVerticalBar())); + return flags; + }(); + if (::mlir::failed(_result_value)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse Vector_CombiningKindAttr parameter 'value' which is to be a `::mlir::vector::CombiningKind`"); + return {}; + } + // Parse literal '>' + if (odsParser.parseGreater()) return {}; + assert(::mlir::succeeded(_result_value)); + return CombiningKindAttr::get(odsParser.getContext(), + ::mlir::vector::CombiningKind((*_result_value))); +} + +void CombiningKindAttr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << "<"; + odsPrinter << stringifyCombiningKind(getValue()); + odsPrinter << ">"; +} + +::mlir::vector::CombiningKind CombiningKindAttr::getValue() const { + return getImpl()->value; +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::CombiningKindAttr) +namespace mlir { +namespace vector { +namespace detail { +struct IteratorTypeAttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::mlir::vector::IteratorType>; + IteratorTypeAttrStorage(::mlir::vector::IteratorType value) : value(std::move(value)) {} + + KeyTy getAsKey() const { + return KeyTy(value); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (value == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static IteratorTypeAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto value = std::move(std::get<0>(tblgenKey)); + return new (allocator.allocate()) IteratorTypeAttrStorage(std::move(value)); + } + + ::mlir::vector::IteratorType value; +}; +} // namespace detail +IteratorTypeAttr IteratorTypeAttr::get(::mlir::MLIRContext *context, ::mlir::vector::IteratorType value) { + return Base::get(context, std::move(value)); +} + +::mlir::Attribute IteratorTypeAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::mlir::vector::IteratorType> _result_value; + // Parse literal '<' + if (odsParser.parseLess()) return {}; + + // Parse variable 'value' + _result_value = [&]() -> ::mlir::FailureOr<::mlir::vector::IteratorType> { + auto loc = odsParser.getCurrentLocation(); + ::llvm::StringRef enumKeyword; + if (::mlir::failed(odsParser.parseKeyword(&enumKeyword))) + return ::mlir::failure(); + auto maybeEnum = ::mlir::vector::symbolizeIteratorType(enumKeyword); + if (maybeEnum) + return *maybeEnum; + return {(::mlir::LogicalResult)(odsParser.emitError(loc) << "expected " << "::mlir::vector::IteratorType" << " to be one of: " << "parallel" << ", " << "reduction")}; + }(); + if (::mlir::failed(_result_value)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse Vector_IteratorTypeEnum parameter 'value' which is to be a `::mlir::vector::IteratorType`"); + return {}; + } + // Parse literal '>' + if (odsParser.parseGreater()) return {}; + assert(::mlir::succeeded(_result_value)); + return IteratorTypeAttr::get(odsParser.getContext(), + ::mlir::vector::IteratorType((*_result_value))); +} + +void IteratorTypeAttr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << "<"; + odsPrinter << stringifyIteratorType(getValue()); + odsPrinter << ">"; +} + +::mlir::vector::IteratorType IteratorTypeAttr::getValue() const { + return getImpl()->value; +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::IteratorTypeAttr) +namespace mlir { +namespace vector { +namespace detail { +struct PrintPunctuationAttrStorage : public ::mlir::AttributeStorage { + using KeyTy = std::tuple<::mlir::vector::PrintPunctuation>; + PrintPunctuationAttrStorage(::mlir::vector::PrintPunctuation value) : value(std::move(value)) {} + + KeyTy getAsKey() const { + return KeyTy(value); + } + + bool operator==(const KeyTy &tblgenKey) const { + return (value == std::get<0>(tblgenKey)); + } + + static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) { + return ::llvm::hash_combine(std::get<0>(tblgenKey)); + } + + static PrintPunctuationAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) { + auto value = std::move(std::get<0>(tblgenKey)); + return new (allocator.allocate()) PrintPunctuationAttrStorage(std::move(value)); + } + + ::mlir::vector::PrintPunctuation value; +}; +} // namespace detail +PrintPunctuationAttr PrintPunctuationAttr::get(::mlir::MLIRContext *context, ::mlir::vector::PrintPunctuation value) { + return Base::get(context, std::move(value)); +} + +::mlir::Attribute PrintPunctuationAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) { + ::mlir::Builder odsBuilder(odsParser.getContext()); + ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation(); + (void) odsLoc; + ::mlir::FailureOr<::mlir::vector::PrintPunctuation> _result_value; + // Parse literal '<' + if (odsParser.parseLess()) return {}; + + // Parse variable 'value' + _result_value = [&]() -> ::mlir::FailureOr<::mlir::vector::PrintPunctuation> { + auto loc = odsParser.getCurrentLocation(); + ::llvm::StringRef enumKeyword; + if (::mlir::failed(odsParser.parseKeyword(&enumKeyword))) + return ::mlir::failure(); + auto maybeEnum = ::mlir::vector::symbolizePrintPunctuation(enumKeyword); + if (maybeEnum) + return *maybeEnum; + return {(::mlir::LogicalResult)(odsParser.emitError(loc) << "expected " << "::mlir::vector::PrintPunctuation" << " to be one of: " << "no_punctuation" << ", " << "newline" << ", " << "comma" << ", " << "open" << ", " << "close")}; + }(); + if (::mlir::failed(_result_value)) { + odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse Vector_PrintPunctuation parameter 'value' which is to be a `::mlir::vector::PrintPunctuation`"); + return {}; + } + // Parse literal '>' + if (odsParser.parseGreater()) return {}; + assert(::mlir::succeeded(_result_value)); + return PrintPunctuationAttr::get(odsParser.getContext(), + ::mlir::vector::PrintPunctuation((*_result_value))); +} + +void PrintPunctuationAttr::print(::mlir::AsmPrinter &odsPrinter) const { + ::mlir::Builder odsBuilder(getContext()); + odsPrinter << "<"; + odsPrinter << stringifyPrintPunctuation(getValue()); + odsPrinter << ">"; +} + +::mlir::vector::PrintPunctuation PrintPunctuationAttr::getValue() const { + return getImpl()->value; +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::PrintPunctuationAttr) +namespace mlir { +namespace vector { + +/// Parse an attribute registered to this dialect. +::mlir::Attribute VectorDialect::parseAttribute(::mlir::DialectAsmParser &parser, + ::mlir::Type type) const { + ::llvm::SMLoc typeLoc = parser.getCurrentLocation(); + ::llvm::StringRef attrTag; + { + ::mlir::Attribute attr; + auto parseResult = generatedAttributeParser(parser, &attrTag, type, attr); + if (parseResult.has_value()) + return attr; + } + + parser.emitError(typeLoc) << "unknown attribute `" + << attrTag << "` in dialect `" << getNamespace() << "`"; + return {}; +} +/// Print an attribute registered to this dialect. +void VectorDialect::printAttribute(::mlir::Attribute attr, + ::mlir::DialectAsmPrinter &printer) const { + if (::mlir::succeeded(generatedAttributePrinter(attr, printer))) + return; + +} +} // namespace vector +} // namespace mlir + +#endif // GET_ATTRDEF_CLASSES + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/IR/VectorAttributes.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/IR/VectorAttributes.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..9d48ba80cda7a886afff7c5b262649393de5f306 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/IR/VectorAttributes.h.inc @@ -0,0 +1,74 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* AttrDef Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifdef GET_ATTRDEF_CLASSES +#undef GET_ATTRDEF_CLASSES + + +namespace mlir { +class AsmParser; +class AsmPrinter; +} // namespace mlir +namespace mlir { +namespace vector { +class CombiningKindAttr; +class IteratorTypeAttr; +class PrintPunctuationAttr; +namespace detail { +struct CombiningKindAttrStorage; +} // namespace detail +class CombiningKindAttr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + static CombiningKindAttr get(::mlir::MLIRContext *context, ::mlir::vector::CombiningKind value); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"kind"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::mlir::vector::CombiningKind getValue() const; +}; +namespace detail { +struct IteratorTypeAttrStorage; +} // namespace detail +class IteratorTypeAttr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + static IteratorTypeAttr get(::mlir::MLIRContext *context, ::mlir::vector::IteratorType value); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"iterator_type"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::mlir::vector::IteratorType getValue() const; +}; +namespace detail { +struct PrintPunctuationAttrStorage; +} // namespace detail +class PrintPunctuationAttr : public ::mlir::Attribute::AttrBase { +public: + using Base::Base; + static PrintPunctuationAttr get(::mlir::MLIRContext *context, ::mlir::vector::PrintPunctuation value); + static constexpr ::llvm::StringLiteral getMnemonic() { + return {"punctuation"}; + } + + static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType); + void print(::mlir::AsmPrinter &odsPrinter) const; + ::mlir::vector::PrintPunctuation getValue() const; +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::CombiningKindAttr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::IteratorTypeAttr) +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::PrintPunctuationAttr) + +#endif // GET_ATTRDEF_CLASSES + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/IR/VectorDialect.cpp.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/IR/VectorDialect.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..4fd4d06b367ca9e7f6db3a12da0034550aec5cd6 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/IR/VectorDialect.cpp.inc @@ -0,0 +1,25 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Dialect Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: Vector.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::VectorDialect) +namespace mlir { +namespace vector { + +VectorDialect::VectorDialect(::mlir::MLIRContext *context) + : ::mlir::Dialect(getDialectNamespace(), context, ::mlir::TypeID::get()) { + + getContext()->loadDialect(); + + initialize(); +} + +VectorDialect::~VectorDialect() = default; + +} // namespace vector +} // namespace mlir diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/IR/VectorDialect.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/IR/VectorDialect.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..c275348612d0695fb735cd92c288cd825bd46753 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/IR/VectorDialect.h.inc @@ -0,0 +1,41 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Dialect Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: Vector.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace vector { + +class VectorDialect : public ::mlir::Dialect { + explicit VectorDialect(::mlir::MLIRContext *context); + + void initialize(); + friend class ::mlir::MLIRContext; +public: + ~VectorDialect() override; + static constexpr ::llvm::StringLiteral getDialectNamespace() { + return ::llvm::StringLiteral("vector"); + } + + /// Parse an attribute registered to this dialect. + ::mlir::Attribute parseAttribute(::mlir::DialectAsmParser &parser, + ::mlir::Type type) const override; + + /// Print an attribute registered to this dialect. + void printAttribute(::mlir::Attribute attr, + ::mlir::DialectAsmPrinter &os) const override; + + /// Materialize a single constant operation from a given attribute value with + /// the desired resultant type. + ::mlir::Operation *materializeConstant(::mlir::OpBuilder &builder, + ::mlir::Attribute value, + ::mlir::Type type, + ::mlir::Location loc) override; +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::VectorDialect) diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/IR/VectorEnums.cpp.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/IR/VectorEnums.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..c98f0b195a705c4007de3d02e3f801501b98a486 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/IR/VectorEnums.cpp.inc @@ -0,0 +1,153 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Enum Utility Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: VectorAttributes.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace vector { +std::string stringifyCombiningKind(CombiningKind symbol) { + auto val = static_cast(symbol); + assert(8191u == (8191u | val) && "invalid bits set in bit enum"); + ::llvm::SmallVector<::llvm::StringRef, 2> strs; + + if (1u == (1u & val)) + strs.push_back("add"); + + if (2u == (2u & val)) + strs.push_back("mul"); + + if (4u == (4u & val)) + strs.push_back("minui"); + + if (8u == (8u & val)) + strs.push_back("minsi"); + + if (16u == (16u & val)) + strs.push_back("minf"); + + if (32u == (32u & val)) + strs.push_back("maxui"); + + if (64u == (64u & val)) + strs.push_back("maxsi"); + + if (128u == (128u & val)) + strs.push_back("maxf"); + + if (256u == (256u & val)) + strs.push_back("and"); + + if (512u == (512u & val)) + strs.push_back("or"); + + if (1024u == (1024u & val)) + strs.push_back("xor"); + + if (4096u == (4096u & val)) + strs.push_back("maximumf"); + + if (2048u == (2048u & val)) + strs.push_back("minimumf"); + return ::llvm::join(strs, "|"); +} + +::std::optional symbolizeCombiningKind(::llvm::StringRef str) { + ::llvm::SmallVector<::llvm::StringRef, 2> symbols; + str.split(symbols, "|"); + + uint32_t val = 0; + for (auto symbol : symbols) { + auto bit = llvm::StringSwitch<::std::optional>(symbol.trim()) + .Case("add", 1) + .Case("mul", 2) + .Case("minui", 4) + .Case("minsi", 8) + .Case("minf", 16) + .Case("maxui", 32) + .Case("maxsi", 64) + .Case("maxf", 128) + .Case("and", 256) + .Case("or", 512) + .Case("xor", 1024) + .Case("maximumf", 4096) + .Case("minimumf", 2048) + .Default(::std::nullopt); + if (bit) { val |= *bit; } else { return ::std::nullopt; } + } + return static_cast(val); +} + +::std::optional symbolizeCombiningKind(uint32_t value) { + if (value & ~static_cast(8191u)) return std::nullopt; + return static_cast(value); +} +} // namespace vector +} // namespace mlir + +namespace mlir { +namespace vector { +::llvm::StringRef stringifyPrintPunctuation(PrintPunctuation val) { + switch (val) { + case PrintPunctuation::NoPunctuation: return "no_punctuation"; + case PrintPunctuation::NewLine: return "newline"; + case PrintPunctuation::Comma: return "comma"; + case PrintPunctuation::Open: return "open"; + case PrintPunctuation::Close: return "close"; + } + return ""; +} + +::std::optional symbolizePrintPunctuation(::llvm::StringRef str) { + return ::llvm::StringSwitch<::std::optional>(str) + .Case("no_punctuation", PrintPunctuation::NoPunctuation) + .Case("newline", PrintPunctuation::NewLine) + .Case("comma", PrintPunctuation::Comma) + .Case("open", PrintPunctuation::Open) + .Case("close", PrintPunctuation::Close) + .Default(::std::nullopt); +} +::std::optional symbolizePrintPunctuation(uint32_t value) { + switch (value) { + case 0: return PrintPunctuation::NoPunctuation; + case 1: return PrintPunctuation::NewLine; + case 2: return PrintPunctuation::Comma; + case 3: return PrintPunctuation::Open; + case 4: return PrintPunctuation::Close; + default: return ::std::nullopt; + } +} + +} // namespace vector +} // namespace mlir + +namespace mlir { +namespace vector { +::llvm::StringRef stringifyIteratorType(IteratorType val) { + switch (val) { + case IteratorType::parallel: return "parallel"; + case IteratorType::reduction: return "reduction"; + } + return ""; +} + +::std::optional symbolizeIteratorType(::llvm::StringRef str) { + return ::llvm::StringSwitch<::std::optional>(str) + .Case("parallel", IteratorType::parallel) + .Case("reduction", IteratorType::reduction) + .Default(::std::nullopt); +} +::std::optional symbolizeIteratorType(uint32_t value) { + switch (value) { + case 0: return IteratorType::parallel; + case 1: return IteratorType::reduction; + default: return ::std::nullopt; + } +} + +} // namespace vector +} // namespace mlir + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/IR/VectorEnums.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/IR/VectorEnums.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..f627cb8633e81b08a667bbf3b844247d46af8e24 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/IR/VectorEnums.h.inc @@ -0,0 +1,291 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Enum Utility Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: VectorAttributes.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace vector { +// Kind of combining function for contractions and reductions +enum class CombiningKind : uint32_t { + ADD = 1, + MUL = 2, + MINUI = 4, + MINSI = 8, + MINF = 16, + MAXUI = 32, + MAXSI = 64, + MAXF = 128, + AND = 256, + OR = 512, + XOR = 1024, + MAXIMUMF = 4096, + MINIMUMF = 2048, +}; + +::std::optional symbolizeCombiningKind(uint32_t); +std::string stringifyCombiningKind(CombiningKind); +::std::optional symbolizeCombiningKind(::llvm::StringRef); + +inline constexpr CombiningKind operator|(CombiningKind a, CombiningKind b) { + return static_cast(static_cast(a) | static_cast(b)); +} +inline constexpr CombiningKind operator&(CombiningKind a, CombiningKind b) { + return static_cast(static_cast(a) & static_cast(b)); +} +inline constexpr CombiningKind operator^(CombiningKind a, CombiningKind b) { + return static_cast(static_cast(a) ^ static_cast(b)); +} +inline constexpr CombiningKind operator~(CombiningKind bits) { + // Ensure only bits that can be present in the enum are set + return static_cast(~static_cast(bits) & static_cast(8191u)); +} +inline constexpr bool bitEnumContainsAll(CombiningKind bits, CombiningKind bit) { + return (bits & bit) == bit; +} +inline constexpr bool bitEnumContainsAny(CombiningKind bits, CombiningKind bit) { + return (static_cast(bits) & static_cast(bit)) != 0; +} +inline constexpr CombiningKind bitEnumClear(CombiningKind bits, CombiningKind bit) { + return bits & ~bit; +} +inline constexpr CombiningKind bitEnumSet(CombiningKind bits, CombiningKind bit, /*optional*/bool value=true) { + return value ? (bits | bit) : bitEnumClear(bits, bit); +} + +inline std::string stringifyEnum(CombiningKind enumValue) { + return stringifyCombiningKind(enumValue); +} + +template +::std::optional symbolizeEnum(::llvm::StringRef); + +template <> +inline ::std::optional symbolizeEnum(::llvm::StringRef str) { + return symbolizeCombiningKind(str); +} +} // namespace vector +} // namespace mlir + +namespace mlir { +template +struct FieldParser; + +template<> +struct FieldParser<::mlir::vector::CombiningKind, ::mlir::vector::CombiningKind> { + template + static FailureOr<::mlir::vector::CombiningKind> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return parser.emitError(loc, "expected keyword for Kind of combining function for contractions and reductions"); + + // Symbolize the keyword. + if (::std::optional<::mlir::vector::CombiningKind> attr = ::mlir::vector::symbolizeEnum<::mlir::vector::CombiningKind>(enumKeyword)) + return *attr; + return parser.emitError(loc, "invalid Kind of combining function for contractions and reductions specification: ") << enumKeyword; + } +}; +} // namespace mlir + +namespace llvm { +inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::vector::CombiningKind value) { + auto valueStr = stringifyEnum(value); + auto underlyingValue = static_cast>(value); + if (underlyingValue && !llvm::has_single_bit(underlyingValue)) + return p << '"' << valueStr << '"'; + return p << valueStr; +} +} // namespace llvm + +namespace llvm { +template<> struct DenseMapInfo<::mlir::vector::CombiningKind> { + using StorageInfo = ::llvm::DenseMapInfo; + + static inline ::mlir::vector::CombiningKind getEmptyKey() { + return static_cast<::mlir::vector::CombiningKind>(StorageInfo::getEmptyKey()); + } + + static inline ::mlir::vector::CombiningKind getTombstoneKey() { + return static_cast<::mlir::vector::CombiningKind>(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const ::mlir::vector::CombiningKind &val) { + return StorageInfo::getHashValue(static_cast(val)); + } + + static bool isEqual(const ::mlir::vector::CombiningKind &lhs, const ::mlir::vector::CombiningKind &rhs) { + return lhs == rhs; + } +}; +} + +namespace mlir { +namespace vector { +// Punctuation for separating vectors or vector elements +enum class PrintPunctuation : uint32_t { + NoPunctuation = 0, + NewLine = 1, + Comma = 2, + Open = 3, + Close = 4, +}; + +::std::optional symbolizePrintPunctuation(uint32_t); +::llvm::StringRef stringifyPrintPunctuation(PrintPunctuation); +::std::optional symbolizePrintPunctuation(::llvm::StringRef); +inline constexpr unsigned getMaxEnumValForPrintPunctuation() { + return 4; +} + + +inline ::llvm::StringRef stringifyEnum(PrintPunctuation enumValue) { + return stringifyPrintPunctuation(enumValue); +} + +template +::std::optional symbolizeEnum(::llvm::StringRef); + +template <> +inline ::std::optional symbolizeEnum(::llvm::StringRef str) { + return symbolizePrintPunctuation(str); +} +} // namespace vector +} // namespace mlir + +namespace mlir { +template +struct FieldParser; + +template<> +struct FieldParser<::mlir::vector::PrintPunctuation, ::mlir::vector::PrintPunctuation> { + template + static FailureOr<::mlir::vector::PrintPunctuation> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return parser.emitError(loc, "expected keyword for Punctuation for separating vectors or vector elements"); + + // Symbolize the keyword. + if (::std::optional<::mlir::vector::PrintPunctuation> attr = ::mlir::vector::symbolizeEnum<::mlir::vector::PrintPunctuation>(enumKeyword)) + return *attr; + return parser.emitError(loc, "invalid Punctuation for separating vectors or vector elements specification: ") << enumKeyword; + } +}; +} // namespace mlir + +namespace llvm { +inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::vector::PrintPunctuation value) { + auto valueStr = stringifyEnum(value); + return p << valueStr; +} +} // namespace llvm + +namespace llvm { +template<> struct DenseMapInfo<::mlir::vector::PrintPunctuation> { + using StorageInfo = ::llvm::DenseMapInfo; + + static inline ::mlir::vector::PrintPunctuation getEmptyKey() { + return static_cast<::mlir::vector::PrintPunctuation>(StorageInfo::getEmptyKey()); + } + + static inline ::mlir::vector::PrintPunctuation getTombstoneKey() { + return static_cast<::mlir::vector::PrintPunctuation>(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const ::mlir::vector::PrintPunctuation &val) { + return StorageInfo::getHashValue(static_cast(val)); + } + + static bool isEqual(const ::mlir::vector::PrintPunctuation &lhs, const ::mlir::vector::PrintPunctuation &rhs) { + return lhs == rhs; + } +}; +} + +namespace mlir { +namespace vector { +// Iterator type +enum class IteratorType : uint32_t { + parallel = 0, + reduction = 1, +}; + +::std::optional symbolizeIteratorType(uint32_t); +::llvm::StringRef stringifyIteratorType(IteratorType); +::std::optional symbolizeIteratorType(::llvm::StringRef); +inline constexpr unsigned getMaxEnumValForIteratorType() { + return 1; +} + + +inline ::llvm::StringRef stringifyEnum(IteratorType enumValue) { + return stringifyIteratorType(enumValue); +} + +template +::std::optional symbolizeEnum(::llvm::StringRef); + +template <> +inline ::std::optional symbolizeEnum(::llvm::StringRef str) { + return symbolizeIteratorType(str); +} +} // namespace vector +} // namespace mlir + +namespace mlir { +template +struct FieldParser; + +template<> +struct FieldParser<::mlir::vector::IteratorType, ::mlir::vector::IteratorType> { + template + static FailureOr<::mlir::vector::IteratorType> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return parser.emitError(loc, "expected keyword for Iterator type"); + + // Symbolize the keyword. + if (::std::optional<::mlir::vector::IteratorType> attr = ::mlir::vector::symbolizeEnum<::mlir::vector::IteratorType>(enumKeyword)) + return *attr; + return parser.emitError(loc, "invalid Iterator type specification: ") << enumKeyword; + } +}; +} // namespace mlir + +namespace llvm { +inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::vector::IteratorType value) { + auto valueStr = stringifyEnum(value); + return p << valueStr; +} +} // namespace llvm + +namespace llvm { +template<> struct DenseMapInfo<::mlir::vector::IteratorType> { + using StorageInfo = ::llvm::DenseMapInfo; + + static inline ::mlir::vector::IteratorType getEmptyKey() { + return static_cast<::mlir::vector::IteratorType>(StorageInfo::getEmptyKey()); + } + + static inline ::mlir::vector::IteratorType getTombstoneKey() { + return static_cast<::mlir::vector::IteratorType>(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const ::mlir::vector::IteratorType &val) { + return StorageInfo::getHashValue(static_cast(val)); + } + + static bool isEqual(const ::mlir::vector::IteratorType &lhs, const ::mlir::vector::IteratorType &rhs) { + return lhs == rhs; + } +}; +} + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/IR/VectorOps.cpp.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/IR/VectorOps.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..fc503bd3bded47052804f090cad509f93baacc0e --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/IR/VectorOps.cpp.inc @@ -0,0 +1,14645 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Op Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: VectorOps.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifdef GET_OP_LIST +#undef GET_OP_LIST + +::mlir::vector::VectorScaleOp, +::mlir::vector::BitCastOp, +::mlir::vector::BroadcastOp, +::mlir::vector::CompressStoreOp, +::mlir::vector::ConstantMaskOp, +::mlir::vector::ContractionOp, +::mlir::vector::CreateMaskOp, +::mlir::vector::ExpandLoadOp, +::mlir::vector::ExtractElementOp, +::mlir::vector::ExtractOp, +::mlir::vector::ExtractStridedSliceOp, +::mlir::vector::FMAOp, +::mlir::vector::FlatTransposeOp, +::mlir::vector::GatherOp, +::mlir::vector::InsertElementOp, +::mlir::vector::InsertOp, +::mlir::vector::InsertStridedSliceOp, +::mlir::vector::LoadOp, +::mlir::vector::MaskOp, +::mlir::vector::MaskedLoadOp, +::mlir::vector::MaskedStoreOp, +::mlir::vector::MatmulOp, +::mlir::vector::MultiDimReductionOp, +::mlir::vector::OuterProductOp, +::mlir::vector::PrintOp, +::mlir::vector::ReductionOp, +::mlir::vector::ReshapeOp, +::mlir::vector::ScalableExtractOp, +::mlir::vector::ScalableInsertOp, +::mlir::vector::ScanOp, +::mlir::vector::ScatterOp, +::mlir::vector::ShapeCastOp, +::mlir::vector::ShuffleOp, +::mlir::vector::SplatOp, +::mlir::vector::StoreOp, +::mlir::vector::TransferReadOp, +::mlir::vector::TransferWriteOp, +::mlir::vector::TransposeOp, +::mlir::vector::TypeCastOp, +::mlir::vector::WarpExecuteOnLane0Op, +::mlir::vector::YieldOp +#endif // GET_OP_LIST + +#ifdef GET_OP_CLASSES +#undef GET_OP_CLASSES + + +//===----------------------------------------------------------------------===// +// Local Utility Method Definitions +//===----------------------------------------------------------------------===// + +namespace mlir { +namespace vector { + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_VectorOps0( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((::llvm::isa<::mlir::IndexType>(type)))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be index, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_VectorOps1( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::VectorType>(type))) && ([](::mlir::Type elementType) { return (true); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be vector of any type values, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_VectorOps2( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((true))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be any type, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_VectorOps3( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::MemRefType>(type))) && ([](::mlir::Type elementType) { return (true); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be memref of any type values, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_VectorOps4( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ([](::mlir::Type elementType) { return (elementType.isSignlessInteger(1)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && ((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() + == 1))))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be vector of 1-bit signless integer values of ranks 1, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_VectorOps5( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() + == 1)))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be of ranks 1, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_VectorOps6( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::VectorType>(type))) && ([](::mlir::Type elementType) { return (elementType.isSignlessInteger(1)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be vector of 1-bit signless integer values, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_VectorOps7( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ([](::mlir::Type elementType) { return (true); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be vector of any type values, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_VectorOps8( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((type.isSignlessIntOrIndex()))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be signless integer or index, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_VectorOps9( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::VectorType>(type))) && ([](::mlir::Type elementType) { return (::llvm::isa<::mlir::FloatType>(elementType)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be vector of floating-point values, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_VectorOps10( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ([](::mlir::Type elementType) { return ((elementType.isSignlessInteger())) || ((elementType.isSignedInteger())) || ((::llvm::isa<::mlir::IndexType>(elementType))) || ((::llvm::isa<::mlir::FloatType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && ((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() + == 1))))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be vector of signless integer or signed integer or index or floating-point values of ranks 1, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_VectorOps11( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::ShapedType>(type))) && ([](::mlir::Type elementType) { return (true); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be shaped of any type values, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_VectorOps12( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ([](::mlir::Type elementType) { return ((::llvm::isa<::mlir::IntegerType>(elementType))) || ((::llvm::isa<::mlir::IndexType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be vector of integer or index values, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_VectorOps13( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ([](::mlir::Type elementType) { return (elementType.isSignlessInteger(1)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be vector of 1-bit signless integer values, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_VectorOps14( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::VectorType>(type))) && ([](::mlir::Type elementType) { return (true); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((::llvm::isa<::mlir::IntegerType>(type))) || ((::llvm::isa<::mlir::IndexType>(type))) || ((::llvm::isa<::mlir::FloatType>(type))))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be , but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_VectorOps15( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::VectorType>(type) && + ::llvm::cast(type).isScalable())) && ((::llvm::cast<::mlir::VectorType>(type).getRank() + == 1)))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be of ranks 1, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_VectorOps16( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ([](::mlir::Type elementType) { return ((::llvm::isa<::mlir::IntegerType>(elementType))) || ((::llvm::isa<::mlir::IndexType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && ((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() + == 1))))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be vector of integer or index values of ranks 1, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_VectorOps17( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((type.isSignlessInteger())) || ((::llvm::isa<::mlir::IndexType>(type))) || ((::llvm::isa<::mlir::FloatType>(type))))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be integer/index/float type, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_VectorOps18( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((::llvm::isa<::mlir::RankedTensorType>(type))) && ([](::mlir::Type elementType) { return (true); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be ranked tensor of any type values, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_VectorOps19( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((((::llvm::isa<::mlir::MemRefType>(type))) && ([](::mlir::Type elementType) { return (true); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && ((::llvm::cast<::mlir::ShapedType>(type).hasStaticShape())))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be statically shaped memref of any type values, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_VectorOps0( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !(((::llvm::isa<::mlir::ArrayAttr>(attr))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(attr), [&](::mlir::Attribute attr) { return attr && (((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(64)))); })))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: 64-bit integer array attribute"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_VectorOps0( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_VectorOps0(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_VectorOps1( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::ArrayAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: array attribute"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_VectorOps1( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_VectorOps1(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_VectorOps2( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !(((::llvm::isa<::mlir::ArrayAttr>(attr))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(attr), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::vector::IteratorTypeAttr>(attr))); })))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: Iterator type should be an enum."; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_VectorOps2( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_VectorOps2(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_VectorOps3( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::vector::CombiningKindAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: Kind of combining function for contractions and reductions"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_VectorOps3( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_VectorOps3(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_VectorOps4( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: i64 dense array attribute"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_VectorOps4( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_VectorOps4(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_VectorOps5( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !(((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(32))))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: 32-bit signless integer attribute"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_VectorOps5( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_VectorOps5(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_VectorOps6( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::vector::PrintPunctuationAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: Punctuation for separating vectors or vector elements"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_VectorOps6( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_VectorOps6(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_VectorOps7( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::arith::FastMathFlagsAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: Floating point fast math flags"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_VectorOps7( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_VectorOps7(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_VectorOps8( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !(((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(64))))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: 64-bit signless integer attribute"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_VectorOps8( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_VectorOps8(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_VectorOps9( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::BoolAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: bool attribute"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_VectorOps9( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_VectorOps9(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_VectorOps10( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::AffineMapAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: AffineMap attribute"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_VectorOps10( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_VectorOps10(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_VectorOps11( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !(((::llvm::isa<::mlir::ArrayAttr>(attr))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(attr), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::BoolAttr>(attr))); })))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: 1-bit boolean array attribute"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_VectorOps11( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_VectorOps11(attr, attrName, [op]() { + return op->emitOpError(); + }); +} + +static ::mlir::LogicalResult __mlir_ods_local_region_constraint_VectorOps0( + ::mlir::Operation *op, ::mlir::Region ®ion, ::llvm::StringRef regionName, + unsigned regionIndex) { + if (!((::llvm::hasNItems(region, 1)))) { + return op->emitOpError("region #") << regionIndex + << (regionName.empty() ? " " : " ('" + regionName + "') ") + << "failed to verify constraint: region with 1 blocks"; + } + return ::mlir::success(); +} +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::VectorScaleOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +VectorScaleOpGenericAdaptorBase::VectorScaleOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.vscale", odsAttrs.getContext()); +} + +VectorScaleOpGenericAdaptorBase::VectorScaleOpGenericAdaptorBase(VectorScaleOp op) : VectorScaleOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair VectorScaleOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr VectorScaleOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +VectorScaleOpAdaptor::VectorScaleOpAdaptor(VectorScaleOp op) : VectorScaleOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult VectorScaleOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair VectorScaleOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range VectorScaleOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +std::pair VectorScaleOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range VectorScaleOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::IndexType> VectorScaleOp::getRes() { + return ::llvm::cast<::mlir::TypedValue<::mlir::IndexType>>(*getODSResults(0).begin()); +} + +void VectorScaleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res) { + odsState.addTypes(res); +} + +void VectorScaleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(VectorScaleOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void VectorScaleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes) { + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void VectorScaleOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void VectorScaleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(VectorScaleOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult VectorScaleOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps0(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult VectorScaleOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::LogicalResult VectorScaleOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = odsBuilder.getIndexType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult VectorScaleOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + result.addTypes(odsBuildableType0); + return ::mlir::success(); +} + +void VectorScaleOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); +} + +void VectorScaleOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::VectorScaleOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::BitCastOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BitCastOpGenericAdaptorBase::BitCastOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.bitcast", odsAttrs.getContext()); +} + +BitCastOpGenericAdaptorBase::BitCastOpGenericAdaptorBase(BitCastOp op) : BitCastOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair BitCastOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr BitCastOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +BitCastOpAdaptor::BitCastOpAdaptor(BitCastOp op) : BitCastOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult BitCastOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair BitCastOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range BitCastOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> BitCastOp::getSource() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &BitCastOp::getSourceMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair BitCastOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range BitCastOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> BitCastOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSResults(0).begin()); +} + +void BitCastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source) { + odsState.addOperands(source); + odsState.addTypes(result); +} + +void BitCastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source) { + odsState.addOperands(source); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BitCastOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult BitCastOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!(((::llvm::cast<::mlir::ShapedType>((*this->getODSOperands(0).begin()).getType()).getRank()) == (::llvm::cast<::mlir::ShapedType>((*this->getODSResults(0).begin()).getType()).getRank()) && (::llvm::cast<::mlir::ShapedType>((*this->getODSResults(0).begin()).getType()).getRank()) == (::llvm::cast<::mlir::ShapedType>((*this->getODSOperands(0).begin()).getType()).getRank())))) + return emitOpError("failed to verify that all of {source, result} have same rank"); + return ::mlir::success(); +} + +::mlir::LogicalResult BitCastOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult BitCastOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(sourceRawOperands); ::llvm::SMLoc sourceOperandsLoc; + (void)sourceOperandsLoc; + ::mlir::Type sourceRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> sourceTypes(sourceRawTypes); + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + sourceOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(sourceRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + sourceRawTypes[0] = type; + } + if (parser.parseKeyword("to")) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(sourceOperands, sourceTypes, sourceOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BitCastOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getSource(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getSource().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "to"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void BitCastOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::BitCastOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::BroadcastOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +BroadcastOpGenericAdaptorBase::BroadcastOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.broadcast", odsAttrs.getContext()); +} + +BroadcastOpGenericAdaptorBase::BroadcastOpGenericAdaptorBase(BroadcastOp op) : BroadcastOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair BroadcastOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr BroadcastOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +BroadcastOpAdaptor::BroadcastOpAdaptor(BroadcastOp op) : BroadcastOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult BroadcastOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair BroadcastOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range BroadcastOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value BroadcastOp::getSource() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &BroadcastOp::getSourceMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair BroadcastOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range BroadcastOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> BroadcastOp::getVector() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSResults(0).begin()); +} + +void BroadcastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type vector, ::mlir::Value source) { + odsState.addOperands(source); + odsState.addTypes(vector); +} + +void BroadcastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source) { + odsState.addOperands(source); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void BroadcastOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult BroadcastOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((getElementTypeOrSelf((*this->getOperation()).getResult(0)) == getElementTypeOrSelf((*this->getOperation()).getOperand(0))))) + return emitOpError("failed to verify that source operand and result have same element type"); + return ::mlir::success(); +} + +::mlir::LogicalResult BroadcastOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult BroadcastOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(sourceRawOperands); ::llvm::SMLoc sourceOperandsLoc; + (void)sourceOperandsLoc; + ::mlir::Type sourceRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> sourceTypes(sourceRawTypes); + ::mlir::Type vectorRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> vectorTypes(vectorRawTypes); + + sourceOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(sourceRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + sourceRawTypes[0] = type; + } + if (parser.parseKeyword("to")) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + vectorRawTypes[0] = type; + } + result.addTypes(vectorTypes); + if (parser.resolveOperands(sourceOperands, sourceTypes, sourceOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void BroadcastOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getSource(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getSource().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "to"; + _odsPrinter << ' '; + { + auto type = getVector().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void BroadcastOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::BroadcastOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::CompressStoreOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CompressStoreOpGenericAdaptorBase::CompressStoreOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.compressstore", odsAttrs.getContext()); +} + +CompressStoreOpGenericAdaptorBase::CompressStoreOpGenericAdaptorBase(CompressStoreOp op) : CompressStoreOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair CompressStoreOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, true, false, false}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 3) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr CompressStoreOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +CompressStoreOpAdaptor::CompressStoreOpAdaptor(CompressStoreOp op) : CompressStoreOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult CompressStoreOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair CompressStoreOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, true, false, false}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 3) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range CompressStoreOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::MemRefType> CompressStoreOp::getBase() { + return ::llvm::cast<::mlir::TypedValue<::mlir::MemRefType>>(*getODSOperands(0).begin()); +} + +::mlir::Operation::operand_range CompressStoreOp::getIndices() { + return getODSOperands(1); +} + +::mlir::TypedValue<::mlir::VectorType> CompressStoreOp::getMask() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(2).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> CompressStoreOp::getValueToStore() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(3).begin()); +} + +::mlir::OpOperand &CompressStoreOp::getBaseMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange CompressStoreOp::getIndicesMutable() { + auto range = getODSOperandIndexAndLength(1); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +::mlir::OpOperand &CompressStoreOp::getMaskMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &CompressStoreOp::getValueToStoreMutable() { + auto range = getODSOperandIndexAndLength(3); + return getOperation()->getOpOperand(range.first); +} + +std::pair CompressStoreOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range CompressStoreOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +void CompressStoreOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value base, ::mlir::ValueRange indices, ::mlir::Value mask, ::mlir::Value valueToStore) { + odsState.addOperands(base); + odsState.addOperands(indices); + odsState.addOperands(mask); + odsState.addOperands(valueToStore); +} + +void CompressStoreOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value base, ::mlir::ValueRange indices, ::mlir::Value mask, ::mlir::Value valueToStore) { + odsState.addOperands(base); + odsState.addOperands(indices); + odsState.addOperands(mask); + odsState.addOperands(valueToStore); + assert(resultTypes.size() == 0u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void CompressStoreOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult CompressStoreOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps4(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup3 = getODSOperands(3); + + for (auto v : valueGroup3) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps5(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult CompressStoreOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult CompressStoreOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand baseRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> baseOperands(baseRawOperands); ::llvm::SMLoc baseOperandsLoc; + (void)baseOperandsLoc; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> indicesOperands; + ::llvm::SMLoc indicesOperandsLoc; + (void)indicesOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand maskRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> maskOperands(maskRawOperands); ::llvm::SMLoc maskOperandsLoc; + (void)maskOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand valueToStoreRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> valueToStoreOperands(valueToStoreRawOperands); ::llvm::SMLoc valueToStoreOperandsLoc; + (void)valueToStoreOperandsLoc; + ::mlir::Type baseRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> baseTypes(baseRawTypes); + ::mlir::Type maskRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> maskTypes(maskRawTypes); + ::mlir::Type valueToStoreRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> valueToStoreTypes(valueToStoreRawTypes); + + baseOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(baseRawOperands[0])) + return ::mlir::failure(); + if (parser.parseLSquare()) + return ::mlir::failure(); + + indicesOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(indicesOperands)) + return ::mlir::failure(); + if (parser.parseRSquare()) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + maskOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(maskRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + valueToStoreOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(valueToStoreRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::MemRefType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + baseRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + maskRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + valueToStoreRawTypes[0] = type; + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + if (parser.resolveOperands(baseOperands, baseTypes, baseOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(indicesOperands, odsBuildableType0, indicesOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(maskOperands, maskTypes, maskOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(valueToStoreOperands, valueToStoreTypes, valueToStoreOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CompressStoreOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getBase(); + _odsPrinter << "["; + _odsPrinter << getIndices(); + _odsPrinter << "]"; + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getMask(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getValueToStore(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getBase().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::MemRefType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getMask().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getValueToStore().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void CompressStoreOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { + for (::mlir::Value value : getODSOperands(0)) + effects.emplace_back(::mlir::MemoryEffects::Write::get(), value, 0, false, ::mlir::SideEffects::DefaultResource::get()); +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::CompressStoreOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::ConstantMaskOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ConstantMaskOpGenericAdaptorBase::ConstantMaskOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.constant_mask", odsAttrs.getContext()); +} + +ConstantMaskOpGenericAdaptorBase::ConstantMaskOpGenericAdaptorBase(ConstantMaskOp op) : ConstantMaskOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ConstantMaskOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ConstantMaskOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::ArrayAttr ConstantMaskOpGenericAdaptorBase::getMaskDimSizesAttr() { + auto attr = ::llvm::cast<::mlir::ArrayAttr>(getProperties().mask_dim_sizes); + return attr; +} + +::mlir::ArrayAttr ConstantMaskOpGenericAdaptorBase::getMaskDimSizes() { + auto attr = getMaskDimSizesAttr(); + return attr; +} + +} // namespace detail +ConstantMaskOpAdaptor::ConstantMaskOpAdaptor(ConstantMaskOp op) : ConstantMaskOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ConstantMaskOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_mask_dim_sizes = getProperties().mask_dim_sizes; (void)tblgen_mask_dim_sizes; + if (!tblgen_mask_dim_sizes) return emitError(loc, "'vector.constant_mask' op ""requires attribute 'mask_dim_sizes'"); + + if (tblgen_mask_dim_sizes && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_mask_dim_sizes))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_mask_dim_sizes), [&](::mlir::Attribute attr) { return attr && (((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(64)))); })))) + return emitError(loc, "'vector.constant_mask' op ""attribute 'mask_dim_sizes' failed to satisfy constraint: 64-bit integer array attribute"); + return ::mlir::success(); +} + +std::pair ConstantMaskOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ConstantMaskOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +std::pair ConstantMaskOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ConstantMaskOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::LogicalResult ConstantMaskOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.mask_dim_sizes; + auto attr = dict.get("mask_dim_sizes"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for mask_dim_sizes in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `mask_dim_sizes` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ConstantMaskOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.mask_dim_sizes; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("mask_dim_sizes", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ConstantMaskOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.mask_dim_sizes.getAsOpaquePointer())); +} + +std::optional ConstantMaskOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "mask_dim_sizes") + return prop.mask_dim_sizes; + return std::nullopt; +} + +void ConstantMaskOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "mask_dim_sizes") { + prop.mask_dim_sizes = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ConstantMaskOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.mask_dim_sizes) attrs.append("mask_dim_sizes", prop.mask_dim_sizes); +} + +::mlir::LogicalResult ConstantMaskOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getMaskDimSizesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps0(attr, "mask_dim_sizes", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ConstantMaskOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.mask_dim_sizes))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ConstantMaskOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.mask_dim_sizes); +} + +::mlir::ArrayAttr ConstantMaskOp::getMaskDimSizesAttr() { + return ::llvm::cast<::mlir::ArrayAttr>(getProperties().mask_dim_sizes); +} + +::mlir::ArrayAttr ConstantMaskOp::getMaskDimSizes() { + auto attr = getMaskDimSizesAttr(); + return attr; +} + +void ConstantMaskOp::setMaskDimSizesAttr(::mlir::ArrayAttr attr) { + (*this)->setAttr(getMaskDimSizesAttrName(), attr); +} + +void ConstantMaskOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::ArrayAttr mask_dim_sizes) { + odsState.getOrAddProperties().mask_dim_sizes = mask_dim_sizes; + odsState.addTypes(resultType0); +} + +void ConstantMaskOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ArrayAttr mask_dim_sizes) { + odsState.getOrAddProperties().mask_dim_sizes = mask_dim_sizes; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ConstantMaskOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 0u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ConstantMaskOp::verifyInvariantsImpl() { + auto tblgen_mask_dim_sizes = getProperties().mask_dim_sizes; (void)tblgen_mask_dim_sizes; + if (!tblgen_mask_dim_sizes) return emitOpError("requires attribute 'mask_dim_sizes'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps0(*this, tblgen_mask_dim_sizes, "mask_dim_sizes"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps6(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ConstantMaskOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult ConstantMaskOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::ArrayAttr mask_dim_sizesAttr; + ::llvm::SmallVector<::mlir::Type, 1> allResultTypes; + + if (parser.parseCustomAttributeWithFallback(mask_dim_sizesAttr, parser.getBuilder().getType<::mlir::NoneType>())) { + return ::mlir::failure(); + } + if (mask_dim_sizesAttr) result.getOrAddProperties().mask_dim_sizes = mask_dim_sizesAttr; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + if (parser.parseTypeList(allResultTypes)) + return ::mlir::failure(); + result.addTypes(allResultTypes); + return ::mlir::success(); +} + +void ConstantMaskOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter.printAttributeWithoutType(getMaskDimSizesAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("mask_dim_sizes"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter << getOperation()->getResultTypes(); +} + +void ConstantMaskOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::ConstantMaskOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::ContractionOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ContractionOpGenericAdaptorBase::ContractionOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.contract", odsAttrs.getContext()); +} + +ContractionOpGenericAdaptorBase::ContractionOpGenericAdaptorBase(ContractionOp op) : ContractionOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ContractionOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ContractionOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::ArrayAttr ContractionOpGenericAdaptorBase::getIndexingMapsAttr() { + auto attr = ::llvm::cast<::mlir::ArrayAttr>(getProperties().indexing_maps); + return attr; +} + +::mlir::ArrayAttr ContractionOpGenericAdaptorBase::getIndexingMaps() { + auto attr = getIndexingMapsAttr(); + return attr; +} + +::mlir::ArrayAttr ContractionOpGenericAdaptorBase::getIteratorTypesAttr() { + auto attr = ::llvm::cast<::mlir::ArrayAttr>(getProperties().iterator_types); + return attr; +} + +::mlir::ArrayAttr ContractionOpGenericAdaptorBase::getIteratorTypes() { + auto attr = getIteratorTypesAttr(); + return attr; +} + +::mlir::vector::CombiningKindAttr ContractionOpGenericAdaptorBase::getKindAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::vector::CombiningKindAttr>(getProperties().kind); + return attr; +} + +::mlir::vector::CombiningKind ContractionOpGenericAdaptorBase::getKind() { + auto attr = getKindAttr(); + return attr.getValue(); +} + +} // namespace detail +ContractionOpAdaptor::ContractionOpAdaptor(ContractionOp op) : ContractionOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ContractionOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_indexing_maps = getProperties().indexing_maps; (void)tblgen_indexing_maps; + if (!tblgen_indexing_maps) return emitError(loc, "'vector.contract' op ""requires attribute 'indexing_maps'"); + auto tblgen_iterator_types = getProperties().iterator_types; (void)tblgen_iterator_types; + if (!tblgen_iterator_types) return emitError(loc, "'vector.contract' op ""requires attribute 'iterator_types'"); + auto tblgen_kind = getProperties().kind; (void)tblgen_kind; + + if (tblgen_indexing_maps && !((::llvm::isa<::mlir::ArrayAttr>(tblgen_indexing_maps)))) + return emitError(loc, "'vector.contract' op ""attribute 'indexing_maps' failed to satisfy constraint: array attribute"); + + if (tblgen_iterator_types && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_iterator_types))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_iterator_types), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::vector::IteratorTypeAttr>(attr))); })))) + return emitError(loc, "'vector.contract' op ""attribute 'iterator_types' failed to satisfy constraint: Iterator type should be an enum."); + + if (tblgen_kind && !((::llvm::isa<::mlir::vector::CombiningKindAttr>(tblgen_kind)))) + return emitError(loc, "'vector.contract' op ""attribute 'kind' failed to satisfy constraint: Kind of combining function for contractions and reductions"); + return ::mlir::success(); +} + +std::pair ContractionOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ContractionOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> ContractionOp::getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> ContractionOp::getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(1).begin()); +} + +::mlir::Value ContractionOp::getAcc() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(2).begin()); +} + +::mlir::OpOperand &ContractionOp::getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &ContractionOp::getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &ContractionOp::getAccMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); +} + +std::pair ContractionOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ContractionOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::LogicalResult ContractionOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.indexing_maps; + auto attr = dict.get("indexing_maps"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for indexing_maps in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `indexing_maps` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.iterator_types; + auto attr = dict.get("iterator_types"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for iterator_types in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `iterator_types` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.kind; + auto attr = dict.get("kind"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for kind in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `kind` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ContractionOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.indexing_maps; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("indexing_maps", + propStorage)); + } + + { + const auto &propStorage = prop.iterator_types; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("iterator_types", + propStorage)); + } + + { + const auto &propStorage = prop.kind; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("kind", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ContractionOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.indexing_maps.getAsOpaquePointer()), + llvm::hash_value(prop.iterator_types.getAsOpaquePointer()), + llvm::hash_value(prop.kind.getAsOpaquePointer())); +} + +std::optional ContractionOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "indexing_maps") + return prop.indexing_maps; + + if (name == "iterator_types") + return prop.iterator_types; + + if (name == "kind") + return prop.kind; + return std::nullopt; +} + +void ContractionOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "indexing_maps") { + prop.indexing_maps = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "iterator_types") { + prop.iterator_types = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "kind") { + prop.kind = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ContractionOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.indexing_maps) attrs.append("indexing_maps", prop.indexing_maps); + + if (prop.iterator_types) attrs.append("iterator_types", prop.iterator_types); + + if (prop.kind) attrs.append("kind", prop.kind); +} + +::mlir::LogicalResult ContractionOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getIndexingMapsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps1(attr, "indexing_maps", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getIteratorTypesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps2(attr, "iterator_types", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getKindAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps3(attr, "kind", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ContractionOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.indexing_maps))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.iterator_types))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readOptionalAttribute(prop.kind))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ContractionOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.indexing_maps); + writer.writeAttribute(prop.iterator_types); + + writer.writeOptionalAttribute(prop.kind); +} + +::mlir::ArrayAttr ContractionOp::getIndexingMapsAttr() { + return ::llvm::cast<::mlir::ArrayAttr>(getProperties().indexing_maps); +} + +::mlir::ArrayAttr ContractionOp::getIndexingMaps() { + auto attr = getIndexingMapsAttr(); + return attr; +} + +::mlir::ArrayAttr ContractionOp::getIteratorTypesAttr() { + return ::llvm::cast<::mlir::ArrayAttr>(getProperties().iterator_types); +} + +::mlir::ArrayAttr ContractionOp::getIteratorTypes() { + auto attr = getIteratorTypesAttr(); + return attr; +} + +::mlir::vector::CombiningKindAttr ContractionOp::getKindAttr() { + return ::llvm::dyn_cast_or_null<::mlir::vector::CombiningKindAttr>(getProperties().kind); +} + +::mlir::vector::CombiningKind ContractionOp::getKind() { + auto attr = getKindAttr(); + return attr.getValue(); +} + +void ContractionOp::setIndexingMapsAttr(::mlir::ArrayAttr attr) { + (*this)->setAttr(getIndexingMapsAttrName(), attr); +} + +void ContractionOp::setIteratorTypesAttr(::mlir::ArrayAttr attr) { + (*this)->setAttr(getIteratorTypesAttrName(), attr); +} + +void ContractionOp::setKindAttr(::mlir::vector::CombiningKindAttr attr) { + (*this)->setAttr(getKindAttrName(), attr); +} + +void ContractionOp::setKind(::mlir::vector::CombiningKind attrValue) { + (*this)->setAttr(getKindAttrName(), ::mlir::vector::CombiningKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue)); +} + +void ContractionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Value acc, ::mlir::ArrayAttr indexing_maps, ::mlir::ArrayAttr iterator_types, ::mlir::vector::CombiningKindAttr kind) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addOperands(acc); + odsState.getOrAddProperties().indexing_maps = indexing_maps; + odsState.getOrAddProperties().iterator_types = iterator_types; + if (kind) { + odsState.getOrAddProperties().kind = kind; + } + odsState.addTypes(resultType0); +} + +void ContractionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Value acc, ::mlir::ArrayAttr indexing_maps, ::mlir::ArrayAttr iterator_types, ::mlir::vector::CombiningKindAttr kind) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addOperands(acc); + odsState.getOrAddProperties().indexing_maps = indexing_maps; + odsState.getOrAddProperties().iterator_types = iterator_types; + if (kind) { + odsState.getOrAddProperties().kind = kind; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ContractionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Value acc, ::mlir::ArrayAttr indexing_maps, ::mlir::ArrayAttr iterator_types, ::mlir::vector::CombiningKind kind) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addOperands(acc); + odsState.getOrAddProperties().indexing_maps = indexing_maps; + odsState.getOrAddProperties().iterator_types = iterator_types; + odsState.getOrAddProperties().kind = ::mlir::vector::CombiningKindAttr::get(odsBuilder.getContext(), kind); + odsState.addTypes(resultType0); +} + +void ContractionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Value acc, ::mlir::ArrayAttr indexing_maps, ::mlir::ArrayAttr iterator_types, ::mlir::vector::CombiningKind kind) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addOperands(acc); + odsState.getOrAddProperties().indexing_maps = indexing_maps; + odsState.getOrAddProperties().iterator_types = iterator_types; + odsState.getOrAddProperties().kind = ::mlir::vector::CombiningKindAttr::get(odsBuilder.getContext(), kind); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ContractionOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ContractionOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { + ::mlir::Builder odsBuilder(opName.getContext()); + if (!properties.kind) + properties.kind = ::mlir::vector::CombiningKindAttr::get(odsBuilder.getContext(), CombiningKind::ADD); +} + +::mlir::LogicalResult ContractionOp::verifyInvariantsImpl() { + auto tblgen_indexing_maps = getProperties().indexing_maps; (void)tblgen_indexing_maps; + if (!tblgen_indexing_maps) return emitOpError("requires attribute 'indexing_maps'"); + auto tblgen_iterator_types = getProperties().iterator_types; (void)tblgen_iterator_types; + if (!tblgen_iterator_types) return emitOpError("requires attribute 'iterator_types'"); + auto tblgen_kind = getProperties().kind; (void)tblgen_kind; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps1(*this, tblgen_indexing_maps, "indexing_maps"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps2(*this, tblgen_iterator_types, "iterator_types"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps3(*this, tblgen_kind, "kind"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps7(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps7(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((((*this->getOperation()).getNumOperands() > 1)) && ((::llvm::isa<::mlir::ShapedType>((*this->getOperation()).getOperand(0).getType()))) && ((::llvm::isa<::mlir::ShapedType>((*this->getOperation()).getOperand(1).getType()))) && ((::mlir::getElementTypeOrSelf((*this->getOperation()).getOperand(0)) == ::mlir::getElementTypeOrSelf((*this->getOperation()).getOperand(1)))))) + return emitOpError("failed to verify that lhs and rhs have same element type"); + if (!((getElementTypeOrSelf((*this->getOperation()).getResult(0)) == getElementTypeOrSelf((*this->getOperation()).getOperand(2))))) + return emitOpError("failed to verify that third operand acc and result have same element type"); + return ::mlir::success(); +} + +::mlir::LogicalResult ContractionOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +void ContractionOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::ContractionOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::CreateMaskOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +CreateMaskOpGenericAdaptorBase::CreateMaskOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.create_mask", odsAttrs.getContext()); +} + +CreateMaskOpGenericAdaptorBase::CreateMaskOpGenericAdaptorBase(CreateMaskOp op) : CreateMaskOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair CreateMaskOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr CreateMaskOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +CreateMaskOpAdaptor::CreateMaskOpAdaptor(CreateMaskOp op) : CreateMaskOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult CreateMaskOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair CreateMaskOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range CreateMaskOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::operand_range CreateMaskOp::getOperands() { + return getODSOperands(0); +} + +::mlir::MutableOperandRange CreateMaskOp::getOperandsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair CreateMaskOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range CreateMaskOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +void CreateMaskOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::ValueRange operands) { + odsState.addOperands(operands); + odsState.addTypes(resultType0); +} + +void CreateMaskOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult CreateMaskOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps6(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult CreateMaskOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult CreateMaskOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> operandsOperands; + ::llvm::SMLoc operandsOperandsLoc; + (void)operandsOperandsLoc; + ::llvm::SmallVector<::mlir::Type, 1> allResultTypes; + + operandsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(operandsOperands)) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + if (parser.parseTypeList(allResultTypes)) + return ::mlir::failure(); + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(operandsOperands, odsBuildableType0, operandsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void CreateMaskOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperands(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter << getOperation()->getResultTypes(); +} + +void CreateMaskOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::CreateMaskOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::ExpandLoadOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ExpandLoadOpGenericAdaptorBase::ExpandLoadOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.expandload", odsAttrs.getContext()); +} + +ExpandLoadOpGenericAdaptorBase::ExpandLoadOpGenericAdaptorBase(ExpandLoadOp op) : ExpandLoadOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ExpandLoadOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, true, false, false}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 3) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr ExpandLoadOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +ExpandLoadOpAdaptor::ExpandLoadOpAdaptor(ExpandLoadOp op) : ExpandLoadOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ExpandLoadOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair ExpandLoadOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, true, false, false}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 3) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range ExpandLoadOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::MemRefType> ExpandLoadOp::getBase() { + return ::llvm::cast<::mlir::TypedValue<::mlir::MemRefType>>(*getODSOperands(0).begin()); +} + +::mlir::Operation::operand_range ExpandLoadOp::getIndices() { + return getODSOperands(1); +} + +::mlir::TypedValue<::mlir::VectorType> ExpandLoadOp::getMask() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(2).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> ExpandLoadOp::getPassThru() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(3).begin()); +} + +::mlir::OpOperand &ExpandLoadOp::getBaseMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange ExpandLoadOp::getIndicesMutable() { + auto range = getODSOperandIndexAndLength(1); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +::mlir::OpOperand &ExpandLoadOp::getMaskMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &ExpandLoadOp::getPassThruMutable() { + auto range = getODSOperandIndexAndLength(3); + return getOperation()->getOpOperand(range.first); +} + +std::pair ExpandLoadOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ExpandLoadOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> ExpandLoadOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSResults(0).begin()); +} + +void ExpandLoadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value base, ::mlir::ValueRange indices, ::mlir::Value mask, ::mlir::Value pass_thru) { + odsState.addOperands(base); + odsState.addOperands(indices); + odsState.addOperands(mask); + odsState.addOperands(pass_thru); + odsState.addTypes(result); +} + +void ExpandLoadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value base, ::mlir::ValueRange indices, ::mlir::Value mask, ::mlir::Value pass_thru) { + odsState.addOperands(base); + odsState.addOperands(indices); + odsState.addOperands(mask); + odsState.addOperands(pass_thru); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ExpandLoadOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ExpandLoadOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps4(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup3 = getODSOperands(3); + + for (auto v : valueGroup3) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps5(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps5(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ExpandLoadOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult ExpandLoadOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand baseRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> baseOperands(baseRawOperands); ::llvm::SMLoc baseOperandsLoc; + (void)baseOperandsLoc; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> indicesOperands; + ::llvm::SMLoc indicesOperandsLoc; + (void)indicesOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand maskRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> maskOperands(maskRawOperands); ::llvm::SMLoc maskOperandsLoc; + (void)maskOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand pass_thruRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> pass_thruOperands(pass_thruRawOperands); ::llvm::SMLoc pass_thruOperandsLoc; + (void)pass_thruOperandsLoc; + ::mlir::Type baseRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> baseTypes(baseRawTypes); + ::mlir::Type maskRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> maskTypes(maskRawTypes); + ::mlir::Type pass_thruRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> pass_thruTypes(pass_thruRawTypes); + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + baseOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(baseRawOperands[0])) + return ::mlir::failure(); + if (parser.parseLSquare()) + return ::mlir::failure(); + + indicesOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(indicesOperands)) + return ::mlir::failure(); + if (parser.parseRSquare()) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + maskOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(maskRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + pass_thruOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(pass_thruRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::MemRefType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + baseRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + maskRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + pass_thruRawTypes[0] = type; + } + if (parser.parseKeyword("into")) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + result.addTypes(resultTypes); + if (parser.resolveOperands(baseOperands, baseTypes, baseOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(indicesOperands, odsBuildableType0, indicesOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(maskOperands, maskTypes, maskOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(pass_thruOperands, pass_thruTypes, pass_thruOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ExpandLoadOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getBase(); + _odsPrinter << "["; + _odsPrinter << getIndices(); + _odsPrinter << "]"; + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getMask(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getPassThru(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getBase().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::MemRefType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getMask().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getPassThru().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "into"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void ExpandLoadOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { + for (::mlir::Value value : getODSOperands(0)) + effects.emplace_back(::mlir::MemoryEffects::Read::get(), value, 0, false, ::mlir::SideEffects::DefaultResource::get()); +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::ExpandLoadOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::ExtractElementOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ExtractElementOpGenericAdaptorBase::ExtractElementOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.extractelement", odsAttrs.getContext()); +} + +ExtractElementOpGenericAdaptorBase::ExtractElementOpGenericAdaptorBase(ExtractElementOp op) : ExtractElementOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ExtractElementOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr ExtractElementOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +ExtractElementOpAdaptor::ExtractElementOpAdaptor(ExtractElementOp op) : ExtractElementOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ExtractElementOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair ExtractElementOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range ExtractElementOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> ExtractElementOp::getVector() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::Value ExtractElementOp::getPosition() { + auto operands = getODSOperands(1); + return operands.empty() ? ::mlir::Value{} : ::llvm::cast<::mlir::Value>(*operands.begin()); +} + +::mlir::OpOperand &ExtractElementOp::getVectorMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange ExtractElementOp::getPositionMutable() { + auto range = getODSOperandIndexAndLength(1); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair ExtractElementOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ExtractElementOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value ExtractElementOp::getResult() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +void ExtractElementOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value vector, /*optional*/::mlir::Value position) { + odsState.addOperands(vector); + if (position) + odsState.addOperands(position); + odsState.addTypes(result); +} + +void ExtractElementOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value vector, /*optional*/::mlir::Value position) { + odsState.addOperands(vector); + if (position) + odsState.addOperands(position); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ExtractElementOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void ExtractElementOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value vector, /*optional*/::mlir::Value position) { + odsState.addOperands(vector); + if (position) + odsState.addOperands(position); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ExtractElementOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ExtractElementOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ExtractElementOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult ExtractElementOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + if (valueGroup1.size() > 1) { + return emitOpError("operand group starting at #") << index + << " requires 0 or 1 element, but found " << valueGroup1.size(); + } + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((std::equal_to<>()(::llvm::cast((*this->getODSOperands(0).begin()).getType()).getElementType(), (*this->getODSResults(0).begin()).getType())))) + return emitOpError("failed to verify that result type matches element type of vector operand"); + return ::mlir::success(); +} + +::mlir::LogicalResult ExtractElementOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::LogicalResult ExtractElementOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = ::llvm::cast(operands[0].getType()).getElementType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult ExtractElementOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand vectorRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> vectorOperands(vectorRawOperands); ::llvm::SMLoc vectorOperandsLoc; + (void)vectorOperandsLoc; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> positionOperands; + ::llvm::SMLoc positionOperandsLoc; + (void)positionOperandsLoc; + ::llvm::SmallVector<::mlir::Type, 1> positionTypes; + ::mlir::Type vectorRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> vectorTypes(vectorRawTypes); + + vectorOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(vectorRawOperands[0])) + return ::mlir::failure(); + if (parser.parseLSquare()) + return ::mlir::failure(); + + { + positionOperandsLoc = parser.getCurrentLocation(); + ::mlir::OpAsmParser::UnresolvedOperand operand; + ::mlir::OptionalParseResult parseResult = + parser.parseOptionalOperand(operand); + if (parseResult.has_value()) { + if (failed(*parseResult)) + return ::mlir::failure(); + positionOperands.push_back(operand); + } + } + if (!positionOperands.empty()) { + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::Type optionalType; + ::mlir::OptionalParseResult parseResult = + parser.parseOptionalType(optionalType); + if (parseResult.has_value()) { + if (failed(*parseResult)) + return ::mlir::failure(); + positionTypes.push_back(optionalType); + } + } + } + if (parser.parseRSquare()) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + vectorRawTypes[0] = type; + } + for (::mlir::Type type : vectorTypes) { + (void)type; + if (!(((::llvm::isa<::mlir::VectorType>(type))) && ([](::mlir::Type elementType) { return (true); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return parser.emitError(parser.getNameLoc()) << "'vector' must be vector of any type values, but got " << type; + } + } + result.addTypes(::llvm::cast(vectorTypes[0]).getElementType()); + if (parser.resolveOperands(vectorOperands, vectorTypes, vectorOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(positionOperands, positionTypes, positionOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ExtractElementOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getVector(); + _odsPrinter << "["; + if (getPosition()) { + if (::mlir::Value value = getPosition()) + _odsPrinter << value; + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter << (getPosition() ? ::llvm::ArrayRef<::mlir::Type>(getPosition().getType()) : ::llvm::ArrayRef<::mlir::Type>()); + } + _odsPrinter << "]"; + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getVector().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void ExtractElementOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::ExtractElementOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::ExtractOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ExtractOpGenericAdaptorBase::ExtractOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.extract", odsAttrs.getContext()); +} + +ExtractOpGenericAdaptorBase::ExtractOpGenericAdaptorBase(ExtractOp op) : ExtractOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ExtractOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr ExtractOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::DenseI64ArrayAttr ExtractOpGenericAdaptorBase::getStaticPositionAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().static_position); + return attr; +} + +::llvm::ArrayRef ExtractOpGenericAdaptorBase::getStaticPosition() { + auto attr = getStaticPositionAttr(); + return attr; +} + +} // namespace detail +ExtractOpAdaptor::ExtractOpAdaptor(ExtractOp op) : ExtractOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ExtractOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_static_position = getProperties().static_position; (void)tblgen_static_position; + if (!tblgen_static_position) return emitError(loc, "'vector.extract' op ""requires attribute 'static_position'"); + + if (tblgen_static_position && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_static_position)))) + return emitError(loc, "'vector.extract' op ""attribute 'static_position' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +std::pair ExtractOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range ExtractOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> ExtractOp::getVector() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::Operation::operand_range ExtractOp::getDynamicPosition() { + return getODSOperands(1); +} + +::mlir::OpOperand &ExtractOp::getVectorMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange ExtractOp::getDynamicPositionMutable() { + auto range = getODSOperandIndexAndLength(1); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair ExtractOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ExtractOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value ExtractOp::getResult() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult ExtractOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.static_position; + auto attr = dict.get("static_position"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for static_position in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `static_position` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ExtractOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.static_position; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("static_position", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ExtractOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.static_position.getAsOpaquePointer())); +} + +std::optional ExtractOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "static_position") + return prop.static_position; + return std::nullopt; +} + +void ExtractOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "static_position") { + prop.static_position = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ExtractOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.static_position) attrs.append("static_position", prop.static_position); +} + +::mlir::LogicalResult ExtractOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getStaticPositionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps4(attr, "static_position", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ExtractOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.static_position))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ExtractOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.static_position); +} + +::mlir::DenseI64ArrayAttr ExtractOp::getStaticPositionAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().static_position); +} + +::llvm::ArrayRef ExtractOp::getStaticPosition() { + auto attr = getStaticPositionAttr(); + return attr; +} + +void ExtractOp::setStaticPositionAttr(::mlir::DenseI64ArrayAttr attr) { + (*this)->setAttr(getStaticPositionAttrName(), attr); +} + +void ExtractOp::setStaticPosition(::llvm::ArrayRef attrValue) { + (*this)->setAttr(getStaticPositionAttrName(), ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue)); +} + +void ExtractOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value vector, ::mlir::ValueRange dynamic_position, ::mlir::DenseI64ArrayAttr static_position) { + odsState.addOperands(vector); + odsState.addOperands(dynamic_position); + odsState.getOrAddProperties().static_position = static_position; + odsState.addTypes(result); +} + +void ExtractOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value vector, ::mlir::ValueRange dynamic_position, ::mlir::DenseI64ArrayAttr static_position) { + odsState.addOperands(vector); + odsState.addOperands(dynamic_position); + odsState.getOrAddProperties().static_position = static_position; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ExtractOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void ExtractOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value vector, ::mlir::ValueRange dynamic_position, ::mlir::DenseI64ArrayAttr static_position) { + odsState.addOperands(vector); + odsState.addOperands(dynamic_position); + odsState.getOrAddProperties().static_position = static_position; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ExtractOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value vector, ::mlir::ValueRange dynamic_position, ::llvm::ArrayRef static_position) { + odsState.addOperands(vector); + odsState.addOperands(dynamic_position); + odsState.getOrAddProperties().static_position = odsBuilder.getDenseI64ArrayAttr(static_position); + odsState.addTypes(result); +} + +void ExtractOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value vector, ::mlir::ValueRange dynamic_position, ::llvm::ArrayRef static_position) { + odsState.addOperands(vector); + odsState.addOperands(dynamic_position); + odsState.getOrAddProperties().static_position = odsBuilder.getDenseI64ArrayAttr(static_position); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ExtractOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void ExtractOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value vector, ::mlir::ValueRange dynamic_position, ::llvm::ArrayRef static_position) { + odsState.addOperands(vector); + odsState.addOperands(dynamic_position); + odsState.getOrAddProperties().static_position = odsBuilder.getDenseI64ArrayAttr(static_position); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ExtractOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ExtractOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ExtractOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult ExtractOp::verifyInvariantsImpl() { + auto tblgen_static_position = getProperties().static_position; (void)tblgen_static_position; + if (!tblgen_static_position) return emitOpError("requires attribute 'static_position'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps4(*this, tblgen_static_position, "static_position"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((getElementTypeOrSelf((*this->getOperation()).getResult(0)) == getElementTypeOrSelf((*this->getOperation()).getOperand(0))))) + return emitOpError("failed to verify that operand and result have same element type"); + return ::mlir::success(); +} + +::mlir::LogicalResult ExtractOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult ExtractOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand vectorRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> vectorOperands(vectorRawOperands); ::llvm::SMLoc vectorOperandsLoc; + (void)vectorOperandsLoc; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> dynamic_positionOperands; + ::llvm::SMLoc dynamic_positionOperandsLoc; + (void)dynamic_positionOperandsLoc; + ::mlir::DenseI64ArrayAttr static_positionAttr; + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + ::mlir::Type vectorRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> vectorTypes(vectorRawTypes); + + vectorOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(vectorRawOperands[0])) + return ::mlir::failure(); + { + dynamic_positionOperandsLoc = parser.getCurrentLocation(); + auto odsResult = parseDynamicIndexList(parser, dynamic_positionOperands, static_positionAttr); + if (odsResult) return ::mlir::failure(); + result.getOrAddProperties().static_position = static_positionAttr; + } + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + if (parser.parseKeyword("from")) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + vectorRawTypes[0] = type; + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + result.addTypes(resultTypes); + if (parser.resolveOperands(vectorOperands, vectorTypes, vectorOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(dynamic_positionOperands, odsBuildableType0, dynamic_positionOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ExtractOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getVector(); + printDynamicIndexList(_odsPrinter, *this, getDynamicPosition(), getStaticPositionAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("static_position"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "from"; + _odsPrinter << ' '; + { + auto type = getVector().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void ExtractOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::mlir::LogicalResult +ExtractOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ExtractOp::Adaptor adaptor(operands, attributes, properties, regions); + return ExtractOp::inferReturnTypes(context, + location, adaptor, inferredReturnTypes); +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::ExtractOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::ExtractStridedSliceOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ExtractStridedSliceOpGenericAdaptorBase::ExtractStridedSliceOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.extract_strided_slice", odsAttrs.getContext()); +} + +ExtractStridedSliceOpGenericAdaptorBase::ExtractStridedSliceOpGenericAdaptorBase(ExtractStridedSliceOp op) : ExtractStridedSliceOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ExtractStridedSliceOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ExtractStridedSliceOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::ArrayAttr ExtractStridedSliceOpGenericAdaptorBase::getOffsetsAttr() { + auto attr = ::llvm::cast<::mlir::ArrayAttr>(getProperties().offsets); + return attr; +} + +::mlir::ArrayAttr ExtractStridedSliceOpGenericAdaptorBase::getOffsets() { + auto attr = getOffsetsAttr(); + return attr; +} + +::mlir::ArrayAttr ExtractStridedSliceOpGenericAdaptorBase::getSizesAttr() { + auto attr = ::llvm::cast<::mlir::ArrayAttr>(getProperties().sizes); + return attr; +} + +::mlir::ArrayAttr ExtractStridedSliceOpGenericAdaptorBase::getSizes() { + auto attr = getSizesAttr(); + return attr; +} + +::mlir::ArrayAttr ExtractStridedSliceOpGenericAdaptorBase::getStridesAttr() { + auto attr = ::llvm::cast<::mlir::ArrayAttr>(getProperties().strides); + return attr; +} + +::mlir::ArrayAttr ExtractStridedSliceOpGenericAdaptorBase::getStrides() { + auto attr = getStridesAttr(); + return attr; +} + +} // namespace detail +ExtractStridedSliceOpAdaptor::ExtractStridedSliceOpAdaptor(ExtractStridedSliceOp op) : ExtractStridedSliceOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ExtractStridedSliceOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_offsets = getProperties().offsets; (void)tblgen_offsets; + if (!tblgen_offsets) return emitError(loc, "'vector.extract_strided_slice' op ""requires attribute 'offsets'"); + auto tblgen_sizes = getProperties().sizes; (void)tblgen_sizes; + if (!tblgen_sizes) return emitError(loc, "'vector.extract_strided_slice' op ""requires attribute 'sizes'"); + auto tblgen_strides = getProperties().strides; (void)tblgen_strides; + if (!tblgen_strides) return emitError(loc, "'vector.extract_strided_slice' op ""requires attribute 'strides'"); + + if (tblgen_offsets && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_offsets))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_offsets), [&](::mlir::Attribute attr) { return attr && (((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(64)))); })))) + return emitError(loc, "'vector.extract_strided_slice' op ""attribute 'offsets' failed to satisfy constraint: 64-bit integer array attribute"); + + if (tblgen_sizes && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_sizes))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_sizes), [&](::mlir::Attribute attr) { return attr && (((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(64)))); })))) + return emitError(loc, "'vector.extract_strided_slice' op ""attribute 'sizes' failed to satisfy constraint: 64-bit integer array attribute"); + + if (tblgen_strides && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_strides))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_strides), [&](::mlir::Attribute attr) { return attr && (((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(64)))); })))) + return emitError(loc, "'vector.extract_strided_slice' op ""attribute 'strides' failed to satisfy constraint: 64-bit integer array attribute"); + return ::mlir::success(); +} + +std::pair ExtractStridedSliceOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ExtractStridedSliceOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> ExtractStridedSliceOp::getVector() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &ExtractStridedSliceOp::getVectorMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair ExtractStridedSliceOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ExtractStridedSliceOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::LogicalResult ExtractStridedSliceOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.offsets; + auto attr = dict.get("offsets"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for offsets in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `offsets` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.sizes; + auto attr = dict.get("sizes"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for sizes in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `sizes` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.strides; + auto attr = dict.get("strides"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for strides in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `strides` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ExtractStridedSliceOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.offsets; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("offsets", + propStorage)); + } + + { + const auto &propStorage = prop.sizes; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("sizes", + propStorage)); + } + + { + const auto &propStorage = prop.strides; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("strides", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ExtractStridedSliceOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.offsets.getAsOpaquePointer()), + llvm::hash_value(prop.sizes.getAsOpaquePointer()), + llvm::hash_value(prop.strides.getAsOpaquePointer())); +} + +std::optional ExtractStridedSliceOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "offsets") + return prop.offsets; + + if (name == "sizes") + return prop.sizes; + + if (name == "strides") + return prop.strides; + return std::nullopt; +} + +void ExtractStridedSliceOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "offsets") { + prop.offsets = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "sizes") { + prop.sizes = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "strides") { + prop.strides = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ExtractStridedSliceOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.offsets) attrs.append("offsets", prop.offsets); + + if (prop.sizes) attrs.append("sizes", prop.sizes); + + if (prop.strides) attrs.append("strides", prop.strides); +} + +::mlir::LogicalResult ExtractStridedSliceOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getOffsetsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps0(attr, "offsets", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getSizesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps0(attr, "sizes", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getStridesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps0(attr, "strides", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ExtractStridedSliceOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.offsets))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.sizes))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.strides))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ExtractStridedSliceOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.offsets); + writer.writeAttribute(prop.sizes); + writer.writeAttribute(prop.strides); +} + +::mlir::ArrayAttr ExtractStridedSliceOp::getOffsetsAttr() { + return ::llvm::cast<::mlir::ArrayAttr>(getProperties().offsets); +} + +::mlir::ArrayAttr ExtractStridedSliceOp::getOffsets() { + auto attr = getOffsetsAttr(); + return attr; +} + +::mlir::ArrayAttr ExtractStridedSliceOp::getSizesAttr() { + return ::llvm::cast<::mlir::ArrayAttr>(getProperties().sizes); +} + +::mlir::ArrayAttr ExtractStridedSliceOp::getSizes() { + auto attr = getSizesAttr(); + return attr; +} + +::mlir::ArrayAttr ExtractStridedSliceOp::getStridesAttr() { + return ::llvm::cast<::mlir::ArrayAttr>(getProperties().strides); +} + +::mlir::ArrayAttr ExtractStridedSliceOp::getStrides() { + auto attr = getStridesAttr(); + return attr; +} + +void ExtractStridedSliceOp::setOffsetsAttr(::mlir::ArrayAttr attr) { + (*this)->setAttr(getOffsetsAttrName(), attr); +} + +void ExtractStridedSliceOp::setSizesAttr(::mlir::ArrayAttr attr) { + (*this)->setAttr(getSizesAttrName(), attr); +} + +void ExtractStridedSliceOp::setStridesAttr(::mlir::ArrayAttr attr) { + (*this)->setAttr(getStridesAttrName(), attr); +} + +void ExtractStridedSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value vector, ::mlir::ArrayAttr offsets, ::mlir::ArrayAttr sizes, ::mlir::ArrayAttr strides) { + odsState.addOperands(vector); + odsState.getOrAddProperties().offsets = offsets; + odsState.getOrAddProperties().sizes = sizes; + odsState.getOrAddProperties().strides = strides; + odsState.addTypes(resultType0); +} + +void ExtractStridedSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value vector, ::mlir::ArrayAttr offsets, ::mlir::ArrayAttr sizes, ::mlir::ArrayAttr strides) { + odsState.addOperands(vector); + odsState.getOrAddProperties().offsets = offsets; + odsState.getOrAddProperties().sizes = sizes; + odsState.getOrAddProperties().strides = strides; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ExtractStridedSliceOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ExtractStridedSliceOp::verifyInvariantsImpl() { + auto tblgen_offsets = getProperties().offsets; (void)tblgen_offsets; + if (!tblgen_offsets) return emitOpError("requires attribute 'offsets'"); + auto tblgen_sizes = getProperties().sizes; (void)tblgen_sizes; + if (!tblgen_sizes) return emitOpError("requires attribute 'sizes'"); + auto tblgen_strides = getProperties().strides; (void)tblgen_strides; + if (!tblgen_strides) return emitOpError("requires attribute 'strides'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps0(*this, tblgen_offsets, "offsets"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps0(*this, tblgen_sizes, "sizes"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps0(*this, tblgen_strides, "strides"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps7(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps7(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((getElementTypeOrSelf((*this->getOperation()).getResult(0)) == getElementTypeOrSelf((*this->getOperation()).getOperand(0))))) + return emitOpError("failed to verify that operand and result have same element type"); + return ::mlir::success(); +} + +::mlir::LogicalResult ExtractStridedSliceOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult ExtractStridedSliceOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand vectorRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> vectorOperands(vectorRawOperands); ::llvm::SMLoc vectorOperandsLoc; + (void)vectorOperandsLoc; + ::mlir::Type vectorRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> vectorTypes(vectorRawTypes); + ::llvm::SmallVector<::mlir::Type, 1> allResultTypes; + + vectorOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(vectorRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + vectorRawTypes[0] = type; + } + if (parser.parseKeyword("to")) + return ::mlir::failure(); + + if (parser.parseTypeList(allResultTypes)) + return ::mlir::failure(); + result.addTypes(allResultTypes); + if (parser.resolveOperands(vectorOperands, vectorTypes, vectorOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ExtractStridedSliceOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getVector(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getVector().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "to"; + _odsPrinter << ' '; + _odsPrinter << getOperation()->getResultTypes(); +} + +void ExtractStridedSliceOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::ExtractStridedSliceOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::FMAOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +FMAOpGenericAdaptorBase::FMAOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.fma", odsAttrs.getContext()); +} + +FMAOpGenericAdaptorBase::FMAOpGenericAdaptorBase(FMAOp op) : FMAOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair FMAOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr FMAOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +FMAOpAdaptor::FMAOpAdaptor(FMAOp op) : FMAOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult FMAOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair FMAOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range FMAOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> FMAOp::getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> FMAOp::getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(1).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> FMAOp::getAcc() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(2).begin()); +} + +::mlir::OpOperand &FMAOp::getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &FMAOp::getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &FMAOp::getAccMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); +} + +std::pair FMAOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range FMAOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> FMAOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSResults(0).begin()); +} + +void FMAOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Value acc) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addOperands(acc); + odsState.addTypes(result); +} + +void FMAOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Value acc) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addOperands(acc); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(FMAOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void FMAOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Value acc) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.addOperands(acc); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void FMAOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void FMAOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(FMAOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult FMAOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps9(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps9(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps9(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps9(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((((*this->getODSOperands(0).begin()).getType()) == ((*this->getODSOperands(1).begin()).getType()) && ((*this->getODSOperands(1).begin()).getType()) == ((*this->getODSOperands(2).begin()).getType()) && ((*this->getODSOperands(2).begin()).getType()) == ((*this->getODSResults(0).begin()).getType()) && ((*this->getODSResults(0).begin()).getType()) == ((*this->getODSOperands(0).begin()).getType())))) + return emitOpError("failed to verify that all of {lhs, rhs, acc, result} have same type"); + return ::mlir::success(); +} + +::mlir::LogicalResult FMAOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::LogicalResult FMAOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = operands[2].getType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult FMAOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(lhsRawOperands); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(rhsRawOperands); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand accRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> accOperands(accRawOperands); ::llvm::SMLoc accOperandsLoc; + (void)accOperandsLoc; + ::mlir::Type lhsRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(lhsRawTypes); + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + accOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(accRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + lhsRawTypes[0] = type; + } + result.addTypes(lhsTypes[0]); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, lhsTypes[0], rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(accOperands, lhsTypes[0], accOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void FMAOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getAcc(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getLhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void FMAOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::FMAOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::FlatTransposeOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +FlatTransposeOpGenericAdaptorBase::FlatTransposeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.flat_transpose", odsAttrs.getContext()); +} + +FlatTransposeOpGenericAdaptorBase::FlatTransposeOpGenericAdaptorBase(FlatTransposeOp op) : FlatTransposeOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair FlatTransposeOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr FlatTransposeOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::IntegerAttr FlatTransposeOpGenericAdaptorBase::getRowsAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().rows); + return attr; +} + +uint32_t FlatTransposeOpGenericAdaptorBase::getRows() { + auto attr = getRowsAttr(); + return attr.getValue().getZExtValue(); +} + +::mlir::IntegerAttr FlatTransposeOpGenericAdaptorBase::getColumnsAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().columns); + return attr; +} + +uint32_t FlatTransposeOpGenericAdaptorBase::getColumns() { + auto attr = getColumnsAttr(); + return attr.getValue().getZExtValue(); +} + +} // namespace detail +FlatTransposeOpAdaptor::FlatTransposeOpAdaptor(FlatTransposeOp op) : FlatTransposeOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult FlatTransposeOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_columns = getProperties().columns; (void)tblgen_columns; + if (!tblgen_columns) return emitError(loc, "'vector.flat_transpose' op ""requires attribute 'columns'"); + auto tblgen_rows = getProperties().rows; (void)tblgen_rows; + if (!tblgen_rows) return emitError(loc, "'vector.flat_transpose' op ""requires attribute 'rows'"); + + if (tblgen_rows && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_rows))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_rows).getType().isSignlessInteger(32))))) + return emitError(loc, "'vector.flat_transpose' op ""attribute 'rows' failed to satisfy constraint: 32-bit signless integer attribute"); + + if (tblgen_columns && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_columns))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_columns).getType().isSignlessInteger(32))))) + return emitError(loc, "'vector.flat_transpose' op ""attribute 'columns' failed to satisfy constraint: 32-bit signless integer attribute"); + return ::mlir::success(); +} + +std::pair FlatTransposeOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range FlatTransposeOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> FlatTransposeOp::getMatrix() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &FlatTransposeOp::getMatrixMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair FlatTransposeOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range FlatTransposeOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> FlatTransposeOp::getRes() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult FlatTransposeOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.columns; + auto attr = dict.get("columns"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for columns in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `columns` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.rows; + auto attr = dict.get("rows"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for rows in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `rows` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute FlatTransposeOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.columns; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("columns", + propStorage)); + } + + { + const auto &propStorage = prop.rows; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("rows", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code FlatTransposeOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.columns.getAsOpaquePointer()), + llvm::hash_value(prop.rows.getAsOpaquePointer())); +} + +std::optional FlatTransposeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "columns") + return prop.columns; + + if (name == "rows") + return prop.rows; + return std::nullopt; +} + +void FlatTransposeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "columns") { + prop.columns = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "rows") { + prop.rows = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void FlatTransposeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.columns) attrs.append("columns", prop.columns); + + if (prop.rows) attrs.append("rows", prop.rows); +} + +::mlir::LogicalResult FlatTransposeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getColumnsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps5(attr, "columns", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getRowsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps5(attr, "rows", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult FlatTransposeOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.columns))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.rows))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void FlatTransposeOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.columns); + writer.writeAttribute(prop.rows); +} + +::mlir::IntegerAttr FlatTransposeOp::getRowsAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().rows); +} + +uint32_t FlatTransposeOp::getRows() { + auto attr = getRowsAttr(); + return attr.getValue().getZExtValue(); +} + +::mlir::IntegerAttr FlatTransposeOp::getColumnsAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().columns); +} + +uint32_t FlatTransposeOp::getColumns() { + auto attr = getColumnsAttr(); + return attr.getValue().getZExtValue(); +} + +void FlatTransposeOp::setRowsAttr(::mlir::IntegerAttr attr) { + (*this)->setAttr(getRowsAttrName(), attr); +} + +void FlatTransposeOp::setRows(uint32_t attrValue) { + (*this)->setAttr(getRowsAttrName(), ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), attrValue)); +} + +void FlatTransposeOp::setColumnsAttr(::mlir::IntegerAttr attr) { + (*this)->setAttr(getColumnsAttrName(), attr); +} + +void FlatTransposeOp::setColumns(uint32_t attrValue) { + (*this)->setAttr(getColumnsAttrName(), ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), attrValue)); +} + +void FlatTransposeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value matrix, ::mlir::IntegerAttr rows, ::mlir::IntegerAttr columns) { + odsState.addOperands(matrix); + odsState.getOrAddProperties().rows = rows; + odsState.getOrAddProperties().columns = columns; + odsState.addTypes(res); +} + +void FlatTransposeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value matrix, ::mlir::IntegerAttr rows, ::mlir::IntegerAttr columns) { + odsState.addOperands(matrix); + odsState.getOrAddProperties().rows = rows; + odsState.getOrAddProperties().columns = columns; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void FlatTransposeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value matrix, uint32_t rows, uint32_t columns) { + odsState.addOperands(matrix); + odsState.getOrAddProperties().rows = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), rows); + odsState.getOrAddProperties().columns = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), columns); + odsState.addTypes(res); +} + +void FlatTransposeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value matrix, uint32_t rows, uint32_t columns) { + odsState.addOperands(matrix); + odsState.getOrAddProperties().rows = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), rows); + odsState.getOrAddProperties().columns = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), columns); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void FlatTransposeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult FlatTransposeOp::verifyInvariantsImpl() { + auto tblgen_columns = getProperties().columns; (void)tblgen_columns; + if (!tblgen_columns) return emitOpError("requires attribute 'columns'"); + auto tblgen_rows = getProperties().rows; (void)tblgen_rows; + if (!tblgen_rows) return emitOpError("requires attribute 'rows'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps5(*this, tblgen_rows, "rows"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps5(*this, tblgen_columns, "columns"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps10(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps10(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((getElementTypeOrSelf((*this->getOperation()).getResult(0)) == getElementTypeOrSelf((*this->getOperation()).getOperand(0))))) + return emitOpError("failed to verify that source operand and result have same element type"); + return ::mlir::success(); +} + +::mlir::LogicalResult FlatTransposeOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult FlatTransposeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand matrixRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> matrixOperands(matrixRawOperands); ::llvm::SMLoc matrixOperandsLoc; + (void)matrixOperandsLoc; + ::mlir::Type matrixRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> matrixTypes(matrixRawTypes); + ::mlir::Type resRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resTypes(resRawTypes); + + matrixOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(matrixRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + matrixRawTypes[0] = type; + } + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resRawTypes[0] = type; + } + result.addTypes(resTypes); + if (parser.resolveOperands(matrixOperands, matrixTypes, matrixOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void FlatTransposeOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getMatrix(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getMatrix().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getRes().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void FlatTransposeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::FlatTransposeOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::GatherOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +GatherOpGenericAdaptorBase::GatherOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.gather", odsAttrs.getContext()); +} + +GatherOpGenericAdaptorBase::GatherOpGenericAdaptorBase(GatherOp op) : GatherOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair GatherOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, true, false, false, false}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 4) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr GatherOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +GatherOpAdaptor::GatherOpAdaptor(GatherOp op) : GatherOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult GatherOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair GatherOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, true, false, false, false}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 4) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range GatherOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::ShapedType> GatherOp::getBase() { + return ::llvm::cast<::mlir::TypedValue<::mlir::ShapedType>>(*getODSOperands(0).begin()); +} + +::mlir::Operation::operand_range GatherOp::getIndices() { + return getODSOperands(1); +} + +::mlir::TypedValue<::mlir::VectorType> GatherOp::getIndexVec() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(2).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> GatherOp::getMask() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(3).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> GatherOp::getPassThru() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(4).begin()); +} + +::mlir::OpOperand &GatherOp::getBaseMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange GatherOp::getIndicesMutable() { + auto range = getODSOperandIndexAndLength(1); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +::mlir::OpOperand &GatherOp::getIndexVecMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &GatherOp::getMaskMutable() { + auto range = getODSOperandIndexAndLength(3); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &GatherOp::getPassThruMutable() { + auto range = getODSOperandIndexAndLength(4); + return getOperation()->getOpOperand(range.first); +} + +std::pair GatherOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range GatherOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> GatherOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSResults(0).begin()); +} + +void GatherOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value base, ::mlir::ValueRange indices, ::mlir::Value index_vec, ::mlir::Value mask, ::mlir::Value pass_thru) { + odsState.addOperands(base); + odsState.addOperands(indices); + odsState.addOperands(index_vec); + odsState.addOperands(mask); + odsState.addOperands(pass_thru); + odsState.addTypes(result); +} + +void GatherOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value base, ::mlir::ValueRange indices, ::mlir::Value index_vec, ::mlir::Value mask, ::mlir::Value pass_thru) { + odsState.addOperands(base); + odsState.addOperands(indices); + odsState.addOperands(index_vec); + odsState.addOperands(mask); + odsState.addOperands(pass_thru); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void GatherOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 4u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult GatherOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps11(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps12(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup3 = getODSOperands(3); + + for (auto v : valueGroup3) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps13(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup4 = getODSOperands(4); + + for (auto v : valueGroup4) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps7(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps7(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult GatherOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult GatherOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand baseRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> baseOperands(baseRawOperands); ::llvm::SMLoc baseOperandsLoc; + (void)baseOperandsLoc; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> indicesOperands; + ::llvm::SMLoc indicesOperandsLoc; + (void)indicesOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand index_vecRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> index_vecOperands(index_vecRawOperands); ::llvm::SMLoc index_vecOperandsLoc; + (void)index_vecOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand maskRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> maskOperands(maskRawOperands); ::llvm::SMLoc maskOperandsLoc; + (void)maskOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand pass_thruRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> pass_thruOperands(pass_thruRawOperands); ::llvm::SMLoc pass_thruOperandsLoc; + (void)pass_thruOperandsLoc; + ::mlir::Type baseRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> baseTypes(baseRawTypes); + ::mlir::Type index_vecRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> index_vecTypes(index_vecRawTypes); + ::mlir::Type maskRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> maskTypes(maskRawTypes); + ::mlir::Type pass_thruRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> pass_thruTypes(pass_thruRawTypes); + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + baseOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(baseRawOperands[0])) + return ::mlir::failure(); + if (parser.parseLSquare()) + return ::mlir::failure(); + + indicesOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(indicesOperands)) + return ::mlir::failure(); + if (parser.parseRSquare()) + return ::mlir::failure(); + if (parser.parseLSquare()) + return ::mlir::failure(); + + index_vecOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(index_vecRawOperands[0])) + return ::mlir::failure(); + if (parser.parseRSquare()) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + maskOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(maskRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + pass_thruOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(pass_thruRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::ShapedType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + baseRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + index_vecRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + maskRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + pass_thruRawTypes[0] = type; + } + if (parser.parseKeyword("into")) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + result.addTypes(resultTypes); + if (parser.resolveOperands(baseOperands, baseTypes, baseOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(indicesOperands, odsBuildableType0, indicesOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(index_vecOperands, index_vecTypes, index_vecOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(maskOperands, maskTypes, maskOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(pass_thruOperands, pass_thruTypes, pass_thruOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void GatherOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getBase(); + _odsPrinter << "["; + _odsPrinter << getIndices(); + _odsPrinter << "]"; + _odsPrinter << ' ' << "["; + _odsPrinter << getIndexVec(); + _odsPrinter << "]"; + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getMask(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getPassThru(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getBase().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::ShapedType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getIndexVec().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getMask().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getPassThru().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "into"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void GatherOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { + for (::mlir::Value value : getODSOperands(0)) + effects.emplace_back(::mlir::MemoryEffects::Read::get(), value, 0, false, ::mlir::SideEffects::DefaultResource::get()); +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::GatherOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::InsertElementOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +InsertElementOpGenericAdaptorBase::InsertElementOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.insertelement", odsAttrs.getContext()); +} + +InsertElementOpGenericAdaptorBase::InsertElementOpGenericAdaptorBase(InsertElementOp op) : InsertElementOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair InsertElementOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 2) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr InsertElementOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +InsertElementOpAdaptor::InsertElementOpAdaptor(InsertElementOp op) : InsertElementOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult InsertElementOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair InsertElementOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 2) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range InsertElementOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value InsertElementOp::getSource() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> InsertElementOp::getDest() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(1).begin()); +} + +::mlir::Value InsertElementOp::getPosition() { + auto operands = getODSOperands(2); + return operands.empty() ? ::mlir::Value{} : ::llvm::cast<::mlir::Value>(*operands.begin()); +} + +::mlir::OpOperand &InsertElementOp::getSourceMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &InsertElementOp::getDestMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange InsertElementOp::getPositionMutable() { + auto range = getODSOperandIndexAndLength(2); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair InsertElementOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range InsertElementOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> InsertElementOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSResults(0).begin()); +} + +void InsertElementOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::Value position) { + odsState.addOperands(source); + odsState.addOperands(dest); + if (position) + odsState.addOperands(position); + odsState.addTypes(result); +} + +void InsertElementOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::Value position) { + odsState.addOperands(source); + odsState.addOperands(dest); + if (position) + odsState.addOperands(position); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(InsertElementOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void InsertElementOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::Value position) { + odsState.addOperands(source); + odsState.addOperands(dest); + if (position) + odsState.addOperands(position); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void InsertElementOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void InsertElementOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(InsertElementOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult InsertElementOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + if (valueGroup2.size() > 1) { + return emitOpError("operand group starting at #") << index + << " requires 0 or 1 element, but found " << valueGroup2.size(); + } + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((std::equal_to<>()(::llvm::cast((*this->getODSResults(0).begin()).getType()).getElementType(), (*this->getODSOperands(0).begin()).getType())))) + return emitOpError("failed to verify that source operand type matches element type of result"); + if (!((((*this->getODSOperands(1).begin()).getType()) == ((*this->getODSResults(0).begin()).getType()) && ((*this->getODSResults(0).begin()).getType()) == ((*this->getODSOperands(1).begin()).getType())))) + return emitOpError("failed to verify that all of {dest, result} have same type"); + return ::mlir::success(); +} + +::mlir::LogicalResult InsertElementOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::LogicalResult InsertElementOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = operands[1].getType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult InsertElementOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(sourceRawOperands); ::llvm::SMLoc sourceOperandsLoc; + (void)sourceOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand destRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> destOperands(destRawOperands); ::llvm::SMLoc destOperandsLoc; + (void)destOperandsLoc; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> positionOperands; + ::llvm::SMLoc positionOperandsLoc; + (void)positionOperandsLoc; + ::llvm::SmallVector<::mlir::Type, 1> positionTypes; + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + sourceOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(sourceRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + destOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(destRawOperands[0])) + return ::mlir::failure(); + if (parser.parseLSquare()) + return ::mlir::failure(); + + { + positionOperandsLoc = parser.getCurrentLocation(); + ::mlir::OpAsmParser::UnresolvedOperand operand; + ::mlir::OptionalParseResult parseResult = + parser.parseOptionalOperand(operand); + if (parseResult.has_value()) { + if (failed(*parseResult)) + return ::mlir::failure(); + positionOperands.push_back(operand); + } + } + if (!positionOperands.empty()) { + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::Type optionalType; + ::mlir::OptionalParseResult parseResult = + parser.parseOptionalType(optionalType); + if (parseResult.has_value()) { + if (failed(*parseResult)) + return ::mlir::failure(); + positionTypes.push_back(optionalType); + } + } + } + if (parser.parseRSquare()) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + for (::mlir::Type type : resultTypes) { + (void)type; + if (!(((::llvm::isa<::mlir::VectorType>(type))) && ([](::mlir::Type elementType) { return (true); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return parser.emitError(parser.getNameLoc()) << "'result' must be vector of any type values, but got " << type; + } + } + result.addTypes(resultTypes); + if (parser.resolveOperands(sourceOperands, ::llvm::cast(resultTypes[0]).getElementType(), sourceOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(destOperands, resultTypes[0], destOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(positionOperands, positionTypes, positionOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void InsertElementOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getSource(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getDest(); + _odsPrinter << "["; + if (getPosition()) { + if (::mlir::Value value = getPosition()) + _odsPrinter << value; + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter << (getPosition() ? ::llvm::ArrayRef<::mlir::Type>(getPosition().getType()) : ::llvm::ArrayRef<::mlir::Type>()); + } + _odsPrinter << "]"; + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void InsertElementOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::InsertElementOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::InsertOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +InsertOpGenericAdaptorBase::InsertOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.insert", odsAttrs.getContext()); +} + +InsertOpGenericAdaptorBase::InsertOpGenericAdaptorBase(InsertOp op) : InsertOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair InsertOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 2) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr InsertOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::DenseI64ArrayAttr InsertOpGenericAdaptorBase::getStaticPositionAttr() { + auto attr = ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().static_position); + return attr; +} + +::llvm::ArrayRef InsertOpGenericAdaptorBase::getStaticPosition() { + auto attr = getStaticPositionAttr(); + return attr; +} + +} // namespace detail +InsertOpAdaptor::InsertOpAdaptor(InsertOp op) : InsertOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult InsertOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_static_position = getProperties().static_position; (void)tblgen_static_position; + if (!tblgen_static_position) return emitError(loc, "'vector.insert' op ""requires attribute 'static_position'"); + + if (tblgen_static_position && !((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_static_position)))) + return emitError(loc, "'vector.insert' op ""attribute 'static_position' failed to satisfy constraint: i64 dense array attribute"); + return ::mlir::success(); +} + +std::pair InsertOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 2) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range InsertOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value InsertOp::getSource() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> InsertOp::getDest() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(1).begin()); +} + +::mlir::Operation::operand_range InsertOp::getDynamicPosition() { + return getODSOperands(2); +} + +::mlir::OpOperand &InsertOp::getSourceMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &InsertOp::getDestMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange InsertOp::getDynamicPositionMutable() { + auto range = getODSOperandIndexAndLength(2); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair InsertOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range InsertOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> InsertOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult InsertOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.static_position; + auto attr = dict.get("static_position"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for static_position in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `static_position` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute InsertOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.static_position; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("static_position", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code InsertOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.static_position.getAsOpaquePointer())); +} + +std::optional InsertOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "static_position") + return prop.static_position; + return std::nullopt; +} + +void InsertOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "static_position") { + prop.static_position = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void InsertOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.static_position) attrs.append("static_position", prop.static_position); +} + +::mlir::LogicalResult InsertOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getStaticPositionAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps4(attr, "static_position", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult InsertOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.static_position))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void InsertOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.static_position); +} + +::mlir::DenseI64ArrayAttr InsertOp::getStaticPositionAttr() { + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(getProperties().static_position); +} + +::llvm::ArrayRef InsertOp::getStaticPosition() { + auto attr = getStaticPositionAttr(); + return attr; +} + +void InsertOp::setStaticPositionAttr(::mlir::DenseI64ArrayAttr attr) { + (*this)->setAttr(getStaticPositionAttrName(), attr); +} + +void InsertOp::setStaticPosition(::llvm::ArrayRef attrValue) { + (*this)->setAttr(getStaticPositionAttrName(), ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue)); +} + +void InsertOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::Value dest, ::mlir::ValueRange dynamic_position, ::mlir::DenseI64ArrayAttr static_position) { + odsState.addOperands(source); + odsState.addOperands(dest); + odsState.addOperands(dynamic_position); + odsState.getOrAddProperties().static_position = static_position; + odsState.addTypes(result); +} + +void InsertOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value source, ::mlir::Value dest, ::mlir::ValueRange dynamic_position, ::mlir::DenseI64ArrayAttr static_position) { + odsState.addOperands(source); + odsState.addOperands(dest); + odsState.addOperands(dynamic_position); + odsState.getOrAddProperties().static_position = static_position; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(InsertOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void InsertOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, ::mlir::ValueRange dynamic_position, ::mlir::DenseI64ArrayAttr static_position) { + odsState.addOperands(source); + odsState.addOperands(dest); + odsState.addOperands(dynamic_position); + odsState.getOrAddProperties().static_position = static_position; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void InsertOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::Value dest, ::mlir::ValueRange dynamic_position, ::llvm::ArrayRef static_position) { + odsState.addOperands(source); + odsState.addOperands(dest); + odsState.addOperands(dynamic_position); + odsState.getOrAddProperties().static_position = odsBuilder.getDenseI64ArrayAttr(static_position); + odsState.addTypes(result); +} + +void InsertOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value source, ::mlir::Value dest, ::mlir::ValueRange dynamic_position, ::llvm::ArrayRef static_position) { + odsState.addOperands(source); + odsState.addOperands(dest); + odsState.addOperands(dynamic_position); + odsState.getOrAddProperties().static_position = odsBuilder.getDenseI64ArrayAttr(static_position); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(InsertOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void InsertOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, ::mlir::ValueRange dynamic_position, ::llvm::ArrayRef static_position) { + odsState.addOperands(source); + odsState.addOperands(dest); + odsState.addOperands(dynamic_position); + odsState.getOrAddProperties().static_position = odsBuilder.getDenseI64ArrayAttr(static_position); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void InsertOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void InsertOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(InsertOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult InsertOp::verifyInvariantsImpl() { + auto tblgen_static_position = getProperties().static_position; (void)tblgen_static_position; + if (!tblgen_static_position) return emitOpError("requires attribute 'static_position'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps4(*this, tblgen_static_position, "static_position"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((getElementTypeOrSelf((*this->getOperation()).getResult(0)) == getElementTypeOrSelf((*this->getOperation()).getOperand(0))))) + return emitOpError("failed to verify that source operand and result have same element type"); + if (!((((*this->getODSOperands(1).begin()).getType()) == ((*this->getODSResults(0).begin()).getType()) && ((*this->getODSResults(0).begin()).getType()) == ((*this->getODSOperands(1).begin()).getType())))) + return emitOpError("failed to verify that all of {dest, result} have same type"); + return ::mlir::success(); +} + +::mlir::LogicalResult InsertOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::LogicalResult InsertOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = operands[1].getType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult InsertOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(sourceRawOperands); ::llvm::SMLoc sourceOperandsLoc; + (void)sourceOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand destRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> destOperands(destRawOperands); ::llvm::SMLoc destOperandsLoc; + (void)destOperandsLoc; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> dynamic_positionOperands; + ::llvm::SMLoc dynamic_positionOperandsLoc; + (void)dynamic_positionOperandsLoc; + ::mlir::DenseI64ArrayAttr static_positionAttr; + ::mlir::Type sourceRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> sourceTypes(sourceRawTypes); + ::mlir::Type destRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> destTypes(destRawTypes); + + sourceOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(sourceRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + destOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(destRawOperands[0])) + return ::mlir::failure(); + { + dynamic_positionOperandsLoc = parser.getCurrentLocation(); + auto odsResult = parseDynamicIndexList(parser, dynamic_positionOperands, static_positionAttr); + if (odsResult) return ::mlir::failure(); + result.getOrAddProperties().static_position = static_positionAttr; + } + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + sourceRawTypes[0] = type; + } + if (parser.parseKeyword("into")) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + destRawTypes[0] = type; + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + result.addTypes(destTypes[0]); + if (parser.resolveOperands(sourceOperands, sourceTypes, sourceOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(destOperands, destTypes, destOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(dynamic_positionOperands, odsBuildableType0, dynamic_positionOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void InsertOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getSource(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getDest(); + _odsPrinter << ' '; + printDynamicIndexList(_odsPrinter, *this, getDynamicPosition(), getStaticPositionAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("static_position"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getSource().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "into"; + _odsPrinter << ' '; + { + auto type = getDest().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void InsertOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::InsertOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::InsertStridedSliceOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +InsertStridedSliceOpGenericAdaptorBase::InsertStridedSliceOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.insert_strided_slice", odsAttrs.getContext()); +} + +InsertStridedSliceOpGenericAdaptorBase::InsertStridedSliceOpGenericAdaptorBase(InsertStridedSliceOp op) : InsertStridedSliceOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair InsertStridedSliceOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr InsertStridedSliceOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::ArrayAttr InsertStridedSliceOpGenericAdaptorBase::getOffsetsAttr() { + auto attr = ::llvm::cast<::mlir::ArrayAttr>(getProperties().offsets); + return attr; +} + +::mlir::ArrayAttr InsertStridedSliceOpGenericAdaptorBase::getOffsets() { + auto attr = getOffsetsAttr(); + return attr; +} + +::mlir::ArrayAttr InsertStridedSliceOpGenericAdaptorBase::getStridesAttr() { + auto attr = ::llvm::cast<::mlir::ArrayAttr>(getProperties().strides); + return attr; +} + +::mlir::ArrayAttr InsertStridedSliceOpGenericAdaptorBase::getStrides() { + auto attr = getStridesAttr(); + return attr; +} + +} // namespace detail +InsertStridedSliceOpAdaptor::InsertStridedSliceOpAdaptor(InsertStridedSliceOp op) : InsertStridedSliceOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult InsertStridedSliceOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_offsets = getProperties().offsets; (void)tblgen_offsets; + if (!tblgen_offsets) return emitError(loc, "'vector.insert_strided_slice' op ""requires attribute 'offsets'"); + auto tblgen_strides = getProperties().strides; (void)tblgen_strides; + if (!tblgen_strides) return emitError(loc, "'vector.insert_strided_slice' op ""requires attribute 'strides'"); + + if (tblgen_offsets && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_offsets))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_offsets), [&](::mlir::Attribute attr) { return attr && (((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(64)))); })))) + return emitError(loc, "'vector.insert_strided_slice' op ""attribute 'offsets' failed to satisfy constraint: 64-bit integer array attribute"); + + if (tblgen_strides && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_strides))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_strides), [&](::mlir::Attribute attr) { return attr && (((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(64)))); })))) + return emitError(loc, "'vector.insert_strided_slice' op ""attribute 'strides' failed to satisfy constraint: 64-bit integer array attribute"); + return ::mlir::success(); +} + +std::pair InsertStridedSliceOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range InsertStridedSliceOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> InsertStridedSliceOp::getSource() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> InsertStridedSliceOp::getDest() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(1).begin()); +} + +::mlir::OpOperand &InsertStridedSliceOp::getSourceMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &InsertStridedSliceOp::getDestMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +std::pair InsertStridedSliceOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range InsertStridedSliceOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> InsertStridedSliceOp::getRes() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult InsertStridedSliceOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.offsets; + auto attr = dict.get("offsets"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for offsets in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `offsets` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.strides; + auto attr = dict.get("strides"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for strides in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `strides` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute InsertStridedSliceOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.offsets; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("offsets", + propStorage)); + } + + { + const auto &propStorage = prop.strides; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("strides", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code InsertStridedSliceOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.offsets.getAsOpaquePointer()), + llvm::hash_value(prop.strides.getAsOpaquePointer())); +} + +std::optional InsertStridedSliceOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "offsets") + return prop.offsets; + + if (name == "strides") + return prop.strides; + return std::nullopt; +} + +void InsertStridedSliceOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "offsets") { + prop.offsets = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "strides") { + prop.strides = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void InsertStridedSliceOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.offsets) attrs.append("offsets", prop.offsets); + + if (prop.strides) attrs.append("strides", prop.strides); +} + +::mlir::LogicalResult InsertStridedSliceOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getOffsetsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps0(attr, "offsets", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getStridesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps0(attr, "strides", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult InsertStridedSliceOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.offsets))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.strides))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void InsertStridedSliceOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.offsets); + writer.writeAttribute(prop.strides); +} + +::mlir::ArrayAttr InsertStridedSliceOp::getOffsetsAttr() { + return ::llvm::cast<::mlir::ArrayAttr>(getProperties().offsets); +} + +::mlir::ArrayAttr InsertStridedSliceOp::getOffsets() { + auto attr = getOffsetsAttr(); + return attr; +} + +::mlir::ArrayAttr InsertStridedSliceOp::getStridesAttr() { + return ::llvm::cast<::mlir::ArrayAttr>(getProperties().strides); +} + +::mlir::ArrayAttr InsertStridedSliceOp::getStrides() { + auto attr = getStridesAttr(); + return attr; +} + +void InsertStridedSliceOp::setOffsetsAttr(::mlir::ArrayAttr attr) { + (*this)->setAttr(getOffsetsAttrName(), attr); +} + +void InsertStridedSliceOp::setStridesAttr(::mlir::ArrayAttr attr) { + (*this)->setAttr(getStridesAttrName(), attr); +} + +void InsertStridedSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value source, ::mlir::Value dest, ::mlir::ArrayAttr offsets, ::mlir::ArrayAttr strides) { + odsState.addOperands(source); + odsState.addOperands(dest); + odsState.getOrAddProperties().offsets = offsets; + odsState.getOrAddProperties().strides = strides; + odsState.addTypes(res); +} + +void InsertStridedSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value source, ::mlir::Value dest, ::mlir::ArrayAttr offsets, ::mlir::ArrayAttr strides) { + odsState.addOperands(source); + odsState.addOperands(dest); + odsState.getOrAddProperties().offsets = offsets; + odsState.getOrAddProperties().strides = strides; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(InsertStridedSliceOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void InsertStridedSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, ::mlir::ArrayAttr offsets, ::mlir::ArrayAttr strides) { + odsState.addOperands(source); + odsState.addOperands(dest); + odsState.getOrAddProperties().offsets = offsets; + odsState.getOrAddProperties().strides = strides; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void InsertStridedSliceOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void InsertStridedSliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(InsertStridedSliceOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult InsertStridedSliceOp::verifyInvariantsImpl() { + auto tblgen_offsets = getProperties().offsets; (void)tblgen_offsets; + if (!tblgen_offsets) return emitOpError("requires attribute 'offsets'"); + auto tblgen_strides = getProperties().strides; (void)tblgen_strides; + if (!tblgen_strides) return emitOpError("requires attribute 'strides'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps0(*this, tblgen_offsets, "offsets"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps0(*this, tblgen_strides, "strides"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps7(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps7(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps7(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((getElementTypeOrSelf((*this->getOperation()).getResult(0)) == getElementTypeOrSelf((*this->getOperation()).getOperand(0))))) + return emitOpError("failed to verify that operand #0 and result have same element type"); + if (!((((*this->getODSOperands(1).begin()).getType()) == ((*this->getODSResults(0).begin()).getType()) && ((*this->getODSResults(0).begin()).getType()) == ((*this->getODSOperands(1).begin()).getType())))) + return emitOpError("failed to verify that all of {dest, res} have same type"); + return ::mlir::success(); +} + +::mlir::LogicalResult InsertStridedSliceOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::LogicalResult InsertStridedSliceOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = operands[1].getType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult InsertStridedSliceOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(sourceRawOperands); ::llvm::SMLoc sourceOperandsLoc; + (void)sourceOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand destRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> destOperands(destRawOperands); ::llvm::SMLoc destOperandsLoc; + (void)destOperandsLoc; + ::mlir::Type sourceRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> sourceTypes(sourceRawTypes); + ::mlir::Type destRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> destTypes(destRawTypes); + + sourceOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(sourceRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + destOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(destRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + sourceRawTypes[0] = type; + } + if (parser.parseKeyword("into")) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + destRawTypes[0] = type; + } + result.addTypes(destTypes[0]); + if (parser.resolveOperands(sourceOperands, sourceTypes, sourceOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(destOperands, destTypes, destOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void InsertStridedSliceOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getSource(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getDest(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getSource().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "into"; + _odsPrinter << ' '; + { + auto type = getDest().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void InsertStridedSliceOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::InsertStridedSliceOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::LoadOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +LoadOpGenericAdaptorBase::LoadOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.load", odsAttrs.getContext()); +} + +LoadOpGenericAdaptorBase::LoadOpGenericAdaptorBase(LoadOp op) : LoadOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair LoadOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr LoadOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +LoadOpAdaptor::LoadOpAdaptor(LoadOp op) : LoadOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult LoadOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair LoadOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range LoadOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::MemRefType> LoadOp::getBase() { + return ::llvm::cast<::mlir::TypedValue<::mlir::MemRefType>>(*getODSOperands(0).begin()); +} + +::mlir::Operation::operand_range LoadOp::getIndices() { + return getODSOperands(1); +} + +::mlir::OpOperand &LoadOp::getBaseMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange LoadOp::getIndicesMutable() { + auto range = getODSOperandIndexAndLength(1); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair LoadOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range LoadOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> LoadOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSResults(0).begin()); +} + +void LoadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value base, ::mlir::ValueRange indices) { + odsState.addOperands(base); + odsState.addOperands(indices); + odsState.addTypes(result); +} + +void LoadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value base, ::mlir::ValueRange indices) { + odsState.addOperands(base); + odsState.addOperands(indices); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void LoadOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult LoadOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps7(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult LoadOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult LoadOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand baseRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> baseOperands(baseRawOperands); ::llvm::SMLoc baseOperandsLoc; + (void)baseOperandsLoc; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> indicesOperands; + ::llvm::SMLoc indicesOperandsLoc; + (void)indicesOperandsLoc; + ::mlir::Type baseRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> baseTypes(baseRawTypes); + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + baseOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(baseRawOperands[0])) + return ::mlir::failure(); + if (parser.parseLSquare()) + return ::mlir::failure(); + + indicesOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(indicesOperands)) + return ::mlir::failure(); + if (parser.parseRSquare()) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::MemRefType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + baseRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + result.addTypes(resultTypes); + if (parser.resolveOperands(baseOperands, baseTypes, baseOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(indicesOperands, odsBuildableType0, indicesOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void LoadOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getBase(); + _odsPrinter << "["; + _odsPrinter << getIndices(); + _odsPrinter << "]"; + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getBase().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::MemRefType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void LoadOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { + for (::mlir::Value value : getODSOperands(0)) + effects.emplace_back(::mlir::MemoryEffects::Read::get(), value, 0, false, ::mlir::SideEffects::DefaultResource::get()); +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::LoadOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::MaskOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +MaskOpGenericAdaptorBase::MaskOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.mask", odsAttrs.getContext()); +} + +MaskOpGenericAdaptorBase::MaskOpGenericAdaptorBase(MaskOp op) : MaskOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair MaskOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr MaskOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::Region &MaskOpGenericAdaptorBase::getMaskRegion() { + return *odsRegions[0]; +} + +::mlir::RegionRange MaskOpGenericAdaptorBase::getRegions() { + return odsRegions; +} + +} // namespace detail +MaskOpAdaptor::MaskOpAdaptor(MaskOp op) : MaskOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult MaskOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair MaskOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range MaskOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> MaskOp::getMask() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::Value MaskOp::getPassthru() { + auto operands = getODSOperands(1); + return operands.empty() ? ::mlir::Value{} : ::llvm::cast<::mlir::Value>(*operands.begin()); +} + +::mlir::OpOperand &MaskOp::getMaskMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange MaskOp::getPassthruMutable() { + auto range = getODSOperandIndexAndLength(1); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair MaskOp::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::result_range MaskOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::result_range MaskOp::getResults() { + return getODSResults(0); +} + +::mlir::Region &MaskOp::getMaskRegion() { + return (*this)->getRegion(0); +} + +::mlir::LogicalResult MaskOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps13(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + if (valueGroup1.size() > 1) { + return emitOpError("operand group starting at #") << index + << " requires 0 or 1 element, but found " << valueGroup1.size(); + } + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_VectorOps0(*this, region, "maskRegion", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult MaskOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::MaskOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::MaskedLoadOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +MaskedLoadOpGenericAdaptorBase::MaskedLoadOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.maskedload", odsAttrs.getContext()); +} + +MaskedLoadOpGenericAdaptorBase::MaskedLoadOpGenericAdaptorBase(MaskedLoadOp op) : MaskedLoadOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair MaskedLoadOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, true, false, false}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 3) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr MaskedLoadOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +MaskedLoadOpAdaptor::MaskedLoadOpAdaptor(MaskedLoadOp op) : MaskedLoadOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult MaskedLoadOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair MaskedLoadOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, true, false, false}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 3) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range MaskedLoadOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::MemRefType> MaskedLoadOp::getBase() { + return ::llvm::cast<::mlir::TypedValue<::mlir::MemRefType>>(*getODSOperands(0).begin()); +} + +::mlir::Operation::operand_range MaskedLoadOp::getIndices() { + return getODSOperands(1); +} + +::mlir::TypedValue<::mlir::VectorType> MaskedLoadOp::getMask() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(2).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> MaskedLoadOp::getPassThru() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(3).begin()); +} + +::mlir::OpOperand &MaskedLoadOp::getBaseMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange MaskedLoadOp::getIndicesMutable() { + auto range = getODSOperandIndexAndLength(1); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +::mlir::OpOperand &MaskedLoadOp::getMaskMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MaskedLoadOp::getPassThruMutable() { + auto range = getODSOperandIndexAndLength(3); + return getOperation()->getOpOperand(range.first); +} + +std::pair MaskedLoadOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range MaskedLoadOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> MaskedLoadOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSResults(0).begin()); +} + +void MaskedLoadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value base, ::mlir::ValueRange indices, ::mlir::Value mask, ::mlir::Value pass_thru) { + odsState.addOperands(base); + odsState.addOperands(indices); + odsState.addOperands(mask); + odsState.addOperands(pass_thru); + odsState.addTypes(result); +} + +void MaskedLoadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value base, ::mlir::ValueRange indices, ::mlir::Value mask, ::mlir::Value pass_thru) { + odsState.addOperands(base); + odsState.addOperands(indices); + odsState.addOperands(mask); + odsState.addOperands(pass_thru); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void MaskedLoadOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult MaskedLoadOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps4(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup3 = getODSOperands(3); + + for (auto v : valueGroup3) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps5(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps5(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult MaskedLoadOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult MaskedLoadOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand baseRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> baseOperands(baseRawOperands); ::llvm::SMLoc baseOperandsLoc; + (void)baseOperandsLoc; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> indicesOperands; + ::llvm::SMLoc indicesOperandsLoc; + (void)indicesOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand maskRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> maskOperands(maskRawOperands); ::llvm::SMLoc maskOperandsLoc; + (void)maskOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand pass_thruRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> pass_thruOperands(pass_thruRawOperands); ::llvm::SMLoc pass_thruOperandsLoc; + (void)pass_thruOperandsLoc; + ::mlir::Type baseRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> baseTypes(baseRawTypes); + ::mlir::Type maskRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> maskTypes(maskRawTypes); + ::mlir::Type pass_thruRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> pass_thruTypes(pass_thruRawTypes); + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + baseOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(baseRawOperands[0])) + return ::mlir::failure(); + if (parser.parseLSquare()) + return ::mlir::failure(); + + indicesOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(indicesOperands)) + return ::mlir::failure(); + if (parser.parseRSquare()) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + maskOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(maskRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + pass_thruOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(pass_thruRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::MemRefType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + baseRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + maskRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + pass_thruRawTypes[0] = type; + } + if (parser.parseKeyword("into")) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + result.addTypes(resultTypes); + if (parser.resolveOperands(baseOperands, baseTypes, baseOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(indicesOperands, odsBuildableType0, indicesOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(maskOperands, maskTypes, maskOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(pass_thruOperands, pass_thruTypes, pass_thruOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void MaskedLoadOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getBase(); + _odsPrinter << "["; + _odsPrinter << getIndices(); + _odsPrinter << "]"; + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getMask(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getPassThru(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getBase().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::MemRefType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getMask().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getPassThru().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "into"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void MaskedLoadOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { + for (::mlir::Value value : getODSOperands(0)) + effects.emplace_back(::mlir::MemoryEffects::Read::get(), value, 0, false, ::mlir::SideEffects::DefaultResource::get()); +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::MaskedLoadOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::MaskedStoreOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +MaskedStoreOpGenericAdaptorBase::MaskedStoreOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.maskedstore", odsAttrs.getContext()); +} + +MaskedStoreOpGenericAdaptorBase::MaskedStoreOpGenericAdaptorBase(MaskedStoreOp op) : MaskedStoreOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair MaskedStoreOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, true, false, false}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 3) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr MaskedStoreOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +MaskedStoreOpAdaptor::MaskedStoreOpAdaptor(MaskedStoreOp op) : MaskedStoreOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult MaskedStoreOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair MaskedStoreOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, true, false, false}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 3) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range MaskedStoreOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::MemRefType> MaskedStoreOp::getBase() { + return ::llvm::cast<::mlir::TypedValue<::mlir::MemRefType>>(*getODSOperands(0).begin()); +} + +::mlir::Operation::operand_range MaskedStoreOp::getIndices() { + return getODSOperands(1); +} + +::mlir::TypedValue<::mlir::VectorType> MaskedStoreOp::getMask() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(2).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> MaskedStoreOp::getValueToStore() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(3).begin()); +} + +::mlir::OpOperand &MaskedStoreOp::getBaseMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange MaskedStoreOp::getIndicesMutable() { + auto range = getODSOperandIndexAndLength(1); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +::mlir::OpOperand &MaskedStoreOp::getMaskMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MaskedStoreOp::getValueToStoreMutable() { + auto range = getODSOperandIndexAndLength(3); + return getOperation()->getOpOperand(range.first); +} + +std::pair MaskedStoreOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range MaskedStoreOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +void MaskedStoreOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value base, ::mlir::ValueRange indices, ::mlir::Value mask, ::mlir::Value valueToStore) { + odsState.addOperands(base); + odsState.addOperands(indices); + odsState.addOperands(mask); + odsState.addOperands(valueToStore); +} + +void MaskedStoreOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value base, ::mlir::ValueRange indices, ::mlir::Value mask, ::mlir::Value valueToStore) { + odsState.addOperands(base); + odsState.addOperands(indices); + odsState.addOperands(mask); + odsState.addOperands(valueToStore); + assert(resultTypes.size() == 0u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void MaskedStoreOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult MaskedStoreOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps4(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup3 = getODSOperands(3); + + for (auto v : valueGroup3) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps5(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult MaskedStoreOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult MaskedStoreOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand baseRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> baseOperands(baseRawOperands); ::llvm::SMLoc baseOperandsLoc; + (void)baseOperandsLoc; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> indicesOperands; + ::llvm::SMLoc indicesOperandsLoc; + (void)indicesOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand maskRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> maskOperands(maskRawOperands); ::llvm::SMLoc maskOperandsLoc; + (void)maskOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand valueToStoreRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> valueToStoreOperands(valueToStoreRawOperands); ::llvm::SMLoc valueToStoreOperandsLoc; + (void)valueToStoreOperandsLoc; + ::mlir::Type baseRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> baseTypes(baseRawTypes); + ::mlir::Type maskRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> maskTypes(maskRawTypes); + ::mlir::Type valueToStoreRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> valueToStoreTypes(valueToStoreRawTypes); + + baseOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(baseRawOperands[0])) + return ::mlir::failure(); + if (parser.parseLSquare()) + return ::mlir::failure(); + + indicesOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(indicesOperands)) + return ::mlir::failure(); + if (parser.parseRSquare()) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + maskOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(maskRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + valueToStoreOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(valueToStoreRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::MemRefType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + baseRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + maskRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + valueToStoreRawTypes[0] = type; + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + if (parser.resolveOperands(baseOperands, baseTypes, baseOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(indicesOperands, odsBuildableType0, indicesOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(maskOperands, maskTypes, maskOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(valueToStoreOperands, valueToStoreTypes, valueToStoreOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void MaskedStoreOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getBase(); + _odsPrinter << "["; + _odsPrinter << getIndices(); + _odsPrinter << "]"; + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getMask(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getValueToStore(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getBase().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::MemRefType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getMask().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getValueToStore().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void MaskedStoreOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { + for (::mlir::Value value : getODSOperands(0)) + effects.emplace_back(::mlir::MemoryEffects::Write::get(), value, 0, false, ::mlir::SideEffects::DefaultResource::get()); +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::MaskedStoreOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::MatmulOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +MatmulOpGenericAdaptorBase::MatmulOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.matrix_multiply", odsAttrs.getContext()); +} + +MatmulOpGenericAdaptorBase::MatmulOpGenericAdaptorBase(MatmulOp op) : MatmulOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair MatmulOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr MatmulOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::IntegerAttr MatmulOpGenericAdaptorBase::getLhsRowsAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().lhs_rows); + return attr; +} + +uint32_t MatmulOpGenericAdaptorBase::getLhsRows() { + auto attr = getLhsRowsAttr(); + return attr.getValue().getZExtValue(); +} + +::mlir::IntegerAttr MatmulOpGenericAdaptorBase::getLhsColumnsAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().lhs_columns); + return attr; +} + +uint32_t MatmulOpGenericAdaptorBase::getLhsColumns() { + auto attr = getLhsColumnsAttr(); + return attr.getValue().getZExtValue(); +} + +::mlir::IntegerAttr MatmulOpGenericAdaptorBase::getRhsColumnsAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().rhs_columns); + return attr; +} + +uint32_t MatmulOpGenericAdaptorBase::getRhsColumns() { + auto attr = getRhsColumnsAttr(); + return attr.getValue().getZExtValue(); +} + +} // namespace detail +MatmulOpAdaptor::MatmulOpAdaptor(MatmulOp op) : MatmulOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult MatmulOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_lhs_columns = getProperties().lhs_columns; (void)tblgen_lhs_columns; + if (!tblgen_lhs_columns) return emitError(loc, "'vector.matrix_multiply' op ""requires attribute 'lhs_columns'"); + auto tblgen_lhs_rows = getProperties().lhs_rows; (void)tblgen_lhs_rows; + if (!tblgen_lhs_rows) return emitError(loc, "'vector.matrix_multiply' op ""requires attribute 'lhs_rows'"); + auto tblgen_rhs_columns = getProperties().rhs_columns; (void)tblgen_rhs_columns; + if (!tblgen_rhs_columns) return emitError(loc, "'vector.matrix_multiply' op ""requires attribute 'rhs_columns'"); + + if (tblgen_lhs_rows && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_lhs_rows))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_lhs_rows).getType().isSignlessInteger(32))))) + return emitError(loc, "'vector.matrix_multiply' op ""attribute 'lhs_rows' failed to satisfy constraint: 32-bit signless integer attribute"); + + if (tblgen_lhs_columns && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_lhs_columns))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_lhs_columns).getType().isSignlessInteger(32))))) + return emitError(loc, "'vector.matrix_multiply' op ""attribute 'lhs_columns' failed to satisfy constraint: 32-bit signless integer attribute"); + + if (tblgen_rhs_columns && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_rhs_columns))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_rhs_columns).getType().isSignlessInteger(32))))) + return emitError(loc, "'vector.matrix_multiply' op ""attribute 'rhs_columns' failed to satisfy constraint: 32-bit signless integer attribute"); + return ::mlir::success(); +} + +std::pair MatmulOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range MatmulOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> MatmulOp::getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> MatmulOp::getRhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(1).begin()); +} + +::mlir::OpOperand &MatmulOp::getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MatmulOp::getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +std::pair MatmulOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range MatmulOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> MatmulOp::getRes() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult MatmulOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.lhs_columns; + auto attr = dict.get("lhs_columns"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for lhs_columns in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `lhs_columns` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.lhs_rows; + auto attr = dict.get("lhs_rows"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for lhs_rows in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `lhs_rows` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.rhs_columns; + auto attr = dict.get("rhs_columns"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for rhs_columns in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `rhs_columns` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute MatmulOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.lhs_columns; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("lhs_columns", + propStorage)); + } + + { + const auto &propStorage = prop.lhs_rows; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("lhs_rows", + propStorage)); + } + + { + const auto &propStorage = prop.rhs_columns; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("rhs_columns", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code MatmulOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.lhs_columns.getAsOpaquePointer()), + llvm::hash_value(prop.lhs_rows.getAsOpaquePointer()), + llvm::hash_value(prop.rhs_columns.getAsOpaquePointer())); +} + +std::optional MatmulOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "lhs_columns") + return prop.lhs_columns; + + if (name == "lhs_rows") + return prop.lhs_rows; + + if (name == "rhs_columns") + return prop.rhs_columns; + return std::nullopt; +} + +void MatmulOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "lhs_columns") { + prop.lhs_columns = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "lhs_rows") { + prop.lhs_rows = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "rhs_columns") { + prop.rhs_columns = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void MatmulOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.lhs_columns) attrs.append("lhs_columns", prop.lhs_columns); + + if (prop.lhs_rows) attrs.append("lhs_rows", prop.lhs_rows); + + if (prop.rhs_columns) attrs.append("rhs_columns", prop.rhs_columns); +} + +::mlir::LogicalResult MatmulOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getLhsColumnsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps5(attr, "lhs_columns", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getLhsRowsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps5(attr, "lhs_rows", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getRhsColumnsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps5(attr, "rhs_columns", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult MatmulOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.lhs_columns))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.lhs_rows))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.rhs_columns))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void MatmulOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.lhs_columns); + writer.writeAttribute(prop.lhs_rows); + writer.writeAttribute(prop.rhs_columns); +} + +::mlir::IntegerAttr MatmulOp::getLhsRowsAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().lhs_rows); +} + +uint32_t MatmulOp::getLhsRows() { + auto attr = getLhsRowsAttr(); + return attr.getValue().getZExtValue(); +} + +::mlir::IntegerAttr MatmulOp::getLhsColumnsAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().lhs_columns); +} + +uint32_t MatmulOp::getLhsColumns() { + auto attr = getLhsColumnsAttr(); + return attr.getValue().getZExtValue(); +} + +::mlir::IntegerAttr MatmulOp::getRhsColumnsAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().rhs_columns); +} + +uint32_t MatmulOp::getRhsColumns() { + auto attr = getRhsColumnsAttr(); + return attr.getValue().getZExtValue(); +} + +void MatmulOp::setLhsRowsAttr(::mlir::IntegerAttr attr) { + (*this)->setAttr(getLhsRowsAttrName(), attr); +} + +void MatmulOp::setLhsRows(uint32_t attrValue) { + (*this)->setAttr(getLhsRowsAttrName(), ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), attrValue)); +} + +void MatmulOp::setLhsColumnsAttr(::mlir::IntegerAttr attr) { + (*this)->setAttr(getLhsColumnsAttrName(), attr); +} + +void MatmulOp::setLhsColumns(uint32_t attrValue) { + (*this)->setAttr(getLhsColumnsAttrName(), ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), attrValue)); +} + +void MatmulOp::setRhsColumnsAttr(::mlir::IntegerAttr attr) { + (*this)->setAttr(getRhsColumnsAttrName(), attr); +} + +void MatmulOp::setRhsColumns(uint32_t attrValue) { + (*this)->setAttr(getRhsColumnsAttrName(), ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), attrValue)); +} + +void MatmulOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value lhs, Value rhs, unsigned lhsRows, unsigned lhsColumns, unsigned rhsColumns) { + odsState.addOperands({lhs, rhs}); + odsState.addAttribute("lhs_rows",odsBuilder.getI32IntegerAttr(lhsRows)); + odsState.addAttribute("lhs_columns",odsBuilder.getI32IntegerAttr(lhsColumns)); + odsState.addAttribute("rhs_columns",odsBuilder.getI32IntegerAttr(rhsColumns)); + odsState.addTypes(VectorType::get(lhsRows * rhsColumns, + ::llvm::cast(lhs.getType()).getElementType())); + +} + +void MatmulOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::IntegerAttr lhs_rows, ::mlir::IntegerAttr lhs_columns, ::mlir::IntegerAttr rhs_columns) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.getOrAddProperties().lhs_rows = lhs_rows; + odsState.getOrAddProperties().lhs_columns = lhs_columns; + odsState.getOrAddProperties().rhs_columns = rhs_columns; + odsState.addTypes(res); +} + +void MatmulOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::IntegerAttr lhs_rows, ::mlir::IntegerAttr lhs_columns, ::mlir::IntegerAttr rhs_columns) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.getOrAddProperties().lhs_rows = lhs_rows; + odsState.getOrAddProperties().lhs_columns = lhs_columns; + odsState.getOrAddProperties().rhs_columns = rhs_columns; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void MatmulOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value lhs, ::mlir::Value rhs, uint32_t lhs_rows, uint32_t lhs_columns, uint32_t rhs_columns) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.getOrAddProperties().lhs_rows = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), lhs_rows); + odsState.getOrAddProperties().lhs_columns = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), lhs_columns); + odsState.getOrAddProperties().rhs_columns = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), rhs_columns); + odsState.addTypes(res); +} + +void MatmulOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, uint32_t lhs_rows, uint32_t lhs_columns, uint32_t rhs_columns) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + odsState.getOrAddProperties().lhs_rows = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), lhs_rows); + odsState.getOrAddProperties().lhs_columns = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), lhs_columns); + odsState.getOrAddProperties().rhs_columns = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), rhs_columns); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void MatmulOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult MatmulOp::verifyInvariantsImpl() { + auto tblgen_lhs_columns = getProperties().lhs_columns; (void)tblgen_lhs_columns; + if (!tblgen_lhs_columns) return emitOpError("requires attribute 'lhs_columns'"); + auto tblgen_lhs_rows = getProperties().lhs_rows; (void)tblgen_lhs_rows; + if (!tblgen_lhs_rows) return emitOpError("requires attribute 'lhs_rows'"); + auto tblgen_rhs_columns = getProperties().rhs_columns; (void)tblgen_rhs_columns; + if (!tblgen_rhs_columns) return emitOpError("requires attribute 'rhs_columns'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps5(*this, tblgen_lhs_rows, "lhs_rows"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps5(*this, tblgen_lhs_columns, "lhs_columns"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps5(*this, tblgen_rhs_columns, "rhs_columns"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps10(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps10(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps10(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((getElementTypeOrSelf((*this->getOperation()).getResult(0)) == getElementTypeOrSelf((*this->getOperation()).getOperand(0))))) + return emitOpError("failed to verify that lhs operand and result have same element type"); + if (!((getElementTypeOrSelf((*this->getOperation()).getResult(0)) == getElementTypeOrSelf((*this->getOperation()).getOperand(1))))) + return emitOpError("failed to verify that rhs operand and result have same element type"); + return ::mlir::success(); +} + +::mlir::LogicalResult MatmulOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult MatmulOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand lhsRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> lhsOperands(lhsRawOperands); ::llvm::SMLoc lhsOperandsLoc; + (void)lhsOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand rhsRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> rhsOperands(rhsRawOperands); ::llvm::SMLoc rhsOperandsLoc; + (void)rhsOperandsLoc; + ::mlir::Type lhsRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> lhsTypes(lhsRawTypes); + ::mlir::Type rhsRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> rhsTypes(rhsRawTypes); + ::mlir::Type resRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resTypes(resRawTypes); + + lhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(lhsRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + rhsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(rhsRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + if (parser.parseLParen()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + lhsRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + rhsRawTypes[0] = type; + } + if (parser.parseRParen()) + return ::mlir::failure(); + if (parser.parseArrow()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resRawTypes[0] = type; + } + result.addTypes(resTypes); + if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(rhsOperands, rhsTypes, rhsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void MatmulOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getLhs(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRhs(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' ' << "("; + { + auto type = getLhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getRhs().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ")"; + _odsPrinter << ' ' << "->"; + _odsPrinter << ' '; + { + auto type = getRes().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void MatmulOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::MatmulOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::MultiDimReductionOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +MultiDimReductionOpGenericAdaptorBase::MultiDimReductionOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.multi_reduction", odsAttrs.getContext()); +} + +MultiDimReductionOpGenericAdaptorBase::MultiDimReductionOpGenericAdaptorBase(MultiDimReductionOp op) : MultiDimReductionOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair MultiDimReductionOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr MultiDimReductionOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::vector::CombiningKindAttr MultiDimReductionOpGenericAdaptorBase::getKindAttr() { + auto attr = ::llvm::cast<::mlir::vector::CombiningKindAttr>(getProperties().kind); + return attr; +} + +::mlir::vector::CombiningKind MultiDimReductionOpGenericAdaptorBase::getKind() { + auto attr = getKindAttr(); + return attr.getValue(); +} + +::mlir::ArrayAttr MultiDimReductionOpGenericAdaptorBase::getReductionDimsAttr() { + auto attr = ::llvm::cast<::mlir::ArrayAttr>(getProperties().reduction_dims); + return attr; +} + +::mlir::ArrayAttr MultiDimReductionOpGenericAdaptorBase::getReductionDims() { + auto attr = getReductionDimsAttr(); + return attr; +} + +} // namespace detail +MultiDimReductionOpAdaptor::MultiDimReductionOpAdaptor(MultiDimReductionOp op) : MultiDimReductionOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult MultiDimReductionOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_kind = getProperties().kind; (void)tblgen_kind; + if (!tblgen_kind) return emitError(loc, "'vector.multi_reduction' op ""requires attribute 'kind'"); + auto tblgen_reduction_dims = getProperties().reduction_dims; (void)tblgen_reduction_dims; + if (!tblgen_reduction_dims) return emitError(loc, "'vector.multi_reduction' op ""requires attribute 'reduction_dims'"); + + if (tblgen_kind && !((::llvm::isa<::mlir::vector::CombiningKindAttr>(tblgen_kind)))) + return emitError(loc, "'vector.multi_reduction' op ""attribute 'kind' failed to satisfy constraint: Kind of combining function for contractions and reductions"); + + if (tblgen_reduction_dims && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_reduction_dims))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_reduction_dims), [&](::mlir::Attribute attr) { return attr && (((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(64)))); })))) + return emitError(loc, "'vector.multi_reduction' op ""attribute 'reduction_dims' failed to satisfy constraint: 64-bit integer array attribute"); + return ::mlir::success(); +} + +std::pair MultiDimReductionOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range MultiDimReductionOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> MultiDimReductionOp::getSource() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::Value MultiDimReductionOp::getAcc() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(1).begin()); +} + +::mlir::OpOperand &MultiDimReductionOp::getSourceMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MultiDimReductionOp::getAccMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +std::pair MultiDimReductionOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range MultiDimReductionOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value MultiDimReductionOp::getDest() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult MultiDimReductionOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.kind; + auto attr = dict.get("kind"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for kind in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `kind` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.reduction_dims; + auto attr = dict.get("reduction_dims"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for reduction_dims in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `reduction_dims` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute MultiDimReductionOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.kind; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("kind", + propStorage)); + } + + { + const auto &propStorage = prop.reduction_dims; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("reduction_dims", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code MultiDimReductionOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.kind.getAsOpaquePointer()), + llvm::hash_value(prop.reduction_dims.getAsOpaquePointer())); +} + +std::optional MultiDimReductionOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "kind") + return prop.kind; + + if (name == "reduction_dims") + return prop.reduction_dims; + return std::nullopt; +} + +void MultiDimReductionOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "kind") { + prop.kind = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "reduction_dims") { + prop.reduction_dims = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void MultiDimReductionOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.kind) attrs.append("kind", prop.kind); + + if (prop.reduction_dims) attrs.append("reduction_dims", prop.reduction_dims); +} + +::mlir::LogicalResult MultiDimReductionOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getKindAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps3(attr, "kind", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getReductionDimsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps0(attr, "reduction_dims", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult MultiDimReductionOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.kind))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.reduction_dims))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void MultiDimReductionOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.kind); + writer.writeAttribute(prop.reduction_dims); +} + +::mlir::vector::CombiningKindAttr MultiDimReductionOp::getKindAttr() { + return ::llvm::cast<::mlir::vector::CombiningKindAttr>(getProperties().kind); +} + +::mlir::vector::CombiningKind MultiDimReductionOp::getKind() { + auto attr = getKindAttr(); + return attr.getValue(); +} + +::mlir::ArrayAttr MultiDimReductionOp::getReductionDimsAttr() { + return ::llvm::cast<::mlir::ArrayAttr>(getProperties().reduction_dims); +} + +::mlir::ArrayAttr MultiDimReductionOp::getReductionDims() { + auto attr = getReductionDimsAttr(); + return attr; +} + +void MultiDimReductionOp::setKindAttr(::mlir::vector::CombiningKindAttr attr) { + (*this)->setAttr(getKindAttrName(), attr); +} + +void MultiDimReductionOp::setKind(::mlir::vector::CombiningKind attrValue) { + (*this)->setAttr(getKindAttrName(), ::mlir::vector::CombiningKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue)); +} + +void MultiDimReductionOp::setReductionDimsAttr(::mlir::ArrayAttr attr) { + (*this)->setAttr(getReductionDimsAttrName(), attr); +} + +void MultiDimReductionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dest, ::mlir::vector::CombiningKindAttr kind, ::mlir::Value source, ::mlir::Value acc, ::mlir::ArrayAttr reduction_dims) { + odsState.addOperands(source); + odsState.addOperands(acc); + odsState.getOrAddProperties().kind = kind; + odsState.getOrAddProperties().reduction_dims = reduction_dims; + odsState.addTypes(dest); +} + +void MultiDimReductionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::vector::CombiningKindAttr kind, ::mlir::Value source, ::mlir::Value acc, ::mlir::ArrayAttr reduction_dims) { + odsState.addOperands(source); + odsState.addOperands(acc); + odsState.getOrAddProperties().kind = kind; + odsState.getOrAddProperties().reduction_dims = reduction_dims; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MultiDimReductionOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void MultiDimReductionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::vector::CombiningKindAttr kind, ::mlir::Value source, ::mlir::Value acc, ::mlir::ArrayAttr reduction_dims) { + odsState.addOperands(source); + odsState.addOperands(acc); + odsState.getOrAddProperties().kind = kind; + odsState.getOrAddProperties().reduction_dims = reduction_dims; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void MultiDimReductionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dest, ::mlir::vector::CombiningKind kind, ::mlir::Value source, ::mlir::Value acc, ::mlir::ArrayAttr reduction_dims) { + odsState.addOperands(source); + odsState.addOperands(acc); + odsState.getOrAddProperties().kind = ::mlir::vector::CombiningKindAttr::get(odsBuilder.getContext(), kind); + odsState.getOrAddProperties().reduction_dims = reduction_dims; + odsState.addTypes(dest); +} + +void MultiDimReductionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::vector::CombiningKind kind, ::mlir::Value source, ::mlir::Value acc, ::mlir::ArrayAttr reduction_dims) { + odsState.addOperands(source); + odsState.addOperands(acc); + odsState.getOrAddProperties().kind = ::mlir::vector::CombiningKindAttr::get(odsBuilder.getContext(), kind); + odsState.getOrAddProperties().reduction_dims = reduction_dims; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MultiDimReductionOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void MultiDimReductionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::vector::CombiningKind kind, ::mlir::Value source, ::mlir::Value acc, ::mlir::ArrayAttr reduction_dims) { + odsState.addOperands(source); + odsState.addOperands(acc); + odsState.getOrAddProperties().kind = ::mlir::vector::CombiningKindAttr::get(odsBuilder.getContext(), kind); + odsState.getOrAddProperties().reduction_dims = reduction_dims; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void MultiDimReductionOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void MultiDimReductionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MultiDimReductionOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult MultiDimReductionOp::verifyInvariantsImpl() { + auto tblgen_kind = getProperties().kind; (void)tblgen_kind; + if (!tblgen_kind) return emitOpError("requires attribute 'kind'"); + auto tblgen_reduction_dims = getProperties().reduction_dims; (void)tblgen_reduction_dims; + if (!tblgen_reduction_dims) return emitOpError("requires attribute 'reduction_dims'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps3(*this, tblgen_kind, "kind"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps0(*this, tblgen_reduction_dims, "reduction_dims"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps7(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((((*this->getODSResults(0).begin()).getType()) == ((*this->getODSOperands(1).begin()).getType()) && ((*this->getODSOperands(1).begin()).getType()) == ((*this->getODSResults(0).begin()).getType())))) + return emitOpError("failed to verify that all of {dest, acc} have same type"); + if (!((getElementTypeOrSelf((*this->getOperation()).getResult(0)) == getElementTypeOrSelf((*this->getOperation()).getOperand(0))))) + return emitOpError("failed to verify that source operand and result have same element type"); + return ::mlir::success(); +} + +::mlir::LogicalResult MultiDimReductionOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::LogicalResult MultiDimReductionOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = operands[1].getType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult MultiDimReductionOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::vector::CombiningKindAttr kindAttr; + ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(sourceRawOperands); ::llvm::SMLoc sourceOperandsLoc; + (void)sourceOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand accRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> accOperands(accRawOperands); ::llvm::SMLoc accOperandsLoc; + (void)accOperandsLoc; + ::mlir::ArrayAttr reduction_dimsAttr; + ::mlir::Type sourceRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> sourceTypes(sourceRawTypes); + ::mlir::Type destRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> destTypes(destRawTypes); + + if (parser.parseCustomAttributeWithFallback(kindAttr, ::mlir::Type{})) { + return ::mlir::failure(); + } + if (kindAttr) result.getOrAddProperties().kind = kindAttr; + if (parser.parseComma()) + return ::mlir::failure(); + + sourceOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(sourceRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + accOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(accRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + + if (parser.parseCustomAttributeWithFallback(reduction_dimsAttr, parser.getBuilder().getType<::mlir::NoneType>())) { + return ::mlir::failure(); + } + if (reduction_dimsAttr) result.getOrAddProperties().reduction_dims = reduction_dimsAttr; + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + sourceRawTypes[0] = type; + } + if (parser.parseKeyword("to")) + return ::mlir::failure(); + + { + ::mlir::Type type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + destRawTypes[0] = type; + } + result.addTypes(destTypes); + if (parser.resolveOperands(sourceOperands, sourceTypes, sourceOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(accOperands, destTypes[0], accOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void MultiDimReductionOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; +_odsPrinter.printStrippedAttrOrType(getKindAttr()); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getSource(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getAcc(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("kind"); + elidedAttrs.push_back("reduction_dims"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' '; + _odsPrinter.printAttributeWithoutType(getReductionDimsAttr()); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getSource().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "to"; + _odsPrinter << ' '; + { + auto type = getDest().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void MultiDimReductionOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::MultiDimReductionOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::OuterProductOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +OuterProductOpGenericAdaptorBase::OuterProductOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.outerproduct", odsAttrs.getContext()); +} + +OuterProductOpGenericAdaptorBase::OuterProductOpGenericAdaptorBase(OuterProductOp op) : OuterProductOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair OuterProductOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 2) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr OuterProductOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::vector::CombiningKindAttr OuterProductOpGenericAdaptorBase::getKindAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::vector::CombiningKindAttr>(getProperties().kind); + return attr; +} + +::mlir::vector::CombiningKind OuterProductOpGenericAdaptorBase::getKind() { + auto attr = getKindAttr(); + return attr.getValue(); +} + +} // namespace detail +OuterProductOpAdaptor::OuterProductOpAdaptor(OuterProductOp op) : OuterProductOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult OuterProductOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_kind = getProperties().kind; (void)tblgen_kind; + + if (tblgen_kind && !((::llvm::isa<::mlir::vector::CombiningKindAttr>(tblgen_kind)))) + return emitError(loc, "'vector.outerproduct' op ""attribute 'kind' failed to satisfy constraint: Kind of combining function for contractions and reductions"); + return ::mlir::success(); +} + +std::pair OuterProductOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 2) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range OuterProductOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> OuterProductOp::getLhs() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::Value OuterProductOp::getRhs() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(1).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> OuterProductOp::getAcc() { + auto operands = getODSOperands(2); + return operands.empty() ? ::mlir::TypedValue<::mlir::VectorType>{} : ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*operands.begin()); +} + +::mlir::OpOperand &OuterProductOp::getLhsMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &OuterProductOp::getRhsMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange OuterProductOp::getAccMutable() { + auto range = getODSOperandIndexAndLength(2); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair OuterProductOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range OuterProductOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::LogicalResult OuterProductOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.kind; + auto attr = dict.get("kind"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for kind in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `kind` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute OuterProductOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.kind; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("kind", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code OuterProductOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.kind.getAsOpaquePointer())); +} + +std::optional OuterProductOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "kind") + return prop.kind; + return std::nullopt; +} + +void OuterProductOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "kind") { + prop.kind = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void OuterProductOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.kind) attrs.append("kind", prop.kind); +} + +::mlir::LogicalResult OuterProductOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getKindAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps3(attr, "kind", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult OuterProductOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.kind))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void OuterProductOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.kind); +} + +::mlir::vector::CombiningKindAttr OuterProductOp::getKindAttr() { + return ::llvm::dyn_cast_or_null<::mlir::vector::CombiningKindAttr>(getProperties().kind); +} + +::mlir::vector::CombiningKind OuterProductOp::getKind() { + auto attr = getKindAttr(); + return attr.getValue(); +} + +void OuterProductOp::setKindAttr(::mlir::vector::CombiningKindAttr attr) { + (*this)->setAttr(getKindAttrName(), attr); +} + +void OuterProductOp::setKind(::mlir::vector::CombiningKind attrValue) { + (*this)->setAttr(getKindAttrName(), ::mlir::vector::CombiningKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue)); +} + +void OuterProductOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::Value acc, ::mlir::vector::CombiningKindAttr kind) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (acc) + odsState.addOperands(acc); + if (kind) { + odsState.getOrAddProperties().kind = kind; + } + odsState.addTypes(resultType0); +} + +void OuterProductOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::Value acc, ::mlir::vector::CombiningKindAttr kind) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (acc) + odsState.addOperands(acc); + if (kind) { + odsState.getOrAddProperties().kind = kind; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void OuterProductOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::Value acc, ::mlir::vector::CombiningKind kind) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (acc) + odsState.addOperands(acc); + odsState.getOrAddProperties().kind = ::mlir::vector::CombiningKindAttr::get(odsBuilder.getContext(), kind); + odsState.addTypes(resultType0); +} + +void OuterProductOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::Value acc, ::mlir::vector::CombiningKind kind) { + odsState.addOperands(lhs); + odsState.addOperands(rhs); + if (acc) + odsState.addOperands(acc); + odsState.getOrAddProperties().kind = ::mlir::vector::CombiningKindAttr::get(odsBuilder.getContext(), kind); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void OuterProductOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void OuterProductOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { + ::mlir::Builder odsBuilder(opName.getContext()); + if (!properties.kind) + properties.kind = ::mlir::vector::CombiningKindAttr::get(odsBuilder.getContext(), CombiningKind::ADD); +} + +::mlir::LogicalResult OuterProductOp::verifyInvariantsImpl() { + auto tblgen_kind = getProperties().kind; (void)tblgen_kind; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps3(*this, tblgen_kind, "kind"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps7(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + if (valueGroup2.size() > 1) { + return emitOpError("operand group starting at #") << index + << " requires 0 or 1 element, but found " << valueGroup2.size(); + } + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps7(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps7(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((getElementTypeOrSelf((*this->getOperation()).getResult(0)) == getElementTypeOrSelf((*this->getOperation()).getOperand(0))))) + return emitOpError("failed to verify that lhs operand and result have same element type"); + if (!((getElementTypeOrSelf((*this->getOperation()).getResult(0)) == getElementTypeOrSelf((*this->getOperation()).getOperand(1))))) + return emitOpError("failed to verify that rhs operand and result have same element type"); + return ::mlir::success(); +} + +::mlir::LogicalResult OuterProductOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +void OuterProductOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::OuterProductOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::PrintOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +PrintOpGenericAdaptorBase::PrintOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.print", odsAttrs.getContext()); +} + +PrintOpGenericAdaptorBase::PrintOpGenericAdaptorBase(PrintOp op) : PrintOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair PrintOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr PrintOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::vector::PrintPunctuationAttr PrintOpGenericAdaptorBase::getPunctuationAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::vector::PrintPunctuationAttr>(getProperties().punctuation); + return attr; +} + +::mlir::vector::PrintPunctuation PrintOpGenericAdaptorBase::getPunctuation() { + auto attr = getPunctuationAttr(); + return attr.getValue(); +} + +} // namespace detail +PrintOpAdaptor::PrintOpAdaptor(PrintOp op) : PrintOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult PrintOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_punctuation = getProperties().punctuation; (void)tblgen_punctuation; + + if (tblgen_punctuation && !((::llvm::isa<::mlir::vector::PrintPunctuationAttr>(tblgen_punctuation)))) + return emitError(loc, "'vector.print' op ""attribute 'punctuation' failed to satisfy constraint: Punctuation for separating vectors or vector elements"); + return ::mlir::success(); +} + +std::pair PrintOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range PrintOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value PrintOp::getSource() { + auto operands = getODSOperands(0); + return operands.empty() ? ::mlir::Value{} : ::llvm::cast<::mlir::Value>(*operands.begin()); +} + +::mlir::MutableOperandRange PrintOp::getSourceMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair PrintOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range PrintOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::LogicalResult PrintOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.punctuation; + auto attr = dict.get("punctuation"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for punctuation in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `punctuation` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute PrintOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.punctuation; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("punctuation", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code PrintOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.punctuation.getAsOpaquePointer())); +} + +std::optional PrintOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "punctuation") + return prop.punctuation; + return std::nullopt; +} + +void PrintOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "punctuation") { + prop.punctuation = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void PrintOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.punctuation) attrs.append("punctuation", prop.punctuation); +} + +::mlir::LogicalResult PrintOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getPunctuationAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps6(attr, "punctuation", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult PrintOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.punctuation))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void PrintOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.punctuation); +} + +::mlir::vector::PrintPunctuationAttr PrintOp::getPunctuationAttr() { + return ::llvm::dyn_cast_or_null<::mlir::vector::PrintPunctuationAttr>(getProperties().punctuation); +} + +::mlir::vector::PrintPunctuation PrintOp::getPunctuation() { + auto attr = getPunctuationAttr(); + return attr.getValue(); +} + +void PrintOp::setPunctuationAttr(::mlir::vector::PrintPunctuationAttr attr) { + (*this)->setAttr(getPunctuationAttrName(), attr); +} + +void PrintOp::setPunctuation(::mlir::vector::PrintPunctuation attrValue) { + (*this)->setAttr(getPunctuationAttrName(), ::mlir::vector::PrintPunctuationAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue)); +} + +void PrintOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, PrintPunctuation punctuation) { + build(odsBuilder, odsState, {}, punctuation); + +} + +void PrintOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Value source, ::mlir::vector::PrintPunctuationAttr punctuation) { + if (source) + odsState.addOperands(source); + if (punctuation) { + odsState.getOrAddProperties().punctuation = punctuation; + } +} + +void PrintOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value source, ::mlir::vector::PrintPunctuationAttr punctuation) { + if (source) + odsState.addOperands(source); + if (punctuation) { + odsState.getOrAddProperties().punctuation = punctuation; + } + assert(resultTypes.size() == 0u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void PrintOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Value source, ::mlir::vector::PrintPunctuation punctuation) { + if (source) + odsState.addOperands(source); + odsState.getOrAddProperties().punctuation = ::mlir::vector::PrintPunctuationAttr::get(odsBuilder.getContext(), punctuation); +} + +void PrintOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value source, ::mlir::vector::PrintPunctuation punctuation) { + if (source) + odsState.addOperands(source); + odsState.getOrAddProperties().punctuation = ::mlir::vector::PrintPunctuationAttr::get(odsBuilder.getContext(), punctuation); + assert(resultTypes.size() == 0u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void PrintOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void PrintOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { + ::mlir::Builder odsBuilder(opName.getContext()); + if (!properties.punctuation) + properties.punctuation = ::mlir::vector::PrintPunctuationAttr::get(odsBuilder.getContext(), ::mlir::vector::PrintPunctuation::NewLine); +} + +::mlir::LogicalResult PrintOp::verifyInvariantsImpl() { + auto tblgen_punctuation = getProperties().punctuation; (void)tblgen_punctuation; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps6(*this, tblgen_punctuation, "punctuation"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + if (valueGroup0.size() > 1) { + return emitOpError("operand group starting at #") << index + << " requires 0 or 1 element, but found " << valueGroup0.size(); + } + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps14(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult PrintOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult PrintOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> sourceOperands; + ::llvm::SMLoc sourceOperandsLoc; + (void)sourceOperandsLoc; + ::llvm::SmallVector<::mlir::Type, 1> sourceTypes; + ::mlir::vector::PrintPunctuationAttr punctuationAttr; + + { + sourceOperandsLoc = parser.getCurrentLocation(); + ::mlir::OpAsmParser::UnresolvedOperand operand; + ::mlir::OptionalParseResult parseResult = + parser.parseOptionalOperand(operand); + if (parseResult.has_value()) { + if (failed(*parseResult)) + return ::mlir::failure(); + sourceOperands.push_back(operand); + } + } + if (!sourceOperands.empty()) { + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::Type optionalType; + ::mlir::OptionalParseResult parseResult = + parser.parseOptionalType(optionalType); + if (parseResult.has_value()) { + if (failed(*parseResult)) + return ::mlir::failure(); + sourceTypes.push_back(optionalType); + } + } + } + if (::mlir::succeeded(parser.parseOptionalKeyword("punctuation"))) { + + if (parser.parseCustomAttributeWithFallback(punctuationAttr, ::mlir::Type{})) { + return ::mlir::failure(); + } + if (punctuationAttr) result.getOrAddProperties().punctuation = punctuationAttr; + } + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.resolveOperands(sourceOperands, sourceTypes, sourceOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void PrintOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + if (getSource()) { + _odsPrinter << ' '; + if (::mlir::Value value = getSource()) + _odsPrinter << value; + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter << (getSource() ? ::llvm::ArrayRef<::mlir::Type>(getSource().getType()) : ::llvm::ArrayRef<::mlir::Type>()); + } + if (getPunctuationAttr() && getPunctuationAttr() != ::mlir::vector::PrintPunctuationAttr::get(::mlir::OpBuilder((*this)->getContext()).getContext(), ::mlir::vector::PrintPunctuation::NewLine)) { + _odsPrinter << ' ' << "punctuation"; + _odsPrinter << ' '; + _odsPrinter.printStrippedAttrOrType(getPunctuationAttr()); + } + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("punctuation"); + { + ::mlir::Builder odsBuilder(getContext()); + ::mlir::Attribute attr = getPunctuationAttr(); + if(attr && (attr == ::mlir::vector::PrintPunctuationAttr::get(odsBuilder.getContext(), ::mlir::vector::PrintPunctuation::NewLine))) + elidedAttrs.push_back("punctuation"); + } + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::PrintOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::ReductionOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ReductionOpGenericAdaptorBase::ReductionOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.reduction", odsAttrs.getContext()); +} + +ReductionOpGenericAdaptorBase::ReductionOpGenericAdaptorBase(ReductionOp op) : ReductionOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ReductionOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr ReductionOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::vector::CombiningKindAttr ReductionOpGenericAdaptorBase::getKindAttr() { + auto attr = ::llvm::cast<::mlir::vector::CombiningKindAttr>(getProperties().kind); + return attr; +} + +::mlir::vector::CombiningKind ReductionOpGenericAdaptorBase::getKind() { + auto attr = getKindAttr(); + return attr.getValue(); +} + +::mlir::arith::FastMathFlagsAttr ReductionOpGenericAdaptorBase::getFastmathAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::arith::FastMathFlagsAttr>(getProperties().fastmath); + return attr; +} + +::mlir::arith::FastMathFlags ReductionOpGenericAdaptorBase::getFastmath() { + auto attr = getFastmathAttr(); + return attr.getValue(); +} + +} // namespace detail +ReductionOpAdaptor::ReductionOpAdaptor(ReductionOp op) : ReductionOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ReductionOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; + auto tblgen_kind = getProperties().kind; (void)tblgen_kind; + if (!tblgen_kind) return emitError(loc, "'vector.reduction' op ""requires attribute 'kind'"); + + if (tblgen_kind && !((::llvm::isa<::mlir::vector::CombiningKindAttr>(tblgen_kind)))) + return emitError(loc, "'vector.reduction' op ""attribute 'kind' failed to satisfy constraint: Kind of combining function for contractions and reductions"); + + if (tblgen_fastmath && !((::llvm::isa<::mlir::arith::FastMathFlagsAttr>(tblgen_fastmath)))) + return emitError(loc, "'vector.reduction' op ""attribute 'fastmath' failed to satisfy constraint: Floating point fast math flags"); + return ::mlir::success(); +} + +std::pair ReductionOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range ReductionOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> ReductionOp::getVector() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::Value ReductionOp::getAcc() { + auto operands = getODSOperands(1); + return operands.empty() ? ::mlir::Value{} : ::llvm::cast<::mlir::Value>(*operands.begin()); +} + +::mlir::OpOperand &ReductionOp::getVectorMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange ReductionOp::getAccMutable() { + auto range = getODSOperandIndexAndLength(1); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair ReductionOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ReductionOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value ReductionOp::getDest() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult ReductionOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.fastmath; + auto attr = dict.get("fastmath"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for fastmath in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `fastmath` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.kind; + auto attr = dict.get("kind"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for kind in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `kind` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ReductionOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.fastmath; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("fastmath", + propStorage)); + } + + { + const auto &propStorage = prop.kind; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("kind", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ReductionOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.fastmath.getAsOpaquePointer()), + llvm::hash_value(prop.kind.getAsOpaquePointer())); +} + +std::optional ReductionOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "fastmath") + return prop.fastmath; + + if (name == "kind") + return prop.kind; + return std::nullopt; +} + +void ReductionOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "fastmath") { + prop.fastmath = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "kind") { + prop.kind = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ReductionOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.fastmath) attrs.append("fastmath", prop.fastmath); + + if (prop.kind) attrs.append("kind", prop.kind); +} + +::mlir::LogicalResult ReductionOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getFastmathAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps7(attr, "fastmath", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getKindAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps3(attr, "kind", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ReductionOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.fastmath))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.kind))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ReductionOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.fastmath); + writer.writeAttribute(prop.kind); +} + +::mlir::vector::CombiningKindAttr ReductionOp::getKindAttr() { + return ::llvm::cast<::mlir::vector::CombiningKindAttr>(getProperties().kind); +} + +::mlir::vector::CombiningKind ReductionOp::getKind() { + auto attr = getKindAttr(); + return attr.getValue(); +} + +::mlir::arith::FastMathFlagsAttr ReductionOp::getFastmathAttr() { + return ::llvm::dyn_cast_or_null<::mlir::arith::FastMathFlagsAttr>(getProperties().fastmath); +} + +::mlir::arith::FastMathFlags ReductionOp::getFastmath() { + auto attr = getFastmathAttr(); + return attr.getValue(); +} + +void ReductionOp::setKindAttr(::mlir::vector::CombiningKindAttr attr) { + (*this)->setAttr(getKindAttrName(), attr); +} + +void ReductionOp::setKind(::mlir::vector::CombiningKind attrValue) { + (*this)->setAttr(getKindAttrName(), ::mlir::vector::CombiningKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue)); +} + +void ReductionOp::setFastmathAttr(::mlir::arith::FastMathFlagsAttr attr) { + (*this)->setAttr(getFastmathAttrName(), attr); +} + +void ReductionOp::setFastmath(::mlir::arith::FastMathFlags attrValue) { + (*this)->setAttr(getFastmathAttrName(), ::mlir::arith::FastMathFlagsAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue)); +} + +void ReductionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dest, ::mlir::vector::CombiningKindAttr kind, ::mlir::Value vector, /*optional*/::mlir::Value acc, ::mlir::arith::FastMathFlagsAttr fastmath) { + odsState.addOperands(vector); + if (acc) + odsState.addOperands(acc); + odsState.getOrAddProperties().kind = kind; + if (fastmath) { + odsState.getOrAddProperties().fastmath = fastmath; + } + odsState.addTypes(dest); +} + +void ReductionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::vector::CombiningKindAttr kind, ::mlir::Value vector, /*optional*/::mlir::Value acc, ::mlir::arith::FastMathFlagsAttr fastmath) { + odsState.addOperands(vector); + if (acc) + odsState.addOperands(acc); + odsState.getOrAddProperties().kind = kind; + if (fastmath) { + odsState.getOrAddProperties().fastmath = fastmath; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ReductionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dest, ::mlir::vector::CombiningKind kind, ::mlir::Value vector, /*optional*/::mlir::Value acc, ::mlir::arith::FastMathFlags fastmath) { + odsState.addOperands(vector); + if (acc) + odsState.addOperands(acc); + odsState.getOrAddProperties().kind = ::mlir::vector::CombiningKindAttr::get(odsBuilder.getContext(), kind); + odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); + odsState.addTypes(dest); +} + +void ReductionOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::vector::CombiningKind kind, ::mlir::Value vector, /*optional*/::mlir::Value acc, ::mlir::arith::FastMathFlags fastmath) { + odsState.addOperands(vector); + if (acc) + odsState.addOperands(acc); + odsState.getOrAddProperties().kind = ::mlir::vector::CombiningKindAttr::get(odsBuilder.getContext(), kind); + odsState.getOrAddProperties().fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), fastmath); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ReductionOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ReductionOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) { + ::mlir::Builder odsBuilder(opName.getContext()); + if (!properties.fastmath) + properties.fastmath = ::mlir::arith::FastMathFlagsAttr::get(odsBuilder.getContext(), ::mlir::arith::FastMathFlags::none); +} + +::mlir::LogicalResult ReductionOp::verifyInvariantsImpl() { + auto tblgen_fastmath = getProperties().fastmath; (void)tblgen_fastmath; + auto tblgen_kind = getProperties().kind; (void)tblgen_kind; + if (!tblgen_kind) return emitOpError("requires attribute 'kind'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps3(*this, tblgen_kind, "kind"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps7(*this, tblgen_fastmath, "fastmath"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + if (valueGroup1.size() > 1) { + return emitOpError("operand group starting at #") << index + << " requires 0 or 1 element, but found " << valueGroup1.size(); + } + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((getElementTypeOrSelf((*this->getOperation()).getResult(0)) == getElementTypeOrSelf((*this->getOperation()).getOperand(0))))) + return emitOpError("failed to verify that source operand and result have same element type"); + return ::mlir::success(); +} + +::mlir::LogicalResult ReductionOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +void ReductionOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::ReductionOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::ReshapeOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ReshapeOpGenericAdaptorBase::ReshapeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.reshape", odsAttrs.getContext()); +} + +ReshapeOpGenericAdaptorBase::ReshapeOpGenericAdaptorBase(ReshapeOp op) : ReshapeOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ReshapeOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; + + unsigned start = 0; + for (unsigned i = 0; i < index; ++i) + start += sizeAttr[i]; + return {start, sizeAttr[index]}; +} + +::mlir::DictionaryAttr ReshapeOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::ArrayAttr ReshapeOpGenericAdaptorBase::getFixedVectorSizesAttr() { + auto attr = ::llvm::cast<::mlir::ArrayAttr>(getProperties().fixed_vector_sizes); + return attr; +} + +::mlir::ArrayAttr ReshapeOpGenericAdaptorBase::getFixedVectorSizes() { + auto attr = getFixedVectorSizesAttr(); + return attr; +} + +} // namespace detail +ReshapeOpAdaptor::ReshapeOpAdaptor(ReshapeOp op) : ReshapeOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ReshapeOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_fixed_vector_sizes = getProperties().fixed_vector_sizes; (void)tblgen_fixed_vector_sizes; + if (!tblgen_fixed_vector_sizes) return emitError(loc, "'vector.reshape' op ""requires attribute 'fixed_vector_sizes'"); + + if (tblgen_fixed_vector_sizes && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_fixed_vector_sizes))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_fixed_vector_sizes), [&](::mlir::Attribute attr) { return attr && (((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(64)))); })))) + return emitError(loc, "'vector.reshape' op ""attribute 'fixed_vector_sizes' failed to satisfy constraint: 64-bit integer array attribute"); + return ::mlir::success(); +} + +std::pair ReshapeOp::getODSOperandIndexAndLength(unsigned index) { + ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; + + unsigned start = 0; + for (unsigned i = 0; i < index; ++i) + start += sizeAttr[i]; + return {start, sizeAttr[index]}; +} + +::mlir::Operation::operand_range ReshapeOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> ReshapeOp::getVector() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::Operation::operand_range ReshapeOp::getInputShape() { + return getODSOperands(1); +} + +::mlir::Operation::operand_range ReshapeOp::getOutputShape() { + return getODSOperands(2); +} + +::mlir::OpOperand &ReshapeOp::getVectorMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange ReshapeOp::getInputShapeMutable() { + auto range = getODSOperandIndexAndLength(1); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); + return mutableRange; +} + +::mlir::MutableOperandRange ReshapeOp::getOutputShapeMutable() { + auto range = getODSOperandIndexAndLength(2); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); + return mutableRange; +} + +std::pair ReshapeOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ReshapeOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> ReshapeOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult ReshapeOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.fixed_vector_sizes; + auto attr = dict.get("fixed_vector_sizes"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for fixed_vector_sizes in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `fixed_vector_sizes` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } +; + { + auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, + ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return convertFromAttribute(propStorage, propAttr, emitError);; + }; + auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; + if (!attr) { + emitError() << "expected key entry for operandSegmentSizes in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + if (::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute ReshapeOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.fixed_vector_sizes; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("fixed_vector_sizes", + propStorage)); + } + + { + const auto &propStorage = prop.operandSegmentSizes; + attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", + ::mlir::DenseI32ArrayAttr::get(ctx, propStorage))); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ReshapeOp::computePropertiesHash(const Properties &prop) { + auto hash_operandSegmentSizes = [] (const auto &propStorage) -> llvm::hash_code { + return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; + }; + return llvm::hash_combine( + llvm::hash_value(prop.fixed_vector_sizes.getAsOpaquePointer()), + hash_operandSegmentSizes(prop.operandSegmentSizes)); +} + +std::optional ReshapeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "fixed_vector_sizes") + return prop.fixed_vector_sizes; + if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); + return std::nullopt; +} + +void ReshapeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "fixed_vector_sizes") { + prop.fixed_vector_sizes = ::llvm::dyn_cast_or_null>(value); + return; + } + if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { + auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); + if (!arrAttr) return; + if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) + return; + llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); + return; + } +} + +void ReshapeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.fixed_vector_sizes) attrs.append("fixed_vector_sizes", prop.fixed_vector_sizes); + attrs.append("operandSegmentSizes", ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes)); +} + +::mlir::LogicalResult ReshapeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getFixedVectorSizesAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps0(attr, "fixed_vector_sizes", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ReshapeOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.fixed_vector_sizes))) + return ::mlir::failure(); + + { + auto &propStorage = prop.operandSegmentSizes; + auto readProp = [&]() { + +if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { + ::mlir::DenseI32ArrayAttr attr; + if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); + if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { + reader.emitError("size mismatch for operand/result_segment_size"); + return ::mlir::failure(); + } + ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); +} else { + return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); +} +; + return ::mlir::success(); + }; + if (::mlir::failed(readProp())) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +void ReshapeOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.fixed_vector_sizes); + + { + auto &propStorage = prop.operandSegmentSizes; + +if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) + writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(getContext(), propStorage)); +else + writer.writeSparseArray(::llvm::ArrayRef(propStorage)); +; + } +} + +::mlir::ArrayAttr ReshapeOp::getFixedVectorSizesAttr() { + return ::llvm::cast<::mlir::ArrayAttr>(getProperties().fixed_vector_sizes); +} + +::mlir::ArrayAttr ReshapeOp::getFixedVectorSizes() { + auto attr = getFixedVectorSizesAttr(); + return attr; +} + +void ReshapeOp::setFixedVectorSizesAttr(::mlir::ArrayAttr attr) { + (*this)->setAttr(getFixedVectorSizesAttrName(), attr); +} + +void ReshapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value vector, ::mlir::ValueRange input_shape, ::mlir::ValueRange output_shape, ::mlir::ArrayAttr fixed_vector_sizes) { + odsState.addOperands(vector); + odsState.addOperands(input_shape); + odsState.addOperands(output_shape); + ::llvm::copy(::llvm::ArrayRef({1, static_cast(input_shape.size()), static_cast(output_shape.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + odsState.getOrAddProperties().fixed_vector_sizes = fixed_vector_sizes; + odsState.addTypes(result); +} + +void ReshapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value vector, ::mlir::ValueRange input_shape, ::mlir::ValueRange output_shape, ::mlir::ArrayAttr fixed_vector_sizes) { + odsState.addOperands(vector); + odsState.addOperands(input_shape); + odsState.addOperands(output_shape); + ::llvm::copy(::llvm::ArrayRef({1, static_cast(input_shape.size()), static_cast(output_shape.size())}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + odsState.getOrAddProperties().fixed_vector_sizes = fixed_vector_sizes; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ReshapeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ReshapeOp::verifyInvariantsImpl() { + auto tblgen_fixed_vector_sizes = getProperties().fixed_vector_sizes; (void)tblgen_fixed_vector_sizes; + if (!tblgen_fixed_vector_sizes) return emitOpError("requires attribute 'fixed_vector_sizes'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps0(*this, tblgen_fixed_vector_sizes, "fixed_vector_sizes"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps7(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps7(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ReshapeOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult ReshapeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand vectorRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> vectorOperands(vectorRawOperands); ::llvm::SMLoc vectorOperandsLoc; + (void)vectorOperandsLoc; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> input_shapeOperands; + ::llvm::SMLoc input_shapeOperandsLoc; + (void)input_shapeOperandsLoc; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> output_shapeOperands; + ::llvm::SMLoc output_shapeOperandsLoc; + (void)output_shapeOperandsLoc; + ::mlir::ArrayAttr fixed_vector_sizesAttr; + ::mlir::Type vectorRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> vectorTypes(vectorRawTypes); + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + vectorOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(vectorRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + if (parser.parseLSquare()) + return ::mlir::failure(); + + input_shapeOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(input_shapeOperands)) + return ::mlir::failure(); + if (parser.parseRSquare()) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + if (parser.parseLSquare()) + return ::mlir::failure(); + + output_shapeOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(output_shapeOperands)) + return ::mlir::failure(); + if (parser.parseRSquare()) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(fixed_vector_sizesAttr, parser.getBuilder().getType<::mlir::NoneType>())) { + return ::mlir::failure(); + } + if (fixed_vector_sizesAttr) result.getOrAddProperties().fixed_vector_sizes = fixed_vector_sizesAttr; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + vectorRawTypes[0] = type; + } + if (parser.parseKeyword("to")) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } +::llvm::copy(::llvm::ArrayRef({1, static_cast(input_shapeOperands.size()), static_cast(output_shapeOperands.size())}), result.getOrAddProperties().operandSegmentSizes.begin()); + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + result.addTypes(resultTypes); + if (parser.resolveOperands(vectorOperands, vectorTypes, vectorOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(input_shapeOperands, odsBuildableType0, input_shapeOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(output_shapeOperands, odsBuildableType0, output_shapeOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ReshapeOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getVector(); + _odsPrinter << ","; + _odsPrinter << ' ' << "["; + _odsPrinter << getInputShape(); + _odsPrinter << "]"; + _odsPrinter << ","; + _odsPrinter << ' ' << "["; + _odsPrinter << getOutputShape(); + _odsPrinter << "]"; + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter.printAttributeWithoutType(getFixedVectorSizesAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("operandSegmentSizes"); + elidedAttrs.push_back("fixed_vector_sizes"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getVector().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "to"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void ReshapeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::ReshapeOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::ScalableExtractOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ScalableExtractOpGenericAdaptorBase::ScalableExtractOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.scalable.extract", odsAttrs.getContext()); +} + +ScalableExtractOpGenericAdaptorBase::ScalableExtractOpGenericAdaptorBase(ScalableExtractOp op) : ScalableExtractOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ScalableExtractOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ScalableExtractOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::IntegerAttr ScalableExtractOpGenericAdaptorBase::getPosAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().pos); + return attr; +} + +uint64_t ScalableExtractOpGenericAdaptorBase::getPos() { + auto attr = getPosAttr(); + return attr.getValue().getZExtValue(); +} + +} // namespace detail +ScalableExtractOpAdaptor::ScalableExtractOpAdaptor(ScalableExtractOp op) : ScalableExtractOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ScalableExtractOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_pos = getProperties().pos; (void)tblgen_pos; + if (!tblgen_pos) return emitError(loc, "'vector.scalable.extract' op ""requires attribute 'pos'"); + + if (tblgen_pos && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_pos))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_pos).getType().isSignlessInteger(64))))) + return emitError(loc, "'vector.scalable.extract' op ""attribute 'pos' failed to satisfy constraint: 64-bit signless integer attribute"); + return ::mlir::success(); +} + +std::pair ScalableExtractOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ScalableExtractOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> ScalableExtractOp::getSource() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &ScalableExtractOp::getSourceMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair ScalableExtractOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ScalableExtractOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> ScalableExtractOp::getRes() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult ScalableExtractOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.pos; + auto attr = dict.get("pos"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for pos in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `pos` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ScalableExtractOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.pos; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("pos", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ScalableExtractOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.pos.getAsOpaquePointer())); +} + +std::optional ScalableExtractOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "pos") + return prop.pos; + return std::nullopt; +} + +void ScalableExtractOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "pos") { + prop.pos = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ScalableExtractOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.pos) attrs.append("pos", prop.pos); +} + +::mlir::LogicalResult ScalableExtractOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getPosAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps8(attr, "pos", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ScalableExtractOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.pos))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ScalableExtractOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.pos); +} + +::mlir::IntegerAttr ScalableExtractOp::getPosAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().pos); +} + +uint64_t ScalableExtractOp::getPos() { + auto attr = getPosAttr(); + return attr.getValue().getZExtValue(); +} + +void ScalableExtractOp::setPosAttr(::mlir::IntegerAttr attr) { + (*this)->setAttr(getPosAttrName(), attr); +} + +void ScalableExtractOp::setPos(uint64_t attrValue) { + (*this)->setAttr(getPosAttrName(), ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), attrValue)); +} + +void ScalableExtractOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value source, ::mlir::IntegerAttr pos) { + odsState.addOperands(source); + odsState.getOrAddProperties().pos = pos; + odsState.addTypes(res); +} + +void ScalableExtractOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::IntegerAttr pos) { + odsState.addOperands(source); + odsState.getOrAddProperties().pos = pos; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ScalableExtractOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value source, uint64_t pos) { + odsState.addOperands(source); + odsState.getOrAddProperties().pos = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), pos); + odsState.addTypes(res); +} + +void ScalableExtractOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, uint64_t pos) { + odsState.addOperands(source); + odsState.getOrAddProperties().pos = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), pos); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ScalableExtractOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ScalableExtractOp::verifyInvariantsImpl() { + auto tblgen_pos = getProperties().pos; (void)tblgen_pos; + if (!tblgen_pos) return emitOpError("requires attribute 'pos'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps8(*this, tblgen_pos, "pos"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps15(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps5(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!(((getElementTypeOrSelf((*this->getODSOperands(0).begin()))) == (getElementTypeOrSelf((*this->getODSResults(0).begin()))) && (getElementTypeOrSelf((*this->getODSResults(0).begin()))) == (getElementTypeOrSelf((*this->getODSOperands(0).begin())))))) + return emitOpError("failed to verify that all of {source, res} have same element type"); + if (!(((getPos() % getResultVectorType().getNumElements()) == 0))) + return emitOpError("failed to verify that position is a multiple of the result length."); + return ::mlir::success(); +} + +::mlir::LogicalResult ScalableExtractOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult ScalableExtractOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(sourceRawOperands); ::llvm::SMLoc sourceOperandsLoc; + (void)sourceOperandsLoc; + ::mlir::IntegerAttr posAttr; + ::mlir::Type resRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resTypes(resRawTypes); + ::mlir::Type sourceRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> sourceTypes(sourceRawTypes); + + sourceOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(sourceRawOperands[0])) + return ::mlir::failure(); + if (parser.parseLSquare()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(posAttr, parser.getBuilder().getIntegerType(64))) { + return ::mlir::failure(); + } + if (posAttr) result.getOrAddProperties().pos = posAttr; + if (parser.parseRSquare()) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resRawTypes[0] = type; + } + if (parser.parseKeyword("from")) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + sourceRawTypes[0] = type; + } + result.addTypes(resTypes); + if (parser.resolveOperands(sourceOperands, sourceTypes, sourceOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ScalableExtractOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getSource(); + _odsPrinter << "["; + _odsPrinter.printAttributeWithoutType(getPosAttr()); + _odsPrinter << "]"; + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("pos"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getRes().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "from"; + _odsPrinter << ' '; + { + auto type = getSource().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void ScalableExtractOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::ScalableExtractOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::ScalableInsertOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ScalableInsertOpGenericAdaptorBase::ScalableInsertOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.scalable.insert", odsAttrs.getContext()); +} + +ScalableInsertOpGenericAdaptorBase::ScalableInsertOpGenericAdaptorBase(ScalableInsertOp op) : ScalableInsertOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ScalableInsertOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ScalableInsertOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::IntegerAttr ScalableInsertOpGenericAdaptorBase::getPosAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().pos); + return attr; +} + +uint64_t ScalableInsertOpGenericAdaptorBase::getPos() { + auto attr = getPosAttr(); + return attr.getValue().getZExtValue(); +} + +} // namespace detail +ScalableInsertOpAdaptor::ScalableInsertOpAdaptor(ScalableInsertOp op) : ScalableInsertOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ScalableInsertOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_pos = getProperties().pos; (void)tblgen_pos; + if (!tblgen_pos) return emitError(loc, "'vector.scalable.insert' op ""requires attribute 'pos'"); + + if (tblgen_pos && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_pos))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_pos).getType().isSignlessInteger(64))))) + return emitError(loc, "'vector.scalable.insert' op ""attribute 'pos' failed to satisfy constraint: 64-bit signless integer attribute"); + return ::mlir::success(); +} + +std::pair ScalableInsertOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ScalableInsertOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> ScalableInsertOp::getSource() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> ScalableInsertOp::getDest() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(1).begin()); +} + +::mlir::OpOperand &ScalableInsertOp::getSourceMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &ScalableInsertOp::getDestMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +std::pair ScalableInsertOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ScalableInsertOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> ScalableInsertOp::getRes() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult ScalableInsertOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.pos; + auto attr = dict.get("pos"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for pos in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `pos` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ScalableInsertOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.pos; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("pos", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ScalableInsertOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.pos.getAsOpaquePointer())); +} + +std::optional ScalableInsertOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "pos") + return prop.pos; + return std::nullopt; +} + +void ScalableInsertOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "pos") { + prop.pos = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ScalableInsertOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.pos) attrs.append("pos", prop.pos); +} + +::mlir::LogicalResult ScalableInsertOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getPosAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps8(attr, "pos", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ScalableInsertOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.pos))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ScalableInsertOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.pos); +} + +::mlir::IntegerAttr ScalableInsertOp::getPosAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().pos); +} + +uint64_t ScalableInsertOp::getPos() { + auto attr = getPosAttr(); + return attr.getValue().getZExtValue(); +} + +void ScalableInsertOp::setPosAttr(::mlir::IntegerAttr attr) { + (*this)->setAttr(getPosAttrName(), attr); +} + +void ScalableInsertOp::setPos(uint64_t attrValue) { + (*this)->setAttr(getPosAttrName(), ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), attrValue)); +} + +void ScalableInsertOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value source, ::mlir::Value dest, ::mlir::IntegerAttr pos) { + odsState.addOperands(source); + odsState.addOperands(dest); + odsState.getOrAddProperties().pos = pos; + odsState.addTypes(res); +} + +void ScalableInsertOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value source, ::mlir::Value dest, ::mlir::IntegerAttr pos) { + odsState.addOperands(source); + odsState.addOperands(dest); + odsState.getOrAddProperties().pos = pos; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ScalableInsertOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void ScalableInsertOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, ::mlir::IntegerAttr pos) { + odsState.addOperands(source); + odsState.addOperands(dest); + odsState.getOrAddProperties().pos = pos; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ScalableInsertOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value source, ::mlir::Value dest, uint64_t pos) { + odsState.addOperands(source); + odsState.addOperands(dest); + odsState.getOrAddProperties().pos = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), pos); + odsState.addTypes(res); +} + +void ScalableInsertOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value source, ::mlir::Value dest, uint64_t pos) { + odsState.addOperands(source); + odsState.addOperands(dest); + odsState.getOrAddProperties().pos = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), pos); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ScalableInsertOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void ScalableInsertOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, uint64_t pos) { + odsState.addOperands(source); + odsState.addOperands(dest); + odsState.getOrAddProperties().pos = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), pos); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ScalableInsertOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ScalableInsertOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ScalableInsertOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult ScalableInsertOp::verifyInvariantsImpl() { + auto tblgen_pos = getProperties().pos; (void)tblgen_pos; + if (!tblgen_pos) return emitOpError("requires attribute 'pos'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps8(*this, tblgen_pos, "pos"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps5(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps15(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps15(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!(((getElementTypeOrSelf((*this->getODSOperands(0).begin()))) == (getElementTypeOrSelf((*this->getODSOperands(1).begin()))) && (getElementTypeOrSelf((*this->getODSOperands(1).begin()))) == (getElementTypeOrSelf((*this->getODSOperands(0).begin())))))) + return emitOpError("failed to verify that all of {source, dest} have same element type"); + if (!((((*this->getODSOperands(1).begin()).getType()) == ((*this->getODSResults(0).begin()).getType()) && ((*this->getODSResults(0).begin()).getType()) == ((*this->getODSOperands(1).begin()).getType())))) + return emitOpError("failed to verify that all of {dest, res} have same type"); + if (!(((getPos() % getSourceVectorType().getNumElements()) == 0))) + return emitOpError("failed to verify that position is a multiple of the source length."); + return ::mlir::success(); +} + +::mlir::LogicalResult ScalableInsertOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::LogicalResult ScalableInsertOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = operands[1].getType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult ScalableInsertOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(sourceRawOperands); ::llvm::SMLoc sourceOperandsLoc; + (void)sourceOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand destRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> destOperands(destRawOperands); ::llvm::SMLoc destOperandsLoc; + (void)destOperandsLoc; + ::mlir::IntegerAttr posAttr; + ::mlir::Type sourceRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> sourceTypes(sourceRawTypes); + ::mlir::Type destRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> destTypes(destRawTypes); + + sourceOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(sourceRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + destOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(destRawOperands[0])) + return ::mlir::failure(); + if (parser.parseLSquare()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(posAttr, parser.getBuilder().getIntegerType(64))) { + return ::mlir::failure(); + } + if (posAttr) result.getOrAddProperties().pos = posAttr; + if (parser.parseRSquare()) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + sourceRawTypes[0] = type; + } + if (parser.parseKeyword("into")) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + destRawTypes[0] = type; + } + result.addTypes(destTypes[0]); + if (parser.resolveOperands(sourceOperands, sourceTypes, sourceOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(destOperands, destTypes, destOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ScalableInsertOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getSource(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getDest(); + _odsPrinter << "["; + _odsPrinter.printAttributeWithoutType(getPosAttr()); + _odsPrinter << "]"; + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("pos"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getSource().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "into"; + _odsPrinter << ' '; + { + auto type = getDest().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void ScalableInsertOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::ScalableInsertOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::ScanOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ScanOpGenericAdaptorBase::ScanOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.scan", odsAttrs.getContext()); +} + +ScanOpGenericAdaptorBase::ScanOpGenericAdaptorBase(ScanOp op) : ScanOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ScanOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ScanOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::vector::CombiningKindAttr ScanOpGenericAdaptorBase::getKindAttr() { + auto attr = ::llvm::cast<::mlir::vector::CombiningKindAttr>(getProperties().kind); + return attr; +} + +::mlir::vector::CombiningKind ScanOpGenericAdaptorBase::getKind() { + auto attr = getKindAttr(); + return attr.getValue(); +} + +::mlir::IntegerAttr ScanOpGenericAdaptorBase::getReductionDimAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().reduction_dim); + return attr; +} + +uint64_t ScanOpGenericAdaptorBase::getReductionDim() { + auto attr = getReductionDimAttr(); + return attr.getValue().getZExtValue(); +} + +::mlir::BoolAttr ScanOpGenericAdaptorBase::getInclusiveAttr() { + auto attr = ::llvm::cast<::mlir::BoolAttr>(getProperties().inclusive); + return attr; +} + +bool ScanOpGenericAdaptorBase::getInclusive() { + auto attr = getInclusiveAttr(); + return attr.getValue(); +} + +} // namespace detail +ScanOpAdaptor::ScanOpAdaptor(ScanOp op) : ScanOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ScanOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_inclusive = getProperties().inclusive; (void)tblgen_inclusive; + if (!tblgen_inclusive) return emitError(loc, "'vector.scan' op ""requires attribute 'inclusive'"); + auto tblgen_kind = getProperties().kind; (void)tblgen_kind; + if (!tblgen_kind) return emitError(loc, "'vector.scan' op ""requires attribute 'kind'"); + auto tblgen_reduction_dim = getProperties().reduction_dim; (void)tblgen_reduction_dim; + if (!tblgen_reduction_dim) return emitError(loc, "'vector.scan' op ""requires attribute 'reduction_dim'"); + + if (tblgen_kind && !((::llvm::isa<::mlir::vector::CombiningKindAttr>(tblgen_kind)))) + return emitError(loc, "'vector.scan' op ""attribute 'kind' failed to satisfy constraint: Kind of combining function for contractions and reductions"); + + if (tblgen_reduction_dim && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_reduction_dim))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_reduction_dim).getType().isSignlessInteger(64))))) + return emitError(loc, "'vector.scan' op ""attribute 'reduction_dim' failed to satisfy constraint: 64-bit signless integer attribute"); + + if (tblgen_inclusive && !((::llvm::isa<::mlir::BoolAttr>(tblgen_inclusive)))) + return emitError(loc, "'vector.scan' op ""attribute 'inclusive' failed to satisfy constraint: bool attribute"); + return ::mlir::success(); +} + +void ScanOp::getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn) { + auto resultGroup0 = getODSResults(0); + if (!resultGroup0.empty()) + setNameFn(*resultGroup0.begin(), "dest"); + auto resultGroup1 = getODSResults(1); + if (!resultGroup1.empty()) + setNameFn(*resultGroup1.begin(), "accumulated_value"); +} + +std::pair ScanOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ScanOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> ScanOp::getSource() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> ScanOp::getInitialValue() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(1).begin()); +} + +::mlir::OpOperand &ScanOp::getSourceMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &ScanOp::getInitialValueMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +std::pair ScanOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ScanOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> ScanOp::getDest() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSResults(0).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> ScanOp::getAccumulatedValue() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSResults(1).begin()); +} + +::mlir::LogicalResult ScanOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.inclusive; + auto attr = dict.get("inclusive"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for inclusive in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `inclusive` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.kind; + auto attr = dict.get("kind"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for kind in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `kind` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.reduction_dim; + auto attr = dict.get("reduction_dim"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for reduction_dim in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `reduction_dim` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ScanOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.inclusive; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("inclusive", + propStorage)); + } + + { + const auto &propStorage = prop.kind; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("kind", + propStorage)); + } + + { + const auto &propStorage = prop.reduction_dim; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("reduction_dim", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ScanOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.inclusive.getAsOpaquePointer()), + llvm::hash_value(prop.kind.getAsOpaquePointer()), + llvm::hash_value(prop.reduction_dim.getAsOpaquePointer())); +} + +std::optional ScanOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "inclusive") + return prop.inclusive; + + if (name == "kind") + return prop.kind; + + if (name == "reduction_dim") + return prop.reduction_dim; + return std::nullopt; +} + +void ScanOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "inclusive") { + prop.inclusive = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "kind") { + prop.kind = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "reduction_dim") { + prop.reduction_dim = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ScanOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.inclusive) attrs.append("inclusive", prop.inclusive); + + if (prop.kind) attrs.append("kind", prop.kind); + + if (prop.reduction_dim) attrs.append("reduction_dim", prop.reduction_dim); +} + +::mlir::LogicalResult ScanOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getInclusiveAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps9(attr, "inclusive", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getKindAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps3(attr, "kind", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getReductionDimAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps8(attr, "reduction_dim", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ScanOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.inclusive))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.kind))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.reduction_dim))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ScanOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.inclusive); + writer.writeAttribute(prop.kind); + writer.writeAttribute(prop.reduction_dim); +} + +::mlir::vector::CombiningKindAttr ScanOp::getKindAttr() { + return ::llvm::cast<::mlir::vector::CombiningKindAttr>(getProperties().kind); +} + +::mlir::vector::CombiningKind ScanOp::getKind() { + auto attr = getKindAttr(); + return attr.getValue(); +} + +::mlir::IntegerAttr ScanOp::getReductionDimAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().reduction_dim); +} + +uint64_t ScanOp::getReductionDim() { + auto attr = getReductionDimAttr(); + return attr.getValue().getZExtValue(); +} + +::mlir::BoolAttr ScanOp::getInclusiveAttr() { + return ::llvm::cast<::mlir::BoolAttr>(getProperties().inclusive); +} + +bool ScanOp::getInclusive() { + auto attr = getInclusiveAttr(); + return attr.getValue(); +} + +void ScanOp::setKindAttr(::mlir::vector::CombiningKindAttr attr) { + (*this)->setAttr(getKindAttrName(), attr); +} + +void ScanOp::setKind(::mlir::vector::CombiningKind attrValue) { + (*this)->setAttr(getKindAttrName(), ::mlir::vector::CombiningKindAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue)); +} + +void ScanOp::setReductionDimAttr(::mlir::IntegerAttr attr) { + (*this)->setAttr(getReductionDimAttrName(), attr); +} + +void ScanOp::setReductionDim(uint64_t attrValue) { + (*this)->setAttr(getReductionDimAttrName(), ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), attrValue)); +} + +void ScanOp::setInclusiveAttr(::mlir::BoolAttr attr) { + (*this)->setAttr(getInclusiveAttrName(), attr); +} + +void ScanOp::setInclusive(bool attrValue) { + (*this)->setAttr(getInclusiveAttrName(), ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue)); +} + +void ScanOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dest, ::mlir::Type accumulated_value, ::mlir::vector::CombiningKindAttr kind, ::mlir::Value source, ::mlir::Value initial_value, ::mlir::IntegerAttr reduction_dim, ::mlir::BoolAttr inclusive) { + odsState.addOperands(source); + odsState.addOperands(initial_value); + odsState.getOrAddProperties().kind = kind; + odsState.getOrAddProperties().reduction_dim = reduction_dim; + odsState.getOrAddProperties().inclusive = inclusive; + odsState.addTypes(dest); + odsState.addTypes(accumulated_value); +} + +void ScanOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::vector::CombiningKindAttr kind, ::mlir::Value source, ::mlir::Value initial_value, ::mlir::IntegerAttr reduction_dim, ::mlir::BoolAttr inclusive) { + odsState.addOperands(source); + odsState.addOperands(initial_value); + odsState.getOrAddProperties().kind = kind; + odsState.getOrAddProperties().reduction_dim = reduction_dim; + odsState.getOrAddProperties().inclusive = inclusive; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ScanOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void ScanOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::vector::CombiningKindAttr kind, ::mlir::Value source, ::mlir::Value initial_value, ::mlir::IntegerAttr reduction_dim, ::mlir::BoolAttr inclusive) { + odsState.addOperands(source); + odsState.addOperands(initial_value); + odsState.getOrAddProperties().kind = kind; + odsState.getOrAddProperties().reduction_dim = reduction_dim; + odsState.getOrAddProperties().inclusive = inclusive; + assert(resultTypes.size() == 2u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ScanOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dest, ::mlir::Type accumulated_value, ::mlir::vector::CombiningKind kind, ::mlir::Value source, ::mlir::Value initial_value, uint64_t reduction_dim, bool inclusive) { + odsState.addOperands(source); + odsState.addOperands(initial_value); + odsState.getOrAddProperties().kind = ::mlir::vector::CombiningKindAttr::get(odsBuilder.getContext(), kind); + odsState.getOrAddProperties().reduction_dim = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), reduction_dim); + odsState.getOrAddProperties().inclusive = odsBuilder.getBoolAttr(inclusive); + odsState.addTypes(dest); + odsState.addTypes(accumulated_value); +} + +void ScanOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::vector::CombiningKind kind, ::mlir::Value source, ::mlir::Value initial_value, uint64_t reduction_dim, bool inclusive) { + odsState.addOperands(source); + odsState.addOperands(initial_value); + odsState.getOrAddProperties().kind = ::mlir::vector::CombiningKindAttr::get(odsBuilder.getContext(), kind); + odsState.getOrAddProperties().reduction_dim = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), reduction_dim); + odsState.getOrAddProperties().inclusive = odsBuilder.getBoolAttr(inclusive); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ScanOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void ScanOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::vector::CombiningKind kind, ::mlir::Value source, ::mlir::Value initial_value, uint64_t reduction_dim, bool inclusive) { + odsState.addOperands(source); + odsState.addOperands(initial_value); + odsState.getOrAddProperties().kind = ::mlir::vector::CombiningKindAttr::get(odsBuilder.getContext(), kind); + odsState.getOrAddProperties().reduction_dim = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(64), reduction_dim); + odsState.getOrAddProperties().inclusive = odsBuilder.getBoolAttr(inclusive); + assert(resultTypes.size() == 2u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ScanOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 2u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ScanOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ScanOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 2u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult ScanOp::verifyInvariantsImpl() { + auto tblgen_inclusive = getProperties().inclusive; (void)tblgen_inclusive; + if (!tblgen_inclusive) return emitOpError("requires attribute 'inclusive'"); + auto tblgen_kind = getProperties().kind; (void)tblgen_kind; + if (!tblgen_kind) return emitOpError("requires attribute 'kind'"); + auto tblgen_reduction_dim = getProperties().reduction_dim; (void)tblgen_reduction_dim; + if (!tblgen_reduction_dim) return emitOpError("requires attribute 'reduction_dim'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps3(*this, tblgen_kind, "kind"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps8(*this, tblgen_reduction_dim, "reduction_dim"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps9(*this, tblgen_inclusive, "inclusive"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps7(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps7(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSResults(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((((*this->getODSOperands(0).begin()).getType()) == ((*this->getODSResults(0).begin()).getType()) && ((*this->getODSResults(0).begin()).getType()) == ((*this->getODSOperands(0).begin()).getType())))) + return emitOpError("failed to verify that all of {source, dest} have same type"); + if (!((((*this->getODSOperands(1).begin()).getType()) == ((*this->getODSResults(1).begin()).getType()) && ((*this->getODSResults(1).begin()).getType()) == ((*this->getODSOperands(1).begin()).getType())))) + return emitOpError("failed to verify that all of {initial_value, accumulated_value} have same type"); + return ::mlir::success(); +} + +::mlir::LogicalResult ScanOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::LogicalResult ScanOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(2); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = operands[0].getType(); + ::mlir::Type odsInferredType1 = operands[1].getType(); + inferredReturnTypes[0] = odsInferredType0; + inferredReturnTypes[1] = odsInferredType1; + return ::mlir::success(); +} + +::mlir::ParseResult ScanOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::vector::CombiningKindAttr kindAttr; + ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(sourceRawOperands); ::llvm::SMLoc sourceOperandsLoc; + (void)sourceOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand initial_valueRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> initial_valueOperands(initial_valueRawOperands); ::llvm::SMLoc initial_valueOperandsLoc; + (void)initial_valueOperandsLoc; + ::mlir::Type sourceRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> sourceTypes(sourceRawTypes); + ::mlir::Type initial_valueRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> initial_valueTypes(initial_valueRawTypes); + + if (parser.parseCustomAttributeWithFallback(kindAttr, ::mlir::Type{})) { + return ::mlir::failure(); + } + if (kindAttr) result.getOrAddProperties().kind = kindAttr; + if (parser.parseComma()) + return ::mlir::failure(); + + sourceOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(sourceRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + initial_valueOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(initial_valueRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + sourceRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + initial_valueRawTypes[0] = type; + } + result.addTypes(sourceTypes[0]); + result.addTypes(initial_valueTypes[0]); + if (parser.resolveOperands(sourceOperands, sourceTypes, sourceOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(initial_valueOperands, initial_valueTypes, initial_valueOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ScanOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; +_odsPrinter.printStrippedAttrOrType(getKindAttr()); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getSource(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getInitialValue(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("kind"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getSource().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getInitialValue().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void ScanOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::ScanOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::ScatterOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ScatterOpGenericAdaptorBase::ScatterOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.scatter", odsAttrs.getContext()); +} + +ScatterOpGenericAdaptorBase::ScatterOpGenericAdaptorBase(ScatterOp op) : ScatterOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ScatterOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, true, false, false, false}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 4) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr ScatterOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +ScatterOpAdaptor::ScatterOpAdaptor(ScatterOp op) : ScatterOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ScatterOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair ScatterOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, true, false, false, false}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 4) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range ScatterOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::MemRefType> ScatterOp::getBase() { + return ::llvm::cast<::mlir::TypedValue<::mlir::MemRefType>>(*getODSOperands(0).begin()); +} + +::mlir::Operation::operand_range ScatterOp::getIndices() { + return getODSOperands(1); +} + +::mlir::TypedValue<::mlir::VectorType> ScatterOp::getIndexVec() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(2).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> ScatterOp::getMask() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(3).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> ScatterOp::getValueToStore() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(4).begin()); +} + +::mlir::OpOperand &ScatterOp::getBaseMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange ScatterOp::getIndicesMutable() { + auto range = getODSOperandIndexAndLength(1); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +::mlir::OpOperand &ScatterOp::getIndexVecMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &ScatterOp::getMaskMutable() { + auto range = getODSOperandIndexAndLength(3); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &ScatterOp::getValueToStoreMutable() { + auto range = getODSOperandIndexAndLength(4); + return getOperation()->getOpOperand(range.first); +} + +std::pair ScatterOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ScatterOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +void ScatterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value base, ::mlir::ValueRange indices, ::mlir::Value index_vec, ::mlir::Value mask, ::mlir::Value valueToStore) { + odsState.addOperands(base); + odsState.addOperands(indices); + odsState.addOperands(index_vec); + odsState.addOperands(mask); + odsState.addOperands(valueToStore); +} + +void ScatterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value base, ::mlir::ValueRange indices, ::mlir::Value index_vec, ::mlir::Value mask, ::mlir::Value valueToStore) { + odsState.addOperands(base); + odsState.addOperands(indices); + odsState.addOperands(index_vec); + odsState.addOperands(mask); + odsState.addOperands(valueToStore); + assert(resultTypes.size() == 0u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ScatterOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 4u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ScatterOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps16(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup3 = getODSOperands(3); + + for (auto v : valueGroup3) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps4(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup4 = getODSOperands(4); + + for (auto v : valueGroup4) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps5(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ScatterOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult ScatterOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand baseRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> baseOperands(baseRawOperands); ::llvm::SMLoc baseOperandsLoc; + (void)baseOperandsLoc; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> indicesOperands; + ::llvm::SMLoc indicesOperandsLoc; + (void)indicesOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand index_vecRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> index_vecOperands(index_vecRawOperands); ::llvm::SMLoc index_vecOperandsLoc; + (void)index_vecOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand maskRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> maskOperands(maskRawOperands); ::llvm::SMLoc maskOperandsLoc; + (void)maskOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand valueToStoreRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> valueToStoreOperands(valueToStoreRawOperands); ::llvm::SMLoc valueToStoreOperandsLoc; + (void)valueToStoreOperandsLoc; + ::mlir::Type baseRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> baseTypes(baseRawTypes); + ::mlir::Type index_vecRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> index_vecTypes(index_vecRawTypes); + ::mlir::Type maskRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> maskTypes(maskRawTypes); + ::mlir::Type valueToStoreRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> valueToStoreTypes(valueToStoreRawTypes); + + baseOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(baseRawOperands[0])) + return ::mlir::failure(); + if (parser.parseLSquare()) + return ::mlir::failure(); + + indicesOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(indicesOperands)) + return ::mlir::failure(); + if (parser.parseRSquare()) + return ::mlir::failure(); + if (parser.parseLSquare()) + return ::mlir::failure(); + + index_vecOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(index_vecRawOperands[0])) + return ::mlir::failure(); + if (parser.parseRSquare()) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + maskOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(maskRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + valueToStoreOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(valueToStoreRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::MemRefType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + baseRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + index_vecRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + maskRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + valueToStoreRawTypes[0] = type; + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + if (parser.resolveOperands(baseOperands, baseTypes, baseOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(indicesOperands, odsBuildableType0, indicesOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(index_vecOperands, index_vecTypes, index_vecOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(maskOperands, maskTypes, maskOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(valueToStoreOperands, valueToStoreTypes, valueToStoreOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ScatterOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getBase(); + _odsPrinter << "["; + _odsPrinter << getIndices(); + _odsPrinter << "]"; + _odsPrinter << ' ' << "["; + _odsPrinter << getIndexVec(); + _odsPrinter << "]"; + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getMask(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getValueToStore(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getBase().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::MemRefType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getIndexVec().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getMask().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getValueToStore().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void ScatterOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { + for (::mlir::Value value : getODSOperands(0)) + effects.emplace_back(::mlir::MemoryEffects::Write::get(), value, 0, false, ::mlir::SideEffects::DefaultResource::get()); +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::ScatterOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::ShapeCastOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ShapeCastOpGenericAdaptorBase::ShapeCastOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.shape_cast", odsAttrs.getContext()); +} + +ShapeCastOpGenericAdaptorBase::ShapeCastOpGenericAdaptorBase(ShapeCastOp op) : ShapeCastOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ShapeCastOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ShapeCastOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +ShapeCastOpAdaptor::ShapeCastOpAdaptor(ShapeCastOp op) : ShapeCastOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ShapeCastOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair ShapeCastOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ShapeCastOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> ShapeCastOp::getSource() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &ShapeCastOp::getSourceMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair ShapeCastOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ShapeCastOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> ShapeCastOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSResults(0).begin()); +} + +void ShapeCastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source) { + odsState.addOperands(source); + odsState.addTypes(result); +} + +void ShapeCastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source) { + odsState.addOperands(source); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ShapeCastOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult ShapeCastOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult ShapeCastOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult ShapeCastOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand sourceRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(sourceRawOperands); ::llvm::SMLoc sourceOperandsLoc; + (void)sourceOperandsLoc; + ::mlir::Type sourceRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> sourceTypes(sourceRawTypes); + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + sourceOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(sourceRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + sourceRawTypes[0] = type; + } + if (parser.parseKeyword("to")) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(sourceOperands, sourceTypes, sourceOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ShapeCastOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getSource(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getSource().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "to"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void ShapeCastOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::ShapeCastOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::ShuffleOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +ShuffleOpGenericAdaptorBase::ShuffleOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.shuffle", odsAttrs.getContext()); +} + +ShuffleOpGenericAdaptorBase::ShuffleOpGenericAdaptorBase(ShuffleOp op) : ShuffleOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair ShuffleOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr ShuffleOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::ArrayAttr ShuffleOpGenericAdaptorBase::getMaskAttr() { + auto attr = ::llvm::cast<::mlir::ArrayAttr>(getProperties().mask); + return attr; +} + +::mlir::ArrayAttr ShuffleOpGenericAdaptorBase::getMask() { + auto attr = getMaskAttr(); + return attr; +} + +} // namespace detail +ShuffleOpAdaptor::ShuffleOpAdaptor(ShuffleOp op) : ShuffleOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult ShuffleOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_mask = getProperties().mask; (void)tblgen_mask; + if (!tblgen_mask) return emitError(loc, "'vector.shuffle' op ""requires attribute 'mask'"); + + if (tblgen_mask && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_mask))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_mask), [&](::mlir::Attribute attr) { return attr && (((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(64)))); })))) + return emitError(loc, "'vector.shuffle' op ""attribute 'mask' failed to satisfy constraint: 64-bit integer array attribute"); + return ::mlir::success(); +} + +std::pair ShuffleOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range ShuffleOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> ShuffleOp::getV1() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> ShuffleOp::getV2() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(1).begin()); +} + +::mlir::OpOperand &ShuffleOp::getV1Mutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &ShuffleOp::getV2Mutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +std::pair ShuffleOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range ShuffleOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> ShuffleOp::getVector() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult ShuffleOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.mask; + auto attr = dict.get("mask"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for mask in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `mask` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute ShuffleOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.mask; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("mask", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code ShuffleOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.mask.getAsOpaquePointer())); +} + +std::optional ShuffleOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "mask") + return prop.mask; + return std::nullopt; +} + +void ShuffleOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "mask") { + prop.mask = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void ShuffleOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.mask) attrs.append("mask", prop.mask); +} + +::mlir::LogicalResult ShuffleOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getMaskAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps0(attr, "mask", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult ShuffleOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.mask))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void ShuffleOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.mask); +} + +::mlir::ArrayAttr ShuffleOp::getMaskAttr() { + return ::llvm::cast<::mlir::ArrayAttr>(getProperties().mask); +} + +::mlir::ArrayAttr ShuffleOp::getMask() { + auto attr = getMaskAttr(); + return attr; +} + +void ShuffleOp::setMaskAttr(::mlir::ArrayAttr attr) { + (*this)->setAttr(getMaskAttrName(), attr); +} + +void ShuffleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type vector, ::mlir::Value v1, ::mlir::Value v2, ::mlir::ArrayAttr mask) { + odsState.addOperands(v1); + odsState.addOperands(v2); + odsState.getOrAddProperties().mask = mask; + odsState.addTypes(vector); +} + +void ShuffleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value v1, ::mlir::Value v2, ::mlir::ArrayAttr mask) { + odsState.addOperands(v1); + odsState.addOperands(v2); + odsState.getOrAddProperties().mask = mask; + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ShuffleOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void ShuffleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value v1, ::mlir::Value v2, ::mlir::ArrayAttr mask) { + odsState.addOperands(v1); + odsState.addOperands(v2); + odsState.getOrAddProperties().mask = mask; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void ShuffleOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void ShuffleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(ShuffleOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult ShuffleOp::verifyInvariantsImpl() { + auto tblgen_mask = getProperties().mask; (void)tblgen_mask; + if (!tblgen_mask) return emitOpError("requires attribute 'mask'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps0(*this, tblgen_mask, "mask"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps7(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((getElementTypeOrSelf((*this->getOperation()).getResult(0)) == getElementTypeOrSelf((*this->getOperation()).getOperand(0))))) + return emitOpError("failed to verify that first operand v1 and result have same element type"); + if (!((getElementTypeOrSelf((*this->getOperation()).getResult(0)) == getElementTypeOrSelf((*this->getOperation()).getOperand(1))))) + return emitOpError("failed to verify that second operand v2 and result have same element type"); + return ::mlir::success(); +} + +::mlir::LogicalResult ShuffleOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult ShuffleOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands; + ::mlir::ArrayAttr maskAttr; + ::llvm::SmallVector<::mlir::Type, 1> allOperandTypes; + ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(allOperands)) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(maskAttr, parser.getBuilder().getType<::mlir::NoneType>())) { + return ::mlir::failure(); + } + if (maskAttr) result.getOrAddProperties().mask = maskAttr; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + if (parser.parseTypeList(allOperandTypes)) + return ::mlir::failure(); + if (parser.resolveOperands(allOperands, allOperandTypes, allOperandLoc, result.operands)) + return ::mlir::failure(); + + ::llvm::SmallVector<::mlir::Type> inferredReturnTypes; + if (::mlir::failed(ShuffleOp::inferReturnTypes(parser.getContext(), + result.location, result.operands, + result.attributes.getDictionary(parser.getContext()), + result.getRawProperties(), + result.regions, inferredReturnTypes))) + return ::mlir::failure(); + result.addTypes(inferredReturnTypes); + return ::mlir::success(); +} + +void ShuffleOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getOperation()->getOperands(); + _odsPrinter << ' '; + _odsPrinter.printAttributeWithoutType(getMaskAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("mask"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter << getOperation()->getOperandTypes(); +} + +void ShuffleOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::mlir::LogicalResult +ShuffleOp::inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, + ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) { + ShuffleOp::Adaptor adaptor(operands, attributes, properties, regions); + return ShuffleOp::inferReturnTypes(context, + location, adaptor, inferredReturnTypes); +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::ShuffleOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::SplatOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +SplatOpGenericAdaptorBase::SplatOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.splat", odsAttrs.getContext()); +} + +SplatOpGenericAdaptorBase::SplatOpGenericAdaptorBase(SplatOp op) : SplatOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair SplatOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr SplatOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +SplatOpAdaptor::SplatOpAdaptor(SplatOp op) : SplatOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult SplatOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair SplatOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range SplatOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value SplatOp::getInput() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &SplatOp::getInputMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair SplatOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range SplatOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> SplatOp::getAggregate() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSResults(0).begin()); +} + +void SplatOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value element, Type aggregateType) { + build(odsBuilder, odsState, aggregateType, element); +} + +void SplatOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type aggregate, ::mlir::Value input) { + odsState.addOperands(input); + odsState.addTypes(aggregate); +} + +void SplatOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input) { + odsState.addOperands(input); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void SplatOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult SplatOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps17(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((std::equal_to<>()(::llvm::cast((*this->getODSResults(0).begin()).getType()).getElementType(), (*this->getODSOperands(0).begin()).getType())))) + return emitOpError("failed to verify that operand type matches element type of result"); + return ::mlir::success(); +} + +::mlir::LogicalResult SplatOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult SplatOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand inputRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> inputOperands(inputRawOperands); ::llvm::SMLoc inputOperandsLoc; + (void)inputOperandsLoc; + ::mlir::Type aggregateRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> aggregateTypes(aggregateRawTypes); + + inputOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(inputRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + aggregateRawTypes[0] = type; + } + for (::mlir::Type type : aggregateTypes) { + (void)type; + if (!(((::llvm::isa<::mlir::VectorType>(type))) && ([](::mlir::Type elementType) { return (true); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) { + return parser.emitError(parser.getNameLoc()) << "'aggregate' must be vector of any type values, but got " << type; + } + } + result.addTypes(aggregateTypes); + if (parser.resolveOperands(inputOperands, ::llvm::cast(aggregateTypes[0]).getElementType(), inputOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void SplatOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getInput(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getAggregate().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void SplatOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::SplatOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::StoreOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +StoreOpGenericAdaptorBase::StoreOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.store", odsAttrs.getContext()); +} + +StoreOpGenericAdaptorBase::StoreOpGenericAdaptorBase(StoreOp op) : StoreOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair StoreOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 2) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr StoreOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +StoreOpAdaptor::StoreOpAdaptor(StoreOp op) : StoreOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult StoreOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair StoreOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 2) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range StoreOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> StoreOp::getValueToStore() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::MemRefType> StoreOp::getBase() { + return ::llvm::cast<::mlir::TypedValue<::mlir::MemRefType>>(*getODSOperands(1).begin()); +} + +::mlir::Operation::operand_range StoreOp::getIndices() { + return getODSOperands(2); +} + +::mlir::OpOperand &StoreOp::getValueToStoreMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &StoreOp::getBaseMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange StoreOp::getIndicesMutable() { + auto range = getODSOperandIndexAndLength(2); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair StoreOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range StoreOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +void StoreOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value valueToStore, ::mlir::Value base, ::mlir::ValueRange indices) { + odsState.addOperands(valueToStore); + odsState.addOperands(base); + odsState.addOperands(indices); +} + +void StoreOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value valueToStore, ::mlir::Value base, ::mlir::ValueRange indices) { + odsState.addOperands(valueToStore); + odsState.addOperands(base); + odsState.addOperands(indices); + assert(resultTypes.size() == 0u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void StoreOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult StoreOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps7(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult StoreOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult StoreOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand valueToStoreRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> valueToStoreOperands(valueToStoreRawOperands); ::llvm::SMLoc valueToStoreOperandsLoc; + (void)valueToStoreOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand baseRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> baseOperands(baseRawOperands); ::llvm::SMLoc baseOperandsLoc; + (void)baseOperandsLoc; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> indicesOperands; + ::llvm::SMLoc indicesOperandsLoc; + (void)indicesOperandsLoc; + ::mlir::Type baseRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> baseTypes(baseRawTypes); + ::mlir::Type valueToStoreRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> valueToStoreTypes(valueToStoreRawTypes); + + valueToStoreOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(valueToStoreRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + baseOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(baseRawOperands[0])) + return ::mlir::failure(); + if (parser.parseLSquare()) + return ::mlir::failure(); + + indicesOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(indicesOperands)) + return ::mlir::failure(); + if (parser.parseRSquare()) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::MemRefType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + baseRawTypes[0] = type; + } + if (parser.parseComma()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + valueToStoreRawTypes[0] = type; + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType(); + if (parser.resolveOperands(valueToStoreOperands, valueToStoreTypes, valueToStoreOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(baseOperands, baseTypes, baseOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(indicesOperands, odsBuildableType0, indicesOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void StoreOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getValueToStore(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getBase(); + _odsPrinter << "["; + _odsPrinter << getIndices(); + _odsPrinter << "]"; + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getBase().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::MemRefType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ","; + _odsPrinter << ' '; + { + auto type = getValueToStore().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void StoreOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { + for (::mlir::Value value : getODSOperands(1)) + effects.emplace_back(::mlir::MemoryEffects::Write::get(), value, 0, false, ::mlir::SideEffects::DefaultResource::get()); +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::StoreOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::TransferReadOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +TransferReadOpGenericAdaptorBase::TransferReadOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.transfer_read", odsAttrs.getContext()); +} + +TransferReadOpGenericAdaptorBase::TransferReadOpGenericAdaptorBase(TransferReadOp op) : TransferReadOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair TransferReadOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; + + unsigned start = 0; + for (unsigned i = 0; i < index; ++i) + start += sizeAttr[i]; + return {start, sizeAttr[index]}; +} + +::mlir::DictionaryAttr TransferReadOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::AffineMapAttr TransferReadOpGenericAdaptorBase::getPermutationMapAttr() { + auto attr = ::llvm::cast<::mlir::AffineMapAttr>(getProperties().permutation_map); + return attr; +} + +::mlir::AffineMap TransferReadOpGenericAdaptorBase::getPermutationMap() { + auto attr = getPermutationMapAttr(); + return attr.getValue(); +} + +::mlir::ArrayAttr TransferReadOpGenericAdaptorBase::getInBoundsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().in_bounds); + return attr; +} + +::std::optional< ::mlir::ArrayAttr > TransferReadOpGenericAdaptorBase::getInBounds() { + auto attr = getInBoundsAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +} // namespace detail +TransferReadOpAdaptor::TransferReadOpAdaptor(TransferReadOp op) : TransferReadOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult TransferReadOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_in_bounds = getProperties().in_bounds; (void)tblgen_in_bounds; + auto tblgen_permutation_map = getProperties().permutation_map; (void)tblgen_permutation_map; + if (!tblgen_permutation_map) return emitError(loc, "'vector.transfer_read' op ""requires attribute 'permutation_map'"); + + if (tblgen_permutation_map && !((::llvm::isa<::mlir::AffineMapAttr>(tblgen_permutation_map)))) + return emitError(loc, "'vector.transfer_read' op ""attribute 'permutation_map' failed to satisfy constraint: AffineMap attribute"); + + if (tblgen_in_bounds && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_in_bounds))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_in_bounds), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::BoolAttr>(attr))); })))) + return emitError(loc, "'vector.transfer_read' op ""attribute 'in_bounds' failed to satisfy constraint: 1-bit boolean array attribute"); + return ::mlir::success(); +} + +std::pair TransferReadOp::getODSOperandIndexAndLength(unsigned index) { + ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; + + unsigned start = 0; + for (unsigned i = 0; i < index; ++i) + start += sizeAttr[i]; + return {start, sizeAttr[index]}; +} + +::mlir::Operation::operand_range TransferReadOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::ShapedType> TransferReadOp::getSource() { + return ::llvm::cast<::mlir::TypedValue<::mlir::ShapedType>>(*getODSOperands(0).begin()); +} + +::mlir::Operation::operand_range TransferReadOp::getIndices() { + return getODSOperands(1); +} + +::mlir::Value TransferReadOp::getPadding() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(2).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> TransferReadOp::getMask() { + auto operands = getODSOperands(3); + return operands.empty() ? ::mlir::TypedValue<::mlir::VectorType>{} : ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*operands.begin()); +} + +::mlir::OpOperand &TransferReadOp::getSourceMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange TransferReadOp::getIndicesMutable() { + auto range = getODSOperandIndexAndLength(1); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(1u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); + return mutableRange; +} + +::mlir::OpOperand &TransferReadOp::getPaddingMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange TransferReadOp::getMaskMutable() { + auto range = getODSOperandIndexAndLength(3); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); + return mutableRange; +} + +std::pair TransferReadOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range TransferReadOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> TransferReadOp::getVector() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult TransferReadOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.in_bounds; + auto attr = dict.get("in_bounds"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for in_bounds in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `in_bounds` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.permutation_map; + auto attr = dict.get("permutation_map"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for permutation_map in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `permutation_map` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } +; + { + auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, + ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return convertFromAttribute(propStorage, propAttr, emitError);; + }; + auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; + if (!attr) { + emitError() << "expected key entry for operandSegmentSizes in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + if (::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute TransferReadOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.in_bounds; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("in_bounds", + propStorage)); + } + + { + const auto &propStorage = prop.permutation_map; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("permutation_map", + propStorage)); + } + + { + const auto &propStorage = prop.operandSegmentSizes; + attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", + ::mlir::DenseI32ArrayAttr::get(ctx, propStorage))); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code TransferReadOp::computePropertiesHash(const Properties &prop) { + auto hash_operandSegmentSizes = [] (const auto &propStorage) -> llvm::hash_code { + return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; + }; + return llvm::hash_combine( + llvm::hash_value(prop.in_bounds.getAsOpaquePointer()), + llvm::hash_value(prop.permutation_map.getAsOpaquePointer()), + hash_operandSegmentSizes(prop.operandSegmentSizes)); +} + +std::optional TransferReadOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "in_bounds") + return prop.in_bounds; + + if (name == "permutation_map") + return prop.permutation_map; + if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); + return std::nullopt; +} + +void TransferReadOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "in_bounds") { + prop.in_bounds = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "permutation_map") { + prop.permutation_map = ::llvm::dyn_cast_or_null>(value); + return; + } + if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { + auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); + if (!arrAttr) return; + if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) + return; + llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); + return; + } +} + +void TransferReadOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.in_bounds) attrs.append("in_bounds", prop.in_bounds); + + if (prop.permutation_map) attrs.append("permutation_map", prop.permutation_map); + attrs.append("operandSegmentSizes", ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes)); +} + +::mlir::LogicalResult TransferReadOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getInBoundsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps11(attr, "in_bounds", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getPermutationMapAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps10(attr, "permutation_map", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult TransferReadOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.in_bounds))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.permutation_map))) + return ::mlir::failure(); + + { + auto &propStorage = prop.operandSegmentSizes; + auto readProp = [&]() { + +if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { + ::mlir::DenseI32ArrayAttr attr; + if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); + if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { + reader.emitError("size mismatch for operand/result_segment_size"); + return ::mlir::failure(); + } + ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); +} else { + return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); +} +; + return ::mlir::success(); + }; + if (::mlir::failed(readProp())) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +void TransferReadOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.in_bounds); + writer.writeAttribute(prop.permutation_map); + + { + auto &propStorage = prop.operandSegmentSizes; + +if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) + writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(getContext(), propStorage)); +else + writer.writeSparseArray(::llvm::ArrayRef(propStorage)); +; + } +} + +::mlir::AffineMapAttr TransferReadOp::getPermutationMapAttr() { + return ::llvm::cast<::mlir::AffineMapAttr>(getProperties().permutation_map); +} + +::mlir::AffineMap TransferReadOp::getPermutationMap() { + auto attr = getPermutationMapAttr(); + return attr.getValue(); +} + +::mlir::ArrayAttr TransferReadOp::getInBoundsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().in_bounds); +} + +::std::optional< ::mlir::ArrayAttr > TransferReadOp::getInBounds() { + auto attr = getInBoundsAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +void TransferReadOp::setPermutationMapAttr(::mlir::AffineMapAttr attr) { + (*this)->setAttr(getPermutationMapAttrName(), attr); +} + +void TransferReadOp::setPermutationMap(::mlir::AffineMap attrValue) { + (*this)->setAttr(getPermutationMapAttrName(), ::mlir::AffineMapAttr::get(attrValue)); +} + +void TransferReadOp::setInBoundsAttr(::mlir::ArrayAttr attr) { + (*this)->setAttr(getInBoundsAttrName(), attr); +} + +::mlir::Attribute TransferReadOp::removeInBoundsAttr() { + auto &attr = getProperties().in_bounds; + attr = {}; + return attr; +} + +void TransferReadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type vector, ::mlir::Value source, ::mlir::ValueRange indices, ::mlir::AffineMapAttr permutation_map, ::mlir::Value padding, /*optional*/::mlir::Value mask, /*optional*/::mlir::ArrayAttr in_bounds) { + odsState.addOperands(source); + odsState.addOperands(indices); + odsState.addOperands(padding); + if (mask) + odsState.addOperands(mask); + ::llvm::copy(::llvm::ArrayRef({1, static_cast(indices.size()), 1, (mask ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + odsState.getOrAddProperties().permutation_map = permutation_map; + if (in_bounds) { + odsState.getOrAddProperties().in_bounds = in_bounds; + } + odsState.addTypes(vector); +} + +void TransferReadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::ValueRange indices, ::mlir::AffineMapAttr permutation_map, ::mlir::Value padding, /*optional*/::mlir::Value mask, /*optional*/::mlir::ArrayAttr in_bounds) { + odsState.addOperands(source); + odsState.addOperands(indices); + odsState.addOperands(padding); + if (mask) + odsState.addOperands(mask); + ::llvm::copy(::llvm::ArrayRef({1, static_cast(indices.size()), 1, (mask ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + odsState.getOrAddProperties().permutation_map = permutation_map; + if (in_bounds) { + odsState.getOrAddProperties().in_bounds = in_bounds; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void TransferReadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type vector, ::mlir::Value source, ::mlir::ValueRange indices, ::mlir::AffineMap permutation_map, ::mlir::Value padding, /*optional*/::mlir::Value mask, /*optional*/::mlir::ArrayAttr in_bounds) { + odsState.addOperands(source); + odsState.addOperands(indices); + odsState.addOperands(padding); + if (mask) + odsState.addOperands(mask); + ::llvm::copy(::llvm::ArrayRef({1, static_cast(indices.size()), 1, (mask ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + odsState.getOrAddProperties().permutation_map = ::mlir::AffineMapAttr::get(permutation_map); + if (in_bounds) { + odsState.getOrAddProperties().in_bounds = in_bounds; + } + odsState.addTypes(vector); +} + +void TransferReadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::ValueRange indices, ::mlir::AffineMap permutation_map, ::mlir::Value padding, /*optional*/::mlir::Value mask, /*optional*/::mlir::ArrayAttr in_bounds) { + odsState.addOperands(source); + odsState.addOperands(indices); + odsState.addOperands(padding); + if (mask) + odsState.addOperands(mask); + ::llvm::copy(::llvm::ArrayRef({1, static_cast(indices.size()), 1, (mask ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + odsState.getOrAddProperties().permutation_map = ::mlir::AffineMapAttr::get(permutation_map); + if (in_bounds) { + odsState.getOrAddProperties().in_bounds = in_bounds; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void TransferReadOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult TransferReadOp::verifyInvariantsImpl() { + auto tblgen_in_bounds = getProperties().in_bounds; (void)tblgen_in_bounds; + auto tblgen_permutation_map = getProperties().permutation_map; (void)tblgen_permutation_map; + if (!tblgen_permutation_map) return emitOpError("requires attribute 'permutation_map'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps10(*this, tblgen_permutation_map, "permutation_map"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps11(*this, tblgen_in_bounds, "in_bounds"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps11(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup3 = getODSOperands(3); + + if (valueGroup3.size() > 1) { + return emitOpError("operand group starting at #") << index + << " requires 0 or 1 element, but found " << valueGroup3.size(); + } + + for (auto v : valueGroup3) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps13(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult TransferReadOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::TransferReadOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::TransferWriteOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +TransferWriteOpGenericAdaptorBase::TransferWriteOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.transfer_write", odsAttrs.getContext()); +} + +TransferWriteOpGenericAdaptorBase::TransferWriteOpGenericAdaptorBase(TransferWriteOp op) : TransferWriteOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair TransferWriteOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; + + unsigned start = 0; + for (unsigned i = 0; i < index; ++i) + start += sizeAttr[i]; + return {start, sizeAttr[index]}; +} + +::mlir::DictionaryAttr TransferWriteOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::AffineMapAttr TransferWriteOpGenericAdaptorBase::getPermutationMapAttr() { + auto attr = ::llvm::cast<::mlir::AffineMapAttr>(getProperties().permutation_map); + return attr; +} + +::mlir::AffineMap TransferWriteOpGenericAdaptorBase::getPermutationMap() { + auto attr = getPermutationMapAttr(); + return attr.getValue(); +} + +::mlir::ArrayAttr TransferWriteOpGenericAdaptorBase::getInBoundsAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().in_bounds); + return attr; +} + +::std::optional< ::mlir::ArrayAttr > TransferWriteOpGenericAdaptorBase::getInBounds() { + auto attr = getInBoundsAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +} // namespace detail +TransferWriteOpAdaptor::TransferWriteOpAdaptor(TransferWriteOp op) : TransferWriteOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult TransferWriteOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_in_bounds = getProperties().in_bounds; (void)tblgen_in_bounds; + auto tblgen_permutation_map = getProperties().permutation_map; (void)tblgen_permutation_map; + if (!tblgen_permutation_map) return emitError(loc, "'vector.transfer_write' op ""requires attribute 'permutation_map'"); + + if (tblgen_permutation_map && !((::llvm::isa<::mlir::AffineMapAttr>(tblgen_permutation_map)))) + return emitError(loc, "'vector.transfer_write' op ""attribute 'permutation_map' failed to satisfy constraint: AffineMap attribute"); + + if (tblgen_in_bounds && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_in_bounds))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_in_bounds), [&](::mlir::Attribute attr) { return attr && ((::llvm::isa<::mlir::BoolAttr>(attr))); })))) + return emitError(loc, "'vector.transfer_write' op ""attribute 'in_bounds' failed to satisfy constraint: 1-bit boolean array attribute"); + return ::mlir::success(); +} + +std::pair TransferWriteOp::getODSOperandIndexAndLength(unsigned index) { + ::llvm::ArrayRef sizeAttr = getProperties().operandSegmentSizes; + + unsigned start = 0; + for (unsigned i = 0; i < index; ++i) + start += sizeAttr[i]; + return {start, sizeAttr[index]}; +} + +::mlir::Operation::operand_range TransferWriteOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> TransferWriteOp::getVector() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::ShapedType> TransferWriteOp::getSource() { + return ::llvm::cast<::mlir::TypedValue<::mlir::ShapedType>>(*getODSOperands(1).begin()); +} + +::mlir::Operation::operand_range TransferWriteOp::getIndices() { + return getODSOperands(2); +} + +::mlir::TypedValue<::mlir::VectorType> TransferWriteOp::getMask() { + auto operands = getODSOperands(3); + return operands.empty() ? ::mlir::TypedValue<::mlir::VectorType>{} : ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*operands.begin()); +} + +::mlir::OpOperand &TransferWriteOp::getVectorMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &TransferWriteOp::getSourceMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange TransferWriteOp::getIndicesMutable() { + auto range = getODSOperandIndexAndLength(2); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(2u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); + return mutableRange; +} + +::mlir::MutableOperandRange TransferWriteOp::getMaskMutable() { + auto range = getODSOperandIndexAndLength(3); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second, ::mlir::MutableOperandRange::OperandSegment(3u, {getOperandSegmentSizesAttrName(), ::mlir::DenseI32ArrayAttr::get(getContext(), getProperties().operandSegmentSizes)})); + return mutableRange; +} + +std::pair TransferWriteOp::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::result_range TransferWriteOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::RankedTensorType> TransferWriteOp::getResult() { + auto results = getODSResults(0); + return results.empty() ? ::mlir::TypedValue<::mlir::RankedTensorType>() : ::llvm::cast<::mlir::TypedValue<::mlir::RankedTensorType>>(*results.begin()); +} + +::mlir::LogicalResult TransferWriteOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.in_bounds; + auto attr = dict.get("in_bounds"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for in_bounds in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `in_bounds` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + + { + auto &propStorage = prop.permutation_map; + auto attr = dict.get("permutation_map"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for permutation_map in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `permutation_map` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } +; + { + auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr, + ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + return convertFromAttribute(propStorage, propAttr, emitError);; + }; + auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");; + if (!attr) { + emitError() << "expected key entry for operandSegmentSizes in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + if (::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::Attribute TransferWriteOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.in_bounds; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("in_bounds", + propStorage)); + } + + { + const auto &propStorage = prop.permutation_map; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("permutation_map", + propStorage)); + } + + { + const auto &propStorage = prop.operandSegmentSizes; + attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", + ::mlir::DenseI32ArrayAttr::get(ctx, propStorage))); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code TransferWriteOp::computePropertiesHash(const Properties &prop) { + auto hash_operandSegmentSizes = [] (const auto &propStorage) -> llvm::hash_code { + return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));; + }; + return llvm::hash_combine( + llvm::hash_value(prop.in_bounds.getAsOpaquePointer()), + llvm::hash_value(prop.permutation_map.getAsOpaquePointer()), + hash_operandSegmentSizes(prop.operandSegmentSizes)); +} + +std::optional TransferWriteOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "in_bounds") + return prop.in_bounds; + + if (name == "permutation_map") + return prop.permutation_map; + if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); + return std::nullopt; +} + +void TransferWriteOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "in_bounds") { + prop.in_bounds = ::llvm::dyn_cast_or_null>(value); + return; + } + + if (name == "permutation_map") { + prop.permutation_map = ::llvm::dyn_cast_or_null>(value); + return; + } + if (name == "operand_segment_sizes" || name == "operandSegmentSizes") { + auto arrAttr = ::llvm::dyn_cast_or_null<::mlir::DenseI32ArrayAttr>(value); + if (!arrAttr) return; + if (arrAttr.size() != sizeof(prop.operandSegmentSizes) / sizeof(int32_t)) + return; + llvm::copy(arrAttr.asArrayRef(), prop.operandSegmentSizes.begin()); + return; + } +} + +void TransferWriteOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.in_bounds) attrs.append("in_bounds", prop.in_bounds); + + if (prop.permutation_map) attrs.append("permutation_map", prop.permutation_map); + attrs.append("operandSegmentSizes", ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes)); +} + +::mlir::LogicalResult TransferWriteOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getInBoundsAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps11(attr, "in_bounds", emitError))) + return ::mlir::failure(); + } + + { + ::mlir::Attribute attr = attrs.get(getPermutationMapAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps10(attr, "permutation_map", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult TransferWriteOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.in_bounds))) + return ::mlir::failure(); + + if (::mlir::failed(reader.readAttribute(prop.permutation_map))) + return ::mlir::failure(); + + { + auto &propStorage = prop.operandSegmentSizes; + auto readProp = [&]() { + +if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) { + ::mlir::DenseI32ArrayAttr attr; + if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure(); + if (attr.size() > static_cast(sizeof(propStorage) / sizeof(int32_t))) { + reader.emitError("size mismatch for operand/result_segment_size"); + return ::mlir::failure(); + } + ::llvm::copy(::llvm::ArrayRef(attr), propStorage.begin()); +} else { + return reader.readSparseArray(::llvm::MutableArrayRef(propStorage)); +} +; + return ::mlir::success(); + }; + if (::mlir::failed(readProp())) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +void TransferWriteOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.in_bounds); + writer.writeAttribute(prop.permutation_map); + + { + auto &propStorage = prop.operandSegmentSizes; + +if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) + writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(getContext(), propStorage)); +else + writer.writeSparseArray(::llvm::ArrayRef(propStorage)); +; + } +} + +::mlir::AffineMapAttr TransferWriteOp::getPermutationMapAttr() { + return ::llvm::cast<::mlir::AffineMapAttr>(getProperties().permutation_map); +} + +::mlir::AffineMap TransferWriteOp::getPermutationMap() { + auto attr = getPermutationMapAttr(); + return attr.getValue(); +} + +::mlir::ArrayAttr TransferWriteOp::getInBoundsAttr() { + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(getProperties().in_bounds); +} + +::std::optional< ::mlir::ArrayAttr > TransferWriteOp::getInBounds() { + auto attr = getInBoundsAttr(); + return attr ? ::std::optional< ::mlir::ArrayAttr >(attr) : (::std::nullopt); +} + +void TransferWriteOp::setPermutationMapAttr(::mlir::AffineMapAttr attr) { + (*this)->setAttr(getPermutationMapAttrName(), attr); +} + +void TransferWriteOp::setPermutationMap(::mlir::AffineMap attrValue) { + (*this)->setAttr(getPermutationMapAttrName(), ::mlir::AffineMapAttr::get(attrValue)); +} + +void TransferWriteOp::setInBoundsAttr(::mlir::ArrayAttr attr) { + (*this)->setAttr(getInBoundsAttrName(), attr); +} + +::mlir::Attribute TransferWriteOp::removeInBoundsAttr() { + auto &attr = getProperties().in_bounds; + attr = {}; + return attr; +} + +void TransferWriteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Type result, ::mlir::Value vector, ::mlir::Value source, ::mlir::ValueRange indices, ::mlir::AffineMapAttr permutation_map, /*optional*/::mlir::Value mask, /*optional*/::mlir::ArrayAttr in_bounds) { + odsState.addOperands(vector); + odsState.addOperands(source); + odsState.addOperands(indices); + if (mask) + odsState.addOperands(mask); + ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(indices.size()), (mask ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + odsState.getOrAddProperties().permutation_map = permutation_map; + if (in_bounds) { + odsState.getOrAddProperties().in_bounds = in_bounds; + } + if (result) + odsState.addTypes(result); +} + +void TransferWriteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value vector, ::mlir::Value source, ::mlir::ValueRange indices, ::mlir::AffineMapAttr permutation_map, /*optional*/::mlir::Value mask, /*optional*/::mlir::ArrayAttr in_bounds) { + odsState.addOperands(vector); + odsState.addOperands(source); + odsState.addOperands(indices); + if (mask) + odsState.addOperands(mask); + ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(indices.size()), (mask ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + odsState.getOrAddProperties().permutation_map = permutation_map; + if (in_bounds) { + odsState.getOrAddProperties().in_bounds = in_bounds; + } + odsState.addTypes(resultTypes); +} + +void TransferWriteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Type result, ::mlir::Value vector, ::mlir::Value source, ::mlir::ValueRange indices, ::mlir::AffineMap permutation_map, /*optional*/::mlir::Value mask, /*optional*/::mlir::ArrayAttr in_bounds) { + odsState.addOperands(vector); + odsState.addOperands(source); + odsState.addOperands(indices); + if (mask) + odsState.addOperands(mask); + ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(indices.size()), (mask ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + odsState.getOrAddProperties().permutation_map = ::mlir::AffineMapAttr::get(permutation_map); + if (in_bounds) { + odsState.getOrAddProperties().in_bounds = in_bounds; + } + if (result) + odsState.addTypes(result); +} + +void TransferWriteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value vector, ::mlir::Value source, ::mlir::ValueRange indices, ::mlir::AffineMap permutation_map, /*optional*/::mlir::Value mask, /*optional*/::mlir::ArrayAttr in_bounds) { + odsState.addOperands(vector); + odsState.addOperands(source); + odsState.addOperands(indices); + if (mask) + odsState.addOperands(mask); + ::llvm::copy(::llvm::ArrayRef({1, 1, static_cast(indices.size()), (mask ? 1 : 0)}), odsState.getOrAddProperties().operandSegmentSizes.begin()); + odsState.getOrAddProperties().permutation_map = ::mlir::AffineMapAttr::get(permutation_map); + if (in_bounds) { + odsState.getOrAddProperties().in_bounds = in_bounds; + } + odsState.addTypes(resultTypes); +} + +void TransferWriteOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult TransferWriteOp::verifyInvariantsImpl() { + auto tblgen_in_bounds = getProperties().in_bounds; (void)tblgen_in_bounds; + auto tblgen_permutation_map = getProperties().permutation_map; (void)tblgen_permutation_map; + if (!tblgen_permutation_map) return emitOpError("requires attribute 'permutation_map'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps10(*this, tblgen_permutation_map, "permutation_map"))) + return ::mlir::failure(); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps11(*this, tblgen_in_bounds, "in_bounds"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps11(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup3 = getODSOperands(3); + + if (valueGroup3.size() > 1) { + return emitOpError("operand group starting at #") << index + << " requires 0 or 1 element, but found " << valueGroup3.size(); + } + + for (auto v : valueGroup3) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps13(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + if (valueGroup0.size() > 1) { + return emitOpError("result group starting at #") << index + << " requires 0 or 1 element, but found " << valueGroup0.size(); + } + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps18(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult TransferWriteOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::TransferWriteOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::TransposeOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +TransposeOpGenericAdaptorBase::TransposeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.transpose", odsAttrs.getContext()); +} + +TransposeOpGenericAdaptorBase::TransposeOpGenericAdaptorBase(TransposeOp op) : TransposeOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair TransposeOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr TransposeOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::ArrayAttr TransposeOpGenericAdaptorBase::getTranspAttr() { + auto attr = ::llvm::cast<::mlir::ArrayAttr>(getProperties().transp); + return attr; +} + +::mlir::ArrayAttr TransposeOpGenericAdaptorBase::getTransp() { + auto attr = getTranspAttr(); + return attr; +} + +} // namespace detail +TransposeOpAdaptor::TransposeOpAdaptor(TransposeOp op) : TransposeOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult TransposeOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_transp = getProperties().transp; (void)tblgen_transp; + if (!tblgen_transp) return emitError(loc, "'vector.transpose' op ""requires attribute 'transp'"); + + if (tblgen_transp && !(((::llvm::isa<::mlir::ArrayAttr>(tblgen_transp))) && (::llvm::all_of(::llvm::cast<::mlir::ArrayAttr>(tblgen_transp), [&](::mlir::Attribute attr) { return attr && (((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(64)))); })))) + return emitError(loc, "'vector.transpose' op ""attribute 'transp' failed to satisfy constraint: 64-bit integer array attribute"); + return ::mlir::success(); +} + +std::pair TransposeOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range TransposeOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> TransposeOp::getVector() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &TransposeOp::getVectorMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair TransposeOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range TransposeOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> TransposeOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult TransposeOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.transp; + auto attr = dict.get("transp"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for transp in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `transp` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute TransposeOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.transp; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("transp", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code TransposeOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.transp.getAsOpaquePointer())); +} + +std::optional TransposeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "transp") + return prop.transp; + return std::nullopt; +} + +void TransposeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "transp") { + prop.transp = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void TransposeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.transp) attrs.append("transp", prop.transp); +} + +::mlir::LogicalResult TransposeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getTranspAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps0(attr, "transp", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult TransposeOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.transp))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void TransposeOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.transp); +} + +::mlir::ArrayAttr TransposeOp::getTranspAttr() { + return ::llvm::cast<::mlir::ArrayAttr>(getProperties().transp); +} + +::mlir::ArrayAttr TransposeOp::getTransp() { + auto attr = getTranspAttr(); + return attr; +} + +void TransposeOp::setTranspAttr(::mlir::ArrayAttr attr) { + (*this)->setAttr(getTranspAttrName(), attr); +} + +void TransposeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value vector, ::mlir::ArrayAttr transp) { + odsState.addOperands(vector); + odsState.getOrAddProperties().transp = transp; + odsState.addTypes(result); +} + +void TransposeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value vector, ::mlir::ArrayAttr transp) { + odsState.addOperands(vector); + odsState.getOrAddProperties().transp = transp; + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void TransposeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult TransposeOp::verifyInvariantsImpl() { + auto tblgen_transp = getProperties().transp; (void)tblgen_transp; + if (!tblgen_transp) return emitOpError("requires attribute 'transp'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps0(*this, tblgen_transp, "transp"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps1(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((getElementTypeOrSelf((*this->getOperation()).getResult(0)) == getElementTypeOrSelf((*this->getOperation()).getOperand(0))))) + return emitOpError("failed to verify that operand and result have same element type"); + return ::mlir::success(); +} + +::mlir::LogicalResult TransposeOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult TransposeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand vectorRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> vectorOperands(vectorRawOperands); ::llvm::SMLoc vectorOperandsLoc; + (void)vectorOperandsLoc; + ::mlir::ArrayAttr transpAttr; + ::mlir::Type vectorRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> vectorTypes(vectorRawTypes); + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + vectorOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(vectorRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + if (parser.parseCustomAttributeWithFallback(transpAttr, parser.getBuilder().getType<::mlir::NoneType>())) { + return ::mlir::failure(); + } + if (transpAttr) result.getOrAddProperties().transp = transpAttr; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + vectorRawTypes[0] = type; + } + if (parser.parseKeyword("to")) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(vectorOperands, vectorTypes, vectorOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void TransposeOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getVector(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter.printAttributeWithoutType(getTranspAttr()); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + elidedAttrs.push_back("transp"); + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getVector().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "to"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void TransposeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::TransposeOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::TypeCastOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +TypeCastOpGenericAdaptorBase::TypeCastOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.type_cast", odsAttrs.getContext()); +} + +TypeCastOpGenericAdaptorBase::TypeCastOpGenericAdaptorBase(TypeCastOp op) : TypeCastOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair TypeCastOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr TypeCastOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +TypeCastOpAdaptor::TypeCastOpAdaptor(TypeCastOp op) : TypeCastOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult TypeCastOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair TypeCastOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range TypeCastOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::MemRefType> TypeCastOp::getMemref() { + return ::llvm::cast<::mlir::TypedValue<::mlir::MemRefType>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &TypeCastOp::getMemrefMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair TypeCastOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range TypeCastOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::MemRefType> TypeCastOp::getResult() { + return ::llvm::cast<::mlir::TypedValue<::mlir::MemRefType>>(*getODSResults(0).begin()); +} + +void TypeCastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value memref) { + odsState.addOperands(memref); + odsState.addTypes(result); +} + +void TypeCastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value memref) { + odsState.addOperands(memref); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void TypeCastOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult TypeCastOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps19(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult TypeCastOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::ParseResult TypeCastOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand memrefRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> memrefOperands(memrefRawOperands); ::llvm::SMLoc memrefOperandsLoc; + (void)memrefOperandsLoc; + ::mlir::Type memrefRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> memrefTypes(memrefRawTypes); + ::mlir::Type resultRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes); + + memrefOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(memrefRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::MemRefType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + memrefRawTypes[0] = type; + } + if (parser.parseKeyword("to")) + return ::mlir::failure(); + + { + ::mlir::MemRefType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resultRawTypes[0] = type; + } + result.addTypes(resultTypes); + if (parser.resolveOperands(memrefOperands, memrefTypes, memrefOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void TypeCastOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getMemref(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getMemref().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::MemRefType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + _odsPrinter << ' ' << "to"; + _odsPrinter << ' '; + { + auto type = getResult().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::MemRefType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void TypeCastOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::TypeCastOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::WarpExecuteOnLane0Op definitions +//===----------------------------------------------------------------------===// + +namespace detail { +WarpExecuteOnLane0OpGenericAdaptorBase::WarpExecuteOnLane0OpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.warp_execute_on_lane_0", odsAttrs.getContext()); +} + +WarpExecuteOnLane0OpGenericAdaptorBase::WarpExecuteOnLane0OpGenericAdaptorBase(WarpExecuteOnLane0Op op) : WarpExecuteOnLane0OpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair WarpExecuteOnLane0OpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr WarpExecuteOnLane0OpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::IntegerAttr WarpExecuteOnLane0OpGenericAdaptorBase::getWarpSizeAttr() { + auto attr = ::llvm::cast<::mlir::IntegerAttr>(getProperties().warp_size); + return attr; +} + +uint64_t WarpExecuteOnLane0OpGenericAdaptorBase::getWarpSize() { + auto attr = getWarpSizeAttr(); + return attr.getValue().getZExtValue(); +} + +::mlir::Region &WarpExecuteOnLane0OpGenericAdaptorBase::getWarpRegion() { + return *odsRegions[0]; +} + +::mlir::RegionRange WarpExecuteOnLane0OpGenericAdaptorBase::getRegions() { + return odsRegions; +} + +} // namespace detail +WarpExecuteOnLane0OpAdaptor::WarpExecuteOnLane0OpAdaptor(WarpExecuteOnLane0Op op) : WarpExecuteOnLane0OpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult WarpExecuteOnLane0OpAdaptor::verify(::mlir::Location loc) { + auto tblgen_warp_size = getProperties().warp_size; (void)tblgen_warp_size; + if (!tblgen_warp_size) return emitError(loc, "'vector.warp_execute_on_lane_0' op ""requires attribute 'warp_size'"); + + if (tblgen_warp_size && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_warp_size))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_warp_size).getType().isSignlessInteger(64))))) + return emitError(loc, "'vector.warp_execute_on_lane_0' op ""attribute 'warp_size' failed to satisfy constraint: 64-bit signless integer attribute"); + return ::mlir::success(); +} + +std::pair WarpExecuteOnLane0Op::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 1) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range WarpExecuteOnLane0Op::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::IndexType> WarpExecuteOnLane0Op::getLaneid() { + return ::llvm::cast<::mlir::TypedValue<::mlir::IndexType>>(*getODSOperands(0).begin()); +} + +::mlir::Operation::operand_range WarpExecuteOnLane0Op::getArgs() { + return getODSOperands(1); +} + +::mlir::OpOperand &WarpExecuteOnLane0Op::getLaneidMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange WarpExecuteOnLane0Op::getArgsMutable() { + auto range = getODSOperandIndexAndLength(1); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair WarpExecuteOnLane0Op::getODSResultIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumResults() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::result_range WarpExecuteOnLane0Op::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::result_range WarpExecuteOnLane0Op::getResults() { + return getODSResults(0); +} + +::mlir::Region &WarpExecuteOnLane0Op::getWarpRegion() { + return (*this)->getRegion(0); +} + +::mlir::LogicalResult WarpExecuteOnLane0Op::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.warp_size; + auto attr = dict.get("warp_size"); + if (attr || /*isRequired=*/true) { + if (!attr) { + emitError() << "expected key entry for warp_size in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `warp_size` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute WarpExecuteOnLane0Op::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.warp_size; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("warp_size", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code WarpExecuteOnLane0Op::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.warp_size.getAsOpaquePointer())); +} + +std::optional WarpExecuteOnLane0Op::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "warp_size") + return prop.warp_size; + return std::nullopt; +} + +void WarpExecuteOnLane0Op::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "warp_size") { + prop.warp_size = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void WarpExecuteOnLane0Op::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.warp_size) attrs.append("warp_size", prop.warp_size); +} + +::mlir::LogicalResult WarpExecuteOnLane0Op::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getWarpSizeAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps8(attr, "warp_size", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult WarpExecuteOnLane0Op::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readAttribute(prop.warp_size))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void WarpExecuteOnLane0Op::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + writer.writeAttribute(prop.warp_size); +} + +::mlir::IntegerAttr WarpExecuteOnLane0Op::getWarpSizeAttr() { + return ::llvm::cast<::mlir::IntegerAttr>(getProperties().warp_size); +} + +uint64_t WarpExecuteOnLane0Op::getWarpSize() { + auto attr = getWarpSizeAttr(); + return attr.getValue().getZExtValue(); +} + +void WarpExecuteOnLane0Op::setWarpSizeAttr(::mlir::IntegerAttr attr) { + (*this)->setAttr(getWarpSizeAttrName(), attr); +} + +void WarpExecuteOnLane0Op::setWarpSize(uint64_t attrValue) { + (*this)->setAttr(getWarpSizeAttrName(), ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(64), attrValue)); +} + +::mlir::LogicalResult WarpExecuteOnLane0Op::verifyInvariantsImpl() { + auto tblgen_warp_size = getProperties().warp_size; (void)tblgen_warp_size; + if (!tblgen_warp_size) return emitOpError("requires attribute 'warp_size'"); + + if (::mlir::failed(__mlir_ods_local_attr_constraint_VectorOps8(*this, tblgen_warp_size, "warp_size"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + + for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0))) + if (::mlir::failed(__mlir_ods_local_region_constraint_VectorOps0(*this, region, "warpRegion", index++))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult WarpExecuteOnLane0Op::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::WarpExecuteOnLane0Op) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::YieldOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +YieldOpGenericAdaptorBase::YieldOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("vector.yield", odsAttrs.getContext()); +} + +YieldOpGenericAdaptorBase::YieldOpGenericAdaptorBase(YieldOp op) : YieldOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair YieldOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr YieldOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +YieldOpAdaptor::YieldOpAdaptor(YieldOp op) : YieldOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult YieldOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair YieldOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 0) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range YieldOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Operation::operand_range YieldOp::getOperands() { + return getODSOperands(0); +} + +::mlir::MutableOperandRange YieldOp::getOperandsMutable() { + auto range = getODSOperandIndexAndLength(0); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair YieldOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range YieldOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +void YieldOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) { + /* nothing to do */ +} + +void YieldOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands) { + odsState.addOperands(operands); +} + +void YieldOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 0u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult YieldOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_VectorOps2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult YieldOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::ParseResult YieldOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> operandsOperands; + ::llvm::SMLoc operandsOperandsLoc; + (void)operandsOperandsLoc; + ::llvm::SmallVector<::mlir::Type, 1> operandsTypes; + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + + operandsOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperandList(operandsOperands)) + return ::mlir::failure(); + if (!operandsOperands.empty()) { + if (parser.parseColon()) + return ::mlir::failure(); + + if (parser.parseTypeList(operandsTypes)) + return ::mlir::failure(); + } + if (parser.resolveOperands(operandsOperands, operandsTypes, operandsOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void YieldOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + if (!getOperands().empty()) { + _odsPrinter << ' '; + _odsPrinter << getOperands(); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + _odsPrinter << getOperands().getTypes(); + } +} + +void YieldOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +::mlir::MutableOperandRange YieldOp::getMutableSuccessorOperands( + ::mlir::RegionBranchPoint point) { + return ::mlir::MutableOperandRange(*this); +} + +} // namespace vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::vector::YieldOp) + + +#endif // GET_OP_CLASSES + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/IR/VectorOps.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/IR/VectorOps.h new file mode 100644 index 0000000000000000000000000000000000000000..fc0c80036ff79ada9a71b74d435c46f62db55f82 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/IR/VectorOps.h @@ -0,0 +1,182 @@ +//===- VectorOps.h - MLIR Vector Dialect Operations -------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file defines the Vector dialect. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_VECTOR_IR_VECTOROPS_H +#define MLIR_DIALECT_VECTOR_IR_VECTOROPS_H + +#include "mlir/Bytecode/BytecodeOpInterface.h" +#include "mlir/Dialect/Arith/IR/Arith.h" +#include "mlir/Dialect/Vector/Interfaces/MaskableOpInterface.h" +#include "mlir/Dialect/Vector/Interfaces/MaskingOpInterface.h" +#include "mlir/IR/AffineMap.h" +#include "mlir/IR/Attributes.h" +#include "mlir/IR/BuiltinTypes.h" +#include "mlir/IR/Dialect.h" +#include "mlir/IR/OpDefinition.h" +#include "mlir/IR/PatternMatch.h" +#include "mlir/Interfaces/ControlFlowInterfaces.h" +#include "mlir/Interfaces/DestinationStyleOpInterface.h" +#include "mlir/Interfaces/InferTypeOpInterface.h" +#include "mlir/Interfaces/SideEffectInterfaces.h" +#include "mlir/Interfaces/VectorInterfaces.h" +#include "mlir/Interfaces/ViewLikeInterface.h" +#include "llvm/ADT/StringExtras.h" + +// Pull in all enum type definitions and utility function declarations. +#include "mlir/Dialect/Vector/IR/VectorEnums.h.inc" + +#define GET_ATTRDEF_CLASSES +#include "mlir/Dialect/Vector/IR/VectorAttributes.h.inc" + +namespace mlir { +class MLIRContext; +class RewritePatternSet; + +namespace arith { +enum class AtomicRMWKind : uint64_t; +} // namespace arith + +namespace vector { +class ContractionOp; +class TransferReadOp; +class TransferWriteOp; +class VectorDialect; + +namespace detail { +struct BitmaskEnumStorage; +} // namespace detail + +/// Default callback to build a region with a 'vector.yield' terminator with no +/// arguments. +void buildTerminatedBody(OpBuilder &builder, Location loc); + +/// Return whether `srcType` can be broadcast to `dstVectorType` under the +/// semantics of the `vector.broadcast` op. +enum class BroadcastableToResult { + Success = 0, + SourceRankHigher = 1, + DimensionMismatch = 2, + SourceTypeNotAVector = 3 +}; +BroadcastableToResult +isBroadcastableTo(Type srcType, VectorType dstVectorType, + std::pair *mismatchingDims = nullptr); + +/// Collect a set of vector-to-vector canonicalization patterns. +void populateVectorToVectorCanonicalizationPatterns(RewritePatternSet &patterns, + PatternBenefit benefit = 1); + +/// Collect a set of patterns that fold arithmetic extension on floating point +/// into vector contract for the backends with native support. +void populateFoldArithExtensionPatterns(RewritePatternSet &patterns); + +/// Returns the integer type required for subscripts in the vector dialect. +IntegerType getVectorSubscriptType(Builder &builder); + +/// Returns an integer array attribute containing the given values using +/// the integer type required for subscripts in the vector dialect. +ArrayAttr getVectorSubscriptAttr(Builder &b, ArrayRef values); + +/// Returns the value obtained by reducing the vector into a scalar using the +/// operation kind associated with a binary AtomicRMWKind op. +Value getVectorReductionOp(arith::AtomicRMWKind op, OpBuilder &builder, + Location loc, Value vector); + +/// Build the default minor identity map suitable for a vector transfer. This +/// also handles the case memref<... x vector<...>> -> vector<...> in which the +/// rank of the identity map must take the vector element type into account. +AffineMap getTransferMinorIdentityMap(ShapedType shapedType, + VectorType vectorType); + +/// Return true if the transfer_write fully writes the data accessed by the +/// transfer_read. +bool checkSameValueRAW(TransferWriteOp defWrite, TransferReadOp read); + +/// Return true if the write op fully over-write the priorWrite transfer_write +/// op. +bool checkSameValueWAW(TransferWriteOp write, TransferWriteOp priorWrite); + +/// Same behavior as `isDisjointTransferSet` but doesn't require the operations +/// to have the same tensor/memref. This allows comparing operations accessing +/// different tensors. +bool isDisjointTransferIndices(VectorTransferOpInterface transferA, + VectorTransferOpInterface transferB); + +/// Return true if we can prove that the transfer operations access disjoint +/// memory. +bool isDisjointTransferSet(VectorTransferOpInterface transferA, + VectorTransferOpInterface transferB); + +/// Return the result value of reducing two scalar/vector values with the +/// corresponding arith operation. +Value makeArithReduction(OpBuilder &b, Location loc, CombiningKind kind, + Value v1, Value acc, Value mask = Value()); + +/// Returns true if `attr` has "parallel" iterator type semantics. +inline bool isParallelIterator(Attribute attr) { + return cast(attr).getValue() == IteratorType::parallel; +} + +/// Returns true if `attr` has "reduction" iterator type semantics. +inline bool isReductionIterator(Attribute attr) { + return cast(attr).getValue() == IteratorType::reduction; +} + +/// Returns the integer numbers in `values`. `values` are expected to be +/// constant operations. +SmallVector getAsIntegers(ArrayRef values); + +/// Returns the integer numbers in `foldResults`. `foldResults` are expected to +/// be constant operations. +SmallVector getAsIntegers(ArrayRef foldResults); + +/// Convert `foldResults` into Values. Integer attributes are converted to +/// constant op. +SmallVector getAsValues(OpBuilder &builder, Location loc, + ArrayRef foldResults); + +/// Returns the constant index ops in `values`. `values` are expected to be +/// constant operations. +SmallVector +getAsConstantIndexOps(ArrayRef values); + +//===----------------------------------------------------------------------===// +// Vector Masking Utilities +//===----------------------------------------------------------------------===// + +/// Create the vector.yield-ended region of a vector.mask op with `maskableOp` +/// as masked operation. +void createMaskOpRegion(OpBuilder &builder, Operation *maskableOp); + +/// Creates a vector.mask operation around a maskable operation. Returns the +/// vector.mask operation if the mask provided is valid. Otherwise, returns the +/// maskable operation itself. +Operation *maskOperation(OpBuilder &builder, Operation *maskableOp, Value mask, + Value passthru = Value()); + +/// Creates a vector select operation that picks values from `newValue` or +/// `passthru` for each result vector lane based on `mask`. This utility is used +/// to propagate the pass-thru value for masked-out or expeculatively executed +/// lanes. VP intrinsics do not support pass-thru values and every mask-out lane +/// is set to poison. LLVM backends are usually able to match op + select +/// patterns and fold them into a native target instructions. +Value selectPassthru(OpBuilder &builder, Value mask, Value newValue, + Value passthru); + +} // namespace vector +} // namespace mlir + +#define GET_OP_CLASSES +#include "mlir/Dialect/Vector/IR/VectorDialect.h.inc" +#include "mlir/Dialect/Vector/IR/VectorOps.h.inc" + +#endif // MLIR_DIALECT_VECTOR_IR_VECTOROPS_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/IR/VectorOps.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/IR/VectorOps.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..93cffc325ca92e47d599948e9c5b4ab703f3b61a --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/IR/VectorOps.h.inc @@ -0,0 +1,6860 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Op Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: VectorOps.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#if defined(GET_OP_CLASSES) || defined(GET_OP_FWD_DEFINES) +#undef GET_OP_FWD_DEFINES +namespace mlir { +namespace vector { +class VectorScaleOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class BitCastOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class BroadcastOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class CompressStoreOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class ConstantMaskOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class ContractionOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class CreateMaskOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class ExpandLoadOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class ExtractElementOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class ExtractOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class ExtractStridedSliceOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class FMAOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class FlatTransposeOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class GatherOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class InsertElementOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class InsertOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class InsertStridedSliceOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class LoadOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class MaskOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class MaskedLoadOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class MaskedStoreOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class MatmulOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class MultiDimReductionOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class OuterProductOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class PrintOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class ReductionOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class ReshapeOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class ScalableExtractOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class ScalableInsertOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class ScanOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class ScatterOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class ShapeCastOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class ShuffleOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class SplatOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class StoreOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class TransferReadOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class TransferWriteOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class TransposeOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class TypeCastOp; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class WarpExecuteOnLane0Op; +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +class YieldOp; +} // namespace vector +} // namespace mlir +#endif + +#ifdef GET_OP_CLASSES +#undef GET_OP_CLASSES + + +//===----------------------------------------------------------------------===// +// Local Utility Method Definitions +//===----------------------------------------------------------------------===// + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::VectorScaleOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class VectorScaleOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + VectorScaleOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + VectorScaleOpGenericAdaptorBase(VectorScaleOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class VectorScaleOpGenericAdaptor : public detail::VectorScaleOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::VectorScaleOpGenericAdaptorBase; +public: + VectorScaleOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + VectorScaleOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : VectorScaleOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + VectorScaleOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class VectorScaleOpAdaptor : public VectorScaleOpGenericAdaptor<::mlir::ValueRange> { +public: + using VectorScaleOpGenericAdaptor::VectorScaleOpGenericAdaptor; + VectorScaleOpAdaptor(VectorScaleOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class VectorScaleOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::ZeroOperands, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = VectorScaleOpAdaptor; + template + using GenericAdaptor = VectorScaleOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.vscale"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::IndexType> getRes(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::VectorScaleOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::BitCastOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BitCastOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + BitCastOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + BitCastOpGenericAdaptorBase(BitCastOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class BitCastOpGenericAdaptor : public detail::BitCastOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BitCastOpGenericAdaptorBase; +public: + BitCastOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BitCastOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BitCastOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + BitCastOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSource() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BitCastOpAdaptor : public BitCastOpGenericAdaptor<::mlir::ValueRange> { +public: + using BitCastOpGenericAdaptor::BitCastOpGenericAdaptor; + BitCastOpAdaptor(BitCastOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class BitCastOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = BitCastOpAdaptor; + template + using GenericAdaptor = BitCastOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.bitcast"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getSource(); + ::mlir::OpOperand &getSourceMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + VectorType getSourceVectorType() { + return ::llvm::cast(getSource().getType()); + } + VectorType getResultVectorType() { + return ::llvm::cast(getResult().getType()); + } +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::BitCastOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::BroadcastOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class BroadcastOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + BroadcastOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + BroadcastOpGenericAdaptorBase(BroadcastOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class BroadcastOpGenericAdaptor : public detail::BroadcastOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::BroadcastOpGenericAdaptorBase; +public: + BroadcastOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + BroadcastOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : BroadcastOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + BroadcastOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSource() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class BroadcastOpAdaptor : public BroadcastOpGenericAdaptor<::mlir::ValueRange> { +public: + using BroadcastOpGenericAdaptor::BroadcastOpGenericAdaptor; + BroadcastOpAdaptor(BroadcastOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class BroadcastOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = BroadcastOpAdaptor; + template + using GenericAdaptor = BroadcastOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.broadcast"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getSource(); + ::mlir::OpOperand &getSourceMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getVector(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type vector, ::mlir::Value source); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + Type getSourceType() { return getSource().getType(); } + VectorType getResultVectorType() { + return ::llvm::cast(getVector().getType()); + } + + /// Return the dimensions of the result vector that were formerly ones in the + /// source tensor and thus correspond to "dim-1" broadcasting. + llvm::SetVector computeBroadcastedUnitDims(); + + /// Broadcast `value` to a vector of `dstShape`, knowing that exactly the + /// `broadcastedDims` dimensions in the dstShape are broadcasted. + /// This requires (and asserts) that the broadcast is free of dim-1 + /// broadcasting. + /// Since vector.broadcast only allows expanding leading dimensions, an extra + /// vector.transpose may be inserted to make the broadcast possible. + /// `value`, `dstShape` and `broadcastedDims` must be properly specified or + /// the helper will assert. This means: + /// 1. `dstShape` must not be empty. + /// 2. `broadcastedDims` must be confined to [0 .. rank(value.getResultVectorType)] + /// 2. `dstShape` trimmed of the dimensions specified in `broadcastedDims` + // must match the `value` shape. + static Value createOrFoldBroadcastOp( + OpBuilder &b, Value value, + ArrayRef dstShape, + const llvm::SetVector &broadcastedDims); +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::BroadcastOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::CompressStoreOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CompressStoreOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + CompressStoreOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + CompressStoreOpGenericAdaptorBase(CompressStoreOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class CompressStoreOpGenericAdaptor : public detail::CompressStoreOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CompressStoreOpGenericAdaptorBase; +public: + CompressStoreOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CompressStoreOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CompressStoreOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + CompressStoreOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getBase() { + return (*getODSOperands(0).begin()); + } + + RangeT getIndices() { + return getODSOperands(1); + } + + ValueT getMask() { + return (*getODSOperands(2).begin()); + } + + ValueT getValueToStore() { + return (*getODSOperands(3).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class CompressStoreOpAdaptor : public CompressStoreOpGenericAdaptor<::mlir::ValueRange> { +public: + using CompressStoreOpGenericAdaptor::CompressStoreOpGenericAdaptor; + CompressStoreOpAdaptor(CompressStoreOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class CompressStoreOp : public ::mlir::Op::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = CompressStoreOpAdaptor; + template + using GenericAdaptor = CompressStoreOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.compressstore"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::MemRefType> getBase(); + ::mlir::Operation::operand_range getIndices(); + ::mlir::TypedValue<::mlir::VectorType> getMask(); + ::mlir::TypedValue<::mlir::VectorType> getValueToStore(); + ::mlir::OpOperand &getBaseMutable(); + ::mlir::MutableOperandRange getIndicesMutable(); + ::mlir::OpOperand &getMaskMutable(); + ::mlir::OpOperand &getValueToStoreMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value base, ::mlir::ValueRange indices, ::mlir::Value mask, ::mlir::Value valueToStore); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value base, ::mlir::ValueRange indices, ::mlir::Value mask, ::mlir::Value valueToStore); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + MemRefType getMemRefType() { + return ::llvm::cast(getBase().getType()); + } + VectorType getMaskVectorType() { + return ::llvm::cast(getMask().getType()); + } + VectorType getVectorType() { + return ::llvm::cast(getValueToStore().getType()); + } +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::CompressStoreOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::ConstantMaskOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ConstantMaskOpGenericAdaptorBase { +public: + struct Properties { + using mask_dim_sizesTy = ::mlir::ArrayAttr; + mask_dim_sizesTy mask_dim_sizes; + + auto getMaskDimSizes() { + auto &propStorage = this->mask_dim_sizes; + return ::llvm::cast<::mlir::ArrayAttr>(propStorage); + } + void setMaskDimSizes(const ::mlir::ArrayAttr &propValue) { + this->mask_dim_sizes = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.mask_dim_sizes == this->mask_dim_sizes && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ConstantMaskOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + ConstantMaskOpGenericAdaptorBase(ConstantMaskOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::ArrayAttr getMaskDimSizesAttr(); + ::mlir::ArrayAttr getMaskDimSizes(); +}; +} // namespace detail +template +class ConstantMaskOpGenericAdaptor : public detail::ConstantMaskOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ConstantMaskOpGenericAdaptorBase; +public: + ConstantMaskOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ConstantMaskOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ConstantMaskOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + ConstantMaskOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ConstantMaskOpAdaptor : public ConstantMaskOpGenericAdaptor<::mlir::ValueRange> { +public: + using ConstantMaskOpGenericAdaptor::ConstantMaskOpGenericAdaptor; + ConstantMaskOpAdaptor(ConstantMaskOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ConstantMaskOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::ZeroOperands, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ConstantMaskOpAdaptor; + template + using GenericAdaptor = ConstantMaskOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("mask_dim_sizes")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getMaskDimSizesAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getMaskDimSizesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.constant_mask"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::ArrayAttr getMaskDimSizesAttr(); + ::mlir::ArrayAttr getMaskDimSizes(); + void setMaskDimSizesAttr(::mlir::ArrayAttr attr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::ArrayAttr mask_dim_sizes); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ArrayAttr mask_dim_sizes); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::ConstantMaskOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::ContractionOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ContractionOpGenericAdaptorBase { +public: + struct Properties { + using indexing_mapsTy = ::mlir::ArrayAttr; + indexing_mapsTy indexing_maps; + + auto getIndexingMaps() { + auto &propStorage = this->indexing_maps; + return ::llvm::cast<::mlir::ArrayAttr>(propStorage); + } + void setIndexingMaps(const ::mlir::ArrayAttr &propValue) { + this->indexing_maps = propValue; + } + using iterator_typesTy = ::mlir::ArrayAttr; + iterator_typesTy iterator_types; + + auto getIteratorTypes() { + auto &propStorage = this->iterator_types; + return ::llvm::cast<::mlir::ArrayAttr>(propStorage); + } + void setIteratorTypes(const ::mlir::ArrayAttr &propValue) { + this->iterator_types = propValue; + } + using kindTy = ::mlir::vector::CombiningKindAttr; + kindTy kind; + + auto getKind() { + auto &propStorage = this->kind; + return ::llvm::dyn_cast_or_null<::mlir::vector::CombiningKindAttr>(propStorage); + } + void setKind(const ::mlir::vector::CombiningKindAttr &propValue) { + this->kind = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.indexing_maps == this->indexing_maps && + rhs.iterator_types == this->iterator_types && + rhs.kind == this->kind && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ContractionOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + ContractionOpGenericAdaptorBase(ContractionOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::ArrayAttr getIndexingMapsAttr(); + ::mlir::ArrayAttr getIndexingMaps(); + ::mlir::ArrayAttr getIteratorTypesAttr(); + ::mlir::ArrayAttr getIteratorTypes(); + ::mlir::vector::CombiningKindAttr getKindAttr(); + ::mlir::vector::CombiningKind getKind(); +}; +} // namespace detail +template +class ContractionOpGenericAdaptor : public detail::ContractionOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ContractionOpGenericAdaptorBase; +public: + ContractionOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ContractionOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ContractionOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + ContractionOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + ValueT getAcc() { + return (*getODSOperands(2).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ContractionOpAdaptor : public ContractionOpGenericAdaptor<::mlir::ValueRange> { +public: + using ContractionOpGenericAdaptor::ContractionOpGenericAdaptor; + ContractionOpAdaptor(ContractionOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ContractionOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<3>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::vector::MaskableOpInterface::Trait, ::mlir::VectorUnrollOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ContractionOpAdaptor; + template + using GenericAdaptor = ContractionOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("indexing_maps"), ::llvm::StringRef("iterator_types"), ::llvm::StringRef("kind")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getIndexingMapsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getIndexingMapsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getIteratorTypesAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getIteratorTypesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getKindAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getKindAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.contract"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getLhs(); + ::mlir::TypedValue<::mlir::VectorType> getRhs(); + ::mlir::Value getAcc(); + ::mlir::OpOperand &getLhsMutable(); + ::mlir::OpOperand &getRhsMutable(); + ::mlir::OpOperand &getAccMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::ArrayAttr getIndexingMapsAttr(); + ::mlir::ArrayAttr getIndexingMaps(); + ::mlir::ArrayAttr getIteratorTypesAttr(); + ::mlir::ArrayAttr getIteratorTypes(); + ::mlir::vector::CombiningKindAttr getKindAttr(); + ::mlir::vector::CombiningKind getKind(); + void setIndexingMapsAttr(::mlir::ArrayAttr attr); + void setIteratorTypesAttr(::mlir::ArrayAttr attr); + void setKindAttr(::mlir::vector::CombiningKindAttr attr); + void setKind(::mlir::vector::CombiningKind attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value lhs, Value rhs, Value acc, ArrayAttr indexingMaps, ArrayAttr iteratorTypes); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value lhs, Value rhs, Value acc, ArrayRef> indexingExprs, ArrayRef iteratorTypes); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value lhs, Value rhs, Value acc, ArrayAttr indexingMaps, ArrayAttr iteratorTypes, CombiningKind kind); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Value acc, ::mlir::ArrayAttr indexing_maps, ::mlir::ArrayAttr iterator_types, ::mlir::vector::CombiningKindAttr kind); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Value acc, ::mlir::ArrayAttr indexing_maps, ::mlir::ArrayAttr iterator_types, ::mlir::vector::CombiningKindAttr kind); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Value acc, ::mlir::ArrayAttr indexing_maps, ::mlir::ArrayAttr iterator_types, ::mlir::vector::CombiningKind kind = CombiningKind::ADD); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Value acc, ::mlir::ArrayAttr indexing_maps, ::mlir::ArrayAttr iterator_types, ::mlir::vector::CombiningKind kind = CombiningKind::ADD); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void populateDefaultProperties(::mlir::OperationName opName, Properties &properties); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &p); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + mlir::Type getExpectedMaskType(); + ::std::optional<::llvm::SmallVector> getShapeForUnroll(); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 3 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + VectorType getLhsType() { + return ::llvm::cast(getLhs().getType()); + } + VectorType getRhsType() { + return ::llvm::cast(getRhs().getType()); + } + Type getAccType() { return getAcc().getType(); } + Type getResultType() { return getResult().getType(); } + SmallVector getTraitAttrNames(); + static unsigned getAccOperandIndex() { return 2; } + + llvm::SmallVector<::mlir::AffineMap, 4> getIndexingMapsArray() { + return llvm::to_vector<4>(getIndexingMaps().getAsValueRange<::mlir::AffineMapAttr>()); + } + + // Returns the bounds of each dimension in the iteration space spanned + // by the iterator types of this operation. + void getIterationBounds(SmallVectorImpl &iterationBounds); + + // Returns a list of index maps, where there is a list entry for each + // op indexing map attribute (i.e. one for each input and output, with + // the output listed last). Each index map, maps from this operations + // iteration space, to vector dimensions of the maps input/output. + void getIterationIndexMap( + std::vector> &iterationIndexMap); + + std::vector> getContractingDimMap(); + std::vector> getBatchDimMap(); + + static CombiningKind getDefaultKind() { + return CombiningKind::ADD; + } + + SmallVector getIteratorTypesArray() { + auto range = + getIteratorTypes() + .template getAsValueRange(); + return {range.begin(), range.end()}; + } +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::ContractionOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::CreateMaskOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class CreateMaskOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + CreateMaskOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + CreateMaskOpGenericAdaptorBase(CreateMaskOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class CreateMaskOpGenericAdaptor : public detail::CreateMaskOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::CreateMaskOpGenericAdaptorBase; +public: + CreateMaskOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + CreateMaskOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : CreateMaskOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + CreateMaskOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return getODSOperands(0); + } + +private: + RangeT odsOperands; +}; +class CreateMaskOpAdaptor : public CreateMaskOpGenericAdaptor<::mlir::ValueRange> { +public: + using CreateMaskOpGenericAdaptor::CreateMaskOpGenericAdaptor; + CreateMaskOpAdaptor(CreateMaskOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class CreateMaskOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = CreateMaskOpAdaptor; + template + using GenericAdaptor = CreateMaskOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.create_mask"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Operation::operand_range getOperands(); + ::mlir::MutableOperandRange getOperandsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, VectorType type, ArrayRef mixedOperands); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::ValueRange operands); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + /// Return the result type of this op. + VectorType getVectorType() { + return cast(getOperation()->getResultTypes()[0]); + } +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::CreateMaskOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::ExpandLoadOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ExpandLoadOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + ExpandLoadOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + ExpandLoadOpGenericAdaptorBase(ExpandLoadOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class ExpandLoadOpGenericAdaptor : public detail::ExpandLoadOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ExpandLoadOpGenericAdaptorBase; +public: + ExpandLoadOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ExpandLoadOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ExpandLoadOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + ExpandLoadOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getBase() { + return (*getODSOperands(0).begin()); + } + + RangeT getIndices() { + return getODSOperands(1); + } + + ValueT getMask() { + return (*getODSOperands(2).begin()); + } + + ValueT getPassThru() { + return (*getODSOperands(3).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ExpandLoadOpAdaptor : public ExpandLoadOpGenericAdaptor<::mlir::ValueRange> { +public: + using ExpandLoadOpGenericAdaptor::ExpandLoadOpGenericAdaptor; + ExpandLoadOpAdaptor(ExpandLoadOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ExpandLoadOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<3>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ExpandLoadOpAdaptor; + template + using GenericAdaptor = ExpandLoadOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.expandload"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::MemRefType> getBase(); + ::mlir::Operation::operand_range getIndices(); + ::mlir::TypedValue<::mlir::VectorType> getMask(); + ::mlir::TypedValue<::mlir::VectorType> getPassThru(); + ::mlir::OpOperand &getBaseMutable(); + ::mlir::MutableOperandRange getIndicesMutable(); + ::mlir::OpOperand &getMaskMutable(); + ::mlir::OpOperand &getPassThruMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value base, ::mlir::ValueRange indices, ::mlir::Value mask, ::mlir::Value pass_thru); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value base, ::mlir::ValueRange indices, ::mlir::Value mask, ::mlir::Value pass_thru); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + MemRefType getMemRefType() { + return ::llvm::cast(getBase().getType()); + } + VectorType getMaskVectorType() { + return ::llvm::cast(getMask().getType()); + } + VectorType getPassThruVectorType() { + return ::llvm::cast(getPassThru().getType()); + } + VectorType getVectorType() { + return ::llvm::cast(getResult().getType()); + } +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::ExpandLoadOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::ExtractElementOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ExtractElementOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + ExtractElementOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + ExtractElementOpGenericAdaptorBase(ExtractElementOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class ExtractElementOpGenericAdaptor : public detail::ExtractElementOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ExtractElementOpGenericAdaptorBase; +public: + ExtractElementOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ExtractElementOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ExtractElementOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + ExtractElementOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getVector() { + return (*getODSOperands(0).begin()); + } + + ValueT getPosition() { + auto operands = getODSOperands(1); + return operands.empty() ? ValueT{} : (*operands.begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ExtractElementOpAdaptor : public ExtractElementOpGenericAdaptor<::mlir::ValueRange> { +public: + using ExtractElementOpGenericAdaptor::ExtractElementOpGenericAdaptor; + ExtractElementOpAdaptor(ExtractElementOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ExtractElementOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<1>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ExtractElementOpAdaptor; + template + using GenericAdaptor = ExtractElementOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.extractelement"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getVector(); + ::mlir::Value getPosition(); + ::mlir::OpOperand &getVectorMutable(); + ::mlir::MutableOperandRange getPositionMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value source); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value vector, /*optional*/::mlir::Value position); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value vector, /*optional*/::mlir::Value position); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value vector, /*optional*/::mlir::Value position); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + VectorType getSourceVectorType() { + return ::llvm::cast(getVector().getType()); + } +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::ExtractElementOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::ExtractOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ExtractOpGenericAdaptorBase { +public: + struct Properties { + using static_positionTy = ::mlir::DenseI64ArrayAttr; + static_positionTy static_position; + + auto getStaticPosition() { + auto &propStorage = this->static_position; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setStaticPosition(const ::mlir::DenseI64ArrayAttr &propValue) { + this->static_position = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.static_position == this->static_position && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ExtractOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + ExtractOpGenericAdaptorBase(ExtractOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::DenseI64ArrayAttr getStaticPositionAttr(); + ::llvm::ArrayRef getStaticPosition(); +}; +} // namespace detail +template +class ExtractOpGenericAdaptor : public detail::ExtractOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ExtractOpGenericAdaptorBase; +public: + ExtractOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ExtractOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ExtractOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + ExtractOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getVector() { + return (*getODSOperands(0).begin()); + } + + RangeT getDynamicPosition() { + return getODSOperands(1); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ExtractOpAdaptor : public ExtractOpGenericAdaptor<::mlir::ValueRange> { +public: + using ExtractOpGenericAdaptor::ExtractOpGenericAdaptor; + ExtractOpAdaptor(ExtractOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ExtractOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<1>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::OpTrait::InferTypeOpAdaptor> { +public: + using Op::Op; + using Op::print; + using Adaptor = ExtractOpAdaptor; + template + using GenericAdaptor = ExtractOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("static_position")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getStaticPositionAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getStaticPositionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.extract"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getVector(); + ::mlir::Operation::operand_range getDynamicPosition(); + ::mlir::OpOperand &getVectorMutable(); + ::mlir::MutableOperandRange getDynamicPositionMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getResult(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getStaticPositionAttr(); + ::llvm::ArrayRef getStaticPosition(); + void setStaticPositionAttr(::mlir::DenseI64ArrayAttr attr); + void setStaticPosition(::llvm::ArrayRef attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value source, int64_t position); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value source, OpFoldResult position); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value source, ArrayRef position); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value source, ArrayRef position); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value vector, ::mlir::ValueRange dynamic_position, ::mlir::DenseI64ArrayAttr static_position); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value vector, ::mlir::ValueRange dynamic_position, ::mlir::DenseI64ArrayAttr static_position); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value vector, ::mlir::ValueRange dynamic_position, ::mlir::DenseI64ArrayAttr static_position); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value vector, ::mlir::ValueRange dynamic_position, ::llvm::ArrayRef static_position); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value vector, ::mlir::ValueRange dynamic_position, ::llvm::ArrayRef static_position); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value vector, ::mlir::ValueRange dynamic_position, ::llvm::ArrayRef static_position); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + static ::mlir::LogicalResult + inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + Adaptor adaptor, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes); + + static bool isCompatibleReturnTypes(::mlir::TypeRange l, ::mlir::TypeRange r); + + + VectorType getSourceVectorType() { + return ::llvm::cast(getVector().getType()); + } + + /// Return a vector with all the static and dynamic position indices. + SmallVector getMixedPosition() { + OpBuilder builder(getContext()); + return getMixedValues(getStaticPosition(), getDynamicPosition(), builder); + } + + unsigned getNumIndices() { + return getStaticPosition().size(); + } + + bool hasDynamicPosition() { + auto dynPos = getDynamicPosition(); + return std::any_of(dynPos.begin(), dynPos.end(), + [](Value operand) { return operand != nullptr; }); + } +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::ExtractOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::ExtractStridedSliceOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ExtractStridedSliceOpGenericAdaptorBase { +public: + struct Properties { + using offsetsTy = ::mlir::ArrayAttr; + offsetsTy offsets; + + auto getOffsets() { + auto &propStorage = this->offsets; + return ::llvm::cast<::mlir::ArrayAttr>(propStorage); + } + void setOffsets(const ::mlir::ArrayAttr &propValue) { + this->offsets = propValue; + } + using sizesTy = ::mlir::ArrayAttr; + sizesTy sizes; + + auto getSizes() { + auto &propStorage = this->sizes; + return ::llvm::cast<::mlir::ArrayAttr>(propStorage); + } + void setSizes(const ::mlir::ArrayAttr &propValue) { + this->sizes = propValue; + } + using stridesTy = ::mlir::ArrayAttr; + stridesTy strides; + + auto getStrides() { + auto &propStorage = this->strides; + return ::llvm::cast<::mlir::ArrayAttr>(propStorage); + } + void setStrides(const ::mlir::ArrayAttr &propValue) { + this->strides = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.offsets == this->offsets && + rhs.sizes == this->sizes && + rhs.strides == this->strides && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ExtractStridedSliceOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + ExtractStridedSliceOpGenericAdaptorBase(ExtractStridedSliceOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::ArrayAttr getOffsetsAttr(); + ::mlir::ArrayAttr getOffsets(); + ::mlir::ArrayAttr getSizesAttr(); + ::mlir::ArrayAttr getSizes(); + ::mlir::ArrayAttr getStridesAttr(); + ::mlir::ArrayAttr getStrides(); +}; +} // namespace detail +template +class ExtractStridedSliceOpGenericAdaptor : public detail::ExtractStridedSliceOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ExtractStridedSliceOpGenericAdaptorBase; +public: + ExtractStridedSliceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ExtractStridedSliceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ExtractStridedSliceOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + ExtractStridedSliceOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getVector() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ExtractStridedSliceOpAdaptor : public ExtractStridedSliceOpGenericAdaptor<::mlir::ValueRange> { +public: + using ExtractStridedSliceOpGenericAdaptor::ExtractStridedSliceOpGenericAdaptor; + ExtractStridedSliceOpAdaptor(ExtractStridedSliceOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ExtractStridedSliceOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ExtractStridedSliceOpAdaptor; + template + using GenericAdaptor = ExtractStridedSliceOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("offsets"), ::llvm::StringRef("sizes"), ::llvm::StringRef("strides")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getOffsetsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getOffsetsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getSizesAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getSizesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getStridesAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getStridesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.extract_strided_slice"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getVector(); + ::mlir::OpOperand &getVectorMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::ArrayAttr getOffsetsAttr(); + ::mlir::ArrayAttr getOffsets(); + ::mlir::ArrayAttr getSizesAttr(); + ::mlir::ArrayAttr getSizes(); + ::mlir::ArrayAttr getStridesAttr(); + ::mlir::ArrayAttr getStrides(); + void setOffsetsAttr(::mlir::ArrayAttr attr); + void setSizesAttr(::mlir::ArrayAttr attr); + void setStridesAttr(::mlir::ArrayAttr attr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value source, ArrayRef offsets, ArrayRef sizes, ArrayRef strides); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value vector, ::mlir::ArrayAttr offsets, ::mlir::ArrayAttr sizes, ::mlir::ArrayAttr strides); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value vector, ::mlir::ArrayAttr offsets, ::mlir::ArrayAttr sizes, ::mlir::ArrayAttr strides); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 3 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + VectorType getSourceVectorType() { + return ::llvm::cast(getVector().getType()); + } + void getOffsets(SmallVectorImpl &results); + bool hasNonUnitStrides() { + return llvm::any_of(getStrides(), [](Attribute attr) { + return ::llvm::cast(attr).getInt() != 1; + }); + } +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::ExtractStridedSliceOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::FMAOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class FMAOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + FMAOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + FMAOpGenericAdaptorBase(FMAOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class FMAOpGenericAdaptor : public detail::FMAOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::FMAOpGenericAdaptorBase; +public: + FMAOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + FMAOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : FMAOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + FMAOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + ValueT getAcc() { + return (*getODSOperands(2).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class FMAOpAdaptor : public FMAOpGenericAdaptor<::mlir::ValueRange> { +public: + using FMAOpGenericAdaptor::FMAOpGenericAdaptor; + FMAOpAdaptor(FMAOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class FMAOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<3>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::VectorUnrollOpInterface::Trait, ::mlir::OpTrait::Elementwise, ::mlir::OpTrait::Scalarizable, ::mlir::OpTrait::Vectorizable, ::mlir::OpTrait::Tensorizable, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = FMAOpAdaptor; + template + using GenericAdaptor = FMAOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.fma"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getLhs(); + ::mlir::TypedValue<::mlir::VectorType> getRhs(); + ::mlir::TypedValue<::mlir::VectorType> getAcc(); + ::mlir::OpOperand &getLhsMutable(); + ::mlir::OpOperand &getRhsMutable(); + ::mlir::OpOperand &getAccMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Value acc); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Value acc); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::Value acc); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + ::std::optional<::llvm::SmallVector> getShapeForUnroll(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + VectorType getVectorType() { return ::llvm::cast(getLhs().getType()); } +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::FMAOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::FlatTransposeOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class FlatTransposeOpGenericAdaptorBase { +public: + struct Properties { + using columnsTy = ::mlir::IntegerAttr; + columnsTy columns; + + auto getColumns() { + auto &propStorage = this->columns; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setColumns(const ::mlir::IntegerAttr &propValue) { + this->columns = propValue; + } + using rowsTy = ::mlir::IntegerAttr; + rowsTy rows; + + auto getRows() { + auto &propStorage = this->rows; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setRows(const ::mlir::IntegerAttr &propValue) { + this->rows = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.columns == this->columns && + rhs.rows == this->rows && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + FlatTransposeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + FlatTransposeOpGenericAdaptorBase(FlatTransposeOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::IntegerAttr getRowsAttr(); + uint32_t getRows(); + ::mlir::IntegerAttr getColumnsAttr(); + uint32_t getColumns(); +}; +} // namespace detail +template +class FlatTransposeOpGenericAdaptor : public detail::FlatTransposeOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::FlatTransposeOpGenericAdaptorBase; +public: + FlatTransposeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + FlatTransposeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : FlatTransposeOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + FlatTransposeOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getMatrix() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class FlatTransposeOpAdaptor : public FlatTransposeOpGenericAdaptor<::mlir::ValueRange> { +public: + using FlatTransposeOpGenericAdaptor::FlatTransposeOpGenericAdaptor; + FlatTransposeOpAdaptor(FlatTransposeOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class FlatTransposeOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = FlatTransposeOpAdaptor; + template + using GenericAdaptor = FlatTransposeOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("columns"), ::llvm::StringRef("rows")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getColumnsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getColumnsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getRowsAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getRowsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.flat_transpose"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getMatrix(); + ::mlir::OpOperand &getMatrixMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getRes(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::IntegerAttr getRowsAttr(); + uint32_t getRows(); + ::mlir::IntegerAttr getColumnsAttr(); + uint32_t getColumns(); + void setRowsAttr(::mlir::IntegerAttr attr); + void setRows(uint32_t attrValue); + void setColumnsAttr(::mlir::IntegerAttr attr); + void setColumns(uint32_t attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value matrix, ::mlir::IntegerAttr rows, ::mlir::IntegerAttr columns); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value matrix, ::mlir::IntegerAttr rows, ::mlir::IntegerAttr columns); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value matrix, uint32_t rows, uint32_t columns); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value matrix, uint32_t rows, uint32_t columns); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::FlatTransposeOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::GatherOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class GatherOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + GatherOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + GatherOpGenericAdaptorBase(GatherOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class GatherOpGenericAdaptor : public detail::GatherOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::GatherOpGenericAdaptorBase; +public: + GatherOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + GatherOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : GatherOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + GatherOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getBase() { + return (*getODSOperands(0).begin()); + } + + RangeT getIndices() { + return getODSOperands(1); + } + + ValueT getIndexVec() { + return (*getODSOperands(2).begin()); + } + + ValueT getMask() { + return (*getODSOperands(3).begin()); + } + + ValueT getPassThru() { + return (*getODSOperands(4).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class GatherOpAdaptor : public GatherOpGenericAdaptor<::mlir::ValueRange> { +public: + using GatherOpGenericAdaptor::GatherOpGenericAdaptor; + GatherOpAdaptor(GatherOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class GatherOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<4>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::vector::MaskableOpInterface::Trait, ::mlir::VectorUnrollOpInterface::Trait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = GatherOpAdaptor; + template + using GenericAdaptor = GatherOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.gather"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::ShapedType> getBase(); + ::mlir::Operation::operand_range getIndices(); + ::mlir::TypedValue<::mlir::VectorType> getIndexVec(); + ::mlir::TypedValue<::mlir::VectorType> getMask(); + ::mlir::TypedValue<::mlir::VectorType> getPassThru(); + ::mlir::OpOperand &getBaseMutable(); + ::mlir::MutableOperandRange getIndicesMutable(); + ::mlir::OpOperand &getIndexVecMutable(); + ::mlir::OpOperand &getMaskMutable(); + ::mlir::OpOperand &getPassThruMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value base, ::mlir::ValueRange indices, ::mlir::Value index_vec, ::mlir::Value mask, ::mlir::Value pass_thru); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value base, ::mlir::ValueRange indices, ::mlir::Value index_vec, ::mlir::Value mask, ::mlir::Value pass_thru); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + mlir::Type getExpectedMaskType(); + ::std::optional<::llvm::SmallVector> getShapeForUnroll(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + ShapedType getBaseType() { return getBase().getType(); } + VectorType getIndexVectorType() { return getIndexVec().getType(); } + VectorType getMaskVectorType() { return getMask().getType(); } + VectorType getPassThruVectorType() { return getPassThru().getType(); } + VectorType getVectorType() { return getResult().getType(); } +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::GatherOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::InsertElementOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class InsertElementOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + InsertElementOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + InsertElementOpGenericAdaptorBase(InsertElementOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class InsertElementOpGenericAdaptor : public detail::InsertElementOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::InsertElementOpGenericAdaptorBase; +public: + InsertElementOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + InsertElementOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : InsertElementOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + InsertElementOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSource() { + return (*getODSOperands(0).begin()); + } + + ValueT getDest() { + return (*getODSOperands(1).begin()); + } + + ValueT getPosition() { + auto operands = getODSOperands(2); + return operands.empty() ? ValueT{} : (*operands.begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class InsertElementOpAdaptor : public InsertElementOpGenericAdaptor<::mlir::ValueRange> { +public: + using InsertElementOpGenericAdaptor::InsertElementOpGenericAdaptor; + InsertElementOpAdaptor(InsertElementOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class InsertElementOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = InsertElementOpAdaptor; + template + using GenericAdaptor = InsertElementOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.insertelement"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getSource(); + ::mlir::TypedValue<::mlir::VectorType> getDest(); + ::mlir::Value getPosition(); + ::mlir::OpOperand &getSourceMutable(); + ::mlir::OpOperand &getDestMutable(); + ::mlir::MutableOperandRange getPositionMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value source, Value dest); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::Value position); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::Value position); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::Value position); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + Type getSourceType() { return getSource().getType(); } + VectorType getDestVectorType() { + return ::llvm::cast(getDest().getType()); + } +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::InsertElementOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::InsertOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class InsertOpGenericAdaptorBase { +public: + struct Properties { + using static_positionTy = ::mlir::DenseI64ArrayAttr; + static_positionTy static_position; + + auto getStaticPosition() { + auto &propStorage = this->static_position; + return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage); + } + void setStaticPosition(const ::mlir::DenseI64ArrayAttr &propValue) { + this->static_position = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.static_position == this->static_position && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + InsertOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + InsertOpGenericAdaptorBase(InsertOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::DenseI64ArrayAttr getStaticPositionAttr(); + ::llvm::ArrayRef getStaticPosition(); +}; +} // namespace detail +template +class InsertOpGenericAdaptor : public detail::InsertOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::InsertOpGenericAdaptorBase; +public: + InsertOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + InsertOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : InsertOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + InsertOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSource() { + return (*getODSOperands(0).begin()); + } + + ValueT getDest() { + return (*getODSOperands(1).begin()); + } + + RangeT getDynamicPosition() { + return getODSOperands(2); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class InsertOpAdaptor : public InsertOpGenericAdaptor<::mlir::ValueRange> { +public: + using InsertOpGenericAdaptor::InsertOpGenericAdaptor; + InsertOpAdaptor(InsertOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class InsertOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = InsertOpAdaptor; + template + using GenericAdaptor = InsertOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("static_position")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getStaticPositionAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getStaticPositionAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.insert"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getSource(); + ::mlir::TypedValue<::mlir::VectorType> getDest(); + ::mlir::Operation::operand_range getDynamicPosition(); + ::mlir::OpOperand &getSourceMutable(); + ::mlir::OpOperand &getDestMutable(); + ::mlir::MutableOperandRange getDynamicPositionMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getResult(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::DenseI64ArrayAttr getStaticPositionAttr(); + ::llvm::ArrayRef getStaticPosition(); + void setStaticPositionAttr(::mlir::DenseI64ArrayAttr attr); + void setStaticPosition(::llvm::ArrayRef attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value source, Value dest, int64_t position); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value source, Value dest, OpFoldResult position); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value source, Value dest, ArrayRef position); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value source, Value dest, ArrayRef position); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::Value dest, ::mlir::ValueRange dynamic_position, ::mlir::DenseI64ArrayAttr static_position); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value source, ::mlir::Value dest, ::mlir::ValueRange dynamic_position, ::mlir::DenseI64ArrayAttr static_position); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, ::mlir::ValueRange dynamic_position, ::mlir::DenseI64ArrayAttr static_position); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source, ::mlir::Value dest, ::mlir::ValueRange dynamic_position, ::llvm::ArrayRef static_position); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value source, ::mlir::Value dest, ::mlir::ValueRange dynamic_position, ::llvm::ArrayRef static_position); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, ::mlir::ValueRange dynamic_position, ::llvm::ArrayRef static_position); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + Type getSourceType() { return getSource().getType(); } + VectorType getDestVectorType() { + return ::llvm::cast(getDest().getType()); + } + + /// Return a vector with all the static and dynamic position indices. + SmallVector getMixedPosition() { + OpBuilder builder(getContext()); + return getMixedValues(getStaticPosition(), getDynamicPosition(), builder); + } + + unsigned getNumIndices() { + return getStaticPosition().size(); + } + + bool hasDynamicPosition() { + return llvm::any_of(getDynamicPosition(), + [](Value operand) { return operand != nullptr; }); + } +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::InsertOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::InsertStridedSliceOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class InsertStridedSliceOpGenericAdaptorBase { +public: + struct Properties { + using offsetsTy = ::mlir::ArrayAttr; + offsetsTy offsets; + + auto getOffsets() { + auto &propStorage = this->offsets; + return ::llvm::cast<::mlir::ArrayAttr>(propStorage); + } + void setOffsets(const ::mlir::ArrayAttr &propValue) { + this->offsets = propValue; + } + using stridesTy = ::mlir::ArrayAttr; + stridesTy strides; + + auto getStrides() { + auto &propStorage = this->strides; + return ::llvm::cast<::mlir::ArrayAttr>(propStorage); + } + void setStrides(const ::mlir::ArrayAttr &propValue) { + this->strides = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.offsets == this->offsets && + rhs.strides == this->strides && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + InsertStridedSliceOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + InsertStridedSliceOpGenericAdaptorBase(InsertStridedSliceOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::ArrayAttr getOffsetsAttr(); + ::mlir::ArrayAttr getOffsets(); + ::mlir::ArrayAttr getStridesAttr(); + ::mlir::ArrayAttr getStrides(); +}; +} // namespace detail +template +class InsertStridedSliceOpGenericAdaptor : public detail::InsertStridedSliceOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::InsertStridedSliceOpGenericAdaptorBase; +public: + InsertStridedSliceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + InsertStridedSliceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : InsertStridedSliceOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + InsertStridedSliceOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSource() { + return (*getODSOperands(0).begin()); + } + + ValueT getDest() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class InsertStridedSliceOpAdaptor : public InsertStridedSliceOpGenericAdaptor<::mlir::ValueRange> { +public: + using InsertStridedSliceOpGenericAdaptor::InsertStridedSliceOpGenericAdaptor; + InsertStridedSliceOpAdaptor(InsertStridedSliceOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class InsertStridedSliceOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = InsertStridedSliceOpAdaptor; + template + using GenericAdaptor = InsertStridedSliceOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("offsets"), ::llvm::StringRef("strides")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getOffsetsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getOffsetsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getStridesAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getStridesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.insert_strided_slice"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getSource(); + ::mlir::TypedValue<::mlir::VectorType> getDest(); + ::mlir::OpOperand &getSourceMutable(); + ::mlir::OpOperand &getDestMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getRes(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::ArrayAttr getOffsetsAttr(); + ::mlir::ArrayAttr getOffsets(); + ::mlir::ArrayAttr getStridesAttr(); + ::mlir::ArrayAttr getStrides(); + void setOffsetsAttr(::mlir::ArrayAttr attr); + void setStridesAttr(::mlir::ArrayAttr attr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value source, Value dest, ArrayRef offsets, ArrayRef strides); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value source, ::mlir::Value dest, ::mlir::ArrayAttr offsets, ::mlir::ArrayAttr strides); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value source, ::mlir::Value dest, ::mlir::ArrayAttr offsets, ::mlir::ArrayAttr strides); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, ::mlir::ArrayAttr offsets, ::mlir::ArrayAttr strides); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + VectorType getSourceVectorType() { + return ::llvm::cast(getSource().getType()); + } + VectorType getDestVectorType() { + return ::llvm::cast(getDest().getType()); + } + bool hasNonUnitStrides() { + return llvm::any_of(getStrides(), [](Attribute attr) { + return ::llvm::cast(attr).getInt() != 1; + }); + } +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::InsertStridedSliceOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::LoadOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class LoadOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + LoadOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + LoadOpGenericAdaptorBase(LoadOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class LoadOpGenericAdaptor : public detail::LoadOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::LoadOpGenericAdaptorBase; +public: + LoadOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + LoadOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : LoadOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + LoadOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getBase() { + return (*getODSOperands(0).begin()); + } + + RangeT getIndices() { + return getODSOperands(1); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class LoadOpAdaptor : public LoadOpGenericAdaptor<::mlir::ValueRange> { +public: + using LoadOpGenericAdaptor::LoadOpGenericAdaptor; + LoadOpAdaptor(LoadOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class LoadOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<1>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = LoadOpAdaptor; + template + using GenericAdaptor = LoadOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.load"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::MemRefType> getBase(); + ::mlir::Operation::operand_range getIndices(); + ::mlir::OpOperand &getBaseMutable(); + ::mlir::MutableOperandRange getIndicesMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value base, ::mlir::ValueRange indices); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value base, ::mlir::ValueRange indices); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + MemRefType getMemRefType() { + return ::llvm::cast(getBase().getType()); + } + + VectorType getVectorType() { + return ::llvm::cast(getResult().getType()); + } +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::LoadOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::MaskOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class MaskOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + MaskOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + MaskOpGenericAdaptorBase(MaskOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); + ::mlir::Region &getMaskRegion(); + ::mlir::RegionRange getRegions(); +}; +} // namespace detail +template +class MaskOpGenericAdaptor : public detail::MaskOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::MaskOpGenericAdaptorBase; +public: + MaskOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + MaskOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : MaskOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + MaskOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getMask() { + return (*getODSOperands(0).begin()); + } + + ValueT getPassthru() { + auto operands = getODSOperands(1); + return operands.empty() ? ValueT{} : (*operands.begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class MaskOpAdaptor : public MaskOpGenericAdaptor<::mlir::ValueRange> { +public: + using MaskOpGenericAdaptor::MaskOpGenericAdaptor; + MaskOpAdaptor(MaskOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class MaskOp : public ::mlir::Op::Impl, ::mlir::OpTrait::SingleBlock, ::mlir::OpTrait::SingleBlockImplicitTerminator::Impl, ::mlir::OpTrait::NoRegionArguments, ::mlir::OpTrait::OpInvariants, ::mlir::vector::MaskingOpInterface::Trait, ::mlir::OpTrait::HasRecursiveMemoryEffects> { +public: + using Op::Op; + using Op::print; + using Adaptor = MaskOpAdaptor; + template + using GenericAdaptor = MaskOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.mask"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getMask(); + ::mlir::Value getPassthru(); + ::mlir::OpOperand &getMaskMutable(); + ::mlir::MutableOperandRange getPassthruMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Operation::result_range getResults(); + ::mlir::Region &getMaskRegion(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value mask, Operation *maskableOp, function_ref maskRegion); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, TypeRange resultTypes, Value mask, Operation *maskableOp, function_ref maskRegion); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, TypeRange resultTypes, Value mask, Value passthru, Operation *maskableOp, function_ref maskRegion); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &p); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::mlir::LogicalResult fold(FoldAdaptor adaptor, ::llvm::SmallVectorImpl<::mlir::OpFoldResult> &results); + Operation *getMaskableOp(); + bool hasPassthru(); +public: + Block *getMaskBlock() { return &getMaskRegion().front(); } + + /// Returns true if mask op is not masking any operation. + bool isEmpty() { + Block *block = getMaskBlock(); + if (block->getOperations().size() > 1) + return false; + return true; + } + + static void ensureTerminator(Region ®ion, Builder &builder, + Location loc); +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::MaskOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::MaskedLoadOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class MaskedLoadOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + MaskedLoadOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + MaskedLoadOpGenericAdaptorBase(MaskedLoadOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class MaskedLoadOpGenericAdaptor : public detail::MaskedLoadOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::MaskedLoadOpGenericAdaptorBase; +public: + MaskedLoadOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + MaskedLoadOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : MaskedLoadOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + MaskedLoadOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getBase() { + return (*getODSOperands(0).begin()); + } + + RangeT getIndices() { + return getODSOperands(1); + } + + ValueT getMask() { + return (*getODSOperands(2).begin()); + } + + ValueT getPassThru() { + return (*getODSOperands(3).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class MaskedLoadOpAdaptor : public MaskedLoadOpGenericAdaptor<::mlir::ValueRange> { +public: + using MaskedLoadOpGenericAdaptor::MaskedLoadOpGenericAdaptor; + MaskedLoadOpAdaptor(MaskedLoadOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class MaskedLoadOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<3>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = MaskedLoadOpAdaptor; + template + using GenericAdaptor = MaskedLoadOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.maskedload"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::MemRefType> getBase(); + ::mlir::Operation::operand_range getIndices(); + ::mlir::TypedValue<::mlir::VectorType> getMask(); + ::mlir::TypedValue<::mlir::VectorType> getPassThru(); + ::mlir::OpOperand &getBaseMutable(); + ::mlir::MutableOperandRange getIndicesMutable(); + ::mlir::OpOperand &getMaskMutable(); + ::mlir::OpOperand &getPassThruMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value base, ::mlir::ValueRange indices, ::mlir::Value mask, ::mlir::Value pass_thru); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value base, ::mlir::ValueRange indices, ::mlir::Value mask, ::mlir::Value pass_thru); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + MemRefType getMemRefType() { + return ::llvm::cast(getBase().getType()); + } + VectorType getMaskVectorType() { + return ::llvm::cast(getMask().getType()); + } + VectorType getPassThruVectorType() { + return ::llvm::cast(getPassThru().getType()); + } + VectorType getVectorType() { + return ::llvm::cast(getResult().getType()); + } +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::MaskedLoadOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::MaskedStoreOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class MaskedStoreOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + MaskedStoreOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + MaskedStoreOpGenericAdaptorBase(MaskedStoreOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class MaskedStoreOpGenericAdaptor : public detail::MaskedStoreOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::MaskedStoreOpGenericAdaptorBase; +public: + MaskedStoreOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + MaskedStoreOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : MaskedStoreOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + MaskedStoreOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getBase() { + return (*getODSOperands(0).begin()); + } + + RangeT getIndices() { + return getODSOperands(1); + } + + ValueT getMask() { + return (*getODSOperands(2).begin()); + } + + ValueT getValueToStore() { + return (*getODSOperands(3).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class MaskedStoreOpAdaptor : public MaskedStoreOpGenericAdaptor<::mlir::ValueRange> { +public: + using MaskedStoreOpGenericAdaptor::MaskedStoreOpGenericAdaptor; + MaskedStoreOpAdaptor(MaskedStoreOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class MaskedStoreOp : public ::mlir::Op::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = MaskedStoreOpAdaptor; + template + using GenericAdaptor = MaskedStoreOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.maskedstore"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::MemRefType> getBase(); + ::mlir::Operation::operand_range getIndices(); + ::mlir::TypedValue<::mlir::VectorType> getMask(); + ::mlir::TypedValue<::mlir::VectorType> getValueToStore(); + ::mlir::OpOperand &getBaseMutable(); + ::mlir::MutableOperandRange getIndicesMutable(); + ::mlir::OpOperand &getMaskMutable(); + ::mlir::OpOperand &getValueToStoreMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value base, ::mlir::ValueRange indices, ::mlir::Value mask, ::mlir::Value valueToStore); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value base, ::mlir::ValueRange indices, ::mlir::Value mask, ::mlir::Value valueToStore); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::mlir::LogicalResult fold(FoldAdaptor adaptor, ::llvm::SmallVectorImpl<::mlir::OpFoldResult> &results); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + MemRefType getMemRefType() { + return ::llvm::cast(getBase().getType()); + } + VectorType getMaskVectorType() { + return ::llvm::cast(getMask().getType()); + } + VectorType getVectorType() { + return ::llvm::cast(getValueToStore().getType()); + } +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::MaskedStoreOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::MatmulOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class MatmulOpGenericAdaptorBase { +public: + struct Properties { + using lhs_columnsTy = ::mlir::IntegerAttr; + lhs_columnsTy lhs_columns; + + auto getLhsColumns() { + auto &propStorage = this->lhs_columns; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setLhsColumns(const ::mlir::IntegerAttr &propValue) { + this->lhs_columns = propValue; + } + using lhs_rowsTy = ::mlir::IntegerAttr; + lhs_rowsTy lhs_rows; + + auto getLhsRows() { + auto &propStorage = this->lhs_rows; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setLhsRows(const ::mlir::IntegerAttr &propValue) { + this->lhs_rows = propValue; + } + using rhs_columnsTy = ::mlir::IntegerAttr; + rhs_columnsTy rhs_columns; + + auto getRhsColumns() { + auto &propStorage = this->rhs_columns; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setRhsColumns(const ::mlir::IntegerAttr &propValue) { + this->rhs_columns = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.lhs_columns == this->lhs_columns && + rhs.lhs_rows == this->lhs_rows && + rhs.rhs_columns == this->rhs_columns && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + MatmulOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + MatmulOpGenericAdaptorBase(MatmulOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::IntegerAttr getLhsRowsAttr(); + uint32_t getLhsRows(); + ::mlir::IntegerAttr getLhsColumnsAttr(); + uint32_t getLhsColumns(); + ::mlir::IntegerAttr getRhsColumnsAttr(); + uint32_t getRhsColumns(); +}; +} // namespace detail +template +class MatmulOpGenericAdaptor : public detail::MatmulOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::MatmulOpGenericAdaptorBase; +public: + MatmulOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + MatmulOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : MatmulOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + MatmulOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class MatmulOpAdaptor : public MatmulOpGenericAdaptor<::mlir::ValueRange> { +public: + using MatmulOpGenericAdaptor::MatmulOpGenericAdaptor; + MatmulOpAdaptor(MatmulOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class MatmulOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = MatmulOpAdaptor; + template + using GenericAdaptor = MatmulOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("lhs_columns"), ::llvm::StringRef("lhs_rows"), ::llvm::StringRef("rhs_columns")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getLhsColumnsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getLhsColumnsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getLhsRowsAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getLhsRowsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getRhsColumnsAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getRhsColumnsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.matrix_multiply"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getLhs(); + ::mlir::TypedValue<::mlir::VectorType> getRhs(); + ::mlir::OpOperand &getLhsMutable(); + ::mlir::OpOperand &getRhsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getRes(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::IntegerAttr getLhsRowsAttr(); + uint32_t getLhsRows(); + ::mlir::IntegerAttr getLhsColumnsAttr(); + uint32_t getLhsColumns(); + ::mlir::IntegerAttr getRhsColumnsAttr(); + uint32_t getRhsColumns(); + void setLhsRowsAttr(::mlir::IntegerAttr attr); + void setLhsRows(uint32_t attrValue); + void setLhsColumnsAttr(::mlir::IntegerAttr attr); + void setLhsColumns(uint32_t attrValue); + void setRhsColumnsAttr(::mlir::IntegerAttr attr); + void setRhsColumns(uint32_t attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value lhs, Value rhs, unsigned lhsRows, unsigned lhsColumns, unsigned rhsColumns); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::IntegerAttr lhs_rows, ::mlir::IntegerAttr lhs_columns, ::mlir::IntegerAttr rhs_columns); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, ::mlir::IntegerAttr lhs_rows, ::mlir::IntegerAttr lhs_columns, ::mlir::IntegerAttr rhs_columns); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value lhs, ::mlir::Value rhs, uint32_t lhs_rows, uint32_t lhs_columns, uint32_t rhs_columns); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, uint32_t lhs_rows, uint32_t lhs_columns, uint32_t rhs_columns); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 3 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::MatmulOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::MultiDimReductionOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class MultiDimReductionOpGenericAdaptorBase { +public: + struct Properties { + using kindTy = ::mlir::vector::CombiningKindAttr; + kindTy kind; + + auto getKind() { + auto &propStorage = this->kind; + return ::llvm::cast<::mlir::vector::CombiningKindAttr>(propStorage); + } + void setKind(const ::mlir::vector::CombiningKindAttr &propValue) { + this->kind = propValue; + } + using reduction_dimsTy = ::mlir::ArrayAttr; + reduction_dimsTy reduction_dims; + + auto getReductionDims() { + auto &propStorage = this->reduction_dims; + return ::llvm::cast<::mlir::ArrayAttr>(propStorage); + } + void setReductionDims(const ::mlir::ArrayAttr &propValue) { + this->reduction_dims = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.kind == this->kind && + rhs.reduction_dims == this->reduction_dims && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + MultiDimReductionOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + MultiDimReductionOpGenericAdaptorBase(MultiDimReductionOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::vector::CombiningKindAttr getKindAttr(); + ::mlir::vector::CombiningKind getKind(); + ::mlir::ArrayAttr getReductionDimsAttr(); + ::mlir::ArrayAttr getReductionDims(); +}; +} // namespace detail +template +class MultiDimReductionOpGenericAdaptor : public detail::MultiDimReductionOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::MultiDimReductionOpGenericAdaptorBase; +public: + MultiDimReductionOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + MultiDimReductionOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : MultiDimReductionOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + MultiDimReductionOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSource() { + return (*getODSOperands(0).begin()); + } + + ValueT getAcc() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class MultiDimReductionOpAdaptor : public MultiDimReductionOpGenericAdaptor<::mlir::ValueRange> { +public: + using MultiDimReductionOpGenericAdaptor::MultiDimReductionOpGenericAdaptor; + MultiDimReductionOpAdaptor(MultiDimReductionOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class MultiDimReductionOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::vector::MaskableOpInterface::Trait, ::mlir::VectorUnrollOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = MultiDimReductionOpAdaptor; + template + using GenericAdaptor = MultiDimReductionOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("kind"), ::llvm::StringRef("reduction_dims")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getKindAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getKindAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getReductionDimsAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getReductionDimsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.multi_reduction"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getSource(); + ::mlir::Value getAcc(); + ::mlir::OpOperand &getSourceMutable(); + ::mlir::OpOperand &getAccMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getDest(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::vector::CombiningKindAttr getKindAttr(); + ::mlir::vector::CombiningKind getKind(); + ::mlir::ArrayAttr getReductionDimsAttr(); + ::mlir::ArrayAttr getReductionDims(); + void setKindAttr(::mlir::vector::CombiningKindAttr attr); + void setKind(::mlir::vector::CombiningKind attrValue); + void setReductionDimsAttr(::mlir::ArrayAttr attr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value source, Value acc, ArrayRef reductionMask, CombiningKind kind); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dest, ::mlir::vector::CombiningKindAttr kind, ::mlir::Value source, ::mlir::Value acc, ::mlir::ArrayAttr reduction_dims); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::vector::CombiningKindAttr kind, ::mlir::Value source, ::mlir::Value acc, ::mlir::ArrayAttr reduction_dims); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::vector::CombiningKindAttr kind, ::mlir::Value source, ::mlir::Value acc, ::mlir::ArrayAttr reduction_dims); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dest, ::mlir::vector::CombiningKind kind, ::mlir::Value source, ::mlir::Value acc, ::mlir::ArrayAttr reduction_dims); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::vector::CombiningKind kind, ::mlir::Value source, ::mlir::Value acc, ::mlir::ArrayAttr reduction_dims); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::vector::CombiningKind kind, ::mlir::Value source, ::mlir::Value acc, ::mlir::ArrayAttr reduction_dims); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + mlir::Type getExpectedMaskType(); + ::std::optional<::llvm::SmallVector> getShapeForUnroll(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + VectorType getSourceVectorType() { + return ::llvm::cast(getSource().getType()); + } + Type getDestType() { + return getDest().getType(); + } + + bool isReducedDim(int64_t d) { + assert(d >= 0 && d < static_cast(getReductionMask().size()) && + "d overflows the number of dims"); + return getReductionMask()[d]; + } + + SmallVector getReductionMask() { + SmallVector res(getSourceVectorType().getRank(), false); + for (auto ia : getReductionDims().getAsRange()) + res[ia.getInt()] = true; + return res; + } + static SmallVector getReductionMask( + ArrayRef reductionDims, unsigned sourceRank) { + SmallVector res(sourceRank, false); + for (auto idx : reductionDims) + res[idx] = true; + return res; + } +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::MultiDimReductionOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::OuterProductOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class OuterProductOpGenericAdaptorBase { +public: + struct Properties { + using kindTy = ::mlir::vector::CombiningKindAttr; + kindTy kind; + + auto getKind() { + auto &propStorage = this->kind; + return ::llvm::dyn_cast_or_null<::mlir::vector::CombiningKindAttr>(propStorage); + } + void setKind(const ::mlir::vector::CombiningKindAttr &propValue) { + this->kind = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.kind == this->kind && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + OuterProductOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + OuterProductOpGenericAdaptorBase(OuterProductOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::vector::CombiningKindAttr getKindAttr(); + ::mlir::vector::CombiningKind getKind(); +}; +} // namespace detail +template +class OuterProductOpGenericAdaptor : public detail::OuterProductOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::OuterProductOpGenericAdaptorBase; +public: + OuterProductOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + OuterProductOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : OuterProductOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + OuterProductOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLhs() { + return (*getODSOperands(0).begin()); + } + + ValueT getRhs() { + return (*getODSOperands(1).begin()); + } + + ValueT getAcc() { + auto operands = getODSOperands(2); + return operands.empty() ? ValueT{} : (*operands.begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class OuterProductOpAdaptor : public OuterProductOpGenericAdaptor<::mlir::ValueRange> { +public: + using OuterProductOpGenericAdaptor::OuterProductOpGenericAdaptor; + OuterProductOpAdaptor(OuterProductOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class OuterProductOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::vector::MaskableOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = OuterProductOpAdaptor; + template + using GenericAdaptor = OuterProductOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("kind")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getKindAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getKindAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.outerproduct"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getLhs(); + ::mlir::Value getRhs(); + ::mlir::TypedValue<::mlir::VectorType> getAcc(); + ::mlir::OpOperand &getLhsMutable(); + ::mlir::OpOperand &getRhsMutable(); + ::mlir::MutableOperandRange getAccMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::vector::CombiningKindAttr getKindAttr(); + ::mlir::vector::CombiningKind getKind(); + void setKindAttr(::mlir::vector::CombiningKindAttr attr); + void setKind(::mlir::vector::CombiningKind attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value lhs, Value rhs, Value acc); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::Value acc, ::mlir::vector::CombiningKindAttr kind); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::Value acc, ::mlir::vector::CombiningKindAttr kind); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type resultType0, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::Value acc, ::mlir::vector::CombiningKind kind = CombiningKind::ADD); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs, /*optional*/::mlir::Value acc, ::mlir::vector::CombiningKind kind = CombiningKind::ADD); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void populateDefaultProperties(::mlir::OperationName opName, Properties &properties); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &p); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + mlir::Type getExpectedMaskType(); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + VectorType getOperandVectorTypeLHS() { + return ::llvm::cast(getLhs().getType()); + } + Type getOperandTypeRHS() { + return getRhs().getType(); + } + VectorType getOperandVectorTypeACC() { + return getAcc() + ? ::llvm::cast(getAcc().getType()) + : VectorType(); + } + VectorType getResultVectorType() { + return ::llvm::cast(getResult().getType()); + } + static CombiningKind getDefaultKind() { + return CombiningKind::ADD; + } +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::OuterProductOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::PrintOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class PrintOpGenericAdaptorBase { +public: + struct Properties { + using punctuationTy = ::mlir::vector::PrintPunctuationAttr; + punctuationTy punctuation; + + auto getPunctuation() { + auto &propStorage = this->punctuation; + return ::llvm::dyn_cast_or_null<::mlir::vector::PrintPunctuationAttr>(propStorage); + } + void setPunctuation(const ::mlir::vector::PrintPunctuationAttr &propValue) { + this->punctuation = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.punctuation == this->punctuation && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + PrintOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + PrintOpGenericAdaptorBase(PrintOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::vector::PrintPunctuationAttr getPunctuationAttr(); + ::mlir::vector::PrintPunctuation getPunctuation(); +}; +} // namespace detail +template +class PrintOpGenericAdaptor : public detail::PrintOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::PrintOpGenericAdaptorBase; +public: + PrintOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + PrintOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : PrintOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + PrintOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSource() { + auto operands = getODSOperands(0); + return operands.empty() ? ValueT{} : (*operands.begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class PrintOpAdaptor : public PrintOpGenericAdaptor<::mlir::ValueRange> { +public: + using PrintOpGenericAdaptor::PrintOpGenericAdaptor; + PrintOpAdaptor(PrintOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class PrintOp : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = PrintOpAdaptor; + template + using GenericAdaptor = PrintOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("punctuation")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getPunctuationAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getPunctuationAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.print"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getSource(); + ::mlir::MutableOperandRange getSourceMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::vector::PrintPunctuationAttr getPunctuationAttr(); + ::mlir::vector::PrintPunctuation getPunctuation(); + void setPunctuationAttr(::mlir::vector::PrintPunctuationAttr attr); + void setPunctuation(::mlir::vector::PrintPunctuation attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, PrintPunctuation punctuation); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Value source, ::mlir::vector::PrintPunctuationAttr punctuation); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value source, ::mlir::vector::PrintPunctuationAttr punctuation); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Value source, ::mlir::vector::PrintPunctuation punctuation = ::mlir::vector::PrintPunctuation::NewLine); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, /*optional*/::mlir::Value source, ::mlir::vector::PrintPunctuation punctuation = ::mlir::vector::PrintPunctuation::NewLine); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void populateDefaultProperties(::mlir::OperationName opName, Properties &properties); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + Type getPrintType() { + return getSource().getType(); + } +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::PrintOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::ReductionOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ReductionOpGenericAdaptorBase { +public: + struct Properties { + using fastmathTy = ::mlir::arith::FastMathFlagsAttr; + fastmathTy fastmath; + + auto getFastmath() { + auto &propStorage = this->fastmath; + return ::llvm::dyn_cast_or_null<::mlir::arith::FastMathFlagsAttr>(propStorage); + } + void setFastmath(const ::mlir::arith::FastMathFlagsAttr &propValue) { + this->fastmath = propValue; + } + using kindTy = ::mlir::vector::CombiningKindAttr; + kindTy kind; + + auto getKind() { + auto &propStorage = this->kind; + return ::llvm::cast<::mlir::vector::CombiningKindAttr>(propStorage); + } + void setKind(const ::mlir::vector::CombiningKindAttr &propValue) { + this->kind = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.fastmath == this->fastmath && + rhs.kind == this->kind && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ReductionOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + ReductionOpGenericAdaptorBase(ReductionOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::vector::CombiningKindAttr getKindAttr(); + ::mlir::vector::CombiningKind getKind(); + ::mlir::arith::FastMathFlagsAttr getFastmathAttr(); + ::mlir::arith::FastMathFlags getFastmath(); +}; +} // namespace detail +template +class ReductionOpGenericAdaptor : public detail::ReductionOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ReductionOpGenericAdaptorBase; +public: + ReductionOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ReductionOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ReductionOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + ReductionOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getVector() { + return (*getODSOperands(0).begin()); + } + + ValueT getAcc() { + auto operands = getODSOperands(1); + return operands.empty() ? ValueT{} : (*operands.begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ReductionOpAdaptor : public ReductionOpGenericAdaptor<::mlir::ValueRange> { +public: + using ReductionOpGenericAdaptor::ReductionOpGenericAdaptor; + ReductionOpAdaptor(ReductionOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ReductionOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<1>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::arith::ArithFastMathInterface::Trait, ::mlir::vector::MaskableOpInterface::Trait, ::mlir::VectorUnrollOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ReductionOpAdaptor; + template + using GenericAdaptor = ReductionOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("fastmath"), ::llvm::StringRef("kind")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getFastmathAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getFastmathAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getKindAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getKindAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.reduction"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getVector(); + ::mlir::Value getAcc(); + ::mlir::OpOperand &getVectorMutable(); + ::mlir::MutableOperandRange getAccMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getDest(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::vector::CombiningKindAttr getKindAttr(); + ::mlir::vector::CombiningKind getKind(); + ::mlir::arith::FastMathFlagsAttr getFastmathAttr(); + ::mlir::arith::FastMathFlags getFastmath(); + void setKindAttr(::mlir::vector::CombiningKindAttr attr); + void setKind(::mlir::vector::CombiningKind attrValue); + void setFastmathAttr(::mlir::arith::FastMathFlagsAttr attr); + void setFastmath(::mlir::arith::FastMathFlags attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, CombiningKind kind, Value vector, Value acc, ::mlir::arith::FastMathFlags fastMathFlags = ::mlir::arith::FastMathFlags::none); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, CombiningKind kind, Value vector, ::mlir::arith::FastMathFlags fastMathFlags = ::mlir::arith::FastMathFlags::none); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dest, ::mlir::vector::CombiningKindAttr kind, ::mlir::Value vector, /*optional*/::mlir::Value acc, ::mlir::arith::FastMathFlagsAttr fastmath); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::vector::CombiningKindAttr kind, ::mlir::Value vector, /*optional*/::mlir::Value acc, ::mlir::arith::FastMathFlagsAttr fastmath); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dest, ::mlir::vector::CombiningKind kind, ::mlir::Value vector, /*optional*/::mlir::Value acc, ::mlir::arith::FastMathFlags fastmath = ::mlir::arith::FastMathFlags::none); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::vector::CombiningKind kind, ::mlir::Value vector, /*optional*/::mlir::Value acc, ::mlir::arith::FastMathFlags fastmath = ::mlir::arith::FastMathFlags::none); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void populateDefaultProperties(::mlir::OperationName opName, Properties &properties); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &p); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + mlir::Type getExpectedMaskType(); + ::std::optional<::llvm::SmallVector> getShapeForUnroll(); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + VectorType getSourceVectorType() { + return ::llvm::cast(getVector().getType()); + } +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::ReductionOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::ReshapeOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ReshapeOpGenericAdaptorBase { +public: + struct Properties { + using fixed_vector_sizesTy = ::mlir::ArrayAttr; + fixed_vector_sizesTy fixed_vector_sizes; + + auto getFixedVectorSizes() { + auto &propStorage = this->fixed_vector_sizes; + return ::llvm::cast<::mlir::ArrayAttr>(propStorage); + } + void setFixedVectorSizes(const ::mlir::ArrayAttr &propValue) { + this->fixed_vector_sizes = propValue; + } + using operandSegmentSizesTy = std::array; + operandSegmentSizesTy operandSegmentSizes; + ::llvm::ArrayRef getOperandSegmentSizes() { + auto &propStorage = this->operandSegmentSizes; + return propStorage; + } + void setOperandSegmentSizes(const ::llvm::ArrayRef &propValue) { + auto &propStorage = this->operandSegmentSizes; + ::llvm::copy(propValue, propStorage.begin()); + } + bool operator==(const Properties &rhs) const { + return + rhs.fixed_vector_sizes == this->fixed_vector_sizes && + rhs.operandSegmentSizes == this->operandSegmentSizes && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ReshapeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + ReshapeOpGenericAdaptorBase(ReshapeOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::ArrayAttr getFixedVectorSizesAttr(); + ::mlir::ArrayAttr getFixedVectorSizes(); +}; +} // namespace detail +template +class ReshapeOpGenericAdaptor : public detail::ReshapeOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ReshapeOpGenericAdaptorBase; +public: + ReshapeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ReshapeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ReshapeOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + ReshapeOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getVector() { + return (*getODSOperands(0).begin()); + } + + RangeT getInputShape() { + return getODSOperands(1); + } + + RangeT getOutputShape() { + return getODSOperands(2); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ReshapeOpAdaptor : public ReshapeOpGenericAdaptor<::mlir::ValueRange> { +public: + using ReshapeOpGenericAdaptor::ReshapeOpGenericAdaptor; + ReshapeOpAdaptor(ReshapeOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ReshapeOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<1>::Impl, ::mlir::OpTrait::AttrSizedOperandSegments, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ReshapeOpAdaptor; + template + using GenericAdaptor = ReshapeOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("fixed_vector_sizes"), ::llvm::StringRef("operandSegmentSizes")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getFixedVectorSizesAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getFixedVectorSizesAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getOperandSegmentSizesAttrName() { + return (*this)->getName().getAttributeNames().back(); + } + + static ::mlir::StringAttr getOperandSegmentSizesAttrName(::mlir::OperationName name) { + return name.getAttributeNames().back(); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.reshape"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getVector(); + ::mlir::Operation::operand_range getInputShape(); + ::mlir::Operation::operand_range getOutputShape(); + ::mlir::OpOperand &getVectorMutable(); + ::mlir::MutableOperandRange getInputShapeMutable(); + ::mlir::MutableOperandRange getOutputShapeMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getResult(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::ArrayAttr getFixedVectorSizesAttr(); + ::mlir::ArrayAttr getFixedVectorSizes(); + void setFixedVectorSizesAttr(::mlir::ArrayAttr attr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value vector, ::mlir::ValueRange input_shape, ::mlir::ValueRange output_shape, ::mlir::ArrayAttr fixed_vector_sizes); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value vector, ::mlir::ValueRange input_shape, ::mlir::ValueRange output_shape, ::mlir::ArrayAttr fixed_vector_sizes); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + VectorType getInputVectorType() { + return ::llvm::cast(getVector().getType()); + } + VectorType getOutputVectorType() { + return ::llvm::cast(getResult().getType()); + } + + /// Returns as integer value the number of input shape operands. + int64_t getNumInputShapeSizes() { return getInputShape().size(); } + + /// Returns as integer value the number of output shape operands. + int64_t getNumOutputShapeSizes() { return getOutputShape().size(); } + + void getFixedVectorSizes(SmallVectorImpl &results); +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::ReshapeOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::ScalableExtractOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ScalableExtractOpGenericAdaptorBase { +public: + struct Properties { + using posTy = ::mlir::IntegerAttr; + posTy pos; + + auto getPos() { + auto &propStorage = this->pos; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setPos(const ::mlir::IntegerAttr &propValue) { + this->pos = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.pos == this->pos && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ScalableExtractOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + ScalableExtractOpGenericAdaptorBase(ScalableExtractOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::IntegerAttr getPosAttr(); + uint64_t getPos(); +}; +} // namespace detail +template +class ScalableExtractOpGenericAdaptor : public detail::ScalableExtractOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ScalableExtractOpGenericAdaptorBase; +public: + ScalableExtractOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ScalableExtractOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ScalableExtractOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + ScalableExtractOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSource() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ScalableExtractOpAdaptor : public ScalableExtractOpGenericAdaptor<::mlir::ValueRange> { +public: + using ScalableExtractOpGenericAdaptor::ScalableExtractOpGenericAdaptor; + ScalableExtractOpAdaptor(ScalableExtractOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ScalableExtractOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ScalableExtractOpAdaptor; + template + using GenericAdaptor = ScalableExtractOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("pos")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getPosAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getPosAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.scalable.extract"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getSource(); + ::mlir::OpOperand &getSourceMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getRes(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::IntegerAttr getPosAttr(); + uint64_t getPos(); + void setPosAttr(::mlir::IntegerAttr attr); + void setPos(uint64_t attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value source, ::mlir::IntegerAttr pos); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::IntegerAttr pos); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value source, uint64_t pos); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, uint64_t pos); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + VectorType getSourceVectorType() { + return ::llvm::cast(getSource().getType()); + } + VectorType getResultVectorType() { + return ::llvm::cast(getRes().getType()); + } +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::ScalableExtractOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::ScalableInsertOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ScalableInsertOpGenericAdaptorBase { +public: + struct Properties { + using posTy = ::mlir::IntegerAttr; + posTy pos; + + auto getPos() { + auto &propStorage = this->pos; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setPos(const ::mlir::IntegerAttr &propValue) { + this->pos = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.pos == this->pos && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ScalableInsertOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + ScalableInsertOpGenericAdaptorBase(ScalableInsertOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::IntegerAttr getPosAttr(); + uint64_t getPos(); +}; +} // namespace detail +template +class ScalableInsertOpGenericAdaptor : public detail::ScalableInsertOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ScalableInsertOpGenericAdaptorBase; +public: + ScalableInsertOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ScalableInsertOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ScalableInsertOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + ScalableInsertOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSource() { + return (*getODSOperands(0).begin()); + } + + ValueT getDest() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ScalableInsertOpAdaptor : public ScalableInsertOpGenericAdaptor<::mlir::ValueRange> { +public: + using ScalableInsertOpGenericAdaptor::ScalableInsertOpGenericAdaptor; + ScalableInsertOpAdaptor(ScalableInsertOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ScalableInsertOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ScalableInsertOpAdaptor; + template + using GenericAdaptor = ScalableInsertOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("pos")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getPosAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getPosAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.scalable.insert"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getSource(); + ::mlir::TypedValue<::mlir::VectorType> getDest(); + ::mlir::OpOperand &getSourceMutable(); + ::mlir::OpOperand &getDestMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getRes(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::IntegerAttr getPosAttr(); + uint64_t getPos(); + void setPosAttr(::mlir::IntegerAttr attr); + void setPos(uint64_t attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value source, ::mlir::Value dest, ::mlir::IntegerAttr pos); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value source, ::mlir::Value dest, ::mlir::IntegerAttr pos); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, ::mlir::IntegerAttr pos); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value source, ::mlir::Value dest, uint64_t pos); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value source, ::mlir::Value dest, uint64_t pos); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, uint64_t pos); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + VectorType getSourceVectorType() { + return ::llvm::cast(getSource().getType()); + } + VectorType getDestVectorType() { + return ::llvm::cast(getDest().getType()); + } +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::ScalableInsertOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::ScanOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ScanOpGenericAdaptorBase { +public: + struct Properties { + using inclusiveTy = ::mlir::BoolAttr; + inclusiveTy inclusive; + + auto getInclusive() { + auto &propStorage = this->inclusive; + return ::llvm::cast<::mlir::BoolAttr>(propStorage); + } + void setInclusive(const ::mlir::BoolAttr &propValue) { + this->inclusive = propValue; + } + using kindTy = ::mlir::vector::CombiningKindAttr; + kindTy kind; + + auto getKind() { + auto &propStorage = this->kind; + return ::llvm::cast<::mlir::vector::CombiningKindAttr>(propStorage); + } + void setKind(const ::mlir::vector::CombiningKindAttr &propValue) { + this->kind = propValue; + } + using reduction_dimTy = ::mlir::IntegerAttr; + reduction_dimTy reduction_dim; + + auto getReductionDim() { + auto &propStorage = this->reduction_dim; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setReductionDim(const ::mlir::IntegerAttr &propValue) { + this->reduction_dim = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.inclusive == this->inclusive && + rhs.kind == this->kind && + rhs.reduction_dim == this->reduction_dim && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ScanOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + ScanOpGenericAdaptorBase(ScanOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::vector::CombiningKindAttr getKindAttr(); + ::mlir::vector::CombiningKind getKind(); + ::mlir::IntegerAttr getReductionDimAttr(); + uint64_t getReductionDim(); + ::mlir::BoolAttr getInclusiveAttr(); + bool getInclusive(); +}; +} // namespace detail +template +class ScanOpGenericAdaptor : public detail::ScanOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ScanOpGenericAdaptorBase; +public: + ScanOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ScanOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ScanOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + ScanOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSource() { + return (*getODSOperands(0).begin()); + } + + ValueT getInitialValue() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ScanOpAdaptor : public ScanOpGenericAdaptor<::mlir::ValueRange> { +public: + using ScanOpGenericAdaptor::ScanOpGenericAdaptor; + ScanOpAdaptor(ScanOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ScanOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::OpAsmOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ScanOpAdaptor; + template + using GenericAdaptor = ScanOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("inclusive"), ::llvm::StringRef("kind"), ::llvm::StringRef("reduction_dim")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getInclusiveAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getInclusiveAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getKindAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getKindAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getReductionDimAttrName() { + return getAttributeNameForIndex(2); + } + + static ::mlir::StringAttr getReductionDimAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 2); + } + + void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn); + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.scan"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getSource(); + ::mlir::TypedValue<::mlir::VectorType> getInitialValue(); + ::mlir::OpOperand &getSourceMutable(); + ::mlir::OpOperand &getInitialValueMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getDest(); + ::mlir::TypedValue<::mlir::VectorType> getAccumulatedValue(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::vector::CombiningKindAttr getKindAttr(); + ::mlir::vector::CombiningKind getKind(); + ::mlir::IntegerAttr getReductionDimAttr(); + uint64_t getReductionDim(); + ::mlir::BoolAttr getInclusiveAttr(); + bool getInclusive(); + void setKindAttr(::mlir::vector::CombiningKindAttr attr); + void setKind(::mlir::vector::CombiningKind attrValue); + void setReductionDimAttr(::mlir::IntegerAttr attr); + void setReductionDim(uint64_t attrValue); + void setInclusiveAttr(::mlir::BoolAttr attr); + void setInclusive(bool attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value source, Value initial_value, CombiningKind kind, int64_t reduction_dim = 0, bool inclusive = true); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dest, ::mlir::Type accumulated_value, ::mlir::vector::CombiningKindAttr kind, ::mlir::Value source, ::mlir::Value initial_value, ::mlir::IntegerAttr reduction_dim, ::mlir::BoolAttr inclusive); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::vector::CombiningKindAttr kind, ::mlir::Value source, ::mlir::Value initial_value, ::mlir::IntegerAttr reduction_dim, ::mlir::BoolAttr inclusive); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::vector::CombiningKindAttr kind, ::mlir::Value source, ::mlir::Value initial_value, ::mlir::IntegerAttr reduction_dim, ::mlir::BoolAttr inclusive); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dest, ::mlir::Type accumulated_value, ::mlir::vector::CombiningKind kind, ::mlir::Value source, ::mlir::Value initial_value, uint64_t reduction_dim, bool inclusive); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::vector::CombiningKind kind, ::mlir::Value source, ::mlir::Value initial_value, uint64_t reduction_dim, bool inclusive); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::vector::CombiningKind kind, ::mlir::Value source, ::mlir::Value initial_value, uint64_t reduction_dim, bool inclusive); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 3 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + VectorType getSourceType() { + return ::llvm::cast(getSource().getType()); + } + VectorType getDestType() { + return ::llvm::cast(getDest().getType()); + } + VectorType getAccumulatorType() { + return ::llvm::cast(getAccumulatedValue().getType()); + } + VectorType getInitialValueType() { + return ::llvm::cast(getInitialValue().getType()); + } +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::ScanOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::ScatterOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ScatterOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + ScatterOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + ScatterOpGenericAdaptorBase(ScatterOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class ScatterOpGenericAdaptor : public detail::ScatterOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ScatterOpGenericAdaptorBase; +public: + ScatterOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ScatterOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ScatterOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + ScatterOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getBase() { + return (*getODSOperands(0).begin()); + } + + RangeT getIndices() { + return getODSOperands(1); + } + + ValueT getIndexVec() { + return (*getODSOperands(2).begin()); + } + + ValueT getMask() { + return (*getODSOperands(3).begin()); + } + + ValueT getValueToStore() { + return (*getODSOperands(4).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ScatterOpAdaptor : public ScatterOpGenericAdaptor<::mlir::ValueRange> { +public: + using ScatterOpGenericAdaptor::ScatterOpGenericAdaptor; + ScatterOpAdaptor(ScatterOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ScatterOp : public ::mlir::Op::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ScatterOpAdaptor; + template + using GenericAdaptor = ScatterOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.scatter"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::MemRefType> getBase(); + ::mlir::Operation::operand_range getIndices(); + ::mlir::TypedValue<::mlir::VectorType> getIndexVec(); + ::mlir::TypedValue<::mlir::VectorType> getMask(); + ::mlir::TypedValue<::mlir::VectorType> getValueToStore(); + ::mlir::OpOperand &getBaseMutable(); + ::mlir::MutableOperandRange getIndicesMutable(); + ::mlir::OpOperand &getIndexVecMutable(); + ::mlir::OpOperand &getMaskMutable(); + ::mlir::OpOperand &getValueToStoreMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value base, ::mlir::ValueRange indices, ::mlir::Value index_vec, ::mlir::Value mask, ::mlir::Value valueToStore); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value base, ::mlir::ValueRange indices, ::mlir::Value index_vec, ::mlir::Value mask, ::mlir::Value valueToStore); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + MemRefType getMemRefType() { return getBase().getType(); } + VectorType getIndexVectorType() { return getIndexVec().getType(); } + VectorType getMaskVectorType() { return getMask().getType(); } + VectorType getVectorType() { return getValueToStore().getType(); } +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::ScatterOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::ShapeCastOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ShapeCastOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + ShapeCastOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + ShapeCastOpGenericAdaptorBase(ShapeCastOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class ShapeCastOpGenericAdaptor : public detail::ShapeCastOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ShapeCastOpGenericAdaptorBase; +public: + ShapeCastOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ShapeCastOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ShapeCastOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + ShapeCastOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSource() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ShapeCastOpAdaptor : public ShapeCastOpGenericAdaptor<::mlir::ValueRange> { +public: + using ShapeCastOpGenericAdaptor::ShapeCastOpGenericAdaptor; + ShapeCastOpAdaptor(ShapeCastOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ShapeCastOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = ShapeCastOpAdaptor; + template + using GenericAdaptor = ShapeCastOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.shape_cast"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getSource(); + ::mlir::OpOperand &getSourceMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value source); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + VectorType getSourceVectorType() { + return ::llvm::cast(getSource().getType()); + } + VectorType getResultVectorType() { + return ::llvm::cast(getResult().getType()); + } +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::ShapeCastOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::ShuffleOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class ShuffleOpGenericAdaptorBase { +public: + struct Properties { + using maskTy = ::mlir::ArrayAttr; + maskTy mask; + + auto getMask() { + auto &propStorage = this->mask; + return ::llvm::cast<::mlir::ArrayAttr>(propStorage); + } + void setMask(const ::mlir::ArrayAttr &propValue) { + this->mask = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.mask == this->mask && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + ShuffleOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + ShuffleOpGenericAdaptorBase(ShuffleOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::ArrayAttr getMaskAttr(); + ::mlir::ArrayAttr getMask(); +}; +} // namespace detail +template +class ShuffleOpGenericAdaptor : public detail::ShuffleOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::ShuffleOpGenericAdaptorBase; +public: + ShuffleOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + ShuffleOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ShuffleOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + ShuffleOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getV1() { + return (*getODSOperands(0).begin()); + } + + ValueT getV2() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class ShuffleOpAdaptor : public ShuffleOpGenericAdaptor<::mlir::ValueRange> { +public: + using ShuffleOpGenericAdaptor::ShuffleOpGenericAdaptor; + ShuffleOpAdaptor(ShuffleOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class ShuffleOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::OpTrait::InferTypeOpAdaptor> { +public: + using Op::Op; + using Op::print; + using Adaptor = ShuffleOpAdaptor; + template + using GenericAdaptor = ShuffleOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("mask")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getMaskAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getMaskAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.shuffle"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getV1(); + ::mlir::TypedValue<::mlir::VectorType> getV2(); + ::mlir::OpOperand &getV1Mutable(); + ::mlir::OpOperand &getV2Mutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getVector(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::ArrayAttr getMaskAttr(); + ::mlir::ArrayAttr getMask(); + void setMaskAttr(::mlir::ArrayAttr attr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value v1, Value v2, ArrayRef odsArg2); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type vector, ::mlir::Value v1, ::mlir::Value v2, ::mlir::ArrayAttr mask); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value v1, ::mlir::Value v2, ::mlir::ArrayAttr mask); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value v1, ::mlir::Value v2, ::mlir::ArrayAttr mask); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + static ::mlir::LogicalResult + inferReturnTypes(::mlir::MLIRContext *context, + std::optional<::mlir::Location> location, + Adaptor adaptor, + ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes); + + + VectorType getV1VectorType() { + return ::llvm::cast(getV1().getType()); + } + VectorType getV2VectorType() { + return ::llvm::cast(getV2().getType()); + } + VectorType getResultVectorType() { + return ::llvm::cast(getVector().getType()); + } +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::ShuffleOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::SplatOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class SplatOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + SplatOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + SplatOpGenericAdaptorBase(SplatOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class SplatOpGenericAdaptor : public detail::SplatOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::SplatOpGenericAdaptorBase; +public: + SplatOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + SplatOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : SplatOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + SplatOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getInput() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class SplatOpAdaptor : public SplatOpGenericAdaptor<::mlir::ValueRange> { +public: + using SplatOpGenericAdaptor::SplatOpGenericAdaptor; + SplatOpAdaptor(SplatOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class SplatOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = SplatOpAdaptor; + template + using GenericAdaptor = SplatOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.splat"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Value getInput(); + ::mlir::OpOperand &getInputMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getAggregate(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value element, Type aggregateType); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type aggregate, ::mlir::Value input); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::SplatOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::StoreOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class StoreOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + StoreOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + StoreOpGenericAdaptorBase(StoreOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class StoreOpGenericAdaptor : public detail::StoreOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::StoreOpGenericAdaptorBase; +public: + StoreOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + StoreOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : StoreOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + StoreOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getValueToStore() { + return (*getODSOperands(0).begin()); + } + + ValueT getBase() { + return (*getODSOperands(1).begin()); + } + + RangeT getIndices() { + return getODSOperands(2); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class StoreOpAdaptor : public StoreOpGenericAdaptor<::mlir::ValueRange> { +public: + using StoreOpGenericAdaptor::StoreOpGenericAdaptor; + StoreOpAdaptor(StoreOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class StoreOp : public ::mlir::Op::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = StoreOpAdaptor; + template + using GenericAdaptor = StoreOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.store"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getValueToStore(); + ::mlir::TypedValue<::mlir::MemRefType> getBase(); + ::mlir::Operation::operand_range getIndices(); + ::mlir::OpOperand &getValueToStoreMutable(); + ::mlir::OpOperand &getBaseMutable(); + ::mlir::MutableOperandRange getIndicesMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value valueToStore, ::mlir::Value base, ::mlir::ValueRange indices); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value valueToStore, ::mlir::Value base, ::mlir::ValueRange indices); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + ::mlir::LogicalResult fold(FoldAdaptor adaptor, ::llvm::SmallVectorImpl<::mlir::OpFoldResult> &results); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + MemRefType getMemRefType() { + return ::llvm::cast(getBase().getType()); + } + + VectorType getVectorType() { + return ::llvm::cast(getValueToStore().getType()); + } +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::StoreOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::TransferReadOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class TransferReadOpGenericAdaptorBase { +public: + struct Properties { + using in_boundsTy = ::mlir::ArrayAttr; + in_boundsTy in_bounds; + + auto getInBounds() { + auto &propStorage = this->in_bounds; + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(propStorage); + } + void setInBounds(const ::mlir::ArrayAttr &propValue) { + this->in_bounds = propValue; + } + using permutation_mapTy = ::mlir::AffineMapAttr; + permutation_mapTy permutation_map; + + auto getPermutationMap() { + auto &propStorage = this->permutation_map; + return ::llvm::cast<::mlir::AffineMapAttr>(propStorage); + } + void setPermutationMap(const ::mlir::AffineMapAttr &propValue) { + this->permutation_map = propValue; + } + using operandSegmentSizesTy = std::array; + operandSegmentSizesTy operandSegmentSizes; + ::llvm::ArrayRef getOperandSegmentSizes() { + auto &propStorage = this->operandSegmentSizes; + return propStorage; + } + void setOperandSegmentSizes(const ::llvm::ArrayRef &propValue) { + auto &propStorage = this->operandSegmentSizes; + ::llvm::copy(propValue, propStorage.begin()); + } + bool operator==(const Properties &rhs) const { + return + rhs.in_bounds == this->in_bounds && + rhs.permutation_map == this->permutation_map && + rhs.operandSegmentSizes == this->operandSegmentSizes && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + TransferReadOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + TransferReadOpGenericAdaptorBase(TransferReadOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::AffineMapAttr getPermutationMapAttr(); + ::mlir::AffineMap getPermutationMap(); + ::mlir::ArrayAttr getInBoundsAttr(); + ::std::optional< ::mlir::ArrayAttr > getInBounds(); +}; +} // namespace detail +template +class TransferReadOpGenericAdaptor : public detail::TransferReadOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::TransferReadOpGenericAdaptorBase; +public: + TransferReadOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + TransferReadOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : TransferReadOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + TransferReadOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSource() { + return (*getODSOperands(0).begin()); + } + + RangeT getIndices() { + return getODSOperands(1); + } + + ValueT getPadding() { + return (*getODSOperands(2).begin()); + } + + ValueT getMask() { + auto operands = getODSOperands(3); + return operands.empty() ? ValueT{} : (*operands.begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class TransferReadOpAdaptor : public TransferReadOpGenericAdaptor<::mlir::ValueRange> { +public: + using TransferReadOpGenericAdaptor::TransferReadOpGenericAdaptor; + TransferReadOpAdaptor(TransferReadOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class TransferReadOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<2>::Impl, ::mlir::OpTrait::AttrSizedOperandSegments, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::VectorTransferOpInterface::Trait, ::mlir::VectorUnrollOpInterface::Trait, ::mlir::vector::MaskableOpInterface::Trait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::DestinationStyleOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = TransferReadOpAdaptor; + template + using GenericAdaptor = TransferReadOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("in_bounds"), ::llvm::StringRef("permutation_map"), ::llvm::StringRef("operandSegmentSizes")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getInBoundsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getInBoundsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getPermutationMapAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getPermutationMapAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getOperandSegmentSizesAttrName() { + return (*this)->getName().getAttributeNames().back(); + } + + static ::mlir::StringAttr getOperandSegmentSizesAttrName(::mlir::OperationName name) { + return name.getAttributeNames().back(); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.transfer_read"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::ShapedType> getSource(); + ::mlir::Operation::operand_range getIndices(); + ::mlir::Value getPadding(); + ::mlir::TypedValue<::mlir::VectorType> getMask(); + ::mlir::OpOperand &getSourceMutable(); + ::mlir::MutableOperandRange getIndicesMutable(); + ::mlir::OpOperand &getPaddingMutable(); + ::mlir::MutableOperandRange getMaskMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getVector(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::AffineMapAttr getPermutationMapAttr(); + ::mlir::AffineMap getPermutationMap(); + ::mlir::ArrayAttr getInBoundsAttr(); + ::std::optional< ::mlir::ArrayAttr > getInBounds(); + void setPermutationMapAttr(::mlir::AffineMapAttr attr); + void setPermutationMap(::mlir::AffineMap attrValue); + void setInBoundsAttr(::mlir::ArrayAttr attr); + ::mlir::Attribute removeInBoundsAttr(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, VectorType vectorType, Value source, ValueRange indices, AffineMapAttr permutationMapAttr, ArrayAttr inBoundsAttr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, VectorType vectorType, Value source, ValueRange indices, AffineMap permutationMap, std::optional> inBounds = ::std::nullopt); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, VectorType vectorType, Value source, ValueRange indices, Value padding, std::optional> inBounds = ::std::nullopt); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, VectorType vectorType, Value source, ValueRange indices, std::optional> inBounds = ::std::nullopt); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type vector, ::mlir::Value source, ::mlir::ValueRange indices, ::mlir::AffineMapAttr permutation_map, ::mlir::Value padding, /*optional*/::mlir::Value mask, /*optional*/::mlir::ArrayAttr in_bounds); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::ValueRange indices, ::mlir::AffineMapAttr permutation_map, ::mlir::Value padding, /*optional*/::mlir::Value mask, /*optional*/::mlir::ArrayAttr in_bounds); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type vector, ::mlir::Value source, ::mlir::ValueRange indices, ::mlir::AffineMap permutation_map, ::mlir::Value padding, /*optional*/::mlir::Value mask, /*optional*/::mlir::ArrayAttr in_bounds); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::ValueRange indices, ::mlir::AffineMap permutation_map, ::mlir::Value padding, /*optional*/::mlir::Value mask, /*optional*/::mlir::ArrayAttr in_bounds); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &p); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + ::std::optional<::llvm::SmallVector> getShapeForUnroll(); + mlir::Type getExpectedMaskType(); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + // MaskableOpInterface methods. + bool supportsPassthru() { return true; } + + MutableOperandRange getDpsInitsMutable() { + return MutableOperandRange(getOperation(), /*start=*/0, /*length=*/0); + } +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::TransferReadOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::TransferWriteOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class TransferWriteOpGenericAdaptorBase { +public: + struct Properties { + using in_boundsTy = ::mlir::ArrayAttr; + in_boundsTy in_bounds; + + auto getInBounds() { + auto &propStorage = this->in_bounds; + return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(propStorage); + } + void setInBounds(const ::mlir::ArrayAttr &propValue) { + this->in_bounds = propValue; + } + using permutation_mapTy = ::mlir::AffineMapAttr; + permutation_mapTy permutation_map; + + auto getPermutationMap() { + auto &propStorage = this->permutation_map; + return ::llvm::cast<::mlir::AffineMapAttr>(propStorage); + } + void setPermutationMap(const ::mlir::AffineMapAttr &propValue) { + this->permutation_map = propValue; + } + using operandSegmentSizesTy = std::array; + operandSegmentSizesTy operandSegmentSizes; + ::llvm::ArrayRef getOperandSegmentSizes() { + auto &propStorage = this->operandSegmentSizes; + return propStorage; + } + void setOperandSegmentSizes(const ::llvm::ArrayRef &propValue) { + auto &propStorage = this->operandSegmentSizes; + ::llvm::copy(propValue, propStorage.begin()); + } + bool operator==(const Properties &rhs) const { + return + rhs.in_bounds == this->in_bounds && + rhs.permutation_map == this->permutation_map && + rhs.operandSegmentSizes == this->operandSegmentSizes && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + TransferWriteOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + TransferWriteOpGenericAdaptorBase(TransferWriteOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::AffineMapAttr getPermutationMapAttr(); + ::mlir::AffineMap getPermutationMap(); + ::mlir::ArrayAttr getInBoundsAttr(); + ::std::optional< ::mlir::ArrayAttr > getInBounds(); +}; +} // namespace detail +template +class TransferWriteOpGenericAdaptor : public detail::TransferWriteOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::TransferWriteOpGenericAdaptorBase; +public: + TransferWriteOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + TransferWriteOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : TransferWriteOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + TransferWriteOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getVector() { + return (*getODSOperands(0).begin()); + } + + ValueT getSource() { + return (*getODSOperands(1).begin()); + } + + RangeT getIndices() { + return getODSOperands(2); + } + + ValueT getMask() { + auto operands = getODSOperands(3); + return operands.empty() ? ValueT{} : (*operands.begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class TransferWriteOpAdaptor : public TransferWriteOpGenericAdaptor<::mlir::ValueRange> { +public: + using TransferWriteOpGenericAdaptor::TransferWriteOpGenericAdaptor; + TransferWriteOpAdaptor(TransferWriteOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class TransferWriteOp : public ::mlir::Op::Impl, ::mlir::OpTrait::AttrSizedOperandSegments, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::VectorTransferOpInterface::Trait, ::mlir::VectorUnrollOpInterface::Trait, ::mlir::vector::MaskableOpInterface::Trait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::DestinationStyleOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = TransferWriteOpAdaptor; + template + using GenericAdaptor = TransferWriteOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("in_bounds"), ::llvm::StringRef("permutation_map"), ::llvm::StringRef("operandSegmentSizes")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getInBoundsAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getInBoundsAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + ::mlir::StringAttr getPermutationMapAttrName() { + return getAttributeNameForIndex(1); + } + + static ::mlir::StringAttr getPermutationMapAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 1); + } + + ::mlir::StringAttr getOperandSegmentSizesAttrName() { + return (*this)->getName().getAttributeNames().back(); + } + + static ::mlir::StringAttr getOperandSegmentSizesAttrName(::mlir::OperationName name) { + return name.getAttributeNames().back(); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.transfer_write"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getVector(); + ::mlir::TypedValue<::mlir::ShapedType> getSource(); + ::mlir::Operation::operand_range getIndices(); + ::mlir::TypedValue<::mlir::VectorType> getMask(); + ::mlir::OpOperand &getVectorMutable(); + ::mlir::OpOperand &getSourceMutable(); + ::mlir::MutableOperandRange getIndicesMutable(); + ::mlir::MutableOperandRange getMaskMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::RankedTensorType> getResult(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::AffineMapAttr getPermutationMapAttr(); + ::mlir::AffineMap getPermutationMap(); + ::mlir::ArrayAttr getInBoundsAttr(); + ::std::optional< ::mlir::ArrayAttr > getInBounds(); + void setPermutationMapAttr(::mlir::AffineMapAttr attr); + void setPermutationMap(::mlir::AffineMap attrValue); + void setInBoundsAttr(::mlir::ArrayAttr attr); + ::mlir::Attribute removeInBoundsAttr(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value vector, Value dest, ValueRange indices, AffineMapAttr permutationMapAttr, Value mask, ArrayAttr inBoundsAttr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value vector, Value dest, ValueRange indices, AffineMapAttr permutationMapAttr, ArrayAttr inBoundsAttr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value vector, Value dest, ValueRange indices, AffineMap permutationMap, std::optional> inBounds = ::std::nullopt); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value vector, Value dest, ValueRange indices, std::optional> inBounds = ::std::nullopt); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Type result, ::mlir::Value vector, ::mlir::Value source, ::mlir::ValueRange indices, ::mlir::AffineMapAttr permutation_map, /*optional*/::mlir::Value mask, /*optional*/::mlir::ArrayAttr in_bounds); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value vector, ::mlir::Value source, ::mlir::ValueRange indices, ::mlir::AffineMapAttr permutation_map, /*optional*/::mlir::Value mask, /*optional*/::mlir::ArrayAttr in_bounds); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Type result, ::mlir::Value vector, ::mlir::Value source, ::mlir::ValueRange indices, ::mlir::AffineMap permutation_map, /*optional*/::mlir::Value mask, /*optional*/::mlir::ArrayAttr in_bounds); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value vector, ::mlir::Value source, ::mlir::ValueRange indices, ::mlir::AffineMap permutation_map, /*optional*/::mlir::Value mask, /*optional*/::mlir::ArrayAttr in_bounds); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &p); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::mlir::LogicalResult fold(FoldAdaptor adaptor, ::llvm::SmallVectorImpl<::mlir::OpFoldResult> &results); + ::std::optional<::llvm::SmallVector> getShapeForUnroll(); + mlir::Type getExpectedMaskType(); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 2 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + /// This method is added to maintain uniformity with load/store + /// ops of other dialects. + Value getValue() { return getVector(); } + + MutableOperandRange getDpsInitsMutable() { return getSourceMutable(); } +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::TransferWriteOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::TransposeOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class TransposeOpGenericAdaptorBase { +public: + struct Properties { + using transpTy = ::mlir::ArrayAttr; + transpTy transp; + + auto getTransp() { + auto &propStorage = this->transp; + return ::llvm::cast<::mlir::ArrayAttr>(propStorage); + } + void setTransp(const ::mlir::ArrayAttr &propValue) { + this->transp = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.transp == this->transp && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + TransposeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + TransposeOpGenericAdaptorBase(TransposeOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::ArrayAttr getTranspAttr(); + ::mlir::ArrayAttr getTransp(); +}; +} // namespace detail +template +class TransposeOpGenericAdaptor : public detail::TransposeOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::TransposeOpGenericAdaptorBase; +public: + TransposeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + TransposeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : TransposeOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + TransposeOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getVector() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class TransposeOpAdaptor : public TransposeOpGenericAdaptor<::mlir::ValueRange> { +public: + using TransposeOpGenericAdaptor::TransposeOpGenericAdaptor; + TransposeOpAdaptor(TransposeOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class TransposeOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::VectorUnrollOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = TransposeOpAdaptor; + template + using GenericAdaptor = TransposeOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("transp")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getTranspAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getTranspAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.transpose"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getVector(); + ::mlir::OpOperand &getVectorMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getResult(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::ArrayAttr getTranspAttr(); + ::mlir::ArrayAttr getTransp(); + void setTranspAttr(::mlir::ArrayAttr attr); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value vector, ArrayRef transp); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value vector, ::mlir::ArrayAttr transp); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value vector, ::mlir::ArrayAttr transp); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context); + ::mlir::OpFoldResult fold(FoldAdaptor adaptor); + ::std::optional<::llvm::SmallVector> getShapeForUnroll(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + VectorType getSourceVectorType() { + return ::llvm::cast(getVector().getType()); + } + VectorType getResultVectorType() { + return ::llvm::cast(getResult().getType()); + } + void getTransp(SmallVectorImpl &results); +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::TransposeOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::TypeCastOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class TypeCastOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + TypeCastOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + TypeCastOpGenericAdaptorBase(TypeCastOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class TypeCastOpGenericAdaptor : public detail::TypeCastOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::TypeCastOpGenericAdaptorBase; +public: + TypeCastOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + TypeCastOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : TypeCastOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + TypeCastOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getMemref() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class TypeCastOpAdaptor : public TypeCastOpGenericAdaptor<::mlir::ValueRange> { +public: + using TypeCastOpGenericAdaptor::TypeCastOpGenericAdaptor; + TypeCastOpAdaptor(TypeCastOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class TypeCastOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::ViewLikeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = TypeCastOpAdaptor; + template + using GenericAdaptor = TypeCastOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.type_cast"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::MemRefType> getMemref(); + ::mlir::OpOperand &getMemrefMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::MemRefType> getResult(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value source); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value memref); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value memref); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: + MemRefType getMemRefType() { + return ::llvm::cast(getMemref().getType()); + } + MemRefType getResultMemRefType() { + return ::llvm::cast(getResult().getType()); + } + // Implement ViewLikeOpInterface. + Value getViewSource() { return getMemref(); } +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::TypeCastOp) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::WarpExecuteOnLane0Op declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class WarpExecuteOnLane0OpGenericAdaptorBase { +public: + struct Properties { + using warp_sizeTy = ::mlir::IntegerAttr; + warp_sizeTy warp_size; + + auto getWarpSize() { + auto &propStorage = this->warp_size; + return ::llvm::cast<::mlir::IntegerAttr>(propStorage); + } + void setWarpSize(const ::mlir::IntegerAttr &propValue) { + this->warp_size = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.warp_size == this->warp_size && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + WarpExecuteOnLane0OpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + WarpExecuteOnLane0OpGenericAdaptorBase(WarpExecuteOnLane0Op op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::IntegerAttr getWarpSizeAttr(); + uint64_t getWarpSize(); + ::mlir::Region &getWarpRegion(); + ::mlir::RegionRange getRegions(); +}; +} // namespace detail +template +class WarpExecuteOnLane0OpGenericAdaptor : public detail::WarpExecuteOnLane0OpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::WarpExecuteOnLane0OpGenericAdaptorBase; +public: + WarpExecuteOnLane0OpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + WarpExecuteOnLane0OpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : WarpExecuteOnLane0OpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + WarpExecuteOnLane0OpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getLaneid() { + return (*getODSOperands(0).begin()); + } + + RangeT getArgs() { + return getODSOperands(1); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class WarpExecuteOnLane0OpAdaptor : public WarpExecuteOnLane0OpGenericAdaptor<::mlir::ValueRange> { +public: + using WarpExecuteOnLane0OpGenericAdaptor::WarpExecuteOnLane0OpGenericAdaptor; + WarpExecuteOnLane0OpAdaptor(WarpExecuteOnLane0Op op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class WarpExecuteOnLane0Op : public ::mlir::Op::Impl, ::mlir::OpTrait::SingleBlock, ::mlir::OpTrait::SingleBlockImplicitTerminator::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::RegionBranchOpInterface::Trait, ::mlir::OpTrait::HasRecursiveMemoryEffects> { +public: + using Op::Op; + using Op::print; + using Adaptor = WarpExecuteOnLane0OpAdaptor; + template + using GenericAdaptor = WarpExecuteOnLane0OpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("warp_size")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getWarpSizeAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getWarpSizeAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.warp_execute_on_lane_0"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::IndexType> getLaneid(); + ::mlir::Operation::operand_range getArgs(); + ::mlir::OpOperand &getLaneidMutable(); + ::mlir::MutableOperandRange getArgsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Operation::result_range getResults(); + ::mlir::Region &getWarpRegion(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::IntegerAttr getWarpSizeAttr(); + uint64_t getWarpSize(); + void setWarpSizeAttr(::mlir::IntegerAttr attr); + void setWarpSize(uint64_t attrValue); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value laneid, int64_t warpSize); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, TypeRange resultTypes, Value laneid, int64_t warpSize); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, TypeRange resultTypes, Value laneid, int64_t warpSize, ValueRange args, TypeRange blockArgTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &p); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + void getSuccessorRegions(::mlir::RegionBranchPoint point, ::llvm::SmallVectorImpl<::mlir::RegionSuccessor> ®ions); + bool areTypesCompatible(::mlir::Type lhs, ::mlir::Type rhs); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: + bool isDefinedOutsideOfRegion(Value value) { + return !getRegion().isAncestor(value.getParentRegion()); + } +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::WarpExecuteOnLane0Op) + +namespace mlir { +namespace vector { + +//===----------------------------------------------------------------------===// +// ::mlir::vector::YieldOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class YieldOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + YieldOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + YieldOpGenericAdaptorBase(YieldOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class YieldOpGenericAdaptor : public detail::YieldOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::YieldOpGenericAdaptorBase; +public: + YieldOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + YieldOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : YieldOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + YieldOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + RangeT getOperands() { + return getODSOperands(0); + } + +private: + RangeT odsOperands; +}; +class YieldOpAdaptor : public YieldOpGenericAdaptor<::mlir::ValueRange> { +public: + using YieldOpGenericAdaptor::YieldOpGenericAdaptor; + YieldOpAdaptor(YieldOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class YieldOp : public ::mlir::Op { +public: + using Op::Op; + using Op::print; + using Adaptor = YieldOpAdaptor; + template + using GenericAdaptor = YieldOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("vector.yield"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::Operation::operand_range getOperands(); + ::mlir::MutableOperandRange getOperandsMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::MutableOperandRange getMutableSuccessorOperands(::mlir::RegionBranchPoint point); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::vector::YieldOp) + + +#endif // GET_OP_CLASSES + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Interfaces/MaskableOpInterface.cpp.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Interfaces/MaskableOpInterface.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..8698b8533ddcaeb884bf568758ca84b6de40175c --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Interfaces/MaskableOpInterface.cpp.inc @@ -0,0 +1,24 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Interface Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +/// Returns true if the operation is masked by a MaskingOpInterface. +bool mlir::vector::MaskableOpInterface::isMasked() { + return getImpl()->isMasked(getImpl(), getOperation()); + } +/// Returns the MaskingOpInterface masking this operation. +mlir::vector::MaskingOpInterface mlir::vector::MaskableOpInterface::getMaskingOp() { + return getImpl()->getMaskingOp(getImpl(), getOperation()); + } +/// Returns true if the operation can have a passthru argument when masked. +bool mlir::vector::MaskableOpInterface::supportsPassthru() { + return getImpl()->supportsPassthru(getImpl(), getOperation()); + } +/// Returns the mask type expected by this operation. Mostly used for verification purposes. It requires the operation to be vectorized. +mlir::Type mlir::vector::MaskableOpInterface::getExpectedMaskType() { + return getImpl()->getExpectedMaskType(getImpl(), getOperation()); + } diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Interfaces/MaskableOpInterface.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Interfaces/MaskableOpInterface.h new file mode 100644 index 0000000000000000000000000000000000000000..01c968570b93dab445a2f2ddb2d322162c8fb824 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Interfaces/MaskableOpInterface.h @@ -0,0 +1,23 @@ +//===- MaskableOpInterface.h ----------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file implements the MaskableOpInterface. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_VECTOR_INTERFACES_MASKABLEOPINTERFACE_H_ +#define MLIR_DIALECT_VECTOR_INTERFACES_MASKABLEOPINTERFACE_H_ + +#include "mlir/Dialect/Vector/Interfaces/MaskingOpInterface.h" +#include "mlir/IR/BuiltinTypes.h" +#include "mlir/IR/OpDefinition.h" + +// Include the generated interface declarations. +#include "mlir/Dialect/Vector/Interfaces/MaskableOpInterface.h.inc" + +#endif // MLIR_DIALECT_VECTOR_INTERFACES_MASKABLEOPINTERFACE_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Interfaces/MaskableOpInterface.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Interfaces/MaskableOpInterface.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..d433527cf508bfe069d514e4218e0acc73f0e86b --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Interfaces/MaskableOpInterface.h.inc @@ -0,0 +1,141 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Interface Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace vector { +class MaskableOpInterface; +namespace detail { +struct MaskableOpInterfaceInterfaceTraits { + struct Concept { + /// The methods defined by the interface. + bool (*isMasked)(const Concept *impl, ::mlir::Operation *); + mlir::vector::MaskingOpInterface (*getMaskingOp)(const Concept *impl, ::mlir::Operation *); + bool (*supportsPassthru)(const Concept *impl, ::mlir::Operation *); + mlir::Type (*getExpectedMaskType)(const Concept *impl, ::mlir::Operation *); + }; + template + class Model : public Concept { + public: + using Interface = ::mlir::vector::MaskableOpInterface; + Model() : Concept{isMasked, getMaskingOp, supportsPassthru, getExpectedMaskType} {} + + static inline bool isMasked(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); + static inline mlir::vector::MaskingOpInterface getMaskingOp(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); + static inline bool supportsPassthru(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); + static inline mlir::Type getExpectedMaskType(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); + }; + template + class FallbackModel : public Concept { + public: + using Interface = ::mlir::vector::MaskableOpInterface; + FallbackModel() : Concept{isMasked, getMaskingOp, supportsPassthru, getExpectedMaskType} {} + + static inline bool isMasked(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); + static inline mlir::vector::MaskingOpInterface getMaskingOp(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); + static inline bool supportsPassthru(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); + static inline mlir::Type getExpectedMaskType(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); + }; + template + class ExternalModel : public FallbackModel { + public: + using ConcreteEntity = ConcreteOp; + bool isMasked(::mlir::Operation *tablegen_opaque_val) const; + mlir::vector::MaskingOpInterface getMaskingOp(::mlir::Operation *tablegen_opaque_val) const; + bool supportsPassthru(::mlir::Operation *tablegen_opaque_val) const; + }; +};template +struct MaskableOpInterfaceTrait; + +} // namespace detail +class MaskableOpInterface : public ::mlir::OpInterface { +public: + using ::mlir::OpInterface::OpInterface; + template + struct Trait : public detail::MaskableOpInterfaceTrait {}; + /// Returns true if the operation is masked by a MaskingOpInterface. + bool isMasked(); + /// Returns the MaskingOpInterface masking this operation. + mlir::vector::MaskingOpInterface getMaskingOp(); + /// Returns true if the operation can have a passthru argument when masked. + bool supportsPassthru(); + /// Returns the mask type expected by this operation. Mostly used for verification purposes. It requires the operation to be vectorized. + mlir::Type getExpectedMaskType(); +}; +namespace detail { + template + struct MaskableOpInterfaceTrait : public ::mlir::OpInterface::Trait { + /// Returns true if the operation is masked by a MaskingOpInterface. + bool isMasked() { + mlir::Operation *parentOp = (*static_cast(this))->getParentOp(); + return parentOp && + mlir::isa(parentOp); + } + /// Returns the MaskingOpInterface masking this operation. + mlir::vector::MaskingOpInterface getMaskingOp() { + return mlir::cast( + (*static_cast(this))->getParentOp()); + } + /// Returns true if the operation can have a passthru argument when masked. + bool supportsPassthru() { + return false; + } + }; +}// namespace detail +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +template +bool detail::MaskableOpInterfaceInterfaceTraits::Model::isMasked(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { + return (llvm::cast(tablegen_opaque_val)).isMasked(); +} +template +mlir::vector::MaskingOpInterface detail::MaskableOpInterfaceInterfaceTraits::Model::getMaskingOp(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { + return (llvm::cast(tablegen_opaque_val)).getMaskingOp(); +} +template +bool detail::MaskableOpInterfaceInterfaceTraits::Model::supportsPassthru(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { + return (llvm::cast(tablegen_opaque_val)).supportsPassthru(); +} +template +mlir::Type detail::MaskableOpInterfaceInterfaceTraits::Model::getExpectedMaskType(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { + return (llvm::cast(tablegen_opaque_val)).getExpectedMaskType(); +} +template +bool detail::MaskableOpInterfaceInterfaceTraits::FallbackModel::isMasked(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { + return static_cast(impl)->isMasked(tablegen_opaque_val); +} +template +mlir::vector::MaskingOpInterface detail::MaskableOpInterfaceInterfaceTraits::FallbackModel::getMaskingOp(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { + return static_cast(impl)->getMaskingOp(tablegen_opaque_val); +} +template +bool detail::MaskableOpInterfaceInterfaceTraits::FallbackModel::supportsPassthru(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { + return static_cast(impl)->supportsPassthru(tablegen_opaque_val); +} +template +mlir::Type detail::MaskableOpInterfaceInterfaceTraits::FallbackModel::getExpectedMaskType(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { + return static_cast(impl)->getExpectedMaskType(tablegen_opaque_val); +} +template +bool detail::MaskableOpInterfaceInterfaceTraits::ExternalModel::isMasked(::mlir::Operation *tablegen_opaque_val) const { +mlir::Operation *parentOp = (llvm::cast(tablegen_opaque_val))->getParentOp(); + return parentOp && + mlir::isa(parentOp); +} +template +mlir::vector::MaskingOpInterface detail::MaskableOpInterfaceInterfaceTraits::ExternalModel::getMaskingOp(::mlir::Operation *tablegen_opaque_val) const { +return mlir::cast( + (llvm::cast(tablegen_opaque_val))->getParentOp()); +} +template +bool detail::MaskableOpInterfaceInterfaceTraits::ExternalModel::supportsPassthru(::mlir::Operation *tablegen_opaque_val) const { +return false; +} +} // namespace vector +} // namespace mlir diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Interfaces/MaskingOpInterface.cpp.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Interfaces/MaskingOpInterface.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..20d64fd008fc1c482f7d2010210c890e5b453bc5 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Interfaces/MaskingOpInterface.cpp.inc @@ -0,0 +1,24 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Interface Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +/// Returns the mask value of this masking operation. +mlir::Value mlir::vector::MaskingOpInterface::getMask() { + return getImpl()->getMask(getImpl(), getOperation()); + } +/// Returns the operation masked by this masking operation. +Operation *mlir::vector::MaskingOpInterface::getMaskableOp() { + return getImpl()->getMaskableOp(getImpl(), getOperation()); + } +/// Returns true if the masking operation has a passthru value. +bool mlir::vector::MaskingOpInterface::hasPassthru() { + return getImpl()->hasPassthru(getImpl(), getOperation()); + } +/// Returns the passthru value of this masking operation. +mlir::Value mlir::vector::MaskingOpInterface::getPassthru() { + return getImpl()->getPassthru(getImpl(), getOperation()); + } diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Interfaces/MaskingOpInterface.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Interfaces/MaskingOpInterface.h new file mode 100644 index 0000000000000000000000000000000000000000..5eb613a6024c376c1132981cd966ed2fc82cdf30 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Interfaces/MaskingOpInterface.h @@ -0,0 +1,22 @@ +//===- MaskingOpInterface.h -----------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file implements the MaskingOpInterface. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_VECTOR_INTERFACES_MASKINGOPINTERFACE_H_ +#define MLIR_DIALECT_VECTOR_INTERFACES_MASKINGOPINTERFACE_H_ + +#include "mlir/IR/BuiltinTypes.h" +#include "mlir/IR/OpDefinition.h" + +// Include the generated interface declarations. +#include "mlir/Dialect/Vector/Interfaces/MaskingOpInterface.h.inc" + +#endif // MLIR_DIALECT_VECTOR_INTERFACES_MASKINGOPINTERFACE_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Interfaces/MaskingOpInterface.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Interfaces/MaskingOpInterface.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..e50209b21a429db28a3349375c3dfd92e10afa17 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Interfaces/MaskingOpInterface.h.inc @@ -0,0 +1,108 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Interface Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace vector { +class MaskingOpInterface; +namespace detail { +struct MaskingOpInterfaceInterfaceTraits { + struct Concept { + /// The methods defined by the interface. + mlir::Value (*getMask)(const Concept *impl, ::mlir::Operation *); + Operation *(*getMaskableOp)(const Concept *impl, ::mlir::Operation *); + bool (*hasPassthru)(const Concept *impl, ::mlir::Operation *); + mlir::Value (*getPassthru)(const Concept *impl, ::mlir::Operation *); + }; + template + class Model : public Concept { + public: + using Interface = ::mlir::vector::MaskingOpInterface; + Model() : Concept{getMask, getMaskableOp, hasPassthru, getPassthru} {} + + static inline mlir::Value getMask(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); + static inline Operation *getMaskableOp(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); + static inline bool hasPassthru(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); + static inline mlir::Value getPassthru(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); + }; + template + class FallbackModel : public Concept { + public: + using Interface = ::mlir::vector::MaskingOpInterface; + FallbackModel() : Concept{getMask, getMaskableOp, hasPassthru, getPassthru} {} + + static inline mlir::Value getMask(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); + static inline Operation *getMaskableOp(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); + static inline bool hasPassthru(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); + static inline mlir::Value getPassthru(const Concept *impl, ::mlir::Operation *tablegen_opaque_val); + }; + template + class ExternalModel : public FallbackModel { + public: + using ConcreteEntity = ConcreteOp; + }; +};template +struct MaskingOpInterfaceTrait; + +} // namespace detail +class MaskingOpInterface : public ::mlir::OpInterface { +public: + using ::mlir::OpInterface::OpInterface; + template + struct Trait : public detail::MaskingOpInterfaceTrait {}; + /// Returns the mask value of this masking operation. + mlir::Value getMask(); + /// Returns the operation masked by this masking operation. + Operation *getMaskableOp(); + /// Returns true if the masking operation has a passthru value. + bool hasPassthru(); + /// Returns the passthru value of this masking operation. + mlir::Value getPassthru(); +}; +namespace detail { + template + struct MaskingOpInterfaceTrait : public ::mlir::OpInterface::Trait { + }; +}// namespace detail +} // namespace vector +} // namespace mlir +namespace mlir { +namespace vector { +template +mlir::Value detail::MaskingOpInterfaceInterfaceTraits::Model::getMask(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { + return (llvm::cast(tablegen_opaque_val)).getMask(); +} +template +Operation *detail::MaskingOpInterfaceInterfaceTraits::Model::getMaskableOp(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { + return (llvm::cast(tablegen_opaque_val)).getMaskableOp(); +} +template +bool detail::MaskingOpInterfaceInterfaceTraits::Model::hasPassthru(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { + return (llvm::cast(tablegen_opaque_val)).hasPassthru(); +} +template +mlir::Value detail::MaskingOpInterfaceInterfaceTraits::Model::getPassthru(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { + return (llvm::cast(tablegen_opaque_val)).getPassthru(); +} +template +mlir::Value detail::MaskingOpInterfaceInterfaceTraits::FallbackModel::getMask(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { + return static_cast(impl)->getMask(tablegen_opaque_val); +} +template +Operation *detail::MaskingOpInterfaceInterfaceTraits::FallbackModel::getMaskableOp(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { + return static_cast(impl)->getMaskableOp(tablegen_opaque_val); +} +template +bool detail::MaskingOpInterfaceInterfaceTraits::FallbackModel::hasPassthru(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { + return static_cast(impl)->hasPassthru(tablegen_opaque_val); +} +template +mlir::Value detail::MaskingOpInterfaceInterfaceTraits::FallbackModel::getPassthru(const Concept *impl, ::mlir::Operation *tablegen_opaque_val) { + return static_cast(impl)->getPassthru(tablegen_opaque_val); +} +} // namespace vector +} // namespace mlir diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Transforms/BufferizableOpInterfaceImpl.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Transforms/BufferizableOpInterfaceImpl.h new file mode 100644 index 0000000000000000000000000000000000000000..bd1a7f3aa102e44108b0415f1db348129cfd8a8f --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Transforms/BufferizableOpInterfaceImpl.h @@ -0,0 +1,21 @@ +//===- BufferizableOpInterfaceImpl.h - Impl. of BufferizableOpInterface ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_VECTOR_BUFFERIZABLEOPINTERFACEIMPL_H +#define MLIR_DIALECT_VECTOR_BUFFERIZABLEOPINTERFACEIMPL_H + +namespace mlir { + +class DialectRegistry; + +namespace vector { +void registerBufferizableOpInterfaceExternalModels(DialectRegistry ®istry); +} // namespace vector +} // namespace mlir + +#endif // MLIR_DIALECT_VECTOR_BUFFERIZABLEOPINTERFACEIMPL_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Transforms/LoweringPatterns.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Transforms/LoweringPatterns.h new file mode 100644 index 0000000000000000000000000000000000000000..292398a3dc5a7d6a5b65c98b29d5b4da19fd0a5a --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Transforms/LoweringPatterns.h @@ -0,0 +1,259 @@ +//===- LoweringPatterns.h - Vector rewrite patterns --------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_VECTOR_TRANSFORMS_LOWERINGPATTERNS_H +#define MLIR_DIALECT_VECTOR_TRANSFORMS_LOWERINGPATTERNS_H + +#include "mlir/Dialect/Vector/Transforms/VectorTransforms.h" + +namespace mlir { +class RewritePatternSet; + +namespace vector { + +//===----------------------------------------------------------------------===// +// Lowering pattern populate functions +//===----------------------------------------------------------------------===// + +/// Populate the pattern set with the following patterns: +/// +/// [OuterProductOpLowering] +/// Progressively lower a `vector.outerproduct` to linearized +/// `vector.extract` + `vector.fma` + `vector.insert`. +/// +/// [ContractionOpLowering] +/// Progressive lowering of ContractionOp. +/// One: +/// %x = vector.contract with at least one free/batch dimension +/// is replaced by: +/// %a = vector.contract with one less free/batch dimension +/// %b = vector.contract with one less free/batch dimension +/// +/// [ContractionOpToMatmulOpLowering] +/// Progressively lower a `vector.contract` with row-major matmul semantics to +/// linearized `vector.shape_cast` + `vector.matmul` on the way to +/// `llvm.matrix.multiply`. +/// +/// [ContractionOpToDotLowering] +/// Progressively lower a `vector.contract` with row-major matmul semantics to +/// linearized `vector.extract` + `vector.reduce` + `vector.insert`. +/// +/// [ContractionOpToOuterProductOpLowering] +/// Progressively lower a `vector.contract` with row-major matmul semantics to +/// linearized `vector.extract` + `vector.outerproduct` + `vector.insert`. +void populateVectorContractLoweringPatterns( + RewritePatternSet &patterns, VectorTransformsOptions options, + PatternBenefit benefit = 1, bool disableOuterProductLowering = false); + +/// Populate the pattern set with the following patterns: +/// +/// [OuterProductOpLowering] +/// Progressively lower a `vector.outerproduct` to linearized +/// `vector.extract` + `vector.fma` + `vector.insert`. +void populateVectorOuterProductLoweringPatterns(RewritePatternSet &patterns, + PatternBenefit benefit = 1); + +/// Collect a set of patterns to convert vector.multi_reduction op into +/// a sequence of vector.reduction ops. The patterns comprise: +/// +/// [InnerOuterDimReductionConversion] +/// Rewrites vector.multi_reduction such that all reduction dimensions are +/// either innermost or outermost, by adding the proper vector.transpose +/// operations. +/// +/// [ReduceMultiDimReductionRank] +/// Once in innermost or outermost reduction +/// form, rewrites n-D vector.multi_reduction into 2-D vector.multi_reduction, +/// by introducing vector.shape_cast ops to collapse + multi-reduce + expand +/// back. +/// +/// [TwoDimMultiReductionToElementWise] +/// Once in 2-D vector.multi_reduction form, with an **outermost** reduction +/// dimension, unroll the outer dimension to obtain a sequence of 1-D vector +/// ops. This also has an opportunity for tree-reduction (in the future). +/// +/// [TwoDimMultiReductionToReduction] +/// Once in 2-D vector.multi_reduction form, with an **innermost** reduction +/// dimension, unroll the outer dimension to obtain a sequence of extract + +/// vector.reduction + insert. This can further lower to horizontal reduction +/// ops. +/// +/// [OneDimMultiReductionToTwoDim] +/// For cases that reduce to 1-D vector reduction (and are thus missing +/// either a parallel or a reduction), we lift them back up to 2-D with a simple +/// vector.shape_cast to vector<1xk> so that the other patterns can kick in, +/// thus fully exiting out of the vector.multi_reduction abstraction. +void populateVectorMultiReductionLoweringPatterns( + RewritePatternSet &patterns, VectorMultiReductionLowering options, + PatternBenefit benefit = 1); + +/// Populate the pattern set with the following patterns: +/// +/// [TransferReadToVectorLoadLowering] +/// Progressive lowering of BroadcastOp to ExtractOp + InsertOp + lower-D +/// BroadcastOp until dim 1. +void populateVectorBroadcastLoweringPatterns(RewritePatternSet &patterns, + PatternBenefit benefit = 1); + +/// Populate the pattern set with the following patterns: +/// +/// [CreateMaskOp] +/// Progressive lowering of CreateMaskOp to lower-D CreateMaskOp until dim 1. +/// +/// [ConstantMaskOp] +/// Progressive lowering of ConstantMaskOp to lower-D ConstantMaskOp until +/// dim 1. +void populateVectorMaskOpLoweringPatterns(RewritePatternSet &patterns, + PatternBenefit benefit = 1); + +/// Collects patterns that lower scalar vector transfer ops to memref loads and +/// stores when beneficial. If `allowMultipleUses` is set to true, the patterns +/// are applied to vector transfer reads with any number of uses. Otherwise, +/// only vector transfer reads with a single use will be lowered. +void populateScalarVectorTransferLoweringPatterns(RewritePatternSet &patterns, + PatternBenefit benefit, + bool allowMultipleUses); + +/// Populate the pattern set with the following patterns: +/// +/// [ShapeCastOp2DDownCastRewritePattern] +/// ShapeOp 2D -> 1D downcast serves the purpose of flattening 2-D to 1-D +/// vectors progressively. +/// +/// [ShapeCastOp2DUpCastRewritePattern] +/// ShapeOp 1D -> 2D upcast serves the purpose of unflattening 2-D from 1-D +/// vectors progressively. +/// +/// [ShapeCastOpRewritePattern] +/// Reference lowering to fully unrolled sequences of single element ExtractOp + +/// InsertOp. Note that applying this pattern can almost always be considered a +/// performance bug. +void populateVectorShapeCastLoweringPatterns(RewritePatternSet &patterns, + PatternBenefit benefit = 1); + +/// Populate the pattern set with the following patterns: +/// +/// [TransposeOpLowering] +/// +/// [TransposeOp2DToShuffleLowering] +/// +void populateVectorTransposeLoweringPatterns(RewritePatternSet &patterns, + VectorTransformsOptions options, + PatternBenefit benefit = 1); + +/// Populate the pattern set with the following patterns: +/// +/// [TransferReadToVectorLoadLowering] +/// Progressive lowering of transfer_read.This pattern supports lowering of +/// `vector.transfer_read` to a combination of `vector.load` and +/// `vector.broadcast` +/// +/// [TransferWriteToVectorStoreLowering] +/// Progressive lowering of transfer_write. This pattern supports lowering of +/// `vector.transfer_write` to `vector.store` +/// +/// [VectorLoadToMemrefLoadLowering] +/// Replace a 0-d vector.load with a memref.load + vector.broadcast. +/// +/// [VectorStoreToMemrefStoreLowering] +/// Replace a 0-d vector.store with a vector.extractelement + memref.store. +/// +/// These patterns lower transfer ops to simpler ops like `vector.load`, +/// `vector.store` and `vector.broadcast`. Only transfers with a transfer rank +/// of a most `maxTransferRank` are lowered. This is useful when combined with +/// VectorToSCF, which reduces the rank of vector transfer ops. +void populateVectorTransferLoweringPatterns( + RewritePatternSet &patterns, + std::optional maxTransferRank = std::nullopt, + PatternBenefit benefit = 1); + +/// Collect a set of transfer read/write lowering patterns that simplify the +/// permutation map (e.g., converting it to a minor identity map) by inserting +/// broadcasts and transposes. More specifically: +/// +/// [TransferReadPermutationLowering] +/// Lower transfer_read op with permutation into a transfer_read with a +/// permutation map composed of leading zeros followed by a minor identity + +/// vector.transpose op. +/// Ex: +/// vector.transfer_read ... +/// permutation_map: (d0, d1, d2) -> (0, d1) +/// into: +/// %v = vector.transfer_read ... +/// permutation_map: (d0, d1, d2) -> (d1, 0) +/// vector.transpose %v, [1, 0] +/// +/// vector.transfer_read ... +/// permutation_map: (d0, d1, d2, d3) -> (0, 0, 0, d1, d3) +/// into: +/// %v = vector.transfer_read ... +/// permutation_map: (d0, d1, d2, d3) -> (0, 0, d1, 0, d3) +/// vector.transpose %v, [0, 1, 3, 2, 4] +/// Note that an alternative is to transform it to linalg.transpose + +/// vector.transfer_read to do the transpose in memory instead. +/// +/// [TransferWritePermutationLowering] +/// Lower transfer_write op with permutation into a transfer_write with a +/// minor identity permutation map. (transfer_write ops cannot have broadcasts.) +/// Ex: +/// vector.transfer_write %v ... +/// permutation_map: (d0, d1, d2) -> (d2, d0, d1) +/// into: +/// %tmp = vector.transpose %v, [2, 0, 1] +/// vector.transfer_write %tmp ... +/// permutation_map: (d0, d1, d2) -> (d0, d1, d2) +/// +/// vector.transfer_write %v ... +/// permutation_map: (d0, d1, d2, d3) -> (d3, d2) +/// into: +/// %tmp = vector.transpose %v, [1, 0] +/// %v = vector.transfer_write %tmp ... +/// permutation_map: (d0, d1, d2, d3) -> (d2, d3) +/// +/// [TransferOpReduceRank] +/// Lower transfer_read op with broadcast in the leading dimensions into +/// transfer_read of lower rank + vector.broadcast. +/// Ex: vector.transfer_read ... +/// permutation_map: (d0, d1, d2, d3) -> (0, d1, 0, d3) +/// into: +/// %v = vector.transfer_read ... +/// permutation_map: (d0, d1, d2, d3) -> (d1, 0, d3) +/// vector.broadcast %v +void populateVectorTransferPermutationMapLoweringPatterns( + RewritePatternSet &patterns, PatternBenefit benefit = 1); + +/// Populate the pattern set with the following patterns: +/// +/// [ScanToArithOps] +/// Convert vector.scan op into arith ops and vector.insert_strided_slice / +/// vector.extract_strided_slice. +void populateVectorScanLoweringPatterns(RewritePatternSet &patterns, + PatternBenefit benefit = 1); + +/// Populate the pattern set with the following patterns: +/// +/// [FlattenGather] +/// Flattens 2 or more dimensional `vector.gather` ops by unrolling the +/// outermost dimension. +/// +/// [Gather1DToConditionalLoads] +/// Turns 1-d `vector.gather` into a scalarized sequence of `vector.loads` or +/// `tensor.extract`s. To avoid out-of-bounds memory accesses, these +/// loads/extracts are made conditional using `scf.if` ops. +void populateVectorGatherLoweringPatterns(RewritePatternSet &patterns, + PatternBenefit benefit = 1); + +/// Populates instances of `MaskOpRewritePattern` to lower masked operations +/// with `vector.mask`. Patterns should rewrite the `vector.mask` operation and +/// not its nested `MaskableOpInterface`. +void populateVectorMaskLoweringPatternsForSideEffectingOps( + RewritePatternSet &patterns); + +} // namespace vector +} // namespace mlir +#endif // MLIR_DIALECT_VECTOR_TRANSFORMS_LOWERINGPATTERNS_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Transforms/Passes.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Transforms/Passes.h new file mode 100644 index 0000000000000000000000000000000000000000..bf89b01e2b60c54a8e3427fab3a023e88088f399 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Transforms/Passes.h @@ -0,0 +1,35 @@ +//===- Passes.h - Pass Entrypoints ------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_VECTOR_TRANSFORMS_PASSES_H_ +#define MLIR_DIALECT_VECTOR_TRANSFORMS_PASSES_H_ + +#include "mlir/Pass/Pass.h" + +namespace mlir { +namespace vector { +#define GEN_PASS_DECL +#include "mlir/Dialect/Vector/Transforms/Passes.h.inc" + +/// Creates an instance of the `vector` dialect bufferization pass. +std::unique_ptr createVectorBufferizePass(); + +/// Creates an instance of the `vector.mask` lowering pass. +std::unique_ptr createLowerVectorMaskPass(); + +//===----------------------------------------------------------------------===// +// Registration +//===----------------------------------------------------------------------===// + +/// Generate the code for registering passes. +#define GEN_PASS_REGISTRATION +#include "mlir/Dialect/Vector/Transforms/Passes.h.inc" +} // namespace vector +} // namespace mlir + +#endif // MLIR_DIALECT_VECTOR_TRANSFORMS_PASSES_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Transforms/Passes.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Transforms/Passes.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..c5da0bb7252e352945060c8e22b61fec1a7ceff5 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Transforms/Passes.h.inc @@ -0,0 +1,264 @@ +/* Autogenerated by mlir-tblgen; don't manually edit */ + +#ifdef GEN_PASS_DECL +// Generate declarations for all passes. +#define GEN_PASS_DECL_LOWERVECTORMASKPASS +#define GEN_PASS_DECL_VECTORBUFFERIZE +#undef GEN_PASS_DECL +#endif // GEN_PASS_DECL + +//===----------------------------------------------------------------------===// +// LowerVectorMaskPass +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_LOWERVECTORMASKPASS +#undef GEN_PASS_DECL_LOWERVECTORMASKPASS +#endif // GEN_PASS_DECL_LOWERVECTORMASKPASS +#ifdef GEN_PASS_DEF_LOWERVECTORMASKPASS +namespace impl { + +template +class LowerVectorMaskPassBase : public ::mlir::OperationPass { +public: + using Base = LowerVectorMaskPassBase; + + LowerVectorMaskPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + LowerVectorMaskPassBase(const LowerVectorMaskPassBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("lower-vector-mask"); + } + ::llvm::StringRef getArgument() const override { return "lower-vector-mask"; } + + ::llvm::StringRef getDescription() const override { return "Lower 'vector.mask' operations"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("LowerVectorMaskPass"); + } + ::llvm::StringRef getName() const override { return "LowerVectorMaskPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(LowerVectorMaskPassBase) + +protected: +private: +}; +} // namespace impl +#undef GEN_PASS_DEF_LOWERVECTORMASKPASS +#endif // GEN_PASS_DEF_LOWERVECTORMASKPASS + +//===----------------------------------------------------------------------===// +// VectorBufferize +//===----------------------------------------------------------------------===// +#ifdef GEN_PASS_DECL_VECTORBUFFERIZE +#undef GEN_PASS_DECL_VECTORBUFFERIZE +#endif // GEN_PASS_DECL_VECTORBUFFERIZE +#ifdef GEN_PASS_DEF_VECTORBUFFERIZE +namespace impl { + +template +class VectorBufferizeBase : public ::mlir::OperationPass { +public: + using Base = VectorBufferizeBase; + + VectorBufferizeBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + VectorBufferizeBase(const VectorBufferizeBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("vector-bufferize"); + } + ::llvm::StringRef getArgument() const override { return "vector-bufferize"; } + + ::llvm::StringRef getDescription() const override { return "Bufferize Vector dialect ops"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("VectorBufferize"); + } + ::llvm::StringRef getName() const override { return "VectorBufferize"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(VectorBufferizeBase) + +protected: +private: +}; +} // namespace impl +#undef GEN_PASS_DEF_VECTORBUFFERIZE +#endif // GEN_PASS_DEF_VECTORBUFFERIZE +#ifdef GEN_PASS_REGISTRATION + +//===----------------------------------------------------------------------===// +// LowerVectorMaskPass Registration +//===----------------------------------------------------------------------===// + +inline void registerLowerVectorMaskPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::vector::createLowerVectorMaskPass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerLowerVectorMaskPassPass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::vector::createLowerVectorMaskPass(); + }); +} + +//===----------------------------------------------------------------------===// +// VectorBufferize Registration +//===----------------------------------------------------------------------===// + +inline void registerVectorBufferize() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::vector::createVectorBufferizePass(); + }); +} + +// Old registration code, kept for temporary backwards compatibility. +inline void registerVectorBufferizePass() { + ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { + return mlir::vector::createVectorBufferizePass(); + }); +} + +//===----------------------------------------------------------------------===// +// Vector Registration +//===----------------------------------------------------------------------===// + +inline void registerVectorPasses() { + registerLowerVectorMaskPass(); + registerVectorBufferize(); +} +#undef GEN_PASS_REGISTRATION +#endif // GEN_PASS_REGISTRATION +// Deprecated. Please use the new per-pass macros. +#ifdef GEN_PASS_CLASSES + +template +class LowerVectorMaskPassBase : public ::mlir::OperationPass { +public: + using Base = LowerVectorMaskPassBase; + + LowerVectorMaskPassBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + LowerVectorMaskPassBase(const LowerVectorMaskPassBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("lower-vector-mask"); + } + ::llvm::StringRef getArgument() const override { return "lower-vector-mask"; } + + ::llvm::StringRef getDescription() const override { return "Lower 'vector.mask' operations"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("LowerVectorMaskPass"); + } + ::llvm::StringRef getName() const override { return "LowerVectorMaskPass"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(LowerVectorMaskPassBase) + +protected: +}; + +template +class VectorBufferizeBase : public ::mlir::OperationPass { +public: + using Base = VectorBufferizeBase; + + VectorBufferizeBase() : ::mlir::OperationPass(::mlir::TypeID::get()) {} + VectorBufferizeBase(const VectorBufferizeBase &other) : ::mlir::OperationPass(other) {} + + /// Returns the command-line argument attached to this pass. + static constexpr ::llvm::StringLiteral getArgumentName() { + return ::llvm::StringLiteral("vector-bufferize"); + } + ::llvm::StringRef getArgument() const override { return "vector-bufferize"; } + + ::llvm::StringRef getDescription() const override { return "Bufferize Vector dialect ops"; } + + /// Returns the derived pass name. + static constexpr ::llvm::StringLiteral getPassName() { + return ::llvm::StringLiteral("VectorBufferize"); + } + ::llvm::StringRef getName() const override { return "VectorBufferize"; } + + /// Support isa/dyn_cast functionality for the derived pass class. + static bool classof(const ::mlir::Pass *pass) { + return pass->getTypeID() == ::mlir::TypeID::get(); + } + + /// A clone method to create a copy of this pass. + std::unique_ptr<::mlir::Pass> clonePass() const override { + return std::make_unique(*static_cast(this)); + } + + /// Return the dialect that must be loaded in the context before this pass. + void getDependentDialects(::mlir::DialectRegistry ®istry) const override { + + } + + /// Explicitly declare the TypeID for this class. We declare an explicit private + /// instantiation because Pass classes should only be visible by the current + /// library. + MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(VectorBufferizeBase) + +protected: +}; +#undef GEN_PASS_CLASSES +#endif // GEN_PASS_CLASSES diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Transforms/VectorDistribution.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Transforms/VectorDistribution.h new file mode 100644 index 0000000000000000000000000000000000000000..a76a58eb5ec6d3cc0ad1ec82068a72111789e458 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Transforms/VectorDistribution.h @@ -0,0 +1,97 @@ +//===- VectorDistribution.h - Vector distribution patterns --*- C++------*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_VECTOR_TRANSFORMS_VECTORDISTRIBUTION_H_ +#define MLIR_DIALECT_VECTOR_TRANSFORMS_VECTORDISTRIBUTION_H_ + +#include "mlir/Dialect/Vector/IR/VectorOps.h" + +namespace mlir { +class RewritePatternSet; +namespace vector { + +struct WarpExecuteOnLane0LoweringOptions { + /// Lamdba function to let users allocate memory needed for the lowering of + /// WarpExecuteOnLane0Op. + /// The function needs to return an allocation that the lowering can use as + /// temporary memory. The allocation needs to match the shape of the type (the + /// type may be VectorType or a scalar) and be availble for the current warp. + /// If there are several warps running in parallel the allocation needs to be + /// split so that each warp has its own allocation. + using WarpAllocationFn = + std::function; + WarpAllocationFn warpAllocationFn = nullptr; + + /// Lamdba function to let user emit operation to syncronize all the thread + /// within a warp. After this operation all the threads can see any memory + /// written before the operation. + using WarpSyncronizationFn = + std::function; + WarpSyncronizationFn warpSyncronizationFn = nullptr; +}; + +void populateWarpExecuteOnLane0OpToScfForPattern( + RewritePatternSet &patterns, + const WarpExecuteOnLane0LoweringOptions &options, + PatternBenefit benefit = 1); + +using DistributionMapFn = std::function; + +/// Distribute transfer_write ops based on the affine map returned by +/// `distributionMapFn`. +/// Example: +/// ``` +/// %0 = vector.warp_execute_on_lane_0(%id){ +/// ... +/// vector.transfer_write %v, %A[%c0] : vector<32xf32>, memref<128xf32> +/// vector.yield +/// } +/// ``` +/// To +/// ``` +/// %r:3 = vector.warp_execute_on_lane_0(%id) -> (vector<1xf32>) { +/// ... +/// vector.yield %v : vector<32xf32> +/// } +/// vector.transfer_write %v, %A[%id] : vector<1xf32>, memref<128xf32> +void populateDistributeTransferWriteOpPatterns( + RewritePatternSet &patterns, const DistributionMapFn &distributionMapFn, + PatternBenefit benefit = 1); + +/// Move scalar operations with no dependency on the warp op outside of the +/// region. +void moveScalarUniformCode(WarpExecuteOnLane0Op op); + +/// Lambda signature to compute a warp shuffle of a given value of a given lane +/// within a given warp size. +using WarpShuffleFromIdxFn = + std::function; + +/// Collect patterns to propagate warp distribution. `distributionMapFn` is used +/// to decide how a value should be distributed when this cannot be inferred +/// from its uses. +void populatePropagateWarpVectorDistributionPatterns( + RewritePatternSet &pattern, const DistributionMapFn &distributionMapFn, + const WarpShuffleFromIdxFn &warpShuffleFromIdxFn, + PatternBenefit benefit = 1); + +/// Lambda signature to compute a reduction of a distributed value for the given +/// reduction kind and size. +using DistributedReductionFn = + std::function; + +/// Collect patterns to distribute vector reduction ops using given lamdba to +/// distribute reduction op. +void populateDistributeReduction( + RewritePatternSet &pattern, + const DistributedReductionFn &distributedReductionFn, + PatternBenefit benefit = 1); + +} // namespace vector +} // namespace mlir +#endif // MLIR_DIALECT_VECTOR_TRANSFORMS_VECTORDISTRIBUTION_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Transforms/VectorRewritePatterns.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Transforms/VectorRewritePatterns.h new file mode 100644 index 0000000000000000000000000000000000000000..f8221ba0ff283ce2f6d4a7daefa6c34efdc43962 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Transforms/VectorRewritePatterns.h @@ -0,0 +1,330 @@ +//===- VectorRewritePatterns.h - Vector rewrite patterns --------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_VECTOR_TRANSFORMS_VECTORREWRITEPATTERNS_H +#define MLIR_DIALECT_VECTOR_TRANSFORMS_VECTORREWRITEPATTERNS_H + +#include +#include + +#include "mlir/Dialect/Vector/IR/VectorOps.h" +#include "mlir/Dialect/Vector/Utils/VectorUtils.h" +#include "mlir/IR/PatternMatch.h" +#include "mlir/Support/LogicalResult.h" + +#include "mlir/Dialect/Vector/Transforms/VectorTransformsEnums.h.inc" + +namespace mlir { +class RewritePatternSet; + +namespace arith { +class AndIOp; +class NarrowTypeEmulationConverter; +class TruncIOp; +} // namespace arith + +namespace vector { +struct VectorTransformsOptions; + +/// Options that control the vector unrolling. +struct UnrollVectorOptions { + using FilterConstraintFnType = std::function; + /// Callback function that indicates whether vector unrolling should be + /// attempted on the operation. + FilterConstraintFnType filterConstraint = nullptr; + UnrollVectorOptions &setFilterConstraint(FilterConstraintFnType constraint) { + filterConstraint = std::move(constraint); + return *this; + } + + using NativeShapeFnType = + std::function>(Operation *op)>; + /// Function that returns the shape of the vector to unroll to for a given + /// operation. The unrolling is aborted if the function returns + /// `std::nullopt`. + NativeShapeFnType nativeShape = nullptr; + UnrollVectorOptions &setNativeShapeFn(NativeShapeFnType fn) { + nativeShape = std::move(fn); + return *this; + } + + /// Set the native shape to use for unrolling. + UnrollVectorOptions &setNativeShape(ArrayRef shape) { + SmallVector tsShape(shape.begin(), shape.end()); + nativeShape = [=](Operation *) -> std::optional> { + return tsShape; + }; + return *this; + } + + /// Function that returns the traversal order (in terms of "for loop order", + /// i.e. slowest varying dimension to fastest varying dimension) that should + /// be used when unrolling the given operation into units of the native vector + /// size. + using UnrollTraversalOrderFnType = + std::function>(Operation *op)>; + UnrollTraversalOrderFnType traversalOrderCallback = nullptr; + UnrollVectorOptions & + setUnrollTraversalOrderFn(UnrollTraversalOrderFnType traversalOrderFn) { + traversalOrderCallback = std::move(traversalOrderFn); + return *this; + } +}; + +/// Canonicalization of a `vector.contraction %a, %b, %c` with row-major matmul +/// semantics to a contraction with MMT semantics (matrix matrix multiplication +/// with the RHS transposed). This specific form is meant to have the vector +/// operands are organized such that the reduction dimension is contiguous. +/// Example: +/// ``` +/// vector.contract {indexing_maps = [affine_map<(m, n, k) -> (m, k)>, +/// affine_map<(m, n, k) -> (n, k)>, +/// affine_map<(m, n, k) -> (m, n)>], +/// iterator_types = ["parallel", "parallel", "reduction"], +/// kind = #vector.kind} %a, %b, %c : ... +/// ``` +/// +/// The `constraint` predicate is used to decide which `vector.contraction` ops +/// to filter out. +void populateVectorContractCanonicalizeMatmulToMMT( + RewritePatternSet &patterns, + std::function constraint = + [](vector::ContractionOp) { return success(); }, + PatternBenefit = 1); + +/// Collect patterns to convert reduction op to vector.contract and fold +/// transpose/broadcast ops into the contract. +void populateVectorReductionToContractPatterns(RewritePatternSet &patterns, + PatternBenefit benefit = 1); + +/// Populate `patterns` with the following patterns. +/// +/// - VectorTransferFullPartialRewriter +/// +/// Split a vector.transfer operation into an in-bounds (i.e., no out-of-bounds +/// masking) fast path and a slow path. +/// +/// Example (a 2-D vector.transfer_read): +/// ``` +/// %1 = vector.transfer_read %0[...], %pad : memref, vector<...> +/// ``` +/// is transformed into: +/// ``` +/// %1:3 = scf.if (%inBounds) { +/// // fast path, direct cast +/// memref.cast %A: memref to compatibleMemRefType +/// scf.yield %view : compatibleMemRefType, index, index +/// } else { +/// // slow path, not in-bounds vector.transfer or linalg.copy. +/// memref.cast %alloc: memref to compatibleMemRefType +/// scf.yield %4 : compatibleMemRefType, index, index +// } +/// %0 = vector.transfer_read %1#0[%1#1, %1#2] {in_bounds = [true ... true]} +/// ``` +/// where `alloc` is a top of the function alloca'ed buffer of one vector. +/// +/// Preconditions: +/// 1. `xferOp.permutation_map()` must be a minor identity map +/// 2. the rank of the `xferOp.memref()` and the rank of the `xferOp.vector()` +/// must be equal. This will be relaxed in the future but requires +/// rank-reducing subviews. +void populateVectorTransferFullPartialPatterns( + RewritePatternSet &patterns, const VectorTransformsOptions &options); + +/// Collect a set of patterns to reduce the rank of the operands of vector +/// transfer ops to operate on the largest contigious vector. +/// These patterns are useful when lowering to dialects with 1d vector type +/// such as llvm and it will result fewer memory reads. +void populateVectorTransferCollapseInnerMostContiguousDimsPatterns( + RewritePatternSet &patterns, PatternBenefit benefit = 1); + +/// Patterns that remove redundant vector broadcasts. +void populateSinkVectorBroadcastPatterns(RewritePatternSet &patterns, + PatternBenefit benefit = 1); + +/// Populate `patterns` with the following patterns. +/// +/// [DecomposeDifferentRankInsertStridedSlice] +/// ========================================== +/// RewritePattern for InsertStridedSliceOp where source and destination vectors +/// have different ranks. +/// +/// When ranks are different, InsertStridedSlice needs to extract a properly +/// ranked vector from the destination vector into which to insert. This pattern +/// only takes care of this extraction part and forwards the rest to +/// [VectorInsertStridedSliceOpSameRankRewritePattern]. +/// +/// For a k-D source and n-D destination vector (k < n), we emit: +/// 1. ExtractOp to extract the (unique) (n-1)-D subvector into which to +/// insert the k-D source. +/// 2. k-D -> (n-1)-D InsertStridedSlice op +/// 3. InsertOp that is the reverse of 1. +/// +/// [DecomposeNDExtractStridedSlice] +/// ================================ +/// For such cases, we can rewrite it to ExtractOp/ExtractElementOp + lower +/// rank ExtractStridedSliceOp + InsertOp/InsertElementOp for the n-D case. +void populateVectorInsertExtractStridedSliceDecompositionPatterns( + RewritePatternSet &patterns, PatternBenefit benefit = 1); + +/// Populate `patterns` with a pattern to breaks down 1-D extract_strided_slice +/// ops into a chain of Extract ops to extract each element from the source, and +/// then a chain of Insert ops to insert to the target vector. +/// +/// If `controlFn` is not nullptr, the pattern will only be invoked on ops that +/// `controlFn` returns true. Otherwise runs on ops. +void populateVectorExtractStridedSliceToExtractInsertChainPatterns( + RewritePatternSet &patterns, + std::function controlFn = nullptr, + PatternBenefit benefit = 1); + +/// Populate `patterns` with a pattern to break down 1-D vector.bitcast ops +/// based on the destination vector shape. Bitcasts from a lower bitwidth +/// element type to a higher bitwidth one are extracted from the lower bitwidth +/// based on the native destination vector shape and inserted based on the ratio +/// of the bitwidths. +/// +/// This acts as a last resort way to break down vector.bitcast ops to smaller +/// vector sizes. Because this pattern composes until it is bitcasting to a +/// single element of the higher bitwidth, the is an optional control function. +/// If `controlFn` is not nullptr, the pattern will only apply to ops where +/// `controlFn` returns true, otherwise applies to all bitcast ops. +void populateBreakDownVectorBitCastOpPatterns( + RewritePatternSet &patterns, + std::function controlFn = nullptr, + PatternBenefit benefit = 1); + +/// Populate `patterns` with the following patterns. +/// +/// Patterns in populateVectorInsertExtractStridedSliceDecompositionPatterns(); +/// +/// [ConvertSameRankInsertStridedSliceIntoShuffle] +/// ============================================== +/// RewritePattern for InsertStridedSliceOp where source and destination vectors +/// have the same rank. For each outermost index in the slice: +/// begin end stride +/// [offset : offset+size*stride : stride] +/// 1. ExtractOp one (k-1)-D source subvector and one (n-1)-D dest subvector. +/// 2. InsertStridedSlice (k-1)-D into (n-1)-D +/// 3. the destination subvector is inserted back in the proper place +/// 3. InsertOp that is the reverse of 1. +/// +/// [Convert1DExtractStridedSliceIntoShuffle] +/// ========================================= +/// For such cases, we can lower it to a ShuffleOp. +void populateVectorInsertExtractStridedSliceTransforms( + RewritePatternSet &patterns, PatternBenefit benefit = 1); + +/// Collect a set of pattern to unroll vector operations to a smaller shapes. +/// `options` structure controls which operations are unrolled and the target +/// shape. +/// `op` is unrolled to the `targetShape` as follows, for each of its operands: +/// 1. the unrolled type `unrolledVectorType` and number of unrolled instances +/// `numUnrolledInstances` are computed from the `targetShape`. For now it is +/// assumed the unrolling factors divide the vector sizes. +/// 2. ExtractStridedSlice are created to break-up the vector operands. +/// 3. the original op is cloned `numUnrolledInstances` times, once for each +/// result. +/// 4. InsertStridedSlice are inserted to re-assemble the slices into the +/// original vectore shape. +/// +/// Example: +/// +/// opA(operand0, operand1) // numUnrolledInstances = 3 +/// +/// operand0 operand1 +/// | | +/// fork fork +/// <----------gather all fork ops ---------> +/// /|\ /|\ +/// f00 f01 f02 f10 f11 f12 +/// <---------- clone op 3 times ---------> +/// opA0(f00, f10), opA1(f01, f11), opA2(f02, f12) +/// \ | / +/// <-------------------- join -------------------------> +/// +/// Other local patterns then kick in iteratively (including DCE) and compose +/// to combine the ExtractStridedSlice/InsertStridedSlice. +void populateVectorUnrollPatterns(RewritePatternSet &patterns, + const UnrollVectorOptions &options, + PatternBenefit benefit = 1); + +/// Collect a set of vector.shape_cast folding patterns. +void populateShapeCastFoldingPatterns(RewritePatternSet &patterns, + PatternBenefit benefit = 1); + +/// Collect a set of leading one dimension removal patterns. +/// +/// These patterns insert vector.shape_cast to remove leading one dimensions +/// to expose more canonical forms of read/write/insert/extract operations. +/// With them, there are more chances that we can cancel out extract-insert +/// pairs or forward write-read pairs. +void populateCastAwayVectorLeadingOneDimPatterns(RewritePatternSet &patterns, + PatternBenefit benefit = 1); + +/// Collect a set of one dimension removal patterns. +/// +/// These patterns insert rank-reducing memref.subview ops to remove one +/// dimensions. With them, there are more chances that we can avoid +/// potentially expensive vector.shape_cast operations. +void populateVectorTransferDropUnitDimsPatterns(RewritePatternSet &patterns, + PatternBenefit benefit = 1); + +/// Collect a set of patterns to flatten n-D vector transfers on contiguous +/// memref. +/// +/// These patterns insert memref.collapse_shape + vector.shape_cast patterns +/// to transform multiple small n-D transfers into a larger 1-D transfer where +/// the memref contiguity properties allow it. +void populateFlattenVectorTransferPatterns(RewritePatternSet &patterns, + PatternBenefit benefit = 1); + +/// Collect a set of patterns that bubble up/down bitcast ops. +/// +/// These patterns move vector.bitcast ops to be before insert ops or after +/// extract ops where suitable. With them, bitcast will happen on smaller +/// vectors and there are more chances to share extract/insert ops. +void populateBubbleVectorBitCastOpPatterns(RewritePatternSet &patterns, + PatternBenefit benefit = 1); + +/// These patterns materialize masks for various vector ops such as transfers. +void populateVectorMaskMaterializationPatterns(RewritePatternSet &patterns, + bool force32BitVectorIndices, + PatternBenefit benefit = 1); + +/// Appends patterns for emulating vector operations over narrow types with ops +/// over wider types. +void populateVectorNarrowTypeEmulationPatterns( + arith::NarrowTypeEmulationConverter &typeConverter, + RewritePatternSet &patterns); + +/// Rewrite a vector `bitcast(trunci)` to use a more efficient sequence of +/// vector operations comprising `shuffle` and `bitwise` ops. +/// Warning: these patterns currently only work for little endian targets. +FailureOr rewriteBitCastOfTruncI(RewriterBase &rewriter, + vector::BitCastOp bitCastOp, + arith::TruncIOp truncOp, + vector::BroadcastOp maybeBroadcastOp); + +/// Rewrite a vector `ext(bitcast)` to use a more efficient sequence of +/// vector operations comprising `shuffle` and `bitwise` ops. +/// Warning: these patterns currently only work for little endian targets. +FailureOr rewriteExtOfBitCast(RewriterBase &rewriter, Operation *extOp, + vector::BitCastOp bitCastOp, + vector::BroadcastOp maybeBroadcastOp); + +/// Appends patterns for rewriting vector operations over narrow types with +/// ops over wider types. +/// Warning: these patterns currently only work for little endian targets. +void populateVectorNarrowTypeRewritePatterns(RewritePatternSet &patterns, + PatternBenefit benefit = 1); + +} // namespace vector +} // namespace mlir + +#endif // MLIR_DIALECT_VECTOR_TRANSFORMS_VECTORREWRITEPATTERNS_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Transforms/VectorTransforms.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Transforms/VectorTransforms.h new file mode 100644 index 0000000000000000000000000000000000000000..08d3bb157a0e396105b2117d126ca4bca2588ff1 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Transforms/VectorTransforms.h @@ -0,0 +1,119 @@ +//===- VectorTransforms.h - Vector transformations as patterns --*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_VECTOR_TRANSFORMS_VECTORTRANSFORMS_H +#define MLIR_DIALECT_VECTOR_TRANSFORMS_VECTORTRANSFORMS_H + +#include "mlir/Dialect/Vector/Transforms/VectorRewritePatterns.h" +#include "mlir/Dialect/Vector/Utils/VectorUtils.h" + +namespace mlir { +class MLIRContext; +class VectorTransferOpInterface; +class RewritePatternSet; +class RewriterBase; + +namespace scf { +class IfOp; +} // namespace scf + +namespace vector { + +//===----------------------------------------------------------------------===// +// Vector transformation options exposed as auxiliary structs. +//===----------------------------------------------------------------------===// + +/// Structure to control the behavior of vector transform patterns. +struct VectorTransformsOptions { + /// Option to control the lowering of vector.contract. + VectorContractLowering vectorContractLowering = VectorContractLowering::Dot; + VectorTransformsOptions & + setVectorTransformsOptions(VectorContractLowering opt) { + vectorContractLowering = opt; + return *this; + } + /// Option to control the lowering of vector.multi_reduction. + VectorMultiReductionLowering vectorMultiReductionLowering = + VectorMultiReductionLowering::InnerParallel; + VectorTransformsOptions & + setVectorMultiReductionLowering(VectorMultiReductionLowering opt) { + vectorMultiReductionLowering = opt; + return *this; + } + /// Option to control the lowering of vector.transpose. + VectorTransposeLowering vectorTransposeLowering = + VectorTransposeLowering::EltWise; + VectorTransformsOptions & + setVectorTransposeLowering(VectorTransposeLowering opt) { + vectorTransposeLowering = opt; + return *this; + } + /// Option to control the splitting of vector transfers. + VectorTransferSplit vectorTransferSplit = VectorTransferSplit::None; + VectorTransformsOptions &setVectorTransferSplit(VectorTransferSplit opt) { + vectorTransferSplit = opt; + return *this; + } +}; + +//===----------------------------------------------------------------------===// +// Standalone transformations and helpers. +//===----------------------------------------------------------------------===// + +/// Split a vector.transfer operation into an in-bounds (i.e., no +/// out-of-bounds masking) fastpath and a slowpath. If `ifOp` is not null and +/// the result is `success, the `ifOp` points to the newly created conditional +/// upon function return. To accomodate for the fact that the original +/// vector.transfer indexing may be arbitrary and the slow path indexes +/// @[0...0] in the temporary buffer, the scf.if op returns a view and values +/// of type index. At this time, only vector.transfer_read case is +/// implemented. +/// +/// Example (a 2-D vector.transfer_read): +/// ``` +/// %1 = vector.transfer_read %0[...], %pad : memref, vector<...> +/// ``` +/// is transformed into: +/// ``` +/// %1:3 = scf.if (%inBounds) { +/// // fastpath, direct cast +/// memref.cast %A: memref to compatibleMemRefType +/// scf.yield %view : compatibleMemRefType, index, index +/// } else { +/// // slowpath, not in-bounds vector.transfer or linalg.copy. +/// memref.cast %alloc: memref to compatibleMemRefType +/// scf.yield %4 : compatibleMemRefType, index, index +// } +/// %0 = vector.transfer_read %1#0[%1#1, %1#2] {in_bounds = [true ... +/// true]} +/// ``` +/// where `alloc` is a top of the function alloca'ed buffer of one vector. +/// +/// Preconditions: +/// 1. `xferOp.permutation_map()` must be a minor identity map +/// 2. the rank of the `xferOp.memref()` and the rank of the +/// `xferOp.vector()` must be equal. This will be relaxed in the future but +/// requires rank-reducing subviews. +LogicalResult splitFullAndPartialTransfer( + RewriterBase &b, VectorTransferOpInterface xferOp, + VectorTransformsOptions options = VectorTransformsOptions(), + scf::IfOp *ifOp = nullptr); + +/// Implements transfer op write to read forwarding and dead transfer write +/// optimizations. +void transferOpflowOpt(RewriterBase &rewriter, Operation *rootOp); + +/// Cast away the leading unit dim, if exists, for the given contract op. +/// Return success if the transformation applies; return failure otherwise. +LogicalResult castAwayContractionLeadingOneDim(vector::ContractionOp contractOp, + RewriterBase &rewriter); + +} // namespace vector +} // namespace mlir + +#endif // MLIR_DIALECT_VECTOR_TRANSFORMS_VECTORTRANSFORMS_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Transforms/VectorTransformsEnums.cpp.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Transforms/VectorTransformsEnums.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..e9853a0cf052b9207a116289f57e6f7425b979b6 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Transforms/VectorTransformsEnums.cpp.inc @@ -0,0 +1,179 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Enum Utility Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: VectorTransformsBase.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace vector { +::llvm::StringRef stringifyVectorContractLowering(VectorContractLowering val) { + switch (val) { + case VectorContractLowering::Dot: return "dot"; + case VectorContractLowering::Matmul: return "matmulintrinsics"; + case VectorContractLowering::OuterProduct: return "outerproduct"; + case VectorContractLowering::ParallelArith: return "parallelarith"; + } + return ""; +} + +::std::optional symbolizeVectorContractLowering(::llvm::StringRef str) { + return ::llvm::StringSwitch<::std::optional>(str) + .Case("dot", VectorContractLowering::Dot) + .Case("matmulintrinsics", VectorContractLowering::Matmul) + .Case("outerproduct", VectorContractLowering::OuterProduct) + .Case("parallelarith", VectorContractLowering::ParallelArith) + .Default(::std::nullopt); +} +::std::optional symbolizeVectorContractLowering(uint32_t value) { + switch (value) { + case 0: return VectorContractLowering::Dot; + case 1: return VectorContractLowering::Matmul; + case 2: return VectorContractLowering::OuterProduct; + case 3: return VectorContractLowering::ParallelArith; + default: return ::std::nullopt; + } +} + +bool VectorContractLoweringAttr::classof(::mlir::Attribute attr) { + return (((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(32)))) && (((::llvm::cast<::mlir::IntegerAttr>(attr).getInt() == 0)) || ((::llvm::cast<::mlir::IntegerAttr>(attr).getInt() == 1)) || ((::llvm::cast<::mlir::IntegerAttr>(attr).getInt() == 2)) || ((::llvm::cast<::mlir::IntegerAttr>(attr).getInt() == 3))); +} +VectorContractLoweringAttr VectorContractLoweringAttr::get(::mlir::MLIRContext *context, VectorContractLowering val) { + ::mlir::IntegerType intType = ::mlir::IntegerType::get(context, 32); + ::mlir::IntegerAttr baseAttr = ::mlir::IntegerAttr::get(intType, static_cast(val)); + return ::llvm::cast(baseAttr); +} +VectorContractLowering VectorContractLoweringAttr::getValue() const { + return static_cast(::mlir::IntegerAttr::getInt()); +} +} // namespace vector +} // namespace mlir + +namespace mlir { +namespace vector { +::llvm::StringRef stringifyVectorMultiReductionLowering(VectorMultiReductionLowering val) { + switch (val) { + case VectorMultiReductionLowering::InnerParallel: return "innerparallel"; + case VectorMultiReductionLowering::InnerReduction: return "innerreduction"; + } + return ""; +} + +::std::optional symbolizeVectorMultiReductionLowering(::llvm::StringRef str) { + return ::llvm::StringSwitch<::std::optional>(str) + .Case("innerparallel", VectorMultiReductionLowering::InnerParallel) + .Case("innerreduction", VectorMultiReductionLowering::InnerReduction) + .Default(::std::nullopt); +} +::std::optional symbolizeVectorMultiReductionLowering(uint32_t value) { + switch (value) { + case 0: return VectorMultiReductionLowering::InnerParallel; + case 1: return VectorMultiReductionLowering::InnerReduction; + default: return ::std::nullopt; + } +} + +bool VectorMultiReductionLoweringAttr::classof(::mlir::Attribute attr) { + return (((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(32)))) && (((::llvm::cast<::mlir::IntegerAttr>(attr).getInt() == 0)) || ((::llvm::cast<::mlir::IntegerAttr>(attr).getInt() == 1))); +} +VectorMultiReductionLoweringAttr VectorMultiReductionLoweringAttr::get(::mlir::MLIRContext *context, VectorMultiReductionLowering val) { + ::mlir::IntegerType intType = ::mlir::IntegerType::get(context, 32); + ::mlir::IntegerAttr baseAttr = ::mlir::IntegerAttr::get(intType, static_cast(val)); + return ::llvm::cast(baseAttr); +} +VectorMultiReductionLowering VectorMultiReductionLoweringAttr::getValue() const { + return static_cast(::mlir::IntegerAttr::getInt()); +} +} // namespace vector +} // namespace mlir + +namespace mlir { +namespace vector { +::llvm::StringRef stringifyVectorTransferSplit(VectorTransferSplit val) { + switch (val) { + case VectorTransferSplit::None: return "none"; + case VectorTransferSplit::VectorTransfer: return "vector-transfer"; + case VectorTransferSplit::LinalgCopy: return "linalg-copy"; + case VectorTransferSplit::ForceInBounds: return "force-in-bounds"; + } + return ""; +} + +::std::optional symbolizeVectorTransferSplit(::llvm::StringRef str) { + return ::llvm::StringSwitch<::std::optional>(str) + .Case("none", VectorTransferSplit::None) + .Case("vector-transfer", VectorTransferSplit::VectorTransfer) + .Case("linalg-copy", VectorTransferSplit::LinalgCopy) + .Case("force-in-bounds", VectorTransferSplit::ForceInBounds) + .Default(::std::nullopt); +} +::std::optional symbolizeVectorTransferSplit(uint32_t value) { + switch (value) { + case 0: return VectorTransferSplit::None; + case 1: return VectorTransferSplit::VectorTransfer; + case 2: return VectorTransferSplit::LinalgCopy; + case 3: return VectorTransferSplit::ForceInBounds; + default: return ::std::nullopt; + } +} + +bool VectorTransferSplitAttr::classof(::mlir::Attribute attr) { + return (((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(32)))) && (((::llvm::cast<::mlir::IntegerAttr>(attr).getInt() == 0)) || ((::llvm::cast<::mlir::IntegerAttr>(attr).getInt() == 1)) || ((::llvm::cast<::mlir::IntegerAttr>(attr).getInt() == 2)) || ((::llvm::cast<::mlir::IntegerAttr>(attr).getInt() == 3))); +} +VectorTransferSplitAttr VectorTransferSplitAttr::get(::mlir::MLIRContext *context, VectorTransferSplit val) { + ::mlir::IntegerType intType = ::mlir::IntegerType::get(context, 32); + ::mlir::IntegerAttr baseAttr = ::mlir::IntegerAttr::get(intType, static_cast(val)); + return ::llvm::cast(baseAttr); +} +VectorTransferSplit VectorTransferSplitAttr::getValue() const { + return static_cast(::mlir::IntegerAttr::getInt()); +} +} // namespace vector +} // namespace mlir + +namespace mlir { +namespace vector { +::llvm::StringRef stringifyVectorTransposeLowering(VectorTransposeLowering val) { + switch (val) { + case VectorTransposeLowering::EltWise: return "eltwise"; + case VectorTransposeLowering::Flat: return "flat_transpose"; + case VectorTransposeLowering::Shuffle1D: return "shuffle_1d"; + case VectorTransposeLowering::Shuffle16x16: return "shuffle_16x16"; + } + return ""; +} + +::std::optional symbolizeVectorTransposeLowering(::llvm::StringRef str) { + return ::llvm::StringSwitch<::std::optional>(str) + .Case("eltwise", VectorTransposeLowering::EltWise) + .Case("flat_transpose", VectorTransposeLowering::Flat) + .Case("shuffle_1d", VectorTransposeLowering::Shuffle1D) + .Case("shuffle_16x16", VectorTransposeLowering::Shuffle16x16) + .Default(::std::nullopt); +} +::std::optional symbolizeVectorTransposeLowering(uint32_t value) { + switch (value) { + case 0: return VectorTransposeLowering::EltWise; + case 1: return VectorTransposeLowering::Flat; + case 2: return VectorTransposeLowering::Shuffle1D; + case 3: return VectorTransposeLowering::Shuffle16x16; + default: return ::std::nullopt; + } +} + +bool VectorTransposeLoweringAttr::classof(::mlir::Attribute attr) { + return (((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(32)))) && (((::llvm::cast<::mlir::IntegerAttr>(attr).getInt() == 0)) || ((::llvm::cast<::mlir::IntegerAttr>(attr).getInt() == 1)) || ((::llvm::cast<::mlir::IntegerAttr>(attr).getInt() == 2)) || ((::llvm::cast<::mlir::IntegerAttr>(attr).getInt() == 3))); +} +VectorTransposeLoweringAttr VectorTransposeLoweringAttr::get(::mlir::MLIRContext *context, VectorTransposeLowering val) { + ::mlir::IntegerType intType = ::mlir::IntegerType::get(context, 32); + ::mlir::IntegerAttr baseAttr = ::mlir::IntegerAttr::get(intType, static_cast(val)); + return ::llvm::cast(baseAttr); +} +VectorTransposeLowering VectorTransposeLoweringAttr::getValue() const { + return static_cast(::mlir::IntegerAttr::getInt()); +} +} // namespace vector +} // namespace mlir + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Transforms/VectorTransformsEnums.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Transforms/VectorTransformsEnums.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..01af719493c53d85851cbf7648311285008444a0 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Transforms/VectorTransformsEnums.h.inc @@ -0,0 +1,381 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Enum Utility Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: VectorTransformsBase.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace vector { +// control the lowering of `vector.contract` operations. +enum class VectorContractLowering : uint32_t { + Dot = 0, + Matmul = 1, + OuterProduct = 2, + ParallelArith = 3, +}; + +::std::optional symbolizeVectorContractLowering(uint32_t); +::llvm::StringRef stringifyVectorContractLowering(VectorContractLowering); +::std::optional symbolizeVectorContractLowering(::llvm::StringRef); +inline constexpr unsigned getMaxEnumValForVectorContractLowering() { + return 3; +} + + +inline ::llvm::StringRef stringifyEnum(VectorContractLowering enumValue) { + return stringifyVectorContractLowering(enumValue); +} + +template +::std::optional symbolizeEnum(::llvm::StringRef); + +template <> +inline ::std::optional symbolizeEnum(::llvm::StringRef str) { + return symbolizeVectorContractLowering(str); +} + +class VectorContractLoweringAttr : public ::mlir::IntegerAttr { +public: + using ValueType = VectorContractLowering; + using ::mlir::IntegerAttr::IntegerAttr; + static bool classof(::mlir::Attribute attr); + static VectorContractLoweringAttr get(::mlir::MLIRContext *context, VectorContractLowering val); + VectorContractLowering getValue() const; +}; +} // namespace vector +} // namespace mlir + +namespace mlir { +template +struct FieldParser; + +template<> +struct FieldParser<::mlir::vector::VectorContractLowering, ::mlir::vector::VectorContractLowering> { + template + static FailureOr<::mlir::vector::VectorContractLowering> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return parser.emitError(loc, "expected keyword for control the lowering of `vector.contract` operations."); + + // Symbolize the keyword. + if (::std::optional<::mlir::vector::VectorContractLowering> attr = ::mlir::vector::symbolizeEnum<::mlir::vector::VectorContractLowering>(enumKeyword)) + return *attr; + return parser.emitError(loc, "invalid control the lowering of `vector.contract` operations. specification: ") << enumKeyword; + } +}; +} // namespace mlir + +namespace llvm { +inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::vector::VectorContractLowering value) { + auto valueStr = stringifyEnum(value); + return p << valueStr; +} +} // namespace llvm + +namespace llvm { +template<> struct DenseMapInfo<::mlir::vector::VectorContractLowering> { + using StorageInfo = ::llvm::DenseMapInfo; + + static inline ::mlir::vector::VectorContractLowering getEmptyKey() { + return static_cast<::mlir::vector::VectorContractLowering>(StorageInfo::getEmptyKey()); + } + + static inline ::mlir::vector::VectorContractLowering getTombstoneKey() { + return static_cast<::mlir::vector::VectorContractLowering>(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const ::mlir::vector::VectorContractLowering &val) { + return StorageInfo::getHashValue(static_cast(val)); + } + + static bool isEqual(const ::mlir::vector::VectorContractLowering &lhs, const ::mlir::vector::VectorContractLowering &rhs) { + return lhs == rhs; + } +}; +} + +namespace mlir { +namespace vector { +// control the lowering of `vector.multi_reduction`. +enum class VectorMultiReductionLowering : uint32_t { + InnerParallel = 0, + InnerReduction = 1, +}; + +::std::optional symbolizeVectorMultiReductionLowering(uint32_t); +::llvm::StringRef stringifyVectorMultiReductionLowering(VectorMultiReductionLowering); +::std::optional symbolizeVectorMultiReductionLowering(::llvm::StringRef); +inline constexpr unsigned getMaxEnumValForVectorMultiReductionLowering() { + return 1; +} + + +inline ::llvm::StringRef stringifyEnum(VectorMultiReductionLowering enumValue) { + return stringifyVectorMultiReductionLowering(enumValue); +} + +template +::std::optional symbolizeEnum(::llvm::StringRef); + +template <> +inline ::std::optional symbolizeEnum(::llvm::StringRef str) { + return symbolizeVectorMultiReductionLowering(str); +} + +class VectorMultiReductionLoweringAttr : public ::mlir::IntegerAttr { +public: + using ValueType = VectorMultiReductionLowering; + using ::mlir::IntegerAttr::IntegerAttr; + static bool classof(::mlir::Attribute attr); + static VectorMultiReductionLoweringAttr get(::mlir::MLIRContext *context, VectorMultiReductionLowering val); + VectorMultiReductionLowering getValue() const; +}; +} // namespace vector +} // namespace mlir + +namespace mlir { +template +struct FieldParser; + +template<> +struct FieldParser<::mlir::vector::VectorMultiReductionLowering, ::mlir::vector::VectorMultiReductionLowering> { + template + static FailureOr<::mlir::vector::VectorMultiReductionLowering> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return parser.emitError(loc, "expected keyword for control the lowering of `vector.multi_reduction`."); + + // Symbolize the keyword. + if (::std::optional<::mlir::vector::VectorMultiReductionLowering> attr = ::mlir::vector::symbolizeEnum<::mlir::vector::VectorMultiReductionLowering>(enumKeyword)) + return *attr; + return parser.emitError(loc, "invalid control the lowering of `vector.multi_reduction`. specification: ") << enumKeyword; + } +}; +} // namespace mlir + +namespace llvm { +inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::vector::VectorMultiReductionLowering value) { + auto valueStr = stringifyEnum(value); + return p << valueStr; +} +} // namespace llvm + +namespace llvm { +template<> struct DenseMapInfo<::mlir::vector::VectorMultiReductionLowering> { + using StorageInfo = ::llvm::DenseMapInfo; + + static inline ::mlir::vector::VectorMultiReductionLowering getEmptyKey() { + return static_cast<::mlir::vector::VectorMultiReductionLowering>(StorageInfo::getEmptyKey()); + } + + static inline ::mlir::vector::VectorMultiReductionLowering getTombstoneKey() { + return static_cast<::mlir::vector::VectorMultiReductionLowering>(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const ::mlir::vector::VectorMultiReductionLowering &val) { + return StorageInfo::getHashValue(static_cast(val)); + } + + static bool isEqual(const ::mlir::vector::VectorMultiReductionLowering &lhs, const ::mlir::vector::VectorMultiReductionLowering &rhs) { + return lhs == rhs; + } +}; +} + +namespace mlir { +namespace vector { +// control the splitting of `vector.transfer` operations into in-bounds and out-of-bounds variants. +enum class VectorTransferSplit : uint32_t { + None = 0, + VectorTransfer = 1, + LinalgCopy = 2, + ForceInBounds = 3, +}; + +::std::optional symbolizeVectorTransferSplit(uint32_t); +::llvm::StringRef stringifyVectorTransferSplit(VectorTransferSplit); +::std::optional symbolizeVectorTransferSplit(::llvm::StringRef); +inline constexpr unsigned getMaxEnumValForVectorTransferSplit() { + return 3; +} + + +inline ::llvm::StringRef stringifyEnum(VectorTransferSplit enumValue) { + return stringifyVectorTransferSplit(enumValue); +} + +template +::std::optional symbolizeEnum(::llvm::StringRef); + +template <> +inline ::std::optional symbolizeEnum(::llvm::StringRef str) { + return symbolizeVectorTransferSplit(str); +} + +class VectorTransferSplitAttr : public ::mlir::IntegerAttr { +public: + using ValueType = VectorTransferSplit; + using ::mlir::IntegerAttr::IntegerAttr; + static bool classof(::mlir::Attribute attr); + static VectorTransferSplitAttr get(::mlir::MLIRContext *context, VectorTransferSplit val); + VectorTransferSplit getValue() const; +}; +} // namespace vector +} // namespace mlir + +namespace mlir { +template +struct FieldParser; + +template<> +struct FieldParser<::mlir::vector::VectorTransferSplit, ::mlir::vector::VectorTransferSplit> { + template + static FailureOr<::mlir::vector::VectorTransferSplit> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return parser.emitError(loc, "expected keyword for control the splitting of `vector.transfer` operations into in-bounds and out-of-bounds variants."); + + // Symbolize the keyword. + if (::std::optional<::mlir::vector::VectorTransferSplit> attr = ::mlir::vector::symbolizeEnum<::mlir::vector::VectorTransferSplit>(enumKeyword)) + return *attr; + return parser.emitError(loc, "invalid control the splitting of `vector.transfer` operations into in-bounds and out-of-bounds variants. specification: ") << enumKeyword; + } +}; +} // namespace mlir + +namespace llvm { +inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::vector::VectorTransferSplit value) { + auto valueStr = stringifyEnum(value); + switch (value) { + case ::mlir::vector::VectorTransferSplit::None: + break; + default: + return p << '"' << valueStr << '"'; + } + return p << valueStr; +} +} // namespace llvm + +namespace llvm { +template<> struct DenseMapInfo<::mlir::vector::VectorTransferSplit> { + using StorageInfo = ::llvm::DenseMapInfo; + + static inline ::mlir::vector::VectorTransferSplit getEmptyKey() { + return static_cast<::mlir::vector::VectorTransferSplit>(StorageInfo::getEmptyKey()); + } + + static inline ::mlir::vector::VectorTransferSplit getTombstoneKey() { + return static_cast<::mlir::vector::VectorTransferSplit>(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const ::mlir::vector::VectorTransferSplit &val) { + return StorageInfo::getHashValue(static_cast(val)); + } + + static bool isEqual(const ::mlir::vector::VectorTransferSplit &lhs, const ::mlir::vector::VectorTransferSplit &rhs) { + return lhs == rhs; + } +}; +} + +namespace mlir { +namespace vector { +// control the lowering of `vector.transpose` operations. +enum class VectorTransposeLowering : uint32_t { + EltWise = 0, + Flat = 1, + Shuffle1D = 2, + Shuffle16x16 = 3, +}; + +::std::optional symbolizeVectorTransposeLowering(uint32_t); +::llvm::StringRef stringifyVectorTransposeLowering(VectorTransposeLowering); +::std::optional symbolizeVectorTransposeLowering(::llvm::StringRef); +inline constexpr unsigned getMaxEnumValForVectorTransposeLowering() { + return 3; +} + + +inline ::llvm::StringRef stringifyEnum(VectorTransposeLowering enumValue) { + return stringifyVectorTransposeLowering(enumValue); +} + +template +::std::optional symbolizeEnum(::llvm::StringRef); + +template <> +inline ::std::optional symbolizeEnum(::llvm::StringRef str) { + return symbolizeVectorTransposeLowering(str); +} + +class VectorTransposeLoweringAttr : public ::mlir::IntegerAttr { +public: + using ValueType = VectorTransposeLowering; + using ::mlir::IntegerAttr::IntegerAttr; + static bool classof(::mlir::Attribute attr); + static VectorTransposeLoweringAttr get(::mlir::MLIRContext *context, VectorTransposeLowering val); + VectorTransposeLowering getValue() const; +}; +} // namespace vector +} // namespace mlir + +namespace mlir { +template +struct FieldParser; + +template<> +struct FieldParser<::mlir::vector::VectorTransposeLowering, ::mlir::vector::VectorTransposeLowering> { + template + static FailureOr<::mlir::vector::VectorTransposeLowering> parse(ParserT &parser) { + // Parse the keyword/string containing the enum. + std::string enumKeyword; + auto loc = parser.getCurrentLocation(); + if (failed(parser.parseOptionalKeywordOrString(&enumKeyword))) + return parser.emitError(loc, "expected keyword for control the lowering of `vector.transpose` operations."); + + // Symbolize the keyword. + if (::std::optional<::mlir::vector::VectorTransposeLowering> attr = ::mlir::vector::symbolizeEnum<::mlir::vector::VectorTransposeLowering>(enumKeyword)) + return *attr; + return parser.emitError(loc, "invalid control the lowering of `vector.transpose` operations. specification: ") << enumKeyword; + } +}; +} // namespace mlir + +namespace llvm { +inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::vector::VectorTransposeLowering value) { + auto valueStr = stringifyEnum(value); + return p << valueStr; +} +} // namespace llvm + +namespace llvm { +template<> struct DenseMapInfo<::mlir::vector::VectorTransposeLowering> { + using StorageInfo = ::llvm::DenseMapInfo; + + static inline ::mlir::vector::VectorTransposeLowering getEmptyKey() { + return static_cast<::mlir::vector::VectorTransposeLowering>(StorageInfo::getEmptyKey()); + } + + static inline ::mlir::vector::VectorTransposeLowering getTombstoneKey() { + return static_cast<::mlir::vector::VectorTransposeLowering>(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const ::mlir::vector::VectorTransposeLowering &val) { + return StorageInfo::getHashValue(static_cast(val)); + } + + static bool isEqual(const ::mlir::vector::VectorTransposeLowering &lhs, const ::mlir::vector::VectorTransposeLowering &rhs) { + return lhs == rhs; + } +}; +} + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Utils/VectorUtils.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Utils/VectorUtils.h new file mode 100644 index 0000000000000000000000000000000000000000..fc00769a4aaa8a3d6e1a0a82f459599d28347bbb --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Vector/Utils/VectorUtils.h @@ -0,0 +1,136 @@ +//===- VectorUtils.h - Vector Utilities -------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_VECTOR_UTILS_VECTORUTILS_H_ +#define MLIR_DIALECT_VECTOR_UTILS_VECTORUTILS_H_ + +#include "mlir/Dialect/Vector/IR/VectorOps.h" +#include "mlir/IR/BuiltinAttributes.h" +#include "mlir/Support/LLVM.h" + +#include "llvm/ADT/DenseMap.h" + +namespace mlir { + +// Forward declarations. +class AffineMap; +class Block; +class Location; +class OpBuilder; +class Operation; +class ShapedType; +class Value; +class VectorType; +class VectorTransferOpInterface; + +namespace affine { +class AffineApplyOp; +class AffineForOp; +} // namespace affine + +namespace vector { +/// Helper function that creates a memref::DimOp or tensor::DimOp depending on +/// the type of `source`. +Value createOrFoldDimOp(OpBuilder &b, Location loc, Value source, int64_t dim); + +/// Returns two dims that are greater than one if the transposition is applied +/// on a 2D slice. Otherwise, returns a failure. +FailureOr> isTranspose2DSlice(vector::TransposeOp op); + +} // namespace vector + +/// Constructs a permutation map of invariant memref indices to vector +/// dimension. +/// +/// If no index is found to be invariant, 0 is added to the permutation_map and +/// corresponds to a vector broadcast along that dimension. +/// +/// The implementation uses the knowledge of the mapping of loops to +/// vector dimension. `loopToVectorDim` carries this information as a map with: +/// - keys representing "vectorized enclosing loops"; +/// - values representing the corresponding vector dimension. +/// Note that loopToVectorDim is a whole function map from which only enclosing +/// loop information is extracted. +/// +/// Prerequisites: `indices` belong to a vectorizable load or store operation +/// (i.e. at most one invariant index along each AffineForOp of +/// `loopToVectorDim`). `insertPoint` is the insertion point for the vectorized +/// load or store operation. +/// +/// Example 1: +/// The following MLIR snippet: +/// +/// ```mlir +/// affine.for %i3 = 0 to %0 { +/// affine.for %i4 = 0 to %1 { +/// affine.for %i5 = 0 to %2 { +/// %a5 = load %arg0[%i4, %i5, %i3] : memref +/// }}} +/// ``` +/// +/// may vectorize with {permutation_map: (d0, d1, d2) -> (d2, d1)} into: +/// +/// ```mlir +/// affine.for %i3 = 0 to %0 step 32 { +/// affine.for %i4 = 0 to %1 { +/// affine.for %i5 = 0 to %2 step 256 { +/// %4 = vector.transfer_read %arg0, %i4, %i5, %i3 +/// {permutation_map: (d0, d1, d2) -> (d2, d1)} : +/// (memref, index, index) -> vector<32x256xf32> +/// }}} +/// ``` +/// +/// Meaning that vector.transfer_read will be responsible for reading the slice: +/// `%arg0[%i4, %i5:%15+256, %i3:%i3+32]` into vector<32x256xf32>. +/// +/// Example 2: +/// The following MLIR snippet: +/// +/// ```mlir +/// %cst0 = arith.constant 0 : index +/// affine.for %i0 = 0 to %0 { +/// %a0 = load %arg0[%cst0, %cst0] : memref +/// } +/// ``` +/// +/// may vectorize with {permutation_map: (d0) -> (0)} into: +/// +/// ```mlir +/// affine.for %i0 = 0 to %0 step 128 { +/// %3 = vector.transfer_read %arg0, %c0_0, %c0_0 +/// {permutation_map: (d0, d1) -> (0)} : +/// (memref, index, index) -> vector<128xf32> +/// } +/// ```` +/// +/// Meaning that vector.transfer_read will be responsible of reading the slice +/// `%arg0[%c0, %c0]` into vector<128xf32> which needs a 1-D vector broadcast. +/// +AffineMap +makePermutationMap(Block *insertPoint, ArrayRef indices, + const DenseMap &loopToVectorDim); +AffineMap +makePermutationMap(Operation *insertPoint, ArrayRef indices, + const DenseMap &loopToVectorDim); + +namespace matcher { + +/// Matches vector.transfer_read, vector.transfer_write and ops that return a +/// vector type that is a multiple of the sub-vector type. This allows passing +/// over other smaller vector types in the function and avoids interfering with +/// operations on those. +/// This is a first approximation, it can easily be extended in the future. +/// TODO: this could all be much simpler if we added a bit that a vector type to +/// mark that a vector is a strict super-vector but it still does not warrant +/// adding even 1 extra bit in the IR for now. +bool operatesOnSuperVectorsOf(Operation &op, VectorType subVectorType); + +} // namespace matcher +} // namespace mlir + +#endif // MLIR_DIALECT_VECTOR_UTILS_VECTORUTILS_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/X86Vector/Transforms.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/X86Vector/Transforms.h new file mode 100644 index 0000000000000000000000000000000000000000..fe98ebd955aa312ca995d69cc412d7c9bc7e8306 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/X86Vector/Transforms.h @@ -0,0 +1,187 @@ +//=- Transforms.h - X86Vector Dialect Transformation Entrypoints -*- C++ -*-=// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_X86VECTOR_TRANSFORMS_H +#define MLIR_DIALECT_X86VECTOR_TRANSFORMS_H + +#include "mlir/IR/Value.h" + +namespace mlir { + +class ImplicitLocOpBuilder; +class LLVMConversionTarget; +class LLVMTypeConverter; +class RewritePatternSet; + +namespace x86vector { + +/// Helper class to factor out the creation and extraction of masks from nibs. +struct MaskHelper { + /// b0 captures the lowest bit, b7 captures the highest bit. + /// Meant to be used with instructions such as mm256BlendPs. + template + static uint8_t blend() { + static_assert(b0 <= 1 && b1 <= 1 && b2 <= 1 && b3 <= 1, "overflow"); + static_assert(b4 <= 1 && b5 <= 1 && b6 <= 1 && b7 <= 1, "overflow"); + return static_cast((b7 << 7) | (b6 << 6) | (b5 << 5) | (b4 << 4) | + (b3 << 3) | (b2 << 2) | (b1 << 1) | b0); + } + /// b0 captures the lowest bit, b7 captures the highest bit. + /// Meant to be used with instructions such as mm256BlendPs. + static void extractBlend(uint8_t mask, uint8_t &b0, uint8_t &b1, uint8_t &b2, + uint8_t &b3, uint8_t &b4, uint8_t &b5, uint8_t &b6, + uint8_t &b7) { + b7 = mask & (1 << 7); + b6 = mask & (1 << 6); + b5 = mask & (1 << 5); + b4 = mask & (1 << 4); + b3 = mask & (1 << 3); + b2 = mask & (1 << 2); + b1 = mask & (1 << 1); + b0 = mask & 1; + } + /// b01 captures the lower 2 bits, b67 captures the higher 2 bits. + /// Meant to be used with instructions such as mm256ShufflePs. + template + static uint8_t shuffle() { + static_assert(b01 <= 0x03, "overflow"); + static_assert(b23 <= 0x03, "overflow"); + static_assert(b45 <= 0x03, "overflow"); + static_assert(b67 <= 0x03, "overflow"); + return static_cast((b67 << 6) | (b45 << 4) | (b23 << 2) | b01); + } + /// b01 captures the lower 2 bits, b67 captures the higher 2 bits. + static void extractShuffle(uint8_t mask, uint8_t &b01, uint8_t &b23, + uint8_t &b45, uint8_t &b67) { + b67 = (mask & (0x03 << 6)) >> 6; + b45 = (mask & (0x03 << 4)) >> 4; + b23 = (mask & (0x03 << 2)) >> 2; + b01 = mask & 0x03; + } + /// b03 captures the lower 4 bits, b47 captures the higher 4 bits. + /// Meant to be used with instructions such as mm256Permute2f128Ps. + template + static uint8_t permute() { + static_assert(b03 <= 0x0f, "overflow"); + static_assert(b47 <= 0x0f, "overflow"); + return static_cast((b47 << 4) + b03); + } + /// b03 captures the lower 4 bits, b47 captures the higher 4 bits. + static void extractPermute(uint8_t mask, uint8_t &b03, uint8_t &b47) { + b47 = (mask & (0x0f << 4)) >> 4; + b03 = mask & 0x0f; + } +}; + +//===----------------------------------------------------------------------===// +/// Helpers extracted from: +/// - clang/lib/Headers/avxintrin.h +/// - clang/test/CodeGen/X86/avx-builtins.c +/// - clang/test/CodeGen/X86/avx2-builtins.c +/// - clang/test/CodeGen/X86/avx-shuffle-builtins.c +/// as well as the Intel Intrinsics Guide +/// (https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html) +/// make it easier to just implement known good lowerings. +/// All intrinsics correspond 1-1 to the Intel definition. +//===----------------------------------------------------------------------===// + +namespace avx2 { + +namespace inline_asm { +//===----------------------------------------------------------------------===// +/// Methods in the inline_asm namespace emit calls to LLVM::InlineAsmOp. +//===----------------------------------------------------------------------===// +/// If bit i of `mask` is zero, take f32@i from v1 else take it from v2. +Value mm256BlendPsAsm(ImplicitLocOpBuilder &b, Value v1, Value v2, + uint8_t mask); + +} // namespace inline_asm + +namespace intrin { +//===----------------------------------------------------------------------===// +/// Methods in the intrin namespace emulate clang's impl. of X86 intrinsics. +//===----------------------------------------------------------------------===// +/// Lower to vector.shuffle v1, v2, [0, 8, 1, 9, 4, 12, 5, 13]. +Value mm256UnpackLoPs(ImplicitLocOpBuilder &b, Value v1, Value v2); + +/// Lower to vector.shuffle v1, v2, [0, 8, 1, 9, 4, 12, 5, 13]. +Value mm256UnpackHiPs(ImplicitLocOpBuilder &b, Value v1, Value v2); + +/// a a b b a a b b +/// Take an 8 bit mask, 2 bit for each position of a[0, 3) **and** b[0, 4): +/// 0:127 | 128:255 +/// b01 b23 C8 D8 | b01+4 b23+4 C8+4 D8+4 +Value mm256ShufflePs(ImplicitLocOpBuilder &b, Value v1, Value v2, uint8_t mask); + +// imm[0:1] out of imm[0:3] is: +// 0 1 2 3 +// a[0:127] or a[128:255] or b[0:127] or b[128:255] | +// a[0:127] or a[128:255] or b[0:127] or b[128:255] +// 0 1 2 3 +// imm[0:1] out of imm[4:7]. +Value mm256Permute2f128Ps(ImplicitLocOpBuilder &b, Value v1, Value v2, + uint8_t mask); + +/// If bit i of `mask` is zero, take f32@i from v1 else take it from v2. +Value mm256BlendPs(ImplicitLocOpBuilder &b, Value v1, Value v2, uint8_t mask); +} // namespace intrin + +//===----------------------------------------------------------------------===// +/// Generic lowerings may either use intrin or inline_asm depending on needs. +//===----------------------------------------------------------------------===// +/// 4x8xf32-specific AVX2 transpose lowering. +void transpose4x8xf32(ImplicitLocOpBuilder &ib, MutableArrayRef vs); + +/// 8x8xf32-specific AVX2 transpose lowering. +void transpose8x8xf32(ImplicitLocOpBuilder &ib, MutableArrayRef vs); + +/// Structure to control the behavior of specialized AVX2 transpose lowering. +struct TransposeLoweringOptions { + bool lower4x8xf32_ = false; + TransposeLoweringOptions &lower4x8xf32(bool lower = true) { + lower4x8xf32_ = lower; + return *this; + } + bool lower8x8xf32_ = false; + TransposeLoweringOptions &lower8x8xf32(bool lower = true) { + lower8x8xf32_ = lower; + return *this; + } +}; + +/// Options for controlling specialized AVX2 lowerings. +struct LoweringOptions { + /// Configure specialized vector lowerings. + TransposeLoweringOptions transposeOptions; + LoweringOptions &setTransposeOptions(TransposeLoweringOptions options) { + transposeOptions = options; + return *this; + } +}; + +/// Insert specialized transpose lowering patterns. +void populateSpecializedTransposeLoweringPatterns( + RewritePatternSet &patterns, LoweringOptions options = LoweringOptions(), + int benefit = 10); + +} // namespace avx2 +} // namespace x86vector + +/// Collect a set of patterns to lower X86Vector ops to ops that map to LLVM +/// intrinsics. +void populateX86VectorLegalizeForLLVMExportPatterns( + LLVMTypeConverter &converter, RewritePatternSet &patterns); + +/// Configure the target to support lowering X86Vector ops to ops that map to +/// LLVM intrinsics. +void configureX86VectorLegalizeForExportTarget(LLVMConversionTarget &target); + +} // namespace mlir + +#endif // MLIR_DIALECT_X86VECTOR_TRANSFORMS_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/X86Vector/X86Vector.cpp.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/X86Vector/X86Vector.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..c1fd133a2f6c68b0e88f0be52af2e75755de93e0 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/X86Vector/X86Vector.cpp.inc @@ -0,0 +1,3792 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Op Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: X86Vector.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifdef GET_OP_LIST +#undef GET_OP_LIST + +::mlir::x86vector::DotIntrOp, +::mlir::x86vector::DotOp, +::mlir::x86vector::MaskCompressIntrOp, +::mlir::x86vector::MaskCompressOp, +::mlir::x86vector::MaskRndScaleOp, +::mlir::x86vector::MaskRndScalePDIntrOp, +::mlir::x86vector::MaskRndScalePSIntrOp, +::mlir::x86vector::MaskScaleFOp, +::mlir::x86vector::MaskScaleFPDIntrOp, +::mlir::x86vector::MaskScaleFPSIntrOp, +::mlir::x86vector::RsqrtIntrOp, +::mlir::x86vector::RsqrtOp, +::mlir::x86vector::Vp2IntersectDIntrOp, +::mlir::x86vector::Vp2IntersectOp, +::mlir::x86vector::Vp2IntersectQIntrOp +#endif // GET_OP_LIST + +#ifdef GET_OP_CLASSES +#undef GET_OP_CLASSES + + +//===----------------------------------------------------------------------===// +// Local Utility Method Definitions +//===----------------------------------------------------------------------===// + +namespace mlir { +namespace x86vector { + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_X86Vector0( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ([](::mlir::Type elementType) { return (elementType.isF32()); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && ((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ((::llvm::cast<::mlir::VectorType>(type).getNumElements() + == 8))))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be vector of 32-bit float values of length 8, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_X86Vector1( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((type.isSignlessInteger(8)))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be 8-bit signless integer, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_X86Vector2( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ([](::mlir::Type elementType) { return ((elementType.isF32())) || ((elementType.isSignlessInteger(32))) || ((elementType.isF64())) || ((elementType.isSignlessInteger(64))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && ((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && (((::llvm::cast<::mlir::VectorType>(type).getNumElements() + == 16)) || ((::llvm::cast<::mlir::VectorType>(type).getNumElements() + == 8)))))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be vector of 32-bit float or 32-bit signless integer or 64-bit float or 64-bit signless integer values of length 16/8, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_X86Vector3( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ([](::mlir::Type elementType) { return (elementType.isSignlessInteger(1)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && ((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && (((::llvm::cast<::mlir::VectorType>(type).getNumElements() + == 16)) || ((::llvm::cast<::mlir::VectorType>(type).getNumElements() + == 8)))))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be vector of 1-bit signless integer values of length 16/8, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_X86Vector4( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((::mlir::LLVM::isCompatibleOuterType(type)))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be LLVM dialect-compatible type, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_X86Vector5( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ([](::mlir::Type elementType) { return ((elementType.isF32())) || ((elementType.isF64())); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && ((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && (((::llvm::cast<::mlir::VectorType>(type).getNumElements() + == 16)) || ((::llvm::cast<::mlir::VectorType>(type).getNumElements() + == 8)))))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be vector of 32-bit float or 64-bit float values of length 16/8, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_X86Vector6( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((type.isSignlessInteger(32)))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be 32-bit signless integer, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_X86Vector7( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((type.isSignlessInteger(16))) || ((type.isSignlessInteger(8))))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be 16-bit signless integer or 8-bit signless integer, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_X86Vector8( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ([](::mlir::Type elementType) { return (elementType.isF64()); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && ((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ((::llvm::cast<::mlir::VectorType>(type).getNumElements() + == 8))))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be vector of 64-bit float values of length 8, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_X86Vector9( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ([](::mlir::Type elementType) { return (elementType.isF32()); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && ((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ((::llvm::cast<::mlir::VectorType>(type).getNumElements() + == 16))))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be vector of 32-bit float values of length 16, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_X86Vector10( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!((type.isSignlessInteger(16)))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be 16-bit signless integer, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_X86Vector11( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ([](::mlir::Type elementType) { return (elementType.isSignlessInteger(32)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && ((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ((::llvm::cast<::mlir::VectorType>(type).getNumElements() + == 16))))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be vector of 32-bit signless integer values of length 16, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_X86Vector12( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ([](::mlir::Type elementType) { return ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && ((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && (((::llvm::cast<::mlir::VectorType>(type).getNumElements() + == 16)) || ((::llvm::cast<::mlir::VectorType>(type).getNumElements() + == 8)))))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be vector of 32-bit signless integer or 64-bit signless integer values of length 16/8, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_type_constraint_X86Vector13( + ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind, + unsigned valueIndex) { + if (!(((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ([](::mlir::Type elementType) { return (elementType.isSignlessInteger(64)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && ((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ((::llvm::cast<::mlir::VectorType>(type).getNumElements() + == 8))))) { + return op->emitOpError(valueKind) << " #" << valueIndex + << " must be vector of 64-bit signless integer values of length 8, but got " << type; + } + return ::mlir::success(); +} + +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_X86Vector0( + ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + if (attr && !((::llvm::isa<::mlir::ElementsAttr>(attr)))) + return emitError() << "attribute '" << attrName + << "' failed to satisfy constraint: constant vector/tensor attribute"; + return ::mlir::success(); +} +static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_X86Vector0( + ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) { + return __mlir_ods_local_attr_constraint_X86Vector0(attr, attrName, [op]() { + return op->emitOpError(); + }); +} +} // namespace x86vector +} // namespace mlir +namespace mlir { +namespace x86vector { + +//===----------------------------------------------------------------------===// +// ::mlir::x86vector::DotIntrOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +DotIntrOpGenericAdaptorBase::DotIntrOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("x86vector.avx.intr.dp.ps.256", odsAttrs.getContext()); +} + +DotIntrOpGenericAdaptorBase::DotIntrOpGenericAdaptorBase(DotIntrOp op) : DotIntrOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair DotIntrOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr DotIntrOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +DotIntrOpAdaptor::DotIntrOpAdaptor(DotIntrOp op) : DotIntrOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult DotIntrOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair DotIntrOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range DotIntrOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> DotIntrOp::getA() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> DotIntrOp::getB() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(1).begin()); +} + +::mlir::TypedValue<::mlir::IntegerType> DotIntrOp::getC() { + return ::llvm::cast<::mlir::TypedValue<::mlir::IntegerType>>(*getODSOperands(2).begin()); +} + +::mlir::OpOperand &DotIntrOp::getAMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &DotIntrOp::getBMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &DotIntrOp::getCMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); +} + +std::pair DotIntrOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range DotIntrOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> DotIntrOp::getRes() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSResults(0).begin()); +} + +void DotIntrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value a, ::mlir::Value b, ::mlir::Value c) { + odsState.addOperands(a); + odsState.addOperands(b); + odsState.addOperands(c); + odsState.addTypes(res); +} + +void DotIntrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value a, ::mlir::Value b, ::mlir::Value c) { + odsState.addOperands(a); + odsState.addOperands(b); + odsState.addOperands(c); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(DotIntrOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void DotIntrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, ::mlir::Value c) { + odsState.addOperands(a); + odsState.addOperands(b); + odsState.addOperands(c); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DotIntrOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void DotIntrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(DotIntrOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult DotIntrOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector0(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((((*this->getODSOperands(0).begin()).getType()) == ((*this->getODSOperands(1).begin()).getType()) && ((*this->getODSOperands(1).begin()).getType()) == ((*this->getODSResults(0).begin()).getType()) && ((*this->getODSResults(0).begin()).getType()) == ((*this->getODSOperands(0).begin()).getType())))) + return emitOpError("failed to verify that all of {a, b, res} have same type"); + return ::mlir::success(); +} + +::mlir::LogicalResult DotIntrOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::LogicalResult DotIntrOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = operands[1].getType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +void DotIntrOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace x86vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::x86vector::DotIntrOp) + +namespace mlir { +namespace x86vector { + +//===----------------------------------------------------------------------===// +// ::mlir::x86vector::DotOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +DotOpGenericAdaptorBase::DotOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("x86vector.avx.intr.dot", odsAttrs.getContext()); +} + +DotOpGenericAdaptorBase::DotOpGenericAdaptorBase(DotOp op) : DotOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair DotOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr DotOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +DotOpAdaptor::DotOpAdaptor(DotOp op) : DotOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult DotOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair DotOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range DotOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> DotOp::getA() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> DotOp::getB() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(1).begin()); +} + +::mlir::OpOperand &DotOp::getAMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &DotOp::getBMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +std::pair DotOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range DotOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> DotOp::getRes() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSResults(0).begin()); +} + +void DotOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value a, ::mlir::Value b) { + odsState.addOperands(a); + odsState.addOperands(b); + odsState.addTypes(res); +} + +void DotOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value a, ::mlir::Value b) { + odsState.addOperands(a); + odsState.addOperands(b); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(DotOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void DotOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b) { + odsState.addOperands(a); + odsState.addOperands(b); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void DotOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void DotOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(DotOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult DotOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector0(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult DotOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::LogicalResult DotOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = operands[0].getType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult DotOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand aRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> aOperands(aRawOperands); ::llvm::SMLoc aOperandsLoc; + (void)aOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand bRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> bOperands(bRawOperands); ::llvm::SMLoc bOperandsLoc; + (void)bOperandsLoc; + ::mlir::Type resRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> resTypes(resRawTypes); + + aOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(aRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + bOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(bRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + resRawTypes[0] = type; + } + result.addTypes(resTypes); + if (parser.resolveOperands(aOperands, resTypes[0], aOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(bOperands, resTypes[0], bOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void DotOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getA(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getB(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getRes().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void DotOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace x86vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::x86vector::DotOp) + +namespace mlir { +namespace x86vector { + +//===----------------------------------------------------------------------===// +// ::mlir::x86vector::MaskCompressIntrOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +MaskCompressIntrOpGenericAdaptorBase::MaskCompressIntrOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("x86vector.avx512.intr.mask.compress", odsAttrs.getContext()); +} + +MaskCompressIntrOpGenericAdaptorBase::MaskCompressIntrOpGenericAdaptorBase(MaskCompressIntrOp op) : MaskCompressIntrOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair MaskCompressIntrOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr MaskCompressIntrOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +MaskCompressIntrOpAdaptor::MaskCompressIntrOpAdaptor(MaskCompressIntrOp op) : MaskCompressIntrOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult MaskCompressIntrOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair MaskCompressIntrOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range MaskCompressIntrOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> MaskCompressIntrOp::getA() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> MaskCompressIntrOp::getSrc() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(1).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> MaskCompressIntrOp::getK() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(2).begin()); +} + +::mlir::OpOperand &MaskCompressIntrOp::getAMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MaskCompressIntrOp::getSrcMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MaskCompressIntrOp::getKMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); +} + +std::pair MaskCompressIntrOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range MaskCompressIntrOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value MaskCompressIntrOp::getRes() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +void MaskCompressIntrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value a, ::mlir::Value src, ::mlir::Value k) { + odsState.addOperands(a); + odsState.addOperands(src); + odsState.addOperands(k); + odsState.addTypes(res); +} + +void MaskCompressIntrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value a, ::mlir::Value src, ::mlir::Value k) { + odsState.addOperands(a); + odsState.addOperands(src); + odsState.addOperands(k); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MaskCompressIntrOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void MaskCompressIntrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value src, ::mlir::Value k) { + odsState.addOperands(a); + odsState.addOperands(src); + odsState.addOperands(k); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void MaskCompressIntrOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void MaskCompressIntrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 3u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MaskCompressIntrOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult MaskCompressIntrOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector4(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((((*this->getODSOperands(0).begin()).getType()) == ((*this->getODSOperands(1).begin()).getType()) && ((*this->getODSOperands(1).begin()).getType()) == ((*this->getODSResults(0).begin()).getType()) && ((*this->getODSResults(0).begin()).getType()) == ((*this->getODSOperands(0).begin()).getType())))) + return emitOpError("failed to verify that all of {a, src, res} have same type"); + if (!((std::equal_to<>()(VectorType::get({::llvm::cast((*this->getODSResults(0).begin()).getType()).getShape()[0]}, IntegerType::get((*this->getODSResults(0).begin()).getType().getContext(), 1)), (*this->getODSOperands(2).begin()).getType())))) + return emitOpError("failed to verify that `k` has the same number of bits as elements in `res`"); + return ::mlir::success(); +} + +::mlir::LogicalResult MaskCompressIntrOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::LogicalResult MaskCompressIntrOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = operands[1].getType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +void MaskCompressIntrOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace x86vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::x86vector::MaskCompressIntrOp) + +namespace mlir { +namespace x86vector { + +//===----------------------------------------------------------------------===// +// ::mlir::x86vector::MaskCompressOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +MaskCompressOpGenericAdaptorBase::MaskCompressOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("x86vector.avx512.mask.compress", odsAttrs.getContext()); +} + +MaskCompressOpGenericAdaptorBase::MaskCompressOpGenericAdaptorBase(MaskCompressOp op) : MaskCompressOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair MaskCompressOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + bool isVariadic[] = {false, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (odsOperandsSize - 2) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::DictionaryAttr MaskCompressOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +::mlir::ElementsAttr MaskCompressOpGenericAdaptorBase::getConstantSrcAttr() { + auto attr = ::llvm::dyn_cast_or_null<::mlir::ElementsAttr>(getProperties().constant_src); + return attr; +} + +::std::optional< ::mlir::ElementsAttr > MaskCompressOpGenericAdaptorBase::getConstantSrc() { + auto attr = getConstantSrcAttr(); + return attr ? ::std::optional< ::mlir::ElementsAttr >(attr) : (::std::nullopt); +} + +} // namespace detail +MaskCompressOpAdaptor::MaskCompressOpAdaptor(MaskCompressOp op) : MaskCompressOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult MaskCompressOpAdaptor::verify(::mlir::Location loc) { + auto tblgen_constant_src = getProperties().constant_src; (void)tblgen_constant_src; + + if (tblgen_constant_src && !((::llvm::isa<::mlir::ElementsAttr>(tblgen_constant_src)))) + return emitError(loc, "'x86vector.avx512.mask.compress' op ""attribute 'constant_src' failed to satisfy constraint: constant vector/tensor attribute"); + return ::mlir::success(); +} + +std::pair MaskCompressOp::getODSOperandIndexAndLength(unsigned index) { + bool isVariadic[] = {false, false, true}; + int prevVariadicCount = 0; + for (unsigned i = 0; i < index; ++i) + if (isVariadic[i]) ++prevVariadicCount; + + // Calculate how many dynamic values a static variadic operand corresponds to. + // This assumes all static variadic operands have the same dynamic value count. + int variadicSize = (getOperation()->getNumOperands() - 2) / 1; + // `index` passed in as the parameter is the static index which counts each + // operand (variadic or not) as size 1. So here for each previous static variadic + // operand, we need to offset by (variadicSize - 1) to get where the dynamic + // value pack for this static operand starts. + int start = index + (variadicSize - 1) * prevVariadicCount; + int size = isVariadic[index] ? variadicSize : 1; + return {start, size}; +} + +::mlir::Operation::operand_range MaskCompressOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> MaskCompressOp::getK() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> MaskCompressOp::getA() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(1).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> MaskCompressOp::getSrc() { + auto operands = getODSOperands(2); + return operands.empty() ? ::mlir::TypedValue<::mlir::VectorType>{} : ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*operands.begin()); +} + +::mlir::OpOperand &MaskCompressOp::getKMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MaskCompressOp::getAMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +::mlir::MutableOperandRange MaskCompressOp::getSrcMutable() { + auto range = getODSOperandIndexAndLength(2); + auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second); + return mutableRange; +} + +std::pair MaskCompressOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range MaskCompressOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> MaskCompressOp::getDst() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSResults(0).begin()); +} + +::mlir::LogicalResult MaskCompressOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr); + if (!dict) { + emitError() << "expected DictionaryAttr to set properties"; + return ::mlir::failure(); + } + + { + auto &propStorage = prop.constant_src; + auto attr = dict.get("constant_src"); + if (attr || /*isRequired=*/false) { + if (!attr) { + emitError() << "expected key entry for constant_src in DictionaryAttr to set " + "Properties."; + return ::mlir::failure(); + } + auto convertedAttr = ::llvm::dyn_cast>(attr); + if (convertedAttr) { + propStorage = convertedAttr; + } else { + emitError() << "Invalid attribute `constant_src` in property conversion: " << attr; + return ::mlir::failure(); + } + } + } + return ::mlir::success(); +} + +::mlir::Attribute MaskCompressOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) { + ::mlir::SmallVector<::mlir::NamedAttribute> attrs; + ::mlir::Builder odsBuilder{ctx}; + + { + const auto &propStorage = prop.constant_src; + if (propStorage) + attrs.push_back(odsBuilder.getNamedAttr("constant_src", + propStorage)); + } + + if (!attrs.empty()) + return odsBuilder.getDictionaryAttr(attrs); + return {}; +} + +llvm::hash_code MaskCompressOp::computePropertiesHash(const Properties &prop) { + return llvm::hash_combine( + llvm::hash_value(prop.constant_src.getAsOpaquePointer())); +} + +std::optional MaskCompressOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) { + if (name == "constant_src") + return prop.constant_src; + return std::nullopt; +} + +void MaskCompressOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) { + if (name == "constant_src") { + prop.constant_src = ::llvm::dyn_cast_or_null>(value); + return; + } +} + +void MaskCompressOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) { + if (prop.constant_src) attrs.append("constant_src", prop.constant_src); +} + +::mlir::LogicalResult MaskCompressOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) { + { + ::mlir::Attribute attr = attrs.get(getConstantSrcAttrName(opName)); + if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_X86Vector0(attr, "constant_src", emitError))) + return ::mlir::failure(); + } + return ::mlir::success(); +} + +::mlir::LogicalResult MaskCompressOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) { + auto &prop = state.getOrAddProperties(); (void)prop; + if (::mlir::failed(reader.readOptionalAttribute(prop.constant_src))) + return ::mlir::failure(); + return ::mlir::success(); +} + +void MaskCompressOp::writeProperties(::mlir::DialectBytecodeWriter &writer) { + auto &prop = getProperties(); (void)prop; + + writer.writeOptionalAttribute(prop.constant_src); +} + +::mlir::ElementsAttr MaskCompressOp::getConstantSrcAttr() { + return ::llvm::dyn_cast_or_null<::mlir::ElementsAttr>(getProperties().constant_src); +} + +::std::optional< ::mlir::ElementsAttr > MaskCompressOp::getConstantSrc() { + auto attr = getConstantSrcAttr(); + return attr ? ::std::optional< ::mlir::ElementsAttr >(attr) : (::std::nullopt); +} + +void MaskCompressOp::setConstantSrcAttr(::mlir::ElementsAttr attr) { + (*this)->setAttr(getConstantSrcAttrName(), attr); +} + +::mlir::Attribute MaskCompressOp::removeConstantSrcAttr() { + auto &attr = getProperties().constant_src; + attr = {}; + return attr; +} + +void MaskCompressOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value k, ::mlir::Value a, /*optional*/::mlir::Value src, /*optional*/::mlir::ElementsAttr constant_src) { + odsState.addOperands(k); + odsState.addOperands(a); + if (src) + odsState.addOperands(src); + if (constant_src) { + odsState.getOrAddProperties().constant_src = constant_src; + } + odsState.addTypes(dst); +} + +void MaskCompressOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value k, ::mlir::Value a, /*optional*/::mlir::Value src, /*optional*/::mlir::ElementsAttr constant_src) { + odsState.addOperands(k); + odsState.addOperands(a); + if (src) + odsState.addOperands(src); + if (constant_src) { + odsState.getOrAddProperties().constant_src = constant_src; + } + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MaskCompressOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void MaskCompressOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value k, ::mlir::Value a, /*optional*/::mlir::Value src, /*optional*/::mlir::ElementsAttr constant_src) { + odsState.addOperands(k); + odsState.addOperands(a); + if (src) + odsState.addOperands(src); + if (constant_src) { + odsState.getOrAddProperties().constant_src = constant_src; + } + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void MaskCompressOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void MaskCompressOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() >= 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MaskCompressOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult MaskCompressOp::verifyInvariantsImpl() { + auto tblgen_constant_src = getProperties().constant_src; (void)tblgen_constant_src; + + if (::mlir::failed(__mlir_ods_local_attr_constraint_X86Vector0(*this, tblgen_constant_src, "constant_src"))) + return ::mlir::failure(); + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector3(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + if (valueGroup2.size() > 1) { + return emitOpError("operand group starting at #") << index + << " requires 0 or 1 element, but found " << valueGroup2.size(); + } + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector2(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector2(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((((*this->getODSOperands(1).begin()).getType()) == ((*this->getODSResults(0).begin()).getType()) && ((*this->getODSResults(0).begin()).getType()) == ((*this->getODSOperands(1).begin()).getType())))) + return emitOpError("failed to verify that all of {a, dst} have same type"); + if (!((std::equal_to<>()(VectorType::get({::llvm::cast((*this->getODSResults(0).begin()).getType()).getShape()[0]}, IntegerType::get((*this->getODSResults(0).begin()).getType().getContext(), 1)), (*this->getODSOperands(0).begin()).getType())))) + return emitOpError("failed to verify that `k` has the same number of bits as elements in `dst`"); + return ::mlir::success(); +} + +::mlir::LogicalResult MaskCompressOp::verifyInvariants() { + if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify())) + return ::mlir::success(); + return ::mlir::failure(); +} + +::mlir::LogicalResult MaskCompressOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = operands[1].getType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult MaskCompressOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand kRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> kOperands(kRawOperands); ::llvm::SMLoc kOperandsLoc; + (void)kOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand aRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> aOperands(aRawOperands); ::llvm::SMLoc aOperandsLoc; + (void)aOperandsLoc; + ::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> srcOperands; + ::llvm::SMLoc srcOperandsLoc; + (void)srcOperandsLoc; + ::mlir::Type dstRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> dstTypes(dstRawTypes); + ::llvm::SmallVector<::mlir::Type, 1> srcTypes; + + kOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(kRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + aOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(aRawOperands[0])) + return ::mlir::failure(); + if (::mlir::succeeded(parser.parseOptionalComma())) { + + { + srcOperandsLoc = parser.getCurrentLocation(); + ::mlir::OpAsmParser::UnresolvedOperand operand; + ::mlir::OptionalParseResult parseResult = + parser.parseOptionalOperand(operand); + if (parseResult.has_value()) { + if (failed(*parseResult)) + return ::mlir::failure(); + srcOperands.push_back(operand); + } + } + } + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() { + return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op "; + }))) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + dstRawTypes[0] = type; + } + if (::mlir::succeeded(parser.parseOptionalComma())) { + + { + ::mlir::Type optionalType; + ::mlir::OptionalParseResult parseResult = + parser.parseOptionalType(optionalType); + if (parseResult.has_value()) { + if (failed(*parseResult)) + return ::mlir::failure(); + srcTypes.push_back(optionalType); + } + } + } + for (::mlir::Type type : dstTypes) { + (void)type; + if (!(((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ([](::mlir::Type elementType) { return ((elementType.isF32())) || ((elementType.isSignlessInteger(32))) || ((elementType.isF64())) || ((elementType.isSignlessInteger(64))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && ((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && (((::llvm::cast<::mlir::VectorType>(type).getNumElements() + == 16)) || ((::llvm::cast<::mlir::VectorType>(type).getNumElements() + == 8)))))) { + return parser.emitError(parser.getNameLoc()) << "'dst' must be vector of 32-bit float or 32-bit signless integer or 64-bit float or 64-bit signless integer values of length 16/8, but got " << type; + } + } + result.addTypes(dstTypes); + if (parser.resolveOperands(kOperands, VectorType::get({::llvm::cast(dstTypes[0]).getShape()[0]}, IntegerType::get(dstTypes[0].getContext(), 1)), kOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(aOperands, dstTypes[0], aOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(srcOperands, srcTypes, srcOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void MaskCompressOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getK(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getA(); + if (getSrc()) { + _odsPrinter << ","; + _odsPrinter << ' '; + if (::mlir::Value value = getSrc()) + _odsPrinter << value; + } + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getDst().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } + if (getSrc()) { + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << (getSrc() ? ::llvm::ArrayRef<::mlir::Type>(getSrc().getType()) : ::llvm::ArrayRef<::mlir::Type>()); + } +} + +void MaskCompressOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace x86vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::x86vector::MaskCompressOp) + +namespace mlir { +namespace x86vector { + +//===----------------------------------------------------------------------===// +// ::mlir::x86vector::MaskRndScaleOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +MaskRndScaleOpGenericAdaptorBase::MaskRndScaleOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("x86vector.avx512.mask.rndscale", odsAttrs.getContext()); +} + +MaskRndScaleOpGenericAdaptorBase::MaskRndScaleOpGenericAdaptorBase(MaskRndScaleOp op) : MaskRndScaleOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair MaskRndScaleOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr MaskRndScaleOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +MaskRndScaleOpAdaptor::MaskRndScaleOpAdaptor(MaskRndScaleOp op) : MaskRndScaleOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult MaskRndScaleOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair MaskRndScaleOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range MaskRndScaleOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> MaskRndScaleOp::getSrc() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::IntegerType> MaskRndScaleOp::getK() { + return ::llvm::cast<::mlir::TypedValue<::mlir::IntegerType>>(*getODSOperands(1).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> MaskRndScaleOp::getA() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(2).begin()); +} + +::mlir::Value MaskRndScaleOp::getImm() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(3).begin()); +} + +::mlir::TypedValue<::mlir::IntegerType> MaskRndScaleOp::getRounding() { + return ::llvm::cast<::mlir::TypedValue<::mlir::IntegerType>>(*getODSOperands(4).begin()); +} + +::mlir::OpOperand &MaskRndScaleOp::getSrcMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MaskRndScaleOp::getKMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MaskRndScaleOp::getAMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MaskRndScaleOp::getImmMutable() { + auto range = getODSOperandIndexAndLength(3); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MaskRndScaleOp::getRoundingMutable() { + auto range = getODSOperandIndexAndLength(4); + return getOperation()->getOpOperand(range.first); +} + +std::pair MaskRndScaleOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range MaskRndScaleOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> MaskRndScaleOp::getDst() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSResults(0).begin()); +} + +void MaskRndScaleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, ::mlir::Value k, ::mlir::Value a, ::mlir::Value imm, ::mlir::Value rounding) { + odsState.addOperands(src); + odsState.addOperands(k); + odsState.addOperands(a); + odsState.addOperands(imm); + odsState.addOperands(rounding); + odsState.addTypes(dst); +} + +void MaskRndScaleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, ::mlir::Value k, ::mlir::Value a, ::mlir::Value imm, ::mlir::Value rounding) { + odsState.addOperands(src); + odsState.addOperands(k); + odsState.addOperands(a); + odsState.addOperands(imm); + odsState.addOperands(rounding); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MaskRndScaleOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void MaskRndScaleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Value k, ::mlir::Value a, ::mlir::Value imm, ::mlir::Value rounding) { + odsState.addOperands(src); + odsState.addOperands(k); + odsState.addOperands(a); + odsState.addOperands(imm); + odsState.addOperands(rounding); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void MaskRndScaleOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 5u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void MaskRndScaleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 5u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MaskRndScaleOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult MaskRndScaleOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector5(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector5(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup3 = getODSOperands(3); + + for (auto v : valueGroup3) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector7(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup4 = getODSOperands(4); + + for (auto v : valueGroup4) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector5(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((((*this->getODSOperands(0).begin()).getType()) == ((*this->getODSOperands(2).begin()).getType()) && ((*this->getODSOperands(2).begin()).getType()) == ((*this->getODSResults(0).begin()).getType()) && ((*this->getODSResults(0).begin()).getType()) == ((*this->getODSOperands(0).begin()).getType())))) + return emitOpError("failed to verify that all of {src, a, dst} have same type"); + if (!((std::equal_to<>()(IntegerType::get((*this->getODSResults(0).begin()).getType().getContext(), (::llvm::cast((*this->getODSResults(0).begin()).getType()).getShape()[0])), (*this->getODSOperands(3).begin()).getType())))) + return emitOpError("failed to verify that imm has the same number of bits as elements in dst"); + return ::mlir::success(); +} + +::mlir::LogicalResult MaskRndScaleOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::LogicalResult MaskRndScaleOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = operands[2].getType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult MaskRndScaleOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand srcRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcOperands(srcRawOperands); ::llvm::SMLoc srcOperandsLoc; + (void)srcOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand kRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> kOperands(kRawOperands); ::llvm::SMLoc kOperandsLoc; + (void)kOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand aRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> aOperands(aRawOperands); ::llvm::SMLoc aOperandsLoc; + (void)aOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand immRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> immOperands(immRawOperands); ::llvm::SMLoc immOperandsLoc; + (void)immOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand roundingRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> roundingOperands(roundingRawOperands); ::llvm::SMLoc roundingOperandsLoc; + (void)roundingOperandsLoc; + ::mlir::Type dstRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> dstTypes(dstRawTypes); + + srcOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(srcRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + kOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(kRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + aOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(aRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + immOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(immRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + roundingOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(roundingRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + dstRawTypes[0] = type; + } + for (::mlir::Type type : dstTypes) { + (void)type; + if (!(((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ([](::mlir::Type elementType) { return ((elementType.isF32())) || ((elementType.isF64())); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && ((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && (((::llvm::cast<::mlir::VectorType>(type).getNumElements() + == 16)) || ((::llvm::cast<::mlir::VectorType>(type).getNumElements() + == 8)))))) { + return parser.emitError(parser.getNameLoc()) << "'dst' must be vector of 32-bit float or 64-bit float values of length 16/8, but got " << type; + } + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(32); + result.addTypes(dstTypes); + if (parser.resolveOperands(srcOperands, dstTypes[0], srcOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(kOperands, odsBuildableType0, kOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(aOperands, dstTypes[0], aOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(immOperands, IntegerType::get(dstTypes[0].getContext(), (::llvm::cast(dstTypes[0]).getShape()[0])), immOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(roundingOperands, odsBuildableType0, roundingOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void MaskRndScaleOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getSrc(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getK(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getA(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getImm(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRounding(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getDst().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void MaskRndScaleOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace x86vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::x86vector::MaskRndScaleOp) + +namespace mlir { +namespace x86vector { + +//===----------------------------------------------------------------------===// +// ::mlir::x86vector::MaskRndScalePDIntrOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +MaskRndScalePDIntrOpGenericAdaptorBase::MaskRndScalePDIntrOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("x86vector.avx512.intr.mask.rndscale.pd.512", odsAttrs.getContext()); +} + +MaskRndScalePDIntrOpGenericAdaptorBase::MaskRndScalePDIntrOpGenericAdaptorBase(MaskRndScalePDIntrOp op) : MaskRndScalePDIntrOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair MaskRndScalePDIntrOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr MaskRndScalePDIntrOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +MaskRndScalePDIntrOpAdaptor::MaskRndScalePDIntrOpAdaptor(MaskRndScalePDIntrOp op) : MaskRndScalePDIntrOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult MaskRndScalePDIntrOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair MaskRndScalePDIntrOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range MaskRndScalePDIntrOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> MaskRndScalePDIntrOp::getSrc() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::IntegerType> MaskRndScalePDIntrOp::getK() { + return ::llvm::cast<::mlir::TypedValue<::mlir::IntegerType>>(*getODSOperands(1).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> MaskRndScalePDIntrOp::getA() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(2).begin()); +} + +::mlir::TypedValue<::mlir::IntegerType> MaskRndScalePDIntrOp::getImm() { + return ::llvm::cast<::mlir::TypedValue<::mlir::IntegerType>>(*getODSOperands(3).begin()); +} + +::mlir::Value MaskRndScalePDIntrOp::getRounding() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(4).begin()); +} + +::mlir::OpOperand &MaskRndScalePDIntrOp::getSrcMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MaskRndScalePDIntrOp::getKMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MaskRndScalePDIntrOp::getAMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MaskRndScalePDIntrOp::getImmMutable() { + auto range = getODSOperandIndexAndLength(3); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MaskRndScalePDIntrOp::getRoundingMutable() { + auto range = getODSOperandIndexAndLength(4); + return getOperation()->getOpOperand(range.first); +} + +std::pair MaskRndScalePDIntrOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range MaskRndScalePDIntrOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value MaskRndScalePDIntrOp::getRes() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +void MaskRndScalePDIntrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value src, ::mlir::Value k, ::mlir::Value a, ::mlir::Value imm, ::mlir::Value rounding) { + odsState.addOperands(src); + odsState.addOperands(k); + odsState.addOperands(a); + odsState.addOperands(imm); + odsState.addOperands(rounding); + odsState.addTypes(res); +} + +void MaskRndScalePDIntrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, ::mlir::Value k, ::mlir::Value a, ::mlir::Value imm, ::mlir::Value rounding) { + odsState.addOperands(src); + odsState.addOperands(k); + odsState.addOperands(a); + odsState.addOperands(imm); + odsState.addOperands(rounding); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MaskRndScalePDIntrOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void MaskRndScalePDIntrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Value k, ::mlir::Value a, ::mlir::Value imm, ::mlir::Value rounding) { + odsState.addOperands(src); + odsState.addOperands(k); + odsState.addOperands(a); + odsState.addOperands(imm); + odsState.addOperands(rounding); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void MaskRndScalePDIntrOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 5u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void MaskRndScalePDIntrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 5u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MaskRndScalePDIntrOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult MaskRndScalePDIntrOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup3 = getODSOperands(3); + + for (auto v : valueGroup3) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup4 = getODSOperands(4); + + for (auto v : valueGroup4) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector4(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector4(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((((*this->getODSOperands(0).begin()).getType()) == ((*this->getODSOperands(2).begin()).getType()) && ((*this->getODSOperands(2).begin()).getType()) == ((*this->getODSResults(0).begin()).getType()) && ((*this->getODSResults(0).begin()).getType()) == ((*this->getODSOperands(0).begin()).getType())))) + return emitOpError("failed to verify that all of {src, a, res} have same type"); + return ::mlir::success(); +} + +::mlir::LogicalResult MaskRndScalePDIntrOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::LogicalResult MaskRndScalePDIntrOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = operands[2].getType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +void MaskRndScalePDIntrOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace x86vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::x86vector::MaskRndScalePDIntrOp) + +namespace mlir { +namespace x86vector { + +//===----------------------------------------------------------------------===// +// ::mlir::x86vector::MaskRndScalePSIntrOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +MaskRndScalePSIntrOpGenericAdaptorBase::MaskRndScalePSIntrOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("x86vector.avx512.intr.mask.rndscale.ps.512", odsAttrs.getContext()); +} + +MaskRndScalePSIntrOpGenericAdaptorBase::MaskRndScalePSIntrOpGenericAdaptorBase(MaskRndScalePSIntrOp op) : MaskRndScalePSIntrOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair MaskRndScalePSIntrOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr MaskRndScalePSIntrOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +MaskRndScalePSIntrOpAdaptor::MaskRndScalePSIntrOpAdaptor(MaskRndScalePSIntrOp op) : MaskRndScalePSIntrOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult MaskRndScalePSIntrOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair MaskRndScalePSIntrOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range MaskRndScalePSIntrOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> MaskRndScalePSIntrOp::getSrc() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::IntegerType> MaskRndScalePSIntrOp::getK() { + return ::llvm::cast<::mlir::TypedValue<::mlir::IntegerType>>(*getODSOperands(1).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> MaskRndScalePSIntrOp::getA() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(2).begin()); +} + +::mlir::TypedValue<::mlir::IntegerType> MaskRndScalePSIntrOp::getImm() { + return ::llvm::cast<::mlir::TypedValue<::mlir::IntegerType>>(*getODSOperands(3).begin()); +} + +::mlir::Value MaskRndScalePSIntrOp::getRounding() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(4).begin()); +} + +::mlir::OpOperand &MaskRndScalePSIntrOp::getSrcMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MaskRndScalePSIntrOp::getKMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MaskRndScalePSIntrOp::getAMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MaskRndScalePSIntrOp::getImmMutable() { + auto range = getODSOperandIndexAndLength(3); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MaskRndScalePSIntrOp::getRoundingMutable() { + auto range = getODSOperandIndexAndLength(4); + return getOperation()->getOpOperand(range.first); +} + +std::pair MaskRndScalePSIntrOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range MaskRndScalePSIntrOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value MaskRndScalePSIntrOp::getRes() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +void MaskRndScalePSIntrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value src, ::mlir::Value k, ::mlir::Value a, ::mlir::Value imm, ::mlir::Value rounding) { + odsState.addOperands(src); + odsState.addOperands(k); + odsState.addOperands(a); + odsState.addOperands(imm); + odsState.addOperands(rounding); + odsState.addTypes(res); +} + +void MaskRndScalePSIntrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, ::mlir::Value k, ::mlir::Value a, ::mlir::Value imm, ::mlir::Value rounding) { + odsState.addOperands(src); + odsState.addOperands(k); + odsState.addOperands(a); + odsState.addOperands(imm); + odsState.addOperands(rounding); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MaskRndScalePSIntrOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void MaskRndScalePSIntrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Value k, ::mlir::Value a, ::mlir::Value imm, ::mlir::Value rounding) { + odsState.addOperands(src); + odsState.addOperands(k); + odsState.addOperands(a); + odsState.addOperands(imm); + odsState.addOperands(rounding); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void MaskRndScalePSIntrOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 5u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void MaskRndScalePSIntrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 5u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MaskRndScalePSIntrOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult MaskRndScalePSIntrOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector9(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector9(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup3 = getODSOperands(3); + + for (auto v : valueGroup3) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector10(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup4 = getODSOperands(4); + + for (auto v : valueGroup4) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector4(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector4(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((((*this->getODSOperands(0).begin()).getType()) == ((*this->getODSOperands(2).begin()).getType()) && ((*this->getODSOperands(2).begin()).getType()) == ((*this->getODSResults(0).begin()).getType()) && ((*this->getODSResults(0).begin()).getType()) == ((*this->getODSOperands(0).begin()).getType())))) + return emitOpError("failed to verify that all of {src, a, res} have same type"); + return ::mlir::success(); +} + +::mlir::LogicalResult MaskRndScalePSIntrOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::LogicalResult MaskRndScalePSIntrOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = operands[2].getType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +void MaskRndScalePSIntrOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace x86vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::x86vector::MaskRndScalePSIntrOp) + +namespace mlir { +namespace x86vector { + +//===----------------------------------------------------------------------===// +// ::mlir::x86vector::MaskScaleFOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +MaskScaleFOpGenericAdaptorBase::MaskScaleFOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("x86vector.avx512.mask.scalef", odsAttrs.getContext()); +} + +MaskScaleFOpGenericAdaptorBase::MaskScaleFOpGenericAdaptorBase(MaskScaleFOp op) : MaskScaleFOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair MaskScaleFOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr MaskScaleFOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +MaskScaleFOpAdaptor::MaskScaleFOpAdaptor(MaskScaleFOp op) : MaskScaleFOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult MaskScaleFOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair MaskScaleFOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range MaskScaleFOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> MaskScaleFOp::getSrc() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> MaskScaleFOp::getA() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(1).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> MaskScaleFOp::getB() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(2).begin()); +} + +::mlir::Value MaskScaleFOp::getK() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(3).begin()); +} + +::mlir::TypedValue<::mlir::IntegerType> MaskScaleFOp::getRounding() { + return ::llvm::cast<::mlir::TypedValue<::mlir::IntegerType>>(*getODSOperands(4).begin()); +} + +::mlir::OpOperand &MaskScaleFOp::getSrcMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MaskScaleFOp::getAMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MaskScaleFOp::getBMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MaskScaleFOp::getKMutable() { + auto range = getODSOperandIndexAndLength(3); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MaskScaleFOp::getRoundingMutable() { + auto range = getODSOperandIndexAndLength(4); + return getOperation()->getOpOperand(range.first); +} + +std::pair MaskScaleFOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range MaskScaleFOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> MaskScaleFOp::getDst() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSResults(0).begin()); +} + +void MaskScaleFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, ::mlir::Value a, ::mlir::Value b, ::mlir::Value k, ::mlir::Value rounding) { + odsState.addOperands(src); + odsState.addOperands(a); + odsState.addOperands(b); + odsState.addOperands(k); + odsState.addOperands(rounding); + odsState.addTypes(dst); +} + +void MaskScaleFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, ::mlir::Value a, ::mlir::Value b, ::mlir::Value k, ::mlir::Value rounding) { + odsState.addOperands(src); + odsState.addOperands(a); + odsState.addOperands(b); + odsState.addOperands(k); + odsState.addOperands(rounding); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MaskScaleFOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void MaskScaleFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Value a, ::mlir::Value b, ::mlir::Value k, ::mlir::Value rounding) { + odsState.addOperands(src); + odsState.addOperands(a); + odsState.addOperands(b); + odsState.addOperands(k); + odsState.addOperands(rounding); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void MaskScaleFOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 5u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void MaskScaleFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 5u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MaskScaleFOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult MaskScaleFOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector5(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector5(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector5(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup3 = getODSOperands(3); + + for (auto v : valueGroup3) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector7(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup4 = getODSOperands(4); + + for (auto v : valueGroup4) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector6(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector5(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((((*this->getODSOperands(0).begin()).getType()) == ((*this->getODSOperands(1).begin()).getType()) && ((*this->getODSOperands(1).begin()).getType()) == ((*this->getODSOperands(2).begin()).getType()) && ((*this->getODSOperands(2).begin()).getType()) == ((*this->getODSResults(0).begin()).getType()) && ((*this->getODSResults(0).begin()).getType()) == ((*this->getODSOperands(0).begin()).getType())))) + return emitOpError("failed to verify that all of {src, a, b, dst} have same type"); + if (!((std::equal_to<>()(IntegerType::get((*this->getODSResults(0).begin()).getType().getContext(), (::llvm::cast((*this->getODSResults(0).begin()).getType()).getShape()[0])), (*this->getODSOperands(3).begin()).getType())))) + return emitOpError("failed to verify that k has the same number of bits as elements in dst"); + return ::mlir::success(); +} + +::mlir::LogicalResult MaskScaleFOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::LogicalResult MaskScaleFOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = operands[2].getType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult MaskScaleFOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand srcRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> srcOperands(srcRawOperands); ::llvm::SMLoc srcOperandsLoc; + (void)srcOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand aRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> aOperands(aRawOperands); ::llvm::SMLoc aOperandsLoc; + (void)aOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand bRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> bOperands(bRawOperands); ::llvm::SMLoc bOperandsLoc; + (void)bOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand kRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> kOperands(kRawOperands); ::llvm::SMLoc kOperandsLoc; + (void)kOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand roundingRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> roundingOperands(roundingRawOperands); ::llvm::SMLoc roundingOperandsLoc; + (void)roundingOperandsLoc; + ::mlir::Type dstRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> dstTypes(dstRawTypes); + + srcOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(srcRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + aOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(aRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + bOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(bRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + kOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(kRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + roundingOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(roundingRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + dstRawTypes[0] = type; + } + for (::mlir::Type type : dstTypes) { + (void)type; + if (!(((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ([](::mlir::Type elementType) { return ((elementType.isF32())) || ((elementType.isF64())); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && ((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && (((::llvm::cast<::mlir::VectorType>(type).getNumElements() + == 16)) || ((::llvm::cast<::mlir::VectorType>(type).getNumElements() + == 8)))))) { + return parser.emitError(parser.getNameLoc()) << "'dst' must be vector of 32-bit float or 64-bit float values of length 16/8, but got " << type; + } + } + ::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(32); + result.addTypes(dstTypes); + if (parser.resolveOperands(srcOperands, dstTypes[0], srcOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(aOperands, dstTypes[0], aOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(bOperands, dstTypes[0], bOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(kOperands, IntegerType::get(dstTypes[0].getContext(), (::llvm::cast(dstTypes[0]).getShape()[0])), kOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(roundingOperands, odsBuildableType0, roundingOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void MaskScaleFOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getSrc(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getA(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getB(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getK(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getRounding(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getDst().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void MaskScaleFOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace x86vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::x86vector::MaskScaleFOp) + +namespace mlir { +namespace x86vector { + +//===----------------------------------------------------------------------===// +// ::mlir::x86vector::MaskScaleFPDIntrOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +MaskScaleFPDIntrOpGenericAdaptorBase::MaskScaleFPDIntrOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("x86vector.avx512.intr.mask.scalef.pd.512", odsAttrs.getContext()); +} + +MaskScaleFPDIntrOpGenericAdaptorBase::MaskScaleFPDIntrOpGenericAdaptorBase(MaskScaleFPDIntrOp op) : MaskScaleFPDIntrOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair MaskScaleFPDIntrOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr MaskScaleFPDIntrOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +MaskScaleFPDIntrOpAdaptor::MaskScaleFPDIntrOpAdaptor(MaskScaleFPDIntrOp op) : MaskScaleFPDIntrOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult MaskScaleFPDIntrOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair MaskScaleFPDIntrOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range MaskScaleFPDIntrOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> MaskScaleFPDIntrOp::getSrc() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> MaskScaleFPDIntrOp::getA() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(1).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> MaskScaleFPDIntrOp::getB() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(2).begin()); +} + +::mlir::TypedValue<::mlir::IntegerType> MaskScaleFPDIntrOp::getK() { + return ::llvm::cast<::mlir::TypedValue<::mlir::IntegerType>>(*getODSOperands(3).begin()); +} + +::mlir::Value MaskScaleFPDIntrOp::getRounding() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(4).begin()); +} + +::mlir::OpOperand &MaskScaleFPDIntrOp::getSrcMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MaskScaleFPDIntrOp::getAMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MaskScaleFPDIntrOp::getBMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MaskScaleFPDIntrOp::getKMutable() { + auto range = getODSOperandIndexAndLength(3); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MaskScaleFPDIntrOp::getRoundingMutable() { + auto range = getODSOperandIndexAndLength(4); + return getOperation()->getOpOperand(range.first); +} + +std::pair MaskScaleFPDIntrOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range MaskScaleFPDIntrOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value MaskScaleFPDIntrOp::getRes() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +void MaskScaleFPDIntrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value src, ::mlir::Value a, ::mlir::Value b, ::mlir::Value k, ::mlir::Value rounding) { + odsState.addOperands(src); + odsState.addOperands(a); + odsState.addOperands(b); + odsState.addOperands(k); + odsState.addOperands(rounding); + odsState.addTypes(res); +} + +void MaskScaleFPDIntrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, ::mlir::Value a, ::mlir::Value b, ::mlir::Value k, ::mlir::Value rounding) { + odsState.addOperands(src); + odsState.addOperands(a); + odsState.addOperands(b); + odsState.addOperands(k); + odsState.addOperands(rounding); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MaskScaleFPDIntrOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void MaskScaleFPDIntrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Value a, ::mlir::Value b, ::mlir::Value k, ::mlir::Value rounding) { + odsState.addOperands(src); + odsState.addOperands(a); + odsState.addOperands(b); + odsState.addOperands(k); + odsState.addOperands(rounding); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void MaskScaleFPDIntrOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 5u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void MaskScaleFPDIntrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 5u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MaskScaleFPDIntrOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult MaskScaleFPDIntrOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector8(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup3 = getODSOperands(3); + + for (auto v : valueGroup3) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector1(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup4 = getODSOperands(4); + + for (auto v : valueGroup4) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector4(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector4(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((((*this->getODSOperands(0).begin()).getType()) == ((*this->getODSOperands(1).begin()).getType()) && ((*this->getODSOperands(1).begin()).getType()) == ((*this->getODSOperands(2).begin()).getType()) && ((*this->getODSOperands(2).begin()).getType()) == ((*this->getODSResults(0).begin()).getType()) && ((*this->getODSResults(0).begin()).getType()) == ((*this->getODSOperands(0).begin()).getType())))) + return emitOpError("failed to verify that all of {src, a, b, res} have same type"); + return ::mlir::success(); +} + +::mlir::LogicalResult MaskScaleFPDIntrOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::LogicalResult MaskScaleFPDIntrOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = operands[2].getType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +void MaskScaleFPDIntrOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace x86vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::x86vector::MaskScaleFPDIntrOp) + +namespace mlir { +namespace x86vector { + +//===----------------------------------------------------------------------===// +// ::mlir::x86vector::MaskScaleFPSIntrOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +MaskScaleFPSIntrOpGenericAdaptorBase::MaskScaleFPSIntrOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("x86vector.avx512.intr.mask.scalef.ps.512", odsAttrs.getContext()); +} + +MaskScaleFPSIntrOpGenericAdaptorBase::MaskScaleFPSIntrOpGenericAdaptorBase(MaskScaleFPSIntrOp op) : MaskScaleFPSIntrOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair MaskScaleFPSIntrOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr MaskScaleFPSIntrOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +MaskScaleFPSIntrOpAdaptor::MaskScaleFPSIntrOpAdaptor(MaskScaleFPSIntrOp op) : MaskScaleFPSIntrOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult MaskScaleFPSIntrOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair MaskScaleFPSIntrOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range MaskScaleFPSIntrOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> MaskScaleFPSIntrOp::getSrc() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> MaskScaleFPSIntrOp::getA() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(1).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> MaskScaleFPSIntrOp::getB() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(2).begin()); +} + +::mlir::TypedValue<::mlir::IntegerType> MaskScaleFPSIntrOp::getK() { + return ::llvm::cast<::mlir::TypedValue<::mlir::IntegerType>>(*getODSOperands(3).begin()); +} + +::mlir::Value MaskScaleFPSIntrOp::getRounding() { + return ::llvm::cast<::mlir::Value>(*getODSOperands(4).begin()); +} + +::mlir::OpOperand &MaskScaleFPSIntrOp::getSrcMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MaskScaleFPSIntrOp::getAMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MaskScaleFPSIntrOp::getBMutable() { + auto range = getODSOperandIndexAndLength(2); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MaskScaleFPSIntrOp::getKMutable() { + auto range = getODSOperandIndexAndLength(3); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &MaskScaleFPSIntrOp::getRoundingMutable() { + auto range = getODSOperandIndexAndLength(4); + return getOperation()->getOpOperand(range.first); +} + +std::pair MaskScaleFPSIntrOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range MaskScaleFPSIntrOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value MaskScaleFPSIntrOp::getRes() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +void MaskScaleFPSIntrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value src, ::mlir::Value a, ::mlir::Value b, ::mlir::Value k, ::mlir::Value rounding) { + odsState.addOperands(src); + odsState.addOperands(a); + odsState.addOperands(b); + odsState.addOperands(k); + odsState.addOperands(rounding); + odsState.addTypes(res); +} + +void MaskScaleFPSIntrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, ::mlir::Value a, ::mlir::Value b, ::mlir::Value k, ::mlir::Value rounding) { + odsState.addOperands(src); + odsState.addOperands(a); + odsState.addOperands(b); + odsState.addOperands(k); + odsState.addOperands(rounding); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MaskScaleFPSIntrOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void MaskScaleFPSIntrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Value a, ::mlir::Value b, ::mlir::Value k, ::mlir::Value rounding) { + odsState.addOperands(src); + odsState.addOperands(a); + odsState.addOperands(b); + odsState.addOperands(k); + odsState.addOperands(rounding); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void MaskScaleFPSIntrOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 5u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void MaskScaleFPSIntrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 5u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(MaskScaleFPSIntrOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult MaskScaleFPSIntrOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector9(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector9(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup2 = getODSOperands(2); + + for (auto v : valueGroup2) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector9(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup3 = getODSOperands(3); + + for (auto v : valueGroup3) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector10(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup4 = getODSOperands(4); + + for (auto v : valueGroup4) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector4(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector4(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((((*this->getODSOperands(0).begin()).getType()) == ((*this->getODSOperands(1).begin()).getType()) && ((*this->getODSOperands(1).begin()).getType()) == ((*this->getODSOperands(2).begin()).getType()) && ((*this->getODSOperands(2).begin()).getType()) == ((*this->getODSResults(0).begin()).getType()) && ((*this->getODSResults(0).begin()).getType()) == ((*this->getODSOperands(0).begin()).getType())))) + return emitOpError("failed to verify that all of {src, a, b, res} have same type"); + return ::mlir::success(); +} + +::mlir::LogicalResult MaskScaleFPSIntrOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::LogicalResult MaskScaleFPSIntrOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = operands[2].getType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +void MaskScaleFPSIntrOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace x86vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::x86vector::MaskScaleFPSIntrOp) + +namespace mlir { +namespace x86vector { + +//===----------------------------------------------------------------------===// +// ::mlir::x86vector::RsqrtIntrOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +RsqrtIntrOpGenericAdaptorBase::RsqrtIntrOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("x86vector.avx.intr.rsqrt.ps.256", odsAttrs.getContext()); +} + +RsqrtIntrOpGenericAdaptorBase::RsqrtIntrOpGenericAdaptorBase(RsqrtIntrOp op) : RsqrtIntrOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair RsqrtIntrOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr RsqrtIntrOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +RsqrtIntrOpAdaptor::RsqrtIntrOpAdaptor(RsqrtIntrOp op) : RsqrtIntrOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult RsqrtIntrOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair RsqrtIntrOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range RsqrtIntrOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> RsqrtIntrOp::getA() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &RsqrtIntrOp::getAMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair RsqrtIntrOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range RsqrtIntrOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value RsqrtIntrOp::getRes() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +void RsqrtIntrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value a) { + odsState.addOperands(a); + odsState.addTypes(res); +} + +void RsqrtIntrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value a) { + odsState.addOperands(a); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(RsqrtIntrOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void RsqrtIntrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a) { + odsState.addOperands(a); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void RsqrtIntrOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void RsqrtIntrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(RsqrtIntrOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult RsqrtIntrOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector4(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult RsqrtIntrOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::LogicalResult RsqrtIntrOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = operands[0].getType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +void RsqrtIntrOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace x86vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::x86vector::RsqrtIntrOp) + +namespace mlir { +namespace x86vector { + +//===----------------------------------------------------------------------===// +// ::mlir::x86vector::RsqrtOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +RsqrtOpGenericAdaptorBase::RsqrtOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("x86vector.avx.rsqrt", odsAttrs.getContext()); +} + +RsqrtOpGenericAdaptorBase::RsqrtOpGenericAdaptorBase(RsqrtOp op) : RsqrtOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair RsqrtOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr RsqrtOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +RsqrtOpAdaptor::RsqrtOpAdaptor(RsqrtOp op) : RsqrtOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult RsqrtOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair RsqrtOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range RsqrtOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> RsqrtOp::getA() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::OpOperand &RsqrtOp::getAMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +std::pair RsqrtOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range RsqrtOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> RsqrtOp::getB() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSResults(0).begin()); +} + +void RsqrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type b, ::mlir::Value a) { + odsState.addOperands(a); + odsState.addTypes(b); +} + +void RsqrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value a) { + odsState.addOperands(a); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(RsqrtOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void RsqrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a) { + odsState.addOperands(a); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void RsqrtOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void RsqrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 1u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(RsqrtOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult RsqrtOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector0(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector0(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult RsqrtOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::LogicalResult RsqrtOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(1); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = operands[0].getType(); + inferredReturnTypes[0] = odsInferredType0; + return ::mlir::success(); +} + +::mlir::ParseResult RsqrtOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand aRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> aOperands(aRawOperands); ::llvm::SMLoc aOperandsLoc; + (void)aOperandsLoc; + ::mlir::Type aRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> aTypes(aRawTypes); + + aOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(aRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + aRawTypes[0] = type; + } + result.addTypes(aTypes[0]); + if (parser.resolveOperands(aOperands, aTypes, aOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void RsqrtOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getA(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getA().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void RsqrtOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace x86vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::x86vector::RsqrtOp) + +namespace mlir { +namespace x86vector { + +//===----------------------------------------------------------------------===// +// ::mlir::x86vector::Vp2IntersectDIntrOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +Vp2IntersectDIntrOpGenericAdaptorBase::Vp2IntersectDIntrOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("x86vector.avx512.intr.vp2intersect.d.512", odsAttrs.getContext()); +} + +Vp2IntersectDIntrOpGenericAdaptorBase::Vp2IntersectDIntrOpGenericAdaptorBase(Vp2IntersectDIntrOp op) : Vp2IntersectDIntrOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair Vp2IntersectDIntrOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr Vp2IntersectDIntrOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +Vp2IntersectDIntrOpAdaptor::Vp2IntersectDIntrOpAdaptor(Vp2IntersectDIntrOp op) : Vp2IntersectDIntrOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult Vp2IntersectDIntrOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair Vp2IntersectDIntrOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range Vp2IntersectDIntrOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> Vp2IntersectDIntrOp::getA() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> Vp2IntersectDIntrOp::getB() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(1).begin()); +} + +::mlir::OpOperand &Vp2IntersectDIntrOp::getAMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &Vp2IntersectDIntrOp::getBMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +std::pair Vp2IntersectDIntrOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range Vp2IntersectDIntrOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value Vp2IntersectDIntrOp::getRes() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +void Vp2IntersectDIntrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value a, ::mlir::Value b) { + odsState.addOperands(a); + odsState.addOperands(b); + odsState.addTypes(res); +} + +void Vp2IntersectDIntrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b) { + odsState.addOperands(a); + odsState.addOperands(b); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void Vp2IntersectDIntrOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult Vp2IntersectDIntrOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector11(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector11(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector4(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult Vp2IntersectDIntrOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +void Vp2IntersectDIntrOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace x86vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::x86vector::Vp2IntersectDIntrOp) + +namespace mlir { +namespace x86vector { + +//===----------------------------------------------------------------------===// +// ::mlir::x86vector::Vp2IntersectOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +Vp2IntersectOpGenericAdaptorBase::Vp2IntersectOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("x86vector.avx512.vp2intersect", odsAttrs.getContext()); +} + +Vp2IntersectOpGenericAdaptorBase::Vp2IntersectOpGenericAdaptorBase(Vp2IntersectOp op) : Vp2IntersectOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair Vp2IntersectOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr Vp2IntersectOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +Vp2IntersectOpAdaptor::Vp2IntersectOpAdaptor(Vp2IntersectOp op) : Vp2IntersectOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult Vp2IntersectOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +void Vp2IntersectOp::getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn) { + auto resultGroup0 = getODSResults(0); + if (!resultGroup0.empty()) + setNameFn(*resultGroup0.begin(), "k1"); + auto resultGroup1 = getODSResults(1); + if (!resultGroup1.empty()) + setNameFn(*resultGroup1.begin(), "k2"); +} + +std::pair Vp2IntersectOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range Vp2IntersectOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> Vp2IntersectOp::getA() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> Vp2IntersectOp::getB() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(1).begin()); +} + +::mlir::OpOperand &Vp2IntersectOp::getAMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &Vp2IntersectOp::getBMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +std::pair Vp2IntersectOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range Vp2IntersectOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> Vp2IntersectOp::getK1() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSResults(0).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> Vp2IntersectOp::getK2() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSResults(1).begin()); +} + +void Vp2IntersectOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type k1, ::mlir::Type k2, ::mlir::Value a, ::mlir::Value b) { + odsState.addOperands(a); + odsState.addOperands(b); + odsState.addTypes(k1); + odsState.addTypes(k2); +} + +void Vp2IntersectOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value a, ::mlir::Value b) { + odsState.addOperands(a); + odsState.addOperands(b); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(Vp2IntersectOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, odsState.operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) + odsState.addTypes(inferredReturnTypes); + else + ::llvm::report_fatal_error("Failed to infer result type(s)."); +} + +void Vp2IntersectOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b) { + odsState.addOperands(a); + odsState.addOperands(b); + assert(resultTypes.size() == 2u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void Vp2IntersectOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 2u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +void Vp2IntersectOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + + ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes; + if (::mlir::succeeded(Vp2IntersectOp::inferReturnTypes(odsBuilder.getContext(), + odsState.location, operands, + odsState.attributes.getDictionary(odsState.getContext()), + odsState.getRawProperties(), + odsState.regions, inferredReturnTypes))) { + assert(inferredReturnTypes.size() == 2u && "mismatched number of return types"); + odsState.addTypes(inferredReturnTypes); + } else { + ::llvm::report_fatal_error("Failed to infer result type(s)."); + } +} + +::mlir::LogicalResult Vp2IntersectOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector12(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector12(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSResults(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector3(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + if (!((((*this->getODSOperands(0).begin()).getType()) == ((*this->getODSOperands(1).begin()).getType()) && ((*this->getODSOperands(1).begin()).getType()) == ((*this->getODSOperands(0).begin()).getType())))) + return emitOpError("failed to verify that all of {a, b} have same type"); + if (!((std::equal_to<>()(VectorType::get({::llvm::cast((*this->getODSOperands(0).begin()).getType()).getShape()[0]}, IntegerType::get((*this->getODSOperands(0).begin()).getType().getContext(), 1)), (*this->getODSResults(0).begin()).getType())))) + return emitOpError("failed to verify that k1 has the same number of bits as elements in a"); + if (!((std::equal_to<>()(VectorType::get({::llvm::cast((*this->getODSOperands(0).begin()).getType()).getShape()[0]}, IntegerType::get((*this->getODSOperands(0).begin()).getType().getContext(), 1)), (*this->getODSResults(1).begin()).getType())))) + return emitOpError("failed to verify that k2 has the same number of bits as elements in b"); + return ::mlir::success(); +} + +::mlir::LogicalResult Vp2IntersectOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +::mlir::LogicalResult Vp2IntersectOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) { + inferredReturnTypes.resize(2); + ::mlir::Builder odsBuilder(context); + ::mlir::Type odsInferredType0 = VectorType::get({::llvm::cast(operands[0].getType()).getShape()[0]}, IntegerType::get(operands[0].getType().getContext(), 1)); + ::mlir::Type odsInferredType1 = VectorType::get({::llvm::cast(operands[0].getType()).getShape()[0]}, IntegerType::get(operands[0].getType().getContext(), 1)); + inferredReturnTypes[0] = odsInferredType0; + inferredReturnTypes[1] = odsInferredType1; + return ::mlir::success(); +} + +::mlir::ParseResult Vp2IntersectOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) { + ::mlir::OpAsmParser::UnresolvedOperand aRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> aOperands(aRawOperands); ::llvm::SMLoc aOperandsLoc; + (void)aOperandsLoc; + ::mlir::OpAsmParser::UnresolvedOperand bRawOperands[1]; + ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> bOperands(bRawOperands); ::llvm::SMLoc bOperandsLoc; + (void)bOperandsLoc; + ::mlir::Type aRawTypes[1]; + ::llvm::ArrayRef<::mlir::Type> aTypes(aRawTypes); + + aOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(aRawOperands[0])) + return ::mlir::failure(); + if (parser.parseComma()) + return ::mlir::failure(); + + bOperandsLoc = parser.getCurrentLocation(); + if (parser.parseOperand(bRawOperands[0])) + return ::mlir::failure(); + { + auto loc = parser.getCurrentLocation();(void)loc; + if (parser.parseOptionalAttrDict(result.attributes)) + return ::mlir::failure(); + } + if (parser.parseColon()) + return ::mlir::failure(); + + { + ::mlir::VectorType type; + if (parser.parseCustomTypeWithFallback(type)) + return ::mlir::failure(); + aRawTypes[0] = type; + } + for (::mlir::Type type : aTypes) { + (void)type; + if (!(((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && ([](::mlir::Type elementType) { return ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) && ((((::llvm::isa<::mlir::VectorType>(type))) && ((::llvm::cast<::mlir::VectorType>(type).getRank() > 0))) && (((::llvm::cast<::mlir::VectorType>(type).getNumElements() + == 16)) || ((::llvm::cast<::mlir::VectorType>(type).getNumElements() + == 8)))))) { + return parser.emitError(parser.getNameLoc()) << "'a' must be vector of 32-bit signless integer or 64-bit signless integer values of length 16/8, but got " << type; + } + } + result.addTypes(VectorType::get({::llvm::cast(aTypes[0]).getShape()[0]}, IntegerType::get(aTypes[0].getContext(), 1))); + result.addTypes(VectorType::get({::llvm::cast(aTypes[0]).getShape()[0]}, IntegerType::get(aTypes[0].getContext(), 1))); + if (parser.resolveOperands(aOperands, aTypes, aOperandsLoc, result.operands)) + return ::mlir::failure(); + if (parser.resolveOperands(bOperands, aTypes[0], bOperandsLoc, result.operands)) + return ::mlir::failure(); + return ::mlir::success(); +} + +void Vp2IntersectOp::print(::mlir::OpAsmPrinter &_odsPrinter) { + _odsPrinter << ' '; + _odsPrinter << getA(); + _odsPrinter << ","; + _odsPrinter << ' '; + _odsPrinter << getB(); + ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs; + _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs); + _odsPrinter << ' ' << ":"; + _odsPrinter << ' '; + { + auto type = getA().getType(); + if (auto validType = ::llvm::dyn_cast<::mlir::VectorType>(type)) + _odsPrinter.printStrippedAttrOrType(validType); + else + _odsPrinter << type; + } +} + +void Vp2IntersectOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace x86vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::x86vector::Vp2IntersectOp) + +namespace mlir { +namespace x86vector { + +//===----------------------------------------------------------------------===// +// ::mlir::x86vector::Vp2IntersectQIntrOp definitions +//===----------------------------------------------------------------------===// + +namespace detail { +Vp2IntersectQIntrOpGenericAdaptorBase::Vp2IntersectQIntrOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs) + odsOpName.emplace("x86vector.avx512.intr.vp2intersect.q.512", odsAttrs.getContext()); +} + +Vp2IntersectQIntrOpGenericAdaptorBase::Vp2IntersectQIntrOpGenericAdaptorBase(Vp2IntersectQIntrOp op) : Vp2IntersectQIntrOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {} + +std::pair Vp2IntersectQIntrOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) { + return {index, 1}; +} + +::mlir::DictionaryAttr Vp2IntersectQIntrOpGenericAdaptorBase::getAttributes() { + return odsAttrs; +} + +} // namespace detail +Vp2IntersectQIntrOpAdaptor::Vp2IntersectQIntrOpAdaptor(Vp2IntersectQIntrOp op) : Vp2IntersectQIntrOpGenericAdaptor(op->getOperands(), op) {} + +::mlir::LogicalResult Vp2IntersectQIntrOpAdaptor::verify(::mlir::Location loc) { + return ::mlir::success(); +} + +std::pair Vp2IntersectQIntrOp::getODSOperandIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::operand_range Vp2IntersectQIntrOp::getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(getOperation()->operand_begin(), valueRange.first), + std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::TypedValue<::mlir::VectorType> Vp2IntersectQIntrOp::getA() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(0).begin()); +} + +::mlir::TypedValue<::mlir::VectorType> Vp2IntersectQIntrOp::getB() { + return ::llvm::cast<::mlir::TypedValue<::mlir::VectorType>>(*getODSOperands(1).begin()); +} + +::mlir::OpOperand &Vp2IntersectQIntrOp::getAMutable() { + auto range = getODSOperandIndexAndLength(0); + return getOperation()->getOpOperand(range.first); +} + +::mlir::OpOperand &Vp2IntersectQIntrOp::getBMutable() { + auto range = getODSOperandIndexAndLength(1); + return getOperation()->getOpOperand(range.first); +} + +std::pair Vp2IntersectQIntrOp::getODSResultIndexAndLength(unsigned index) { + return {index, 1}; +} + +::mlir::Operation::result_range Vp2IntersectQIntrOp::getODSResults(unsigned index) { + auto valueRange = getODSResultIndexAndLength(index); + return {std::next(getOperation()->result_begin(), valueRange.first), + std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)}; +} + +::mlir::Value Vp2IntersectQIntrOp::getRes() { + return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin()); +} + +void Vp2IntersectQIntrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value a, ::mlir::Value b) { + odsState.addOperands(a); + odsState.addOperands(b); + odsState.addTypes(res); +} + +void Vp2IntersectQIntrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b) { + odsState.addOperands(a); + odsState.addOperands(b); + assert(resultTypes.size() == 1u && "mismatched number of results"); + odsState.addTypes(resultTypes); +} + +void Vp2IntersectQIntrOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) { + assert(operands.size() == 2u && "mismatched number of parameters"); + odsState.addOperands(operands); + odsState.addAttributes(attributes); + assert(resultTypes.size() == 1u && "mismatched number of return types"); + odsState.addTypes(resultTypes); +} + +::mlir::LogicalResult Vp2IntersectQIntrOp::verifyInvariantsImpl() { + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSOperands(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector13(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + auto valueGroup1 = getODSOperands(1); + + for (auto v : valueGroup1) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector13(*this, v.getType(), "operand", index++))) + return ::mlir::failure(); + } + } + { + unsigned index = 0; (void)index; + auto valueGroup0 = getODSResults(0); + + for (auto v : valueGroup0) { + if (::mlir::failed(__mlir_ods_local_type_constraint_X86Vector4(*this, v.getType(), "result", index++))) + return ::mlir::failure(); + } + } + return ::mlir::success(); +} + +::mlir::LogicalResult Vp2IntersectQIntrOp::verifyInvariants() { + return verifyInvariantsImpl(); +} + +void Vp2IntersectQIntrOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) { +} + +} // namespace x86vector +} // namespace mlir +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::x86vector::Vp2IntersectQIntrOp) + + +#endif // GET_OP_CLASSES + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/X86Vector/X86Vector.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/X86Vector/X86Vector.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..baba93f1da953b559b8036af528db5eebacdddde --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/X86Vector/X86Vector.h.inc @@ -0,0 +1,1889 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Op Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: X86Vector.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#if defined(GET_OP_CLASSES) || defined(GET_OP_FWD_DEFINES) +#undef GET_OP_FWD_DEFINES +namespace mlir { +namespace x86vector { +class DotIntrOp; +} // namespace x86vector +} // namespace mlir +namespace mlir { +namespace x86vector { +class DotOp; +} // namespace x86vector +} // namespace mlir +namespace mlir { +namespace x86vector { +class MaskCompressIntrOp; +} // namespace x86vector +} // namespace mlir +namespace mlir { +namespace x86vector { +class MaskCompressOp; +} // namespace x86vector +} // namespace mlir +namespace mlir { +namespace x86vector { +class MaskRndScaleOp; +} // namespace x86vector +} // namespace mlir +namespace mlir { +namespace x86vector { +class MaskRndScalePDIntrOp; +} // namespace x86vector +} // namespace mlir +namespace mlir { +namespace x86vector { +class MaskRndScalePSIntrOp; +} // namespace x86vector +} // namespace mlir +namespace mlir { +namespace x86vector { +class MaskScaleFOp; +} // namespace x86vector +} // namespace mlir +namespace mlir { +namespace x86vector { +class MaskScaleFPDIntrOp; +} // namespace x86vector +} // namespace mlir +namespace mlir { +namespace x86vector { +class MaskScaleFPSIntrOp; +} // namespace x86vector +} // namespace mlir +namespace mlir { +namespace x86vector { +class RsqrtIntrOp; +} // namespace x86vector +} // namespace mlir +namespace mlir { +namespace x86vector { +class RsqrtOp; +} // namespace x86vector +} // namespace mlir +namespace mlir { +namespace x86vector { +class Vp2IntersectDIntrOp; +} // namespace x86vector +} // namespace mlir +namespace mlir { +namespace x86vector { +class Vp2IntersectOp; +} // namespace x86vector +} // namespace mlir +namespace mlir { +namespace x86vector { +class Vp2IntersectQIntrOp; +} // namespace x86vector +} // namespace mlir +#endif + +#ifdef GET_OP_CLASSES +#undef GET_OP_CLASSES + + +//===----------------------------------------------------------------------===// +// Local Utility Method Definitions +//===----------------------------------------------------------------------===// + +namespace mlir { +namespace x86vector { + +//===----------------------------------------------------------------------===// +// ::mlir::x86vector::DotIntrOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class DotIntrOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + DotIntrOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + DotIntrOpGenericAdaptorBase(DotIntrOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class DotIntrOpGenericAdaptor : public detail::DotIntrOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::DotIntrOpGenericAdaptorBase; +public: + DotIntrOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + DotIntrOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : DotIntrOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + DotIntrOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getA() { + return (*getODSOperands(0).begin()); + } + + ValueT getB() { + return (*getODSOperands(1).begin()); + } + + ValueT getC() { + return (*getODSOperands(2).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class DotIntrOpAdaptor : public DotIntrOpGenericAdaptor<::mlir::ValueRange> { +public: + using DotIntrOpGenericAdaptor::DotIntrOpGenericAdaptor; + DotIntrOpAdaptor(DotIntrOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class DotIntrOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<3>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = DotIntrOpAdaptor; + template + using GenericAdaptor = DotIntrOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("x86vector.avx.intr.dp.ps.256"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getA(); + ::mlir::TypedValue<::mlir::VectorType> getB(); + ::mlir::TypedValue<::mlir::IntegerType> getC(); + ::mlir::OpOperand &getAMutable(); + ::mlir::OpOperand &getBMutable(); + ::mlir::OpOperand &getCMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getRes(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value a, ::mlir::Value b, ::mlir::Value c); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value a, ::mlir::Value b, ::mlir::Value c); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, ::mlir::Value c); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace x86vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::x86vector::DotIntrOp) + +namespace mlir { +namespace x86vector { + +//===----------------------------------------------------------------------===// +// ::mlir::x86vector::DotOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class DotOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + DotOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + DotOpGenericAdaptorBase(DotOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class DotOpGenericAdaptor : public detail::DotOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::DotOpGenericAdaptorBase; +public: + DotOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + DotOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : DotOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + DotOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getA() { + return (*getODSOperands(0).begin()); + } + + ValueT getB() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class DotOpAdaptor : public DotOpGenericAdaptor<::mlir::ValueRange> { +public: + using DotOpGenericAdaptor::DotOpGenericAdaptor; + DotOpAdaptor(DotOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class DotOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::SameOperandsAndResultType, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = DotOpAdaptor; + template + using GenericAdaptor = DotOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("x86vector.avx.intr.dot"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getA(); + ::mlir::TypedValue<::mlir::VectorType> getB(); + ::mlir::OpOperand &getAMutable(); + ::mlir::OpOperand &getBMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getRes(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value a, ::mlir::Value b); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value a, ::mlir::Value b); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace x86vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::x86vector::DotOp) + +namespace mlir { +namespace x86vector { + +//===----------------------------------------------------------------------===// +// ::mlir::x86vector::MaskCompressIntrOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class MaskCompressIntrOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + MaskCompressIntrOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + MaskCompressIntrOpGenericAdaptorBase(MaskCompressIntrOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class MaskCompressIntrOpGenericAdaptor : public detail::MaskCompressIntrOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::MaskCompressIntrOpGenericAdaptorBase; +public: + MaskCompressIntrOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + MaskCompressIntrOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : MaskCompressIntrOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + MaskCompressIntrOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getA() { + return (*getODSOperands(0).begin()); + } + + ValueT getSrc() { + return (*getODSOperands(1).begin()); + } + + ValueT getK() { + return (*getODSOperands(2).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class MaskCompressIntrOpAdaptor : public MaskCompressIntrOpGenericAdaptor<::mlir::ValueRange> { +public: + using MaskCompressIntrOpGenericAdaptor::MaskCompressIntrOpGenericAdaptor; + MaskCompressIntrOpAdaptor(MaskCompressIntrOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class MaskCompressIntrOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<3>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = MaskCompressIntrOpAdaptor; + template + using GenericAdaptor = MaskCompressIntrOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("x86vector.avx512.intr.mask.compress"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getA(); + ::mlir::TypedValue<::mlir::VectorType> getSrc(); + ::mlir::TypedValue<::mlir::VectorType> getK(); + ::mlir::OpOperand &getAMutable(); + ::mlir::OpOperand &getSrcMutable(); + ::mlir::OpOperand &getKMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getRes(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value a, ::mlir::Value src, ::mlir::Value k); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value a, ::mlir::Value src, ::mlir::Value k); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value src, ::mlir::Value k); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace x86vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::x86vector::MaskCompressIntrOp) + +namespace mlir { +namespace x86vector { + +//===----------------------------------------------------------------------===// +// ::mlir::x86vector::MaskCompressOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class MaskCompressOpGenericAdaptorBase { +public: + struct Properties { + using constant_srcTy = ::mlir::ElementsAttr; + constant_srcTy constant_src; + + auto getConstantSrc() { + auto &propStorage = this->constant_src; + return ::llvm::dyn_cast_or_null<::mlir::ElementsAttr>(propStorage); + } + void setConstantSrc(const ::mlir::ElementsAttr &propValue) { + this->constant_src = propValue; + } + bool operator==(const Properties &rhs) const { + return + rhs.constant_src == this->constant_src && + true; + } + bool operator!=(const Properties &rhs) const { + return !(*this == rhs); + } + }; +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + Properties properties; + ::mlir::RegionRange odsRegions; +public: + MaskCompressOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}); + + MaskCompressOpGenericAdaptorBase(MaskCompressOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + const Properties &getProperties() { + return properties; + } + + ::mlir::DictionaryAttr getAttributes(); + ::mlir::ElementsAttr getConstantSrcAttr(); + ::std::optional< ::mlir::ElementsAttr > getConstantSrc(); +}; +} // namespace detail +template +class MaskCompressOpGenericAdaptor : public detail::MaskCompressOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::MaskCompressOpGenericAdaptorBase; +public: + MaskCompressOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + MaskCompressOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : MaskCompressOpGenericAdaptor(values, attrs, (properties ? *properties.as() : Properties{}), regions) {} + + template >> + MaskCompressOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getK() { + return (*getODSOperands(0).begin()); + } + + ValueT getA() { + return (*getODSOperands(1).begin()); + } + + ValueT getSrc() { + auto operands = getODSOperands(2); + return operands.empty() ? ValueT{} : (*operands.begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class MaskCompressOpAdaptor : public MaskCompressOpGenericAdaptor<::mlir::ValueRange> { +public: + using MaskCompressOpGenericAdaptor::MaskCompressOpGenericAdaptor; + MaskCompressOpAdaptor(MaskCompressOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class MaskCompressOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = MaskCompressOpAdaptor; + template + using GenericAdaptor = MaskCompressOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + using Properties = FoldAdaptor::Properties; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + static ::llvm::StringRef attrNames[] = {::llvm::StringRef("constant_src")}; + return ::llvm::ArrayRef(attrNames); + } + + ::mlir::StringAttr getConstantSrcAttrName() { + return getAttributeNameForIndex(0); + } + + static ::mlir::StringAttr getConstantSrcAttrName(::mlir::OperationName name) { + return getAttributeNameForIndex(name, 0); + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("x86vector.avx512.mask.compress"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getK(); + ::mlir::TypedValue<::mlir::VectorType> getA(); + ::mlir::TypedValue<::mlir::VectorType> getSrc(); + ::mlir::OpOperand &getKMutable(); + ::mlir::OpOperand &getAMutable(); + ::mlir::MutableOperandRange getSrcMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getDst(); + static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop); + static llvm::hash_code computePropertiesHash(const Properties &prop); + static std::optional getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name); + static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value); + static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs); + static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError); + static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state); + void writeProperties(::mlir::DialectBytecodeWriter &writer); + ::mlir::ElementsAttr getConstantSrcAttr(); + ::std::optional< ::mlir::ElementsAttr > getConstantSrc(); + void setConstantSrcAttr(::mlir::ElementsAttr attr); + ::mlir::Attribute removeConstantSrcAttr(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value k, ::mlir::Value a, /*optional*/::mlir::Value src, /*optional*/::mlir::ElementsAttr constant_src); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value k, ::mlir::Value a, /*optional*/::mlir::Value src, /*optional*/::mlir::ElementsAttr constant_src); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value k, ::mlir::Value a, /*optional*/::mlir::Value src, /*optional*/::mlir::ElementsAttr constant_src); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + ::mlir::LogicalResult verify(); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +private: + ::mlir::StringAttr getAttributeNameForIndex(unsigned index) { + return getAttributeNameForIndex((*this)->getName(), index); + } + + static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) { + assert(index < 1 && "invalid attribute index"); + assert(name.getStringRef() == getOperationName() && "invalid operation name"); + return name.getAttributeNames()[index]; + } + +public: +}; +} // namespace x86vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::x86vector::MaskCompressOp) + +namespace mlir { +namespace x86vector { + +//===----------------------------------------------------------------------===// +// ::mlir::x86vector::MaskRndScaleOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class MaskRndScaleOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + MaskRndScaleOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + MaskRndScaleOpGenericAdaptorBase(MaskRndScaleOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class MaskRndScaleOpGenericAdaptor : public detail::MaskRndScaleOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::MaskRndScaleOpGenericAdaptorBase; +public: + MaskRndScaleOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + MaskRndScaleOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : MaskRndScaleOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + MaskRndScaleOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSrc() { + return (*getODSOperands(0).begin()); + } + + ValueT getK() { + return (*getODSOperands(1).begin()); + } + + ValueT getA() { + return (*getODSOperands(2).begin()); + } + + ValueT getImm() { + return (*getODSOperands(3).begin()); + } + + ValueT getRounding() { + return (*getODSOperands(4).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class MaskRndScaleOpAdaptor : public MaskRndScaleOpGenericAdaptor<::mlir::ValueRange> { +public: + using MaskRndScaleOpGenericAdaptor::MaskRndScaleOpGenericAdaptor; + MaskRndScaleOpAdaptor(MaskRndScaleOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class MaskRndScaleOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<5>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = MaskRndScaleOpAdaptor; + template + using GenericAdaptor = MaskRndScaleOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("x86vector.avx512.mask.rndscale"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getSrc(); + ::mlir::TypedValue<::mlir::IntegerType> getK(); + ::mlir::TypedValue<::mlir::VectorType> getA(); + ::mlir::Value getImm(); + ::mlir::TypedValue<::mlir::IntegerType> getRounding(); + ::mlir::OpOperand &getSrcMutable(); + ::mlir::OpOperand &getKMutable(); + ::mlir::OpOperand &getAMutable(); + ::mlir::OpOperand &getImmMutable(); + ::mlir::OpOperand &getRoundingMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getDst(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, ::mlir::Value k, ::mlir::Value a, ::mlir::Value imm, ::mlir::Value rounding); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, ::mlir::Value k, ::mlir::Value a, ::mlir::Value imm, ::mlir::Value rounding); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Value k, ::mlir::Value a, ::mlir::Value imm, ::mlir::Value rounding); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace x86vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::x86vector::MaskRndScaleOp) + +namespace mlir { +namespace x86vector { + +//===----------------------------------------------------------------------===// +// ::mlir::x86vector::MaskRndScalePDIntrOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class MaskRndScalePDIntrOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + MaskRndScalePDIntrOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + MaskRndScalePDIntrOpGenericAdaptorBase(MaskRndScalePDIntrOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class MaskRndScalePDIntrOpGenericAdaptor : public detail::MaskRndScalePDIntrOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::MaskRndScalePDIntrOpGenericAdaptorBase; +public: + MaskRndScalePDIntrOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + MaskRndScalePDIntrOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : MaskRndScalePDIntrOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + MaskRndScalePDIntrOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSrc() { + return (*getODSOperands(0).begin()); + } + + ValueT getK() { + return (*getODSOperands(1).begin()); + } + + ValueT getA() { + return (*getODSOperands(2).begin()); + } + + ValueT getImm() { + return (*getODSOperands(3).begin()); + } + + ValueT getRounding() { + return (*getODSOperands(4).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class MaskRndScalePDIntrOpAdaptor : public MaskRndScalePDIntrOpGenericAdaptor<::mlir::ValueRange> { +public: + using MaskRndScalePDIntrOpGenericAdaptor::MaskRndScalePDIntrOpGenericAdaptor; + MaskRndScalePDIntrOpAdaptor(MaskRndScalePDIntrOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class MaskRndScalePDIntrOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<5>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = MaskRndScalePDIntrOpAdaptor; + template + using GenericAdaptor = MaskRndScalePDIntrOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("x86vector.avx512.intr.mask.rndscale.pd.512"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getSrc(); + ::mlir::TypedValue<::mlir::IntegerType> getK(); + ::mlir::TypedValue<::mlir::VectorType> getA(); + ::mlir::TypedValue<::mlir::IntegerType> getImm(); + ::mlir::Value getRounding(); + ::mlir::OpOperand &getSrcMutable(); + ::mlir::OpOperand &getKMutable(); + ::mlir::OpOperand &getAMutable(); + ::mlir::OpOperand &getImmMutable(); + ::mlir::OpOperand &getRoundingMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getRes(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value src, ::mlir::Value k, ::mlir::Value a, ::mlir::Value imm, ::mlir::Value rounding); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, ::mlir::Value k, ::mlir::Value a, ::mlir::Value imm, ::mlir::Value rounding); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Value k, ::mlir::Value a, ::mlir::Value imm, ::mlir::Value rounding); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace x86vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::x86vector::MaskRndScalePDIntrOp) + +namespace mlir { +namespace x86vector { + +//===----------------------------------------------------------------------===// +// ::mlir::x86vector::MaskRndScalePSIntrOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class MaskRndScalePSIntrOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + MaskRndScalePSIntrOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + MaskRndScalePSIntrOpGenericAdaptorBase(MaskRndScalePSIntrOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class MaskRndScalePSIntrOpGenericAdaptor : public detail::MaskRndScalePSIntrOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::MaskRndScalePSIntrOpGenericAdaptorBase; +public: + MaskRndScalePSIntrOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + MaskRndScalePSIntrOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : MaskRndScalePSIntrOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + MaskRndScalePSIntrOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSrc() { + return (*getODSOperands(0).begin()); + } + + ValueT getK() { + return (*getODSOperands(1).begin()); + } + + ValueT getA() { + return (*getODSOperands(2).begin()); + } + + ValueT getImm() { + return (*getODSOperands(3).begin()); + } + + ValueT getRounding() { + return (*getODSOperands(4).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class MaskRndScalePSIntrOpAdaptor : public MaskRndScalePSIntrOpGenericAdaptor<::mlir::ValueRange> { +public: + using MaskRndScalePSIntrOpGenericAdaptor::MaskRndScalePSIntrOpGenericAdaptor; + MaskRndScalePSIntrOpAdaptor(MaskRndScalePSIntrOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class MaskRndScalePSIntrOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<5>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = MaskRndScalePSIntrOpAdaptor; + template + using GenericAdaptor = MaskRndScalePSIntrOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("x86vector.avx512.intr.mask.rndscale.ps.512"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getSrc(); + ::mlir::TypedValue<::mlir::IntegerType> getK(); + ::mlir::TypedValue<::mlir::VectorType> getA(); + ::mlir::TypedValue<::mlir::IntegerType> getImm(); + ::mlir::Value getRounding(); + ::mlir::OpOperand &getSrcMutable(); + ::mlir::OpOperand &getKMutable(); + ::mlir::OpOperand &getAMutable(); + ::mlir::OpOperand &getImmMutable(); + ::mlir::OpOperand &getRoundingMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getRes(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value src, ::mlir::Value k, ::mlir::Value a, ::mlir::Value imm, ::mlir::Value rounding); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, ::mlir::Value k, ::mlir::Value a, ::mlir::Value imm, ::mlir::Value rounding); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Value k, ::mlir::Value a, ::mlir::Value imm, ::mlir::Value rounding); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace x86vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::x86vector::MaskRndScalePSIntrOp) + +namespace mlir { +namespace x86vector { + +//===----------------------------------------------------------------------===// +// ::mlir::x86vector::MaskScaleFOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class MaskScaleFOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + MaskScaleFOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + MaskScaleFOpGenericAdaptorBase(MaskScaleFOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class MaskScaleFOpGenericAdaptor : public detail::MaskScaleFOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::MaskScaleFOpGenericAdaptorBase; +public: + MaskScaleFOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + MaskScaleFOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : MaskScaleFOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + MaskScaleFOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSrc() { + return (*getODSOperands(0).begin()); + } + + ValueT getA() { + return (*getODSOperands(1).begin()); + } + + ValueT getB() { + return (*getODSOperands(2).begin()); + } + + ValueT getK() { + return (*getODSOperands(3).begin()); + } + + ValueT getRounding() { + return (*getODSOperands(4).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class MaskScaleFOpAdaptor : public MaskScaleFOpGenericAdaptor<::mlir::ValueRange> { +public: + using MaskScaleFOpGenericAdaptor::MaskScaleFOpGenericAdaptor; + MaskScaleFOpAdaptor(MaskScaleFOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class MaskScaleFOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<5>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = MaskScaleFOpAdaptor; + template + using GenericAdaptor = MaskScaleFOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("x86vector.avx512.mask.scalef"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getSrc(); + ::mlir::TypedValue<::mlir::VectorType> getA(); + ::mlir::TypedValue<::mlir::VectorType> getB(); + ::mlir::Value getK(); + ::mlir::TypedValue<::mlir::IntegerType> getRounding(); + ::mlir::OpOperand &getSrcMutable(); + ::mlir::OpOperand &getAMutable(); + ::mlir::OpOperand &getBMutable(); + ::mlir::OpOperand &getKMutable(); + ::mlir::OpOperand &getRoundingMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getDst(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type dst, ::mlir::Value src, ::mlir::Value a, ::mlir::Value b, ::mlir::Value k, ::mlir::Value rounding); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, ::mlir::Value a, ::mlir::Value b, ::mlir::Value k, ::mlir::Value rounding); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Value a, ::mlir::Value b, ::mlir::Value k, ::mlir::Value rounding); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace x86vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::x86vector::MaskScaleFOp) + +namespace mlir { +namespace x86vector { + +//===----------------------------------------------------------------------===// +// ::mlir::x86vector::MaskScaleFPDIntrOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class MaskScaleFPDIntrOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + MaskScaleFPDIntrOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + MaskScaleFPDIntrOpGenericAdaptorBase(MaskScaleFPDIntrOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class MaskScaleFPDIntrOpGenericAdaptor : public detail::MaskScaleFPDIntrOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::MaskScaleFPDIntrOpGenericAdaptorBase; +public: + MaskScaleFPDIntrOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + MaskScaleFPDIntrOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : MaskScaleFPDIntrOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + MaskScaleFPDIntrOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSrc() { + return (*getODSOperands(0).begin()); + } + + ValueT getA() { + return (*getODSOperands(1).begin()); + } + + ValueT getB() { + return (*getODSOperands(2).begin()); + } + + ValueT getK() { + return (*getODSOperands(3).begin()); + } + + ValueT getRounding() { + return (*getODSOperands(4).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class MaskScaleFPDIntrOpAdaptor : public MaskScaleFPDIntrOpGenericAdaptor<::mlir::ValueRange> { +public: + using MaskScaleFPDIntrOpGenericAdaptor::MaskScaleFPDIntrOpGenericAdaptor; + MaskScaleFPDIntrOpAdaptor(MaskScaleFPDIntrOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class MaskScaleFPDIntrOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<5>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = MaskScaleFPDIntrOpAdaptor; + template + using GenericAdaptor = MaskScaleFPDIntrOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("x86vector.avx512.intr.mask.scalef.pd.512"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getSrc(); + ::mlir::TypedValue<::mlir::VectorType> getA(); + ::mlir::TypedValue<::mlir::VectorType> getB(); + ::mlir::TypedValue<::mlir::IntegerType> getK(); + ::mlir::Value getRounding(); + ::mlir::OpOperand &getSrcMutable(); + ::mlir::OpOperand &getAMutable(); + ::mlir::OpOperand &getBMutable(); + ::mlir::OpOperand &getKMutable(); + ::mlir::OpOperand &getRoundingMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getRes(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value src, ::mlir::Value a, ::mlir::Value b, ::mlir::Value k, ::mlir::Value rounding); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, ::mlir::Value a, ::mlir::Value b, ::mlir::Value k, ::mlir::Value rounding); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Value a, ::mlir::Value b, ::mlir::Value k, ::mlir::Value rounding); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace x86vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::x86vector::MaskScaleFPDIntrOp) + +namespace mlir { +namespace x86vector { + +//===----------------------------------------------------------------------===// +// ::mlir::x86vector::MaskScaleFPSIntrOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class MaskScaleFPSIntrOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + MaskScaleFPSIntrOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + MaskScaleFPSIntrOpGenericAdaptorBase(MaskScaleFPSIntrOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class MaskScaleFPSIntrOpGenericAdaptor : public detail::MaskScaleFPSIntrOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::MaskScaleFPSIntrOpGenericAdaptorBase; +public: + MaskScaleFPSIntrOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + MaskScaleFPSIntrOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : MaskScaleFPSIntrOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + MaskScaleFPSIntrOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getSrc() { + return (*getODSOperands(0).begin()); + } + + ValueT getA() { + return (*getODSOperands(1).begin()); + } + + ValueT getB() { + return (*getODSOperands(2).begin()); + } + + ValueT getK() { + return (*getODSOperands(3).begin()); + } + + ValueT getRounding() { + return (*getODSOperands(4).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class MaskScaleFPSIntrOpAdaptor : public MaskScaleFPSIntrOpGenericAdaptor<::mlir::ValueRange> { +public: + using MaskScaleFPSIntrOpGenericAdaptor::MaskScaleFPSIntrOpGenericAdaptor; + MaskScaleFPSIntrOpAdaptor(MaskScaleFPSIntrOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class MaskScaleFPSIntrOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<5>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = MaskScaleFPSIntrOpAdaptor; + template + using GenericAdaptor = MaskScaleFPSIntrOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("x86vector.avx512.intr.mask.scalef.ps.512"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getSrc(); + ::mlir::TypedValue<::mlir::VectorType> getA(); + ::mlir::TypedValue<::mlir::VectorType> getB(); + ::mlir::TypedValue<::mlir::IntegerType> getK(); + ::mlir::Value getRounding(); + ::mlir::OpOperand &getSrcMutable(); + ::mlir::OpOperand &getAMutable(); + ::mlir::OpOperand &getBMutable(); + ::mlir::OpOperand &getKMutable(); + ::mlir::OpOperand &getRoundingMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getRes(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value src, ::mlir::Value a, ::mlir::Value b, ::mlir::Value k, ::mlir::Value rounding); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value src, ::mlir::Value a, ::mlir::Value b, ::mlir::Value k, ::mlir::Value rounding); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value src, ::mlir::Value a, ::mlir::Value b, ::mlir::Value k, ::mlir::Value rounding); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace x86vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::x86vector::MaskScaleFPSIntrOp) + +namespace mlir { +namespace x86vector { + +//===----------------------------------------------------------------------===// +// ::mlir::x86vector::RsqrtIntrOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class RsqrtIntrOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + RsqrtIntrOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + RsqrtIntrOpGenericAdaptorBase(RsqrtIntrOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class RsqrtIntrOpGenericAdaptor : public detail::RsqrtIntrOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::RsqrtIntrOpGenericAdaptorBase; +public: + RsqrtIntrOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + RsqrtIntrOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : RsqrtIntrOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + RsqrtIntrOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getA() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class RsqrtIntrOpAdaptor : public RsqrtIntrOpGenericAdaptor<::mlir::ValueRange> { +public: + using RsqrtIntrOpGenericAdaptor::RsqrtIntrOpGenericAdaptor; + RsqrtIntrOpAdaptor(RsqrtIntrOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class RsqrtIntrOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::SameOperandsAndResultType, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = RsqrtIntrOpAdaptor; + template + using GenericAdaptor = RsqrtIntrOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("x86vector.avx.intr.rsqrt.ps.256"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getA(); + ::mlir::OpOperand &getAMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getRes(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value a); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value a); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace x86vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::x86vector::RsqrtIntrOp) + +namespace mlir { +namespace x86vector { + +//===----------------------------------------------------------------------===// +// ::mlir::x86vector::RsqrtOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class RsqrtOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + RsqrtOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + RsqrtOpGenericAdaptorBase(RsqrtOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class RsqrtOpGenericAdaptor : public detail::RsqrtOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::RsqrtOpGenericAdaptorBase; +public: + RsqrtOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + RsqrtOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : RsqrtOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + RsqrtOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getA() { + return (*getODSOperands(0).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class RsqrtOpAdaptor : public RsqrtOpGenericAdaptor<::mlir::ValueRange> { +public: + using RsqrtOpGenericAdaptor::RsqrtOpGenericAdaptor; + RsqrtOpAdaptor(RsqrtOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class RsqrtOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::SameOperandsAndResultType, ::mlir::InferTypeOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = RsqrtOpAdaptor; + template + using GenericAdaptor = RsqrtOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("x86vector.avx.rsqrt"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getA(); + ::mlir::OpOperand &getAMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getB(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type b, ::mlir::Value a); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value a); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace x86vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::x86vector::RsqrtOp) + +namespace mlir { +namespace x86vector { + +//===----------------------------------------------------------------------===// +// ::mlir::x86vector::Vp2IntersectDIntrOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class Vp2IntersectDIntrOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + Vp2IntersectDIntrOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + Vp2IntersectDIntrOpGenericAdaptorBase(Vp2IntersectDIntrOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class Vp2IntersectDIntrOpGenericAdaptor : public detail::Vp2IntersectDIntrOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::Vp2IntersectDIntrOpGenericAdaptorBase; +public: + Vp2IntersectDIntrOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + Vp2IntersectDIntrOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : Vp2IntersectDIntrOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + Vp2IntersectDIntrOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getA() { + return (*getODSOperands(0).begin()); + } + + ValueT getB() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class Vp2IntersectDIntrOpAdaptor : public Vp2IntersectDIntrOpGenericAdaptor<::mlir::ValueRange> { +public: + using Vp2IntersectDIntrOpGenericAdaptor::Vp2IntersectDIntrOpGenericAdaptor; + Vp2IntersectDIntrOpAdaptor(Vp2IntersectDIntrOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class Vp2IntersectDIntrOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = Vp2IntersectDIntrOpAdaptor; + template + using GenericAdaptor = Vp2IntersectDIntrOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("x86vector.avx512.intr.vp2intersect.d.512"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getA(); + ::mlir::TypedValue<::mlir::VectorType> getB(); + ::mlir::OpOperand &getAMutable(); + ::mlir::OpOperand &getBMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getRes(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value a, ::mlir::Value b); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace x86vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::x86vector::Vp2IntersectDIntrOp) + +namespace mlir { +namespace x86vector { + +//===----------------------------------------------------------------------===// +// ::mlir::x86vector::Vp2IntersectOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class Vp2IntersectOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + Vp2IntersectOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + Vp2IntersectOpGenericAdaptorBase(Vp2IntersectOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class Vp2IntersectOpGenericAdaptor : public detail::Vp2IntersectOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::Vp2IntersectOpGenericAdaptorBase; +public: + Vp2IntersectOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + Vp2IntersectOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : Vp2IntersectOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + Vp2IntersectOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getA() { + return (*getODSOperands(0).begin()); + } + + ValueT getB() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class Vp2IntersectOpAdaptor : public Vp2IntersectOpGenericAdaptor<::mlir::ValueRange> { +public: + using Vp2IntersectOpGenericAdaptor::Vp2IntersectOpGenericAdaptor; + Vp2IntersectOpAdaptor(Vp2IntersectOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class Vp2IntersectOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::OpAsmOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = Vp2IntersectOpAdaptor; + template + using GenericAdaptor = Vp2IntersectOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn); + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("x86vector.avx512.vp2intersect"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getA(); + ::mlir::TypedValue<::mlir::VectorType> getB(); + ::mlir::OpOperand &getAMutable(); + ::mlir::OpOperand &getBMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getK1(); + ::mlir::TypedValue<::mlir::VectorType> getK2(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type k1, ::mlir::Type k2, ::mlir::Value a, ::mlir::Value b); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value a, ::mlir::Value b); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes); + static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result); + void print(::mlir::OpAsmPrinter &_odsPrinter); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace x86vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::x86vector::Vp2IntersectOp) + +namespace mlir { +namespace x86vector { + +//===----------------------------------------------------------------------===// +// ::mlir::x86vector::Vp2IntersectQIntrOp declarations +//===----------------------------------------------------------------------===// + +namespace detail { +class Vp2IntersectQIntrOpGenericAdaptorBase { +public: +protected: + ::mlir::DictionaryAttr odsAttrs; + ::std::optional<::mlir::OperationName> odsOpName; + ::mlir::RegionRange odsRegions; +public: + Vp2IntersectQIntrOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}); + + Vp2IntersectQIntrOpGenericAdaptorBase(Vp2IntersectQIntrOp op); + + std::pair getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize); + ::mlir::DictionaryAttr getAttributes(); +}; +} // namespace detail +template +class Vp2IntersectQIntrOpGenericAdaptor : public detail::Vp2IntersectQIntrOpGenericAdaptorBase { + using ValueT = ::llvm::detail::ValueOfRange; + using Base = detail::Vp2IntersectQIntrOpGenericAdaptorBase; +public: + Vp2IntersectQIntrOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {} + + Vp2IntersectQIntrOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : Vp2IntersectQIntrOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {} + + template >> + Vp2IntersectQIntrOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {} + + std::pair getODSOperandIndexAndLength(unsigned index) { + return Base::getODSOperandIndexAndLength(index, odsOperands.size()); + } + + RangeT getODSOperands(unsigned index) { + auto valueRange = getODSOperandIndexAndLength(index); + return {std::next(odsOperands.begin(), valueRange.first), + std::next(odsOperands.begin(), valueRange.first + valueRange.second)}; + } + + ValueT getA() { + return (*getODSOperands(0).begin()); + } + + ValueT getB() { + return (*getODSOperands(1).begin()); + } + + RangeT getOperands() { + return odsOperands; + } + +private: + RangeT odsOperands; +}; +class Vp2IntersectQIntrOpAdaptor : public Vp2IntersectQIntrOpGenericAdaptor<::mlir::ValueRange> { +public: + using Vp2IntersectQIntrOpGenericAdaptor::Vp2IntersectQIntrOpGenericAdaptor; + Vp2IntersectQIntrOpAdaptor(Vp2IntersectQIntrOp op); + + ::mlir::LogicalResult verify(::mlir::Location loc); +}; +class Vp2IntersectQIntrOp : public ::mlir::Op::Impl, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait> { +public: + using Op::Op; + using Op::print; + using Adaptor = Vp2IntersectQIntrOpAdaptor; + template + using GenericAdaptor = Vp2IntersectQIntrOpGenericAdaptor; + using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>; + static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { + return {}; + } + + static constexpr ::llvm::StringLiteral getOperationName() { + return ::llvm::StringLiteral("x86vector.avx512.intr.vp2intersect.q.512"); + } + + std::pair getODSOperandIndexAndLength(unsigned index); + ::mlir::Operation::operand_range getODSOperands(unsigned index); + ::mlir::TypedValue<::mlir::VectorType> getA(); + ::mlir::TypedValue<::mlir::VectorType> getB(); + ::mlir::OpOperand &getAMutable(); + ::mlir::OpOperand &getBMutable(); + std::pair getODSResultIndexAndLength(unsigned index); + ::mlir::Operation::result_range getODSResults(unsigned index); + ::mlir::Value getRes(); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type res, ::mlir::Value a, ::mlir::Value b); + static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b); + static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {}); + ::mlir::LogicalResult verifyInvariantsImpl(); + ::mlir::LogicalResult verifyInvariants(); + void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects); +public: +}; +} // namespace x86vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::x86vector::Vp2IntersectQIntrOp) + + +#endif // GET_OP_CLASSES + diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/X86Vector/X86VectorConversions.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/X86Vector/X86VectorConversions.inc new file mode 100644 index 0000000000000000000000000000000000000000..4fb21d1f8b61008e156b97cbf72d9adbeb42f5e9 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/X86Vector/X86VectorConversions.inc @@ -0,0 +1,117 @@ +if (auto op = dyn_cast<::mlir::x86vector::DotIntrOp>(opInst)) { + + llvm::Module *module = builder.GetInsertBlock()->getModule(); + llvm::Function *fn = llvm::Intrinsic::getDeclaration( + module, + llvm::Intrinsic::x86_avx_dp_ps_256, { } ); + auto operands = moduleTranslation.lookupValues(opInst.getOperands()); + + auto *inst = builder.CreateCall(fn, operands); + (void) inst; + moduleTranslation.mapValue(op.getRes()) = inst; + return success(); +} +if (auto op = dyn_cast<::mlir::x86vector::MaskCompressIntrOp>(opInst)) { + + llvm::Module *module = builder.GetInsertBlock()->getModule(); + llvm::Function *fn = llvm::Intrinsic::getDeclaration( + module, + llvm::Intrinsic::x86_avx512_mask_compress, { moduleTranslation.convertType(opInst.getResult(0).getType()) } ); + auto operands = moduleTranslation.lookupValues(opInst.getOperands()); + + auto *inst = builder.CreateCall(fn, operands); + (void) inst; + moduleTranslation.mapValue(op.getRes()) = inst; + return success(); +} +if (auto op = dyn_cast<::mlir::x86vector::MaskRndScalePDIntrOp>(opInst)) { + + llvm::Module *module = builder.GetInsertBlock()->getModule(); + llvm::Function *fn = llvm::Intrinsic::getDeclaration( + module, + llvm::Intrinsic::x86_avx512_mask_rndscale_pd_512, { } ); + auto operands = moduleTranslation.lookupValues(opInst.getOperands()); + + auto *inst = builder.CreateCall(fn, operands); + (void) inst; + moduleTranslation.mapValue(op.getRes()) = inst; + return success(); +} +if (auto op = dyn_cast<::mlir::x86vector::MaskRndScalePSIntrOp>(opInst)) { + + llvm::Module *module = builder.GetInsertBlock()->getModule(); + llvm::Function *fn = llvm::Intrinsic::getDeclaration( + module, + llvm::Intrinsic::x86_avx512_mask_rndscale_ps_512, { } ); + auto operands = moduleTranslation.lookupValues(opInst.getOperands()); + + auto *inst = builder.CreateCall(fn, operands); + (void) inst; + moduleTranslation.mapValue(op.getRes()) = inst; + return success(); +} +if (auto op = dyn_cast<::mlir::x86vector::MaskScaleFPDIntrOp>(opInst)) { + + llvm::Module *module = builder.GetInsertBlock()->getModule(); + llvm::Function *fn = llvm::Intrinsic::getDeclaration( + module, + llvm::Intrinsic::x86_avx512_mask_scalef_pd_512, { } ); + auto operands = moduleTranslation.lookupValues(opInst.getOperands()); + + auto *inst = builder.CreateCall(fn, operands); + (void) inst; + moduleTranslation.mapValue(op.getRes()) = inst; + return success(); +} +if (auto op = dyn_cast<::mlir::x86vector::MaskScaleFPSIntrOp>(opInst)) { + + llvm::Module *module = builder.GetInsertBlock()->getModule(); + llvm::Function *fn = llvm::Intrinsic::getDeclaration( + module, + llvm::Intrinsic::x86_avx512_mask_scalef_ps_512, { } ); + auto operands = moduleTranslation.lookupValues(opInst.getOperands()); + + auto *inst = builder.CreateCall(fn, operands); + (void) inst; + moduleTranslation.mapValue(op.getRes()) = inst; + return success(); +} +if (auto op = dyn_cast<::mlir::x86vector::RsqrtIntrOp>(opInst)) { + + llvm::Module *module = builder.GetInsertBlock()->getModule(); + llvm::Function *fn = llvm::Intrinsic::getDeclaration( + module, + llvm::Intrinsic::x86_avx_rsqrt_ps_256, { } ); + auto operands = moduleTranslation.lookupValues(opInst.getOperands()); + + auto *inst = builder.CreateCall(fn, operands); + (void) inst; + moduleTranslation.mapValue(op.getRes()) = inst; + return success(); +} +if (auto op = dyn_cast<::mlir::x86vector::Vp2IntersectDIntrOp>(opInst)) { + + llvm::Module *module = builder.GetInsertBlock()->getModule(); + llvm::Function *fn = llvm::Intrinsic::getDeclaration( + module, + llvm::Intrinsic::x86_avx512_vp2intersect_d_512, { } ); + auto operands = moduleTranslation.lookupValues(opInst.getOperands()); + + auto *inst = builder.CreateCall(fn, operands); + (void) inst; + moduleTranslation.mapValue(op.getRes()) = inst; + return success(); +} +if (auto op = dyn_cast<::mlir::x86vector::Vp2IntersectQIntrOp>(opInst)) { + + llvm::Module *module = builder.GetInsertBlock()->getModule(); + llvm::Function *fn = llvm::Intrinsic::getDeclaration( + module, + llvm::Intrinsic::x86_avx512_vp2intersect_q_512, { } ); + auto operands = moduleTranslation.lookupValues(opInst.getOperands()); + + auto *inst = builder.CreateCall(fn, operands); + (void) inst; + moduleTranslation.mapValue(op.getRes()) = inst; + return success(); +} diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/X86Vector/X86VectorDialect.cpp.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/X86Vector/X86VectorDialect.cpp.inc new file mode 100644 index 0000000000000000000000000000000000000000..527dc1293c9f5b69e06f5ed63003bb0ef2f8b84d --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/X86Vector/X86VectorDialect.cpp.inc @@ -0,0 +1,23 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Dialect Definitions *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: X86Vector.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::x86vector::X86VectorDialect) +namespace mlir { +namespace x86vector { + +X86VectorDialect::X86VectorDialect(::mlir::MLIRContext *context) + : ::mlir::Dialect(getDialectNamespace(), context, ::mlir::TypeID::get()) { + + initialize(); +} + +X86VectorDialect::~X86VectorDialect() = default; + +} // namespace x86vector +} // namespace mlir diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/X86Vector/X86VectorDialect.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/X86Vector/X86VectorDialect.h new file mode 100644 index 0000000000000000000000000000000000000000..4017bc1a917e2ed6ee277ee20a2312cdd8a76cbe --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/X86Vector/X86VectorDialect.h @@ -0,0 +1,29 @@ +//===- X86VectorDialect.h - MLIR Dialect for X86Vector ----------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file declares the Target dialect for X86Vector in MLIR. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_X86VECTOR_X86VECTORDIALECT_H_ +#define MLIR_DIALECT_X86VECTOR_X86VECTORDIALECT_H_ + +#include "mlir/Bytecode/BytecodeOpInterface.h" +#include "mlir/IR/BuiltinTypes.h" +#include "mlir/IR/Dialect.h" +#include "mlir/IR/OpDefinition.h" +#include "mlir/IR/OpImplementation.h" +#include "mlir/Interfaces/InferTypeOpInterface.h" +#include "mlir/Interfaces/SideEffectInterfaces.h" + +#include "mlir/Dialect/X86Vector/X86VectorDialect.h.inc" + +#define GET_OP_CLASSES +#include "mlir/Dialect/X86Vector/X86Vector.h.inc" + +#endif // MLIR_DIALECT_X86VECTOR_X86VECTORDIALECT_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/X86Vector/X86VectorDialect.h.inc b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/X86Vector/X86VectorDialect.h.inc new file mode 100644 index 0000000000000000000000000000000000000000..6683c4ae86bef254e729e5d98d224a9ce3f55b2f --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/X86Vector/X86VectorDialect.h.inc @@ -0,0 +1,26 @@ +/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ +|* *| +|* Dialect Declarations *| +|* *| +|* Automatically generated file, do not edit! *| +|* From: X86Vector.td *| +|* *| +\*===----------------------------------------------------------------------===*/ + +namespace mlir { +namespace x86vector { + +class X86VectorDialect : public ::mlir::Dialect { + explicit X86VectorDialect(::mlir::MLIRContext *context); + + void initialize(); + friend class ::mlir::MLIRContext; +public: + ~X86VectorDialect() override; + static constexpr ::llvm::StringLiteral getDialectNamespace() { + return ::llvm::StringLiteral("x86vector"); + } +}; +} // namespace x86vector +} // namespace mlir +MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::x86vector::X86VectorDialect) diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/AsyncRuntime.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/AsyncRuntime.h new file mode 100644 index 0000000000000000000000000000000000000000..063381ba5d67c7fa5b5de6d73eac279891087947 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/AsyncRuntime.h @@ -0,0 +1,168 @@ +//===- AsyncRuntime.h - Async runtime reference implementation ------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file declares basic Async runtime API for supporting Async dialect +// to LLVM dialect lowering. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_EXECUTIONENGINE_ASYNCRUNTIME_H_ +#define MLIR_EXECUTIONENGINE_ASYNCRUNTIME_H_ + +#include +#include + +#ifdef _WIN32 +#ifndef MLIR_ASYNC_RUNTIME_EXPORT +#ifdef mlir_async_runtime_EXPORTS +// We are building this library +#define MLIR_ASYNC_RUNTIME_EXPORT __declspec(dllexport) +#else +// We are using this library +#define MLIR_ASYNC_RUNTIME_EXPORT __declspec(dllimport) +#endif // mlir_async_runtime_EXPORTS +#endif // MLIR_ASYNC_RUNTIME_EXPORT +#else +// Non-windows: use visibility attributes. +#define MLIR_ASYNC_RUNTIME_EXPORT __attribute__((visibility("default"))) +#endif // _WIN32 + +namespace mlir { +namespace runtime { + +//===----------------------------------------------------------------------===// +// Async runtime API. +//===----------------------------------------------------------------------===// + +// Runtime implementation of `async.token` data type. +using AsyncToken = struct AsyncToken; + +// Runtime implementation of `async.group` data type. +using AsyncGroup = struct AsyncGroup; + +// Runtime implementation of `async.value` data type. +using AsyncValue = struct AsyncValue; + +// Async value payload stored in a memory owned by the async.value. +using ValueStorage = std::byte *; + +// Async runtime uses LLVM coroutines to represent asynchronous tasks. Task +// function is a coroutine handle and a resume function that continue coroutine +// execution from a suspension point. +using CoroHandle = void *; // coroutine handle +using CoroResume = void (*)(void *); // coroutine resume function + +// Async runtime uses reference counting to manage the lifetime of async values +// (values of async types like tokens, values and groups). +using RefCountedObjPtr = void *; + +// Adds references to reference counted runtime object. +extern "C" MLIR_ASYNC_RUNTIME_EXPORT void + mlirAsyncRuntimeAddRef(RefCountedObjPtr, int64_t); + +// Drops references from reference counted runtime object. +extern "C" MLIR_ASYNC_RUNTIME_EXPORT void + mlirAsyncRuntimeDropRef(RefCountedObjPtr, int64_t); + +// Create a new `async.token` in not-ready state. +extern "C" MLIR_ASYNC_RUNTIME_EXPORT AsyncToken *mlirAsyncRuntimeCreateToken(); + +// Create a new `async.value` in not-ready state. Size parameter specifies the +// number of bytes that will be allocated for the async value storage. Storage +// is owned by the `async.value` and deallocated when the async value is +// destructed (reference count drops to zero). +extern "C" MLIR_ASYNC_RUNTIME_EXPORT AsyncValue * + mlirAsyncRuntimeCreateValue(int64_t); + +// Create a new `async.group` in empty state. +extern "C" MLIR_ASYNC_RUNTIME_EXPORT AsyncGroup * +mlirAsyncRuntimeCreateGroup(int64_t size); + +extern "C" MLIR_ASYNC_RUNTIME_EXPORT int64_t +mlirAsyncRuntimeAddTokenToGroup(AsyncToken *, AsyncGroup *); + +// Switches `async.token` to ready state and runs all awaiters. +extern "C" MLIR_ASYNC_RUNTIME_EXPORT void +mlirAsyncRuntimeEmplaceToken(AsyncToken *); + +// Switches `async.value` to ready state and runs all awaiters. +extern "C" MLIR_ASYNC_RUNTIME_EXPORT void +mlirAsyncRuntimeEmplaceValue(AsyncValue *); + +// Switches `async.token` to error state and runs all awaiters. +extern "C" MLIR_ASYNC_RUNTIME_EXPORT void +mlirAsyncRuntimeSetTokenError(AsyncToken *); + +// Switches `async.value` to error state and runs all awaiters. +extern "C" MLIR_ASYNC_RUNTIME_EXPORT void +mlirAsyncRuntimeSetValueError(AsyncValue *); + +// Returns true if token is in the error state. +extern "C" MLIR_ASYNC_RUNTIME_EXPORT bool +mlirAsyncRuntimeIsTokenError(AsyncToken *); + +// Returns true if value is in the error state. +extern "C" MLIR_ASYNC_RUNTIME_EXPORT bool +mlirAsyncRuntimeIsValueError(AsyncValue *); + +// Returns true if group is in the error state (any of the tokens or values +// added to the group are in the error state). +extern "C" MLIR_ASYNC_RUNTIME_EXPORT bool +mlirAsyncRuntimeIsGroupError(AsyncGroup *); + +// Blocks the caller thread until the token becomes ready. +extern "C" MLIR_ASYNC_RUNTIME_EXPORT void +mlirAsyncRuntimeAwaitToken(AsyncToken *); + +// Blocks the caller thread until the value becomes ready. +extern "C" MLIR_ASYNC_RUNTIME_EXPORT void +mlirAsyncRuntimeAwaitValue(AsyncValue *); + +// Blocks the caller thread until the elements in the group become ready. +extern "C" MLIR_ASYNC_RUNTIME_EXPORT void +mlirAsyncRuntimeAwaitAllInGroup(AsyncGroup *); + +// Returns a pointer to the storage owned by the async value. +extern "C" MLIR_ASYNC_RUNTIME_EXPORT ValueStorage +mlirAsyncRuntimeGetValueStorage(AsyncValue *); + +// Executes the task (coro handle + resume function) in one of the threads +// managed by the runtime. +extern "C" MLIR_ASYNC_RUNTIME_EXPORT void mlirAsyncRuntimeExecute(CoroHandle, + CoroResume); + +// Executes the task (coro handle + resume function) in one of the threads +// managed by the runtime after the token becomes ready. +extern "C" MLIR_ASYNC_RUNTIME_EXPORT void +mlirAsyncRuntimeAwaitTokenAndExecute(AsyncToken *, CoroHandle, CoroResume); + +// Executes the task (coro handle + resume function) in one of the threads +// managed by the runtime after the value becomes ready. +extern "C" MLIR_ASYNC_RUNTIME_EXPORT void +mlirAsyncRuntimeAwaitValueAndExecute(AsyncValue *, CoroHandle, CoroResume); + +// Executes the task (coro handle + resume function) in one of the threads +// managed by the runtime after the all members of the group become ready. +extern "C" MLIR_ASYNC_RUNTIME_EXPORT void +mlirAsyncRuntimeAwaitAllInGroupAndExecute(AsyncGroup *, CoroHandle, CoroResume); + +// Returns the current number of available worker threads in the threadpool. +extern "C" MLIR_ASYNC_RUNTIME_EXPORT int64_t +mlirAsyncRuntimGetNumWorkerThreads(); + +//===----------------------------------------------------------------------===// +// Small async runtime support library for testing. +//===----------------------------------------------------------------------===// + +extern "C" MLIR_ASYNC_RUNTIME_EXPORT void +mlirAsyncRuntimePrintCurrentThreadId(); + +} // namespace runtime +} // namespace mlir + +#endif // MLIR_EXECUTIONENGINE_ASYNCRUNTIME_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/CRunnerUtils.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/CRunnerUtils.h new file mode 100644 index 0000000000000000000000000000000000000000..e8f429463cb0b9b70d5e9f63d2a3ec9030d7ec5a --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/CRunnerUtils.h @@ -0,0 +1,498 @@ +//===- CRunnerUtils.h - Utils for debugging MLIR execution ----------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file declares basic classes and functions to manipulate structured MLIR +// types at runtime. Entities in this file must be compliant with C++11 and be +// retargetable, including on targets without a C++ runtime. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_EXECUTIONENGINE_CRUNNERUTILS_H +#define MLIR_EXECUTIONENGINE_CRUNNERUTILS_H + +#ifdef _WIN32 +#ifndef MLIR_CRUNNERUTILS_EXPORT +#ifdef mlir_c_runner_utils_EXPORTS +// We are building this library +#define MLIR_CRUNNERUTILS_EXPORT __declspec(dllexport) +#define MLIR_CRUNNERUTILS_DEFINE_FUNCTIONS +#else +// We are using this library +#define MLIR_CRUNNERUTILS_EXPORT __declspec(dllimport) +#endif // mlir_c_runner_utils_EXPORTS +#endif // MLIR_CRUNNERUTILS_EXPORT +#else // _WIN32 +// Non-windows: use visibility attributes. +#define MLIR_CRUNNERUTILS_EXPORT __attribute__((visibility("default"))) +#define MLIR_CRUNNERUTILS_DEFINE_FUNCTIONS +#endif // _WIN32 + +#include +#include +#include +#include +#include + +//===----------------------------------------------------------------------===// +// Codegen-compatible structures for Vector type. +//===----------------------------------------------------------------------===// +namespace mlir { +namespace detail { + +constexpr bool isPowerOf2(int n) { return (!(n & (n - 1))); } + +constexpr unsigned nextPowerOf2(int n) { + return (n <= 1) ? 1 : (isPowerOf2(n) ? n : (2 * nextPowerOf2((n + 1) / 2))); +} + +template +struct Vector1D; + +template +struct Vector1D { + Vector1D() { + static_assert(detail::nextPowerOf2(sizeof(T[Dim])) == sizeof(T[Dim]), + "size error"); + } + inline T &operator[](unsigned i) { return vector[i]; } + inline const T &operator[](unsigned i) const { return vector[i]; } + +private: + T vector[Dim]; +}; + +// 1-D vector, padded to the next power of 2 allocation. +// Specialization occurs to avoid zero size arrays (which fail in -Werror). +template +struct Vector1D { + Vector1D() { + static_assert(nextPowerOf2(sizeof(T[Dim])) > sizeof(T[Dim]), "size error"); + static_assert(nextPowerOf2(sizeof(T[Dim])) < 2 * sizeof(T[Dim]), + "size error"); + } + inline T &operator[](unsigned i) { return vector[i]; } + inline const T &operator[](unsigned i) const { return vector[i]; } + +private: + T vector[Dim]; + char padding[nextPowerOf2(sizeof(T[Dim])) - sizeof(T[Dim])]; +}; +} // namespace detail +} // namespace mlir + +// N-D vectors recurse down to 1-D. +template +struct Vector { + inline Vector &operator[](unsigned i) { return vector[i]; } + inline const Vector &operator[](unsigned i) const { + return vector[i]; + } + +private: + Vector vector[Dim]; +}; + +// 1-D vectors in LLVM are automatically padded to the next power of 2. +// We insert explicit padding in to account for this. +template +struct Vector + : public mlir::detail::Vector1D { +}; + +template +using Vector1D = Vector; +template +using Vector2D = Vector; +template +using Vector3D = Vector; +template +using Vector4D = Vector; + +template +void dropFront(int64_t arr[N], int64_t *res) { + for (unsigned i = 1; i < N; ++i) + *(res + i - 1) = arr[i]; +} + +//===----------------------------------------------------------------------===// +// Codegen-compatible structures for StridedMemRef type. +//===----------------------------------------------------------------------===// +template +class StridedMemrefIterator; + +/// StridedMemRef descriptor type with static rank. +template +struct StridedMemRefType { + T *basePtr; + T *data; + int64_t offset; + int64_t sizes[N]; + int64_t strides[N]; + + template ().begin())> + T &operator[](Range &&indices) { + assert(indices.size() == N && + "indices should match rank in memref subscript"); + int64_t curOffset = offset; + for (int dim = N - 1; dim >= 0; --dim) { + int64_t currentIndex = *(indices.begin() + dim); + assert(currentIndex < sizes[dim] && "Index overflow"); + curOffset += currentIndex * strides[dim]; + } + return data[curOffset]; + } + + StridedMemrefIterator begin() { return {*this, offset}; } + StridedMemrefIterator end() { return {*this, -1}; } + + // This operator[] is extremely slow and only for sugaring purposes. + StridedMemRefType operator[](int64_t idx) { + StridedMemRefType res; + res.basePtr = basePtr; + res.data = data; + res.offset = offset + idx * strides[0]; + dropFront(sizes, res.sizes); + dropFront(strides, res.strides); + return res; + } +}; + +/// StridedMemRef descriptor type specialized for rank 1. +template +struct StridedMemRefType { + T *basePtr; + T *data; + int64_t offset; + int64_t sizes[1]; + int64_t strides[1]; + + template ().begin())> + T &operator[](Range indices) { + assert(indices.size() == 1 && + "indices should match rank in memref subscript"); + return (*this)[*indices.begin()]; + } + + StridedMemrefIterator begin() { return {*this, offset}; } + StridedMemrefIterator end() { return {*this, -1}; } + + T &operator[](int64_t idx) { return *(data + offset + idx * strides[0]); } +}; + +/// StridedMemRef descriptor type specialized for rank 0. +template +struct StridedMemRefType { + T *basePtr; + T *data; + int64_t offset; + + template ().begin())> + T &operator[](Range indices) { + assert((indices.size() == 0) && + "Expect empty indices for 0-rank memref subscript"); + return data[offset]; + } + + StridedMemrefIterator begin() { return {*this, offset}; } + StridedMemrefIterator end() { return {*this, offset + 1}; } +}; + +/// Iterate over all elements in a strided memref. +template +class StridedMemrefIterator { +public: + using iterator_category = std::forward_iterator_tag; + using value_type = T; + using difference_type = std::ptrdiff_t; + using pointer = T *; + using reference = T &; + + StridedMemrefIterator(StridedMemRefType &descriptor, + int64_t offset = 0) + : offset(offset), descriptor(&descriptor) {} + StridedMemrefIterator &operator++() { + int dim = Rank - 1; + while (dim >= 0 && indices[dim] == (descriptor->sizes[dim] - 1)) { + offset -= indices[dim] * descriptor->strides[dim]; + indices[dim] = 0; + --dim; + } + if (dim < 0) { + offset = -1; + return *this; + } + ++indices[dim]; + offset += descriptor->strides[dim]; + return *this; + } + + reference operator*() { return descriptor->data[offset]; } + pointer operator->() { return &descriptor->data[offset]; } + + const std::array &getIndices() { return indices; } + + bool operator==(const StridedMemrefIterator &other) const { + return other.offset == offset && other.descriptor == descriptor; + } + + bool operator!=(const StridedMemrefIterator &other) const { + return !(*this == other); + } + +private: + /// Offset in the buffer. This can be derived from the indices and the + /// descriptor. + int64_t offset = 0; + + /// Array of indices in the multi-dimensional memref. + std::array indices = {}; + + /// Descriptor for the strided memref. + StridedMemRefType *descriptor; +}; + +/// Iterate over all elements in a 0-ranked strided memref. +template +class StridedMemrefIterator { +public: + using iterator_category = std::forward_iterator_tag; + using value_type = T; + using difference_type = std::ptrdiff_t; + using pointer = T *; + using reference = T &; + + StridedMemrefIterator(StridedMemRefType &descriptor, int64_t offset = 0) + : elt(descriptor.data + offset) {} + + StridedMemrefIterator &operator++() { + ++elt; + return *this; + } + + reference operator*() { return *elt; } + pointer operator->() { return elt; } + + // There are no indices for a 0-ranked memref, but this API is provided for + // consistency with the general case. + const std::array &getIndices() { + // Since this is a 0-array of indices we can keep a single global const + // copy. + static const std::array indices = {}; + return indices; + } + + bool operator==(const StridedMemrefIterator &other) const { + return other.elt == elt; + } + + bool operator!=(const StridedMemrefIterator &other) const { + return !(*this == other); + } + +private: + /// Pointer to the single element in the zero-ranked memref. + T *elt; +}; + +//===----------------------------------------------------------------------===// +// Codegen-compatible structure for UnrankedMemRef type. +//===----------------------------------------------------------------------===// +// Unranked MemRef +template +struct UnrankedMemRefType { + int64_t rank; + void *descriptor; +}; + +//===----------------------------------------------------------------------===// +// DynamicMemRefType type. +//===----------------------------------------------------------------------===// +template +class DynamicMemRefIterator; + +// A reference to one of the StridedMemRef types. +template +class DynamicMemRefType { +public: + int64_t rank; + T *basePtr; + T *data; + int64_t offset; + const int64_t *sizes; + const int64_t *strides; + + explicit DynamicMemRefType(const StridedMemRefType &memRef) + : rank(0), basePtr(memRef.basePtr), data(memRef.data), + offset(memRef.offset), sizes(nullptr), strides(nullptr) {} + template + explicit DynamicMemRefType(const StridedMemRefType &memRef) + : rank(N), basePtr(memRef.basePtr), data(memRef.data), + offset(memRef.offset), sizes(memRef.sizes), strides(memRef.strides) {} + explicit DynamicMemRefType(const ::UnrankedMemRefType &memRef) + : rank(memRef.rank) { + auto *desc = static_cast *>(memRef.descriptor); + basePtr = desc->basePtr; + data = desc->data; + offset = desc->offset; + sizes = rank == 0 ? nullptr : desc->sizes; + strides = sizes + rank; + } + + template ().begin())> + T &operator[](Range &&indices) { + assert(indices.size() == rank && + "indices should match rank in memref subscript"); + if (rank == 0) + return data[offset]; + + int64_t curOffset = offset; + for (int dim = rank - 1; dim >= 0; --dim) { + int64_t currentIndex = *(indices.begin() + dim); + assert(currentIndex < sizes[dim] && "Index overflow"); + curOffset += currentIndex * strides[dim]; + } + return data[curOffset]; + } + + DynamicMemRefIterator begin() { return {*this, offset}; } + DynamicMemRefIterator end() { return {*this, -1}; } + + // This operator[] is extremely slow and only for sugaring purposes. + DynamicMemRefType operator[](int64_t idx) { + assert(rank > 0 && "can't make a subscript of a zero ranked array"); + + DynamicMemRefType res(*this); + --res.rank; + res.offset += idx * res.strides[0]; + ++res.sizes; + ++res.strides; + return res; + } + + // This operator* can be used in conjunction with the previous operator[] in + // order to access the underlying value in case of zero-ranked memref. + T &operator*() { + assert(rank == 0 && "not a zero-ranked memRef"); + return data[offset]; + } +}; + +/// Iterate over all elements in a dynamic memref. +template +class DynamicMemRefIterator { +public: + using iterator_category = std::forward_iterator_tag; + using value_type = T; + using difference_type = std::ptrdiff_t; + using pointer = T *; + using reference = T &; + + DynamicMemRefIterator(DynamicMemRefType &descriptor, int64_t offset = 0) + : offset(offset), descriptor(&descriptor) { + indices.resize(descriptor.rank, 0); + } + + DynamicMemRefIterator &operator++() { + if (descriptor->rank == 0) { + offset = -1; + return *this; + } + + int dim = descriptor->rank - 1; + + while (dim >= 0 && indices[dim] == (descriptor->sizes[dim] - 1)) { + offset -= indices[dim] * descriptor->strides[dim]; + indices[dim] = 0; + --dim; + } + + if (dim < 0) { + offset = -1; + return *this; + } + + ++indices[dim]; + offset += descriptor->strides[dim]; + return *this; + } + + reference operator*() { return descriptor->data[offset]; } + pointer operator->() { return &descriptor->data[offset]; } + + const std::vector &getIndices() { return indices; } + + bool operator==(const DynamicMemRefIterator &other) const { + return other.offset == offset && other.descriptor == descriptor; + } + + bool operator!=(const DynamicMemRefIterator &other) const { + return !(*this == other); + } + +private: + /// Offset in the buffer. This can be derived from the indices and the + /// descriptor. + int64_t offset = 0; + + /// Array of indices in the multi-dimensional memref. + std::vector indices = {}; + + /// Descriptor for the dynamic memref. + DynamicMemRefType *descriptor; +}; + +//===----------------------------------------------------------------------===// +// Small runtime support library for memref.copy lowering during codegen. +//===----------------------------------------------------------------------===// +extern "C" MLIR_CRUNNERUTILS_EXPORT void +memrefCopy(int64_t elemSize, ::UnrankedMemRefType *src, + ::UnrankedMemRefType *dst); + +//===----------------------------------------------------------------------===// +// Small runtime support library for vector.print lowering during codegen. +//===----------------------------------------------------------------------===// +extern "C" MLIR_CRUNNERUTILS_EXPORT void printI64(int64_t i); +extern "C" MLIR_CRUNNERUTILS_EXPORT void printU64(uint64_t u); +extern "C" MLIR_CRUNNERUTILS_EXPORT void printF32(float f); +extern "C" MLIR_CRUNNERUTILS_EXPORT void printF64(double d); +extern "C" MLIR_CRUNNERUTILS_EXPORT void printOpen(); +extern "C" MLIR_CRUNNERUTILS_EXPORT void printClose(); +extern "C" MLIR_CRUNNERUTILS_EXPORT void printComma(); +extern "C" MLIR_CRUNNERUTILS_EXPORT void printNewline(); + +//===----------------------------------------------------------------------===// +// Small runtime support library for timing execution and printing GFLOPS +//===----------------------------------------------------------------------===// +extern "C" MLIR_CRUNNERUTILS_EXPORT void printFlops(double flops); +extern "C" MLIR_CRUNNERUTILS_EXPORT double rtclock(); + +//===----------------------------------------------------------------------===// +// Runtime support library for random number generation. +//===----------------------------------------------------------------------===// +// Uses a seed to initialize a random generator and returns the generator. +extern "C" MLIR_CRUNNERUTILS_EXPORT void *rtsrand(uint64_t s); +// Returns a random number in the range of [0, m). +extern "C" MLIR_CRUNNERUTILS_EXPORT uint64_t rtrand(void *, uint64_t m); +// Deletes the random number generator. +extern "C" MLIR_CRUNNERUTILS_EXPORT void rtdrand(void *); + +//===----------------------------------------------------------------------===// +// Runtime support library to allow the use of std::sort in MLIR program. +//===----------------------------------------------------------------------===// +extern "C" MLIR_CRUNNERUTILS_EXPORT void +_mlir_ciface_stdSortI64(uint64_t n, StridedMemRefType *vref); +extern "C" MLIR_CRUNNERUTILS_EXPORT void +_mlir_ciface_stdSortF64(uint64_t n, StridedMemRefType *vref); +extern "C" MLIR_CRUNNERUTILS_EXPORT void +_mlir_ciface_stdSortF32(uint64_t n, StridedMemRefType *vref); +#endif // MLIR_EXECUTIONENGINE_CRUNNERUTILS_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h new file mode 100644 index 0000000000000000000000000000000000000000..66f49c787c19058da7ebab4dd09499db566c2af0 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h @@ -0,0 +1,258 @@ +//===- ExecutionEngine.h - MLIR Execution engine and utils -----*- C++ -*--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file provides a JIT-backed execution engine for MLIR modules. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_EXECUTIONENGINE_EXECUTIONENGINE_H_ +#define MLIR_EXECUTIONENGINE_EXECUTIONENGINE_H_ + +#include "mlir/Support/LLVM.h" +#include "llvm/ExecutionEngine/ObjectCache.h" +#include "llvm/ExecutionEngine/Orc/LLJIT.h" +#include "llvm/ExecutionEngine/SectionMemoryManager.h" +#include "llvm/IR/LLVMContext.h" +#include "llvm/Support/Error.h" + +#include +#include +#include + +namespace llvm { +template +class Expected; +class Module; +class ExecutionEngine; +class JITEventListener; +class MemoryBuffer; +} // namespace llvm + +namespace mlir { + +class Operation; + +/// A simple object cache following Lang's LLJITWithObjectCache example. +class SimpleObjectCache : public llvm::ObjectCache { +public: + void notifyObjectCompiled(const llvm::Module *m, + llvm::MemoryBufferRef objBuffer) override; + std::unique_ptr getObject(const llvm::Module *m) override; + + /// Dump cached object to output file `filename`. + void dumpToObjectFile(StringRef filename); + + /// Returns `true` if cache hasn't been populated yet. + bool isEmpty(); + +private: + llvm::StringMap> cachedObjects; +}; + +struct ExecutionEngineOptions { + /// If `llvmModuleBuilder` is provided, it will be used to create an LLVM + /// module from the given MLIR IR. Otherwise, a default + /// `translateModuleToLLVMIR` function will be used to translate to LLVM IR. + llvm::function_ref(Operation *, + llvm::LLVMContext &)> + llvmModuleBuilder = nullptr; + + /// If `transformer` is provided, it will be called on the LLVM module during + /// JIT-compilation and can be used, e.g., for reporting or optimization. + llvm::function_ref transformer = {}; + + /// `jitCodeGenOptLevel`, when provided, is used as the optimization level for + /// target code generation. + std::optional jitCodeGenOptLevel; + + /// If `sharedLibPaths` are provided, the underlying JIT-compilation will + /// open and link the shared libraries for symbol resolution. Libraries that + /// are designed to be used with the `ExecutionEngine` may implement a + /// loading and unloading protocol: if they implement the two functions with + /// the names defined in `kLibraryInitFnName` and `kLibraryDestroyFnName`, + /// these functions will be called upon loading the library and upon + /// destruction of the `ExecutionEngine`. In the init function, the library + /// may provide a list of symbols that it wants to make available to code + /// run by the `ExecutionEngine`. If the two functions are not defined, only + /// symbols with public visibility are available to the executed code. + ArrayRef sharedLibPaths = {}; + + /// Specifies an existing `sectionMemoryMapper` to be associated with the + /// compiled code. If none is provided, a default memory mapper that directly + /// calls into the operating system is used. + llvm::SectionMemoryManager::MemoryMapper *sectionMemoryMapper = nullptr; + + /// If `enableObjectCache` is set, the JIT compiler will create one to store + /// the object generated for the given module. The contents of the cache can + /// be dumped to a file via the `dumpToObjectFile` method. + bool enableObjectDump = false; + + /// If enable `enableGDBNotificationListener` is set, the JIT compiler will + /// notify the llvm's global GDB notification listener. + bool enableGDBNotificationListener = true; + + /// If `enablePerfNotificationListener` is set, the JIT compiler will notify + /// the llvm's global Perf notification listener. + bool enablePerfNotificationListener = true; +}; + +/// JIT-backed execution engine for MLIR. Assumes the IR can be converted to +/// LLVM IR. For each function, creates a wrapper function with the fixed +/// interface +/// +/// void _mlir_funcName(void **) +/// +/// where the only argument is interpreted as a list of pointers to the actual +/// arguments of the function, followed by a pointer to the result. This allows +/// the engine to provide the caller with a generic function pointer that can +/// be used to invoke the JIT-compiled function. +class ExecutionEngine { +public: + /// Name of init functions of shared libraries. If a library provides a + /// function with this name and the one of the destroy function, this function + /// is called upon loading the library. + static constexpr const char *const kLibraryInitFnName = + "__mlir_execution_engine_init"; + + /// Name of destroy functions of shared libraries. If a library provides a + /// function with this name and the one of the init function, this function is + /// called upon destructing the `ExecutionEngine`. + static constexpr const char *const kLibraryDestroyFnName = + "__mlir_execution_engine_destroy"; + + /// Function type for init functions of shared libraries. The library may + /// provide a list of symbols that it wants to make available to code run by + /// the `ExecutionEngine`. If the two functions are not defined, only symbols + /// with public visibility are available to the executed code. + using LibraryInitFn = void (*)(llvm::StringMap &); + + /// Function type for destroy functions of shared libraries. + using LibraryDestroyFn = void (*)(); + + ExecutionEngine(bool enableObjectDump, bool enableGDBNotificationListener, + bool enablePerfNotificationListener); + + ~ExecutionEngine(); + + /// Creates an execution engine for the given MLIR IR. If TargetMachine is + /// not provided, default TM is created (i.e. ignoring any command line flags + /// that could affect the set-up). + static llvm::Expected> + create(Operation *op, const ExecutionEngineOptions &options = {}, + std::unique_ptr tm = nullptr); + + /// Looks up a packed-argument function wrapping the function with the given + /// name and returns a pointer to it. Propagates errors in case of failure. + llvm::Expected lookupPacked(StringRef name) const; + + /// Looks up the original function with the given name and returns a + /// pointer to it. This is not necesarily a packed function. Propagates + /// errors in case of failure. + llvm::Expected lookup(StringRef name) const; + + /// Invokes the function with the given name passing it the list of opaque + /// pointers to the actual arguments. + llvm::Error invokePacked(StringRef name, + MutableArrayRef args = std::nullopt); + + /// Trait that defines how a given type is passed to the JIT code. This + /// defaults to passing the address but can be specialized. + template + struct Argument { + static void pack(SmallVectorImpl &args, T &val) { + args.push_back(&val); + } + }; + + /// Tag to wrap an output parameter when invoking a jitted function. + template + struct Result { + Result(T &result) : value(result) {} + T &value; + }; + + /// Helper function to wrap an output operand when using + /// ExecutionEngine::invoke. + template + static Result result(T &t) { + return Result(t); + } + + // Specialization for output parameter: their address is forwarded directly to + // the native code. + template + struct Argument> { + static void pack(SmallVectorImpl &args, Result &result) { + args.push_back(&result.value); + } + }; + + /// Invokes the function with the given name passing it the list of arguments + /// by value. Function result can be obtain through output parameter using the + /// `Result` wrapper defined above. For example: + /// + /// func @foo(%arg0 : i32) -> i32 attributes { llvm.emit_c_interface } + /// + /// can be invoked: + /// + /// int32_t result = 0; + /// llvm::Error error = jit->invoke("foo", 42, + /// result(result)); + template + llvm::Error invoke(StringRef funcName, Args... args) { + const std::string adapterName = + std::string("_mlir_ciface_") + funcName.str(); + llvm::SmallVector argsArray; + // Pack every arguments in an array of pointers. Delegate the packing to a + // trait so that it can be overridden per argument type. + (Argument::pack(argsArray, args), ...); + return invokePacked(adapterName, argsArray); + } + + /// Set the target triple and the data layout for the input module based on + /// the input TargetMachine. This is implicitly done when creating the + /// engine. + static void setupTargetTripleAndDataLayout(llvm::Module *llvmModule, + llvm::TargetMachine *tm); + + /// Dump object code to output file `filename`. + void dumpToObjectFile(StringRef filename); + + /// Register symbols with this ExecutionEngine. + void registerSymbols( + llvm::function_ref + symbolMap); + +private: + /// Ordering of llvmContext and jit is important for destruction purposes: the + /// jit must be destroyed before the context. + llvm::LLVMContext llvmContext; + + /// Underlying LLJIT. + std::unique_ptr jit; + + /// Underlying cache. + std::unique_ptr cache; + + /// Names of functions that may be looked up. + std::vector functionNames; + + /// GDB notification listener. + llvm::JITEventListener *gdbListener; + + /// Perf notification listener. + llvm::JITEventListener *perfListener; + + /// Destroy functions in the libraries loaded by the ExecutionEngine that are + /// called when this ExecutionEngine is destructed. + SmallVector destroyFns; +}; + +} // namespace mlir + +#endif // MLIR_EXECUTIONENGINE_EXECUTIONENGINE_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/Float16bits.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/Float16bits.h new file mode 100644 index 0000000000000000000000000000000000000000..5eb1f2ce07639d26bf30a228ef4b99235c8f2d93 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/Float16bits.h @@ -0,0 +1,55 @@ +//===--- Float16bits.h - supports 2-byte floats ---------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file implements f16 and bf16 to support the compilation and execution +// of programs using these types. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_EXECUTIONENGINE_FLOAT16BITS_H_ +#define MLIR_EXECUTIONENGINE_FLOAT16BITS_H_ + +#include +#include + +#ifdef _WIN32 +#ifdef mlir_float16_utils_EXPORTS // We are building this library +#define MLIR_FLOAT16_EXPORT __declspec(dllexport) +#define MLIR_FLOAT16_DEFINE_FUNCTIONS +#else // We are using this library +#define MLIR_FLOAT16_EXPORT __declspec(dllimport) +#endif // mlir_float16_utils_EXPORTS +#else // Non-windows: use visibility attributes. +#define MLIR_FLOAT16_EXPORT __attribute__((visibility("default"))) +#define MLIR_FLOAT16_DEFINE_FUNCTIONS +#endif // _WIN32 + +// Implements half precision and bfloat with f16 and bf16, using the MLIR type +// names. These data types are also used for c-interface runtime routines. +extern "C" { +struct MLIR_FLOAT16_EXPORT f16 { + f16(float f = 0); + uint16_t bits; +}; + +struct MLIR_FLOAT16_EXPORT bf16 { + bf16(float f = 0); + uint16_t bits; +}; +} + +// Outputs a half precision value. +MLIR_FLOAT16_EXPORT std::ostream &operator<<(std::ostream &os, const f16 &f); +// Outputs a bfloat value. +MLIR_FLOAT16_EXPORT std::ostream &operator<<(std::ostream &os, const bf16 &d); + +extern "C" MLIR_FLOAT16_EXPORT void printF16(uint16_t bits); +extern "C" MLIR_FLOAT16_EXPORT void printBF16(uint16_t bits); + +#undef MLIR_FLOAT16_EXPORT +#endif // MLIR_EXECUTIONENGINE_FLOAT16BITS_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/MemRefUtils.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/MemRefUtils.h new file mode 100644 index 0000000000000000000000000000000000000000..918647d9feac347f60d8c8292ee9ef7b4050fa15 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/MemRefUtils.h @@ -0,0 +1,214 @@ +//===- MemRefUtils.h - Memref helpers to invoke MLIR JIT code ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Utils for MLIR ABI interfacing with frameworks. +// +// The templated free functions below make it possible to allocate dense +// contiguous buffers with shapes that interoperate properly with the MLIR +// codegen ABI. +// +//===----------------------------------------------------------------------===// + +#include "mlir/ExecutionEngine/CRunnerUtils.h" +#include "mlir/Support/LLVM.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/STLExtras.h" + +#include "llvm/Support/raw_ostream.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef MLIR_EXECUTIONENGINE_MEMREFUTILS_H_ +#define MLIR_EXECUTIONENGINE_MEMREFUTILS_H_ + +namespace mlir { +using AllocFunType = llvm::function_ref; + +namespace detail { + +/// Given a shape with sizes greater than 0 along all dimensions, returns the +/// distance, in number of elements, between a slice in a dimension and the next +/// slice in the same dimension. +/// e.g. shape[3, 4, 5] -> strides[20, 5, 1] +template +inline std::array makeStrides(ArrayRef shape) { + assert(shape.size() == N && "expect shape specification to match rank"); + std::array res; + int64_t running = 1; + for (int64_t idx = N - 1; idx >= 0; --idx) { + assert(shape[idx] && "size must be non-negative for all shape dimensions"); + res[idx] = running; + running *= shape[idx]; + } + return res; +} + +/// Build a `StridedMemRefDescriptor` that matches the MLIR ABI. +/// This is an implementation detail that is kept in sync with MLIR codegen +/// conventions. Additionally takes a `shapeAlloc` array which +/// is used instead of `shape` to allocate "more aligned" data and compute the +/// corresponding strides. +template +typename std::enable_if<(N >= 1), StridedMemRefType>::type +makeStridedMemRefDescriptor(T *ptr, T *alignedPtr, ArrayRef shape, + ArrayRef shapeAlloc) { + assert(shape.size() == N); + assert(shapeAlloc.size() == N); + StridedMemRefType descriptor; + descriptor.basePtr = static_cast(ptr); + descriptor.data = static_cast(alignedPtr); + descriptor.offset = 0; + std::copy(shape.begin(), shape.end(), descriptor.sizes); + auto strides = makeStrides(shapeAlloc); + std::copy(strides.begin(), strides.end(), descriptor.strides); + return descriptor; +} + +/// Build a `StridedMemRefDescriptor` that matches the MLIR ABI. +/// This is an implementation detail that is kept in sync with MLIR codegen +/// conventions. Additionally takes a `shapeAlloc` array which +/// is used instead of `shape` to allocate "more aligned" data and compute the +/// corresponding strides. +template +typename std::enable_if<(N == 0), StridedMemRefType>::type +makeStridedMemRefDescriptor(T *ptr, T *alignedPtr, ArrayRef shape = {}, + ArrayRef shapeAlloc = {}) { + assert(shape.size() == N); + assert(shapeAlloc.size() == N); + StridedMemRefType descriptor; + descriptor.basePtr = static_cast(ptr); + descriptor.data = static_cast(alignedPtr); + descriptor.offset = 0; + return descriptor; +} + +/// Align `nElements` of type T with an optional `alignment`. +/// This replaces a portable `posix_memalign`. +/// `alignment` must be a power of 2 and greater than the size of T. By default +/// the alignment is sizeof(T). +template +std::pair +allocAligned(size_t nElements, AllocFunType allocFun = &::malloc, + std::optional alignment = std::optional()) { + assert(sizeof(T) <= UINT_MAX && "Elemental type overflows"); + auto size = nElements * sizeof(T); + auto desiredAlignment = alignment.value_or(nextPowerOf2(sizeof(T))); + assert((desiredAlignment & (desiredAlignment - 1)) == 0); + assert(desiredAlignment >= sizeof(T)); + T *data = reinterpret_cast(allocFun(size + desiredAlignment)); + uintptr_t addr = reinterpret_cast(data); + uintptr_t rem = addr % desiredAlignment; + T *alignedData = (rem == 0) + ? data + : reinterpret_cast(addr + (desiredAlignment - rem)); + assert(reinterpret_cast(alignedData) % desiredAlignment == 0); + return std::make_pair(data, alignedData); +} + +} // namespace detail + +//===----------------------------------------------------------------------===// +// Public API +//===----------------------------------------------------------------------===// + +/// Convenient callback to "visit" a memref element by element. +/// This takes a reference to an individual element as well as the coordinates. +/// It can be used in conjuction with a StridedMemrefIterator. +template +using ElementWiseVisitor = llvm::function_ref)>; + +/// Owning MemRef type that abstracts over the runtime type for ranked strided +/// memref. +template +class OwningMemRef { +public: + using DescriptorType = StridedMemRefType; + using FreeFunType = std::function; + + /// Allocate a new dense StridedMemrefRef with a given `shape`. An optional + /// `shapeAlloc` array can be supplied to "pad" every dimension individually. + /// If an ElementWiseVisitor is provided, it will be used to initialize the + /// data, else the memory will be zero-initialized. The alloc and free method + /// used to manage the data allocation can be optionally provided, and default + /// to malloc/free. + OwningMemRef( + ArrayRef shape, ArrayRef shapeAlloc = {}, + ElementWiseVisitor init = {}, + std::optional alignment = std::optional(), + AllocFunType allocFun = &::malloc, + std::function)> freeFun = + [](StridedMemRefType descriptor) { + ::free(descriptor.data); + }) + : freeFunc(freeFun) { + if (shapeAlloc.empty()) + shapeAlloc = shape; + assert(shape.size() == Rank); + assert(shapeAlloc.size() == Rank); + for (unsigned i = 0; i < Rank; ++i) + assert(shape[i] <= shapeAlloc[i] && + "shapeAlloc must be greater than or equal to shape"); + int64_t nElements = 1; + for (int64_t s : shapeAlloc) + nElements *= s; + auto [data, alignedData] = + detail::allocAligned(nElements, allocFun, alignment); + descriptor = detail::makeStridedMemRefDescriptor(data, alignedData, + shape, shapeAlloc); + if (init) { + for (StridedMemrefIterator it = descriptor.begin(), + end = descriptor.end(); + it != end; ++it) + init(*it, it.getIndices()); + } else { + memset(descriptor.data, 0, + nElements * sizeof(T) + + alignment.value_or(detail::nextPowerOf2(sizeof(T)))); + } + } + /// Take ownership of an existing descriptor with a custom deleter. + OwningMemRef(DescriptorType descriptor, FreeFunType freeFunc) + : freeFunc(freeFunc), descriptor(descriptor) {} + ~OwningMemRef() { + if (freeFunc) + freeFunc(descriptor); + } + OwningMemRef(const OwningMemRef &) = delete; + OwningMemRef &operator=(const OwningMemRef &) = delete; + OwningMemRef &operator=(const OwningMemRef &&other) { + freeFunc = other.freeFunc; + descriptor = other.descriptor; + other.freeFunc = nullptr; + memset(&other.descriptor, 0, sizeof(other.descriptor)); + } + OwningMemRef(OwningMemRef &&other) { *this = std::move(other); } + + DescriptorType &operator*() { return descriptor; } + DescriptorType *operator->() { return &descriptor; } + T &operator[](std::initializer_list indices) { + return descriptor[indices]; + } + +private: + /// Custom deleter used to release the data buffer manager with the descriptor + /// below. + FreeFunType freeFunc; + /// The descriptor is an instance of StridedMemRefType. + DescriptorType descriptor; +}; + +} // namespace mlir + +#endif // MLIR_EXECUTIONENGINE_MEMREFUTILS_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/Msan.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/Msan.h new file mode 100644 index 0000000000000000000000000000000000000000..ee94660ae650c769f7539cc6f0e7833e372282af --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/Msan.h @@ -0,0 +1,35 @@ +//===- Msan.h - Utils related to the memory sanitizer ---------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file declares and defines macros related to msan. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_EXECUTIONENGINE_MSAN_H +#define MLIR_EXECUTIONENGINE_MSAN_H + +// Memory sanitizer currently can't be enabled for the jit-compiled code, and +// to suppress msan warnings we need to unpoison pointers and pointed-to +// datastructures before they can be accessed. + +#ifndef __has_feature +#define __has_feature(x) 0 +#endif + +#if __has_feature(memory_sanitizer) && !defined(MLIR_MEMORY_SANITIZER) +#define MLIR_MEMORY_SANITIZER +#endif + +#if defined(MLIR_MEMORY_SANITIZER) +#include +#define MLIR_MSAN_MEMORY_IS_INITIALIZED(p, s) __msan_unpoison((p), (s)) +#else // Memory sanitizer: OFF +#define MLIR_MSAN_MEMORY_IS_INITIALIZED(p, s) +#endif // MLIR_MEMORY_SANITIZER + +#endif // MLIR_EXECUTIONENGINE_MSAN_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/OptUtils.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/OptUtils.h new file mode 100644 index 0000000000000000000000000000000000000000..4cee8c6d60ff11ee044190814148e66ed5167b73 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/OptUtils.h @@ -0,0 +1,39 @@ +//===- OptUtils.h - MLIR Execution Engine opt pass utilities ----*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file declares the utility functions to trigger LLVM optimizations from +// MLIR Execution Engine. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_EXECUTIONENGINE_OPTUTILS_H +#define MLIR_EXECUTIONENGINE_OPTUTILS_H + +#include +#include + +namespace llvm { +class Module; +class Error; +class TargetMachine; +} // namespace llvm + +namespace mlir { + +/// Create a module transformer function for MLIR ExecutionEngine that runs +/// LLVM IR passes corresponding to the given speed and size optimization +/// levels (e.g. -O2 or -Os). If not null, `targetMachine` is used to +/// initialize passes that provide target-specific information to the LLVM +/// optimizer. `targetMachine` must outlive the returned std::function. +std::function +makeOptimizingTransformer(unsigned optLevel, unsigned sizeLevel, + llvm::TargetMachine *targetMachine); + +} // namespace mlir + +#endif // MLIR_EXECUTIONENGINE_OPTUTILS_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/RunnerUtils.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/RunnerUtils.h new file mode 100644 index 0000000000000000000000000000000000000000..56c0983e5f15b5af32ac4ea86e5cf243ee27213b --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/RunnerUtils.h @@ -0,0 +1,461 @@ +//===- RunnerUtils.h - Utils for debugging MLIR execution -----------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file declares basic classes and functions to debug structured MLIR +// types at runtime. Entities in this file may not be compatible with targets +// without a C++ runtime. These may be progressively migrated to CRunnerUtils.h +// over time. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_EXECUTIONENGINE_RUNNERUTILS_H +#define MLIR_EXECUTIONENGINE_RUNNERUTILS_H + +#ifdef _WIN32 +#ifndef MLIR_RUNNERUTILS_EXPORT +#ifdef mlir_runner_utils_EXPORTS +// We are building this library +#define MLIR_RUNNERUTILS_EXPORT __declspec(dllexport) +#else +// We are using this library +#define MLIR_RUNNERUTILS_EXPORT __declspec(dllimport) +#endif // mlir_runner_utils_EXPORTS +#endif // MLIR_RUNNERUTILS_EXPORT +#else +// Non-windows: use visibility attributes. +#define MLIR_RUNNERUTILS_EXPORT __attribute__((visibility("default"))) +#endif // _WIN32 + +#include +#include +#include +#include +#include + +#include "mlir/ExecutionEngine/CRunnerUtils.h" + +template +void printMemRefMetaData(StreamType &os, const DynamicMemRefType &v) { + // Make the printed pointer format platform independent by casting it to an + // integer and manually formatting it to a hex with prefix as tests expect. + os << "base@ = " << std::hex << std::showbase + << reinterpret_cast(v.data) << std::dec << std::noshowbase + << " rank = " << v.rank << " offset = " << v.offset; + auto print = [&](const int64_t *ptr) { + if (v.rank == 0) + return; + os << ptr[0]; + for (int64_t i = 1; i < v.rank; ++i) + os << ", " << ptr[i]; + }; + os << " sizes = ["; + print(v.sizes); + os << "] strides = ["; + print(v.strides); + os << "]"; +} + +template +void printMemRefMetaData(StreamType &os, StridedMemRefType &v) { + static_assert(N >= 0, "Expected N > 0"); + os << "MemRef "; + printMemRefMetaData(os, DynamicMemRefType(v)); +} + +template +void printUnrankedMemRefMetaData(StreamType &os, UnrankedMemRefType &v) { + os << "Unranked MemRef "; + printMemRefMetaData(os, DynamicMemRefType(v)); +} + +//////////////////////////////////////////////////////////////////////////////// +// Templated instantiation follows. +//////////////////////////////////////////////////////////////////////////////// +namespace impl { +using index_type = uint64_t; +using complex64 = std::complex; +using complex32 = std::complex; + +template +std::ostream &operator<<(std::ostream &os, const Vector &v); + +template +struct StaticSizeMult { + static constexpr int value = 1; +}; + +template +struct StaticSizeMult { + static constexpr int value = N * StaticSizeMult::value; +}; + +static inline void printSpace(std::ostream &os, int count) { + for (int i = 0; i < count; ++i) { + os << ' '; + } +} + +template +struct VectorDataPrinter { + static void print(std::ostream &os, const Vector &val); +}; + +template +void VectorDataPrinter::print(std::ostream &os, + const Vector &val) { + static_assert(M > 0, "0 dimensioned tensor"); + static_assert(sizeof(val) == M * StaticSizeMult::value * sizeof(T), + "Incorrect vector size!"); + // First + os << "(" << val[0]; + if (M > 1) + os << ", "; + if (sizeof...(Dims) > 1) + os << "\n"; + // Kernel + for (unsigned i = 1; i + 1 < M; ++i) { + printSpace(os, 2 * sizeof...(Dims)); + os << val[i] << ", "; + if (sizeof...(Dims) > 1) + os << "\n"; + } + // Last + if (M > 1) { + printSpace(os, sizeof...(Dims)); + os << val[M - 1]; + } + os << ")"; +} + +template +std::ostream &operator<<(std::ostream &os, const Vector &v) { + VectorDataPrinter::print(os, v); + return os; +} + +template +struct MemRefDataPrinter { + static void print(std::ostream &os, T *base, int64_t dim, int64_t rank, + int64_t offset, const int64_t *sizes, + const int64_t *strides); + static void printFirst(std::ostream &os, T *base, int64_t dim, int64_t rank, + int64_t offset, const int64_t *sizes, + const int64_t *strides); + static void printLast(std::ostream &os, T *base, int64_t dim, int64_t rank, + int64_t offset, const int64_t *sizes, + const int64_t *strides); +}; + +template +void MemRefDataPrinter::printFirst(std::ostream &os, T *base, int64_t dim, + int64_t rank, int64_t offset, + const int64_t *sizes, + const int64_t *strides) { + os << "["; + print(os, base, dim - 1, rank, offset, sizes + 1, strides + 1); + // If single element, close square bracket and return early. + if (sizes[0] <= 1) { + os << "]"; + return; + } + os << ", "; + if (dim > 1) + os << "\n"; +} + +template +void MemRefDataPrinter::print(std::ostream &os, T *base, int64_t dim, + int64_t rank, int64_t offset, + const int64_t *sizes, const int64_t *strides) { + if (dim == 0) { + os << base[offset]; + return; + } + printFirst(os, base, dim, rank, offset, sizes, strides); + for (unsigned i = 1; i + 1 < sizes[0]; ++i) { + printSpace(os, rank - dim + 1); + print(os, base, dim - 1, rank, offset + i * strides[0], sizes + 1, + strides + 1); + os << ", "; + if (dim > 1) + os << "\n"; + } + if (sizes[0] <= 1) + return; + printLast(os, base, dim, rank, offset, sizes, strides); +} + +template +void MemRefDataPrinter::printLast(std::ostream &os, T *base, int64_t dim, + int64_t rank, int64_t offset, + const int64_t *sizes, + const int64_t *strides) { + printSpace(os, rank - dim + 1); + print(os, base, dim - 1, rank, offset + (sizes[0] - 1) * (*strides), + sizes + 1, strides + 1); + os << "]"; +} + +template +void printMemRefShape(StridedMemRefType &m) { + std::cout << "Memref "; + printMemRefMetaData(std::cout, DynamicMemRefType(m)); +} + +template +void printMemRefShape(UnrankedMemRefType &m) { + std::cout << "Unranked Memref "; + printMemRefMetaData(std::cout, DynamicMemRefType(m)); +} + +template +void printMemRef(const DynamicMemRefType &m) { + printMemRefMetaData(std::cout, m); + std::cout << " data = " << std::endl; + if (m.rank == 0) + std::cout << "["; + MemRefDataPrinter::print(std::cout, m.data, m.rank, m.rank, m.offset, + m.sizes, m.strides); + if (m.rank == 0) + std::cout << "]"; + std::cout << std::endl; +} + +template +void printMemRef(StridedMemRefType &m) { + std::cout << "Memref "; + printMemRef(DynamicMemRefType(m)); +} + +template +void printMemRef(UnrankedMemRefType &m) { + std::cout << "Unranked Memref "; + printMemRef(DynamicMemRefType(m)); +} + +/// Verify the result of two computations are equivalent up to a small +/// numerical error and return the number of errors. +template +struct MemRefDataVerifier { + /// Maximum number of errors printed by the verifier. + static constexpr int printLimit = 10; + + /// Verify the relative difference of the values is smaller than epsilon. + static bool verifyRelErrorSmallerThan(T actual, T expected, T epsilon); + + /// Verify the values are equivalent (integers) or are close (floating-point). + static bool verifyElem(T actual, T expected); + + /// Verify the data element-by-element and return the number of errors. + static int64_t verify(std::ostream &os, T *actualBasePtr, T *expectedBasePtr, + int64_t dim, int64_t offset, const int64_t *sizes, + const int64_t *strides, int64_t &printCounter); +}; + +template +bool MemRefDataVerifier::verifyRelErrorSmallerThan(T actual, T expected, + T epsilon) { + // Return an error if one of the values is infinite or NaN. + if (!std::isfinite(actual) || !std::isfinite(expected)) + return false; + // Return true if the relative error is smaller than epsilon. + T delta = std::abs(actual - expected); + return (delta <= epsilon * std::abs(expected)); +} + +template +bool MemRefDataVerifier::verifyElem(T actual, T expected) { + return actual == expected; +} + +template <> +inline bool MemRefDataVerifier::verifyElem(double actual, + double expected) { + return verifyRelErrorSmallerThan(actual, expected, 1e-12); +} + +template <> +inline bool MemRefDataVerifier::verifyElem(float actual, + float expected) { + return verifyRelErrorSmallerThan(actual, expected, 1e-6f); +} + +template +int64_t MemRefDataVerifier::verify(std::ostream &os, T *actualBasePtr, + T *expectedBasePtr, int64_t dim, + int64_t offset, const int64_t *sizes, + const int64_t *strides, + int64_t &printCounter) { + int64_t errors = 0; + // Verify the elements at the current offset. + if (dim == 0) { + if (!verifyElem(actualBasePtr[offset], expectedBasePtr[offset])) { + if (printCounter < printLimit) { + os << actualBasePtr[offset] << " != " << expectedBasePtr[offset] + << " offset = " << offset << "\n"; + printCounter++; + } + errors++; + } + } else { + // Iterate the current dimension and verify recursively. + for (int64_t i = 0; i < sizes[0]; ++i) { + errors += + verify(os, actualBasePtr, expectedBasePtr, dim - 1, + offset + i * strides[0], sizes + 1, strides + 1, printCounter); + } + } + return errors; +} + +/// Verify the equivalence of two dynamic memrefs and return the number of +/// errors or -1 if the shape of the memrefs do not match. +template +int64_t verifyMemRef(const DynamicMemRefType &actual, + const DynamicMemRefType &expected) { + // Check if the memref shapes match. + for (int64_t i = 0; i < actual.rank; ++i) { + if (expected.rank != actual.rank || actual.offset != expected.offset || + actual.sizes[i] != expected.sizes[i] || + actual.strides[i] != expected.strides[i]) { + printMemRefMetaData(std::cerr, actual); + printMemRefMetaData(std::cerr, expected); + return -1; + } + } + // Return the number of errors. + int64_t printCounter = 0; + return MemRefDataVerifier::verify( + std::cerr, actual.basePtr, expected.basePtr, actual.rank, actual.offset, + actual.sizes, actual.strides, printCounter); +} + +/// Verify the equivalence of two unranked memrefs and return the number of +/// errors or -1 if the shape of the memrefs do not match. +template +int64_t verifyMemRef(UnrankedMemRefType &actual, + UnrankedMemRefType &expected) { + return verifyMemRef(DynamicMemRefType(actual), + DynamicMemRefType(expected)); +} + +} // namespace impl + +//////////////////////////////////////////////////////////////////////////////// +// Currently exposed C API. +//////////////////////////////////////////////////////////////////////////////// +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemrefShapeI8(UnrankedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemrefShapeI32(UnrankedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemrefShapeI64(UnrankedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemrefShapeF32(UnrankedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemrefShapeF64(UnrankedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemrefShapeInd(UnrankedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemrefShapeC32(UnrankedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemrefShapeC64(UnrankedMemRefType *m); + +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemrefI8(UnrankedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemrefI32(UnrankedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemrefI64(UnrankedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemrefF32(UnrankedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemrefF64(UnrankedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemrefInd(UnrankedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemrefC32(UnrankedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemrefC64(UnrankedMemRefType *m); + +extern "C" MLIR_RUNNERUTILS_EXPORT int64_t _mlir_ciface_nanoTime(); + +extern "C" MLIR_RUNNERUTILS_EXPORT void printMemrefI32(int64_t rank, void *ptr); +extern "C" MLIR_RUNNERUTILS_EXPORT void printMemrefI64(int64_t rank, void *ptr); +extern "C" MLIR_RUNNERUTILS_EXPORT void printMemrefF32(int64_t rank, void *ptr); +extern "C" MLIR_RUNNERUTILS_EXPORT void printMemrefF64(int64_t rank, void *ptr); +extern "C" MLIR_RUNNERUTILS_EXPORT void printMemrefInd(int64_t rank, void *ptr); +extern "C" MLIR_RUNNERUTILS_EXPORT void printMemrefC32(int64_t rank, void *ptr); +extern "C" MLIR_RUNNERUTILS_EXPORT void printMemrefC64(int64_t rank, void *ptr); +extern "C" MLIR_RUNNERUTILS_EXPORT void printCString(char *str); + +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemref0dF32(StridedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemref1dF32(StridedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemref2dF32(StridedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemref3dF32(StridedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemref4dF32(StridedMemRefType *m); + +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemref1dI8(StridedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemref1dI32(StridedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemref1dI64(StridedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemref1dF64(StridedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemref1dInd(StridedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemref1dC32(StridedMemRefType *m); +extern "C" MLIR_RUNNERUTILS_EXPORT void +_mlir_ciface_printMemref1dC64(StridedMemRefType *m); + +extern "C" MLIR_RUNNERUTILS_EXPORT void _mlir_ciface_printMemrefVector4x4xf32( + StridedMemRefType, 2> *m); + +extern "C" MLIR_RUNNERUTILS_EXPORT int64_t _mlir_ciface_verifyMemRefI32( + UnrankedMemRefType *actual, UnrankedMemRefType *expected); +extern "C" MLIR_RUNNERUTILS_EXPORT int64_t _mlir_ciface_verifyMemRefF32( + UnrankedMemRefType *actual, UnrankedMemRefType *expected); +extern "C" MLIR_RUNNERUTILS_EXPORT int64_t _mlir_ciface_verifyMemRefF64( + UnrankedMemRefType *actual, UnrankedMemRefType *expected); +extern "C" MLIR_RUNNERUTILS_EXPORT int64_t +_mlir_ciface_verifyMemRefInd(UnrankedMemRefType *actual, + UnrankedMemRefType *expected); +extern "C" MLIR_RUNNERUTILS_EXPORT int64_t +_mlir_ciface_verifyMemRefC32(UnrankedMemRefType *actual, + UnrankedMemRefType *expected); +extern "C" MLIR_RUNNERUTILS_EXPORT int64_t +_mlir_ciface_verifyMemRefC64(UnrankedMemRefType *actual, + UnrankedMemRefType *expected); + +extern "C" MLIR_RUNNERUTILS_EXPORT int64_t verifyMemRefI32(int64_t rank, + void *actualPtr, + void *expectedPtr); +extern "C" MLIR_RUNNERUTILS_EXPORT int64_t verifyMemRefF32(int64_t rank, + void *actualPtr, + void *expectedPtr); +extern "C" MLIR_RUNNERUTILS_EXPORT int64_t verifyMemRefF64(int64_t rank, + void *actualPtr, + void *expectedPtr); +extern "C" MLIR_RUNNERUTILS_EXPORT int64_t verifyMemRefInd(int64_t rank, + void *actualPtr, + void *expectedPtr); +extern "C" MLIR_RUNNERUTILS_EXPORT int64_t verifyMemRefC32(int64_t rank, + void *actualPtr, + void *expectedPtr); +extern "C" MLIR_RUNNERUTILS_EXPORT int64_t verifyMemRefC64(int64_t rank, + void *actualPtr, + void *expectedPtr); + +#endif // MLIR_EXECUTIONENGINE_RUNNERUTILS_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/SparseTensor/ArithmeticUtils.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/SparseTensor/ArithmeticUtils.h new file mode 100644 index 0000000000000000000000000000000000000000..32b7d6ef1f668c318c96023ac84571d4ac179a20 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/SparseTensor/ArithmeticUtils.h @@ -0,0 +1,133 @@ +//===- ArithmeticUtils.h - Arithmetic helper functions ----------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// A collection of "safe" arithmetic helper methods. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_EXECUTIONENGINE_SPARSETENSOR_ARITHMETICUTILS_H +#define MLIR_EXECUTIONENGINE_SPARSETENSOR_ARITHMETICUTILS_H + +#include +#include +#include +#include + +namespace mlir { +namespace sparse_tensor { +namespace detail { + +//===----------------------------------------------------------------------===// +// +// Safe comparison functions. +// +// Variants of the `==`, `!=`, `<`, `<=`, `>`, and `>=` operators which +// are careful to ensure that negatives are always considered strictly +// less than non-negatives regardless of the signedness of the types of +// the two arguments. They are "safe" in that they guarantee to *always* +// give an output and that that output is correct; in particular this means +// they never use assertions or other mechanisms for "returning an error". +// +// These functions are C++17-compatible backports of the safe comparison +// functions added in C++20, and the implementations are based on the +// sample implementations provided by the standard: +// . +// +//===----------------------------------------------------------------------===// + +template +constexpr bool safelyEQ(T t, U u) noexcept { + using UT = std::make_unsigned_t; + using UU = std::make_unsigned_t; + if constexpr (std::is_signed_v == std::is_signed_v) + return t == u; + else if constexpr (std::is_signed_v) + return t < 0 ? false : static_cast(t) == u; + else + return u < 0 ? false : t == static_cast(u); +} + +template +constexpr bool safelyNE(T t, U u) noexcept { + return !safelyEQ(t, u); +} + +template +constexpr bool safelyLT(T t, U u) noexcept { + using UT = std::make_unsigned_t; + using UU = std::make_unsigned_t; + if constexpr (std::is_signed_v == std::is_signed_v) + return t < u; + else if constexpr (std::is_signed_v) + return t < 0 ? true : static_cast(t) < u; + else + return u < 0 ? false : t < static_cast(u); +} + +template +constexpr bool safelyGT(T t, U u) noexcept { + return safelyLT(u, t); +} + +template +constexpr bool safelyLE(T t, U u) noexcept { + return !safelyGT(t, u); +} + +template +constexpr bool safelyGE(T t, U u) noexcept { + return !safelyLT(t, u); +} + +//===----------------------------------------------------------------------===// +// +// Overflow checking functions. +// +// These functions use assertions to ensure correctness with respect to +// overflow/underflow. Unlike the "safe" functions above, these "checked" +// functions only guarantee that *if* they return an answer then that answer +// is correct. When assertions are enabled, they do their best to remain +// as fast as possible (since MLIR keeps assertions enabled by default, +// even for optimized builds). When assertions are disabled, they use the +// standard unchecked implementations. +// +//===----------------------------------------------------------------------===// + +/// A version of `static_cast` which checks for overflow/underflow. +/// The implementation avoids performing runtime assertions whenever +/// the types alone are sufficient to statically prove that overflow +/// cannot happen. +template +[[nodiscard]] inline To checkOverflowCast(From x) { + // Check the lower bound. (For when casting from signed types.) + constexpr To minTo = std::numeric_limits::min(); + constexpr From minFrom = std::numeric_limits::min(); + if constexpr (!safelyGE(minFrom, minTo)) + assert(safelyGE(x, minTo) && "cast would underflow"); + // Check the upper bound. + constexpr To maxTo = std::numeric_limits::max(); + constexpr From maxFrom = std::numeric_limits::max(); + if constexpr (!safelyLE(maxFrom, maxTo)) + assert(safelyLE(x, maxTo) && "cast would overflow"); + // Now do the cast itself. + return static_cast(x); +} + +/// A version of `operator*` on `uint64_t` which guards against overflows +/// (when assertions are enabled). +inline uint64_t checkedMul(uint64_t lhs, uint64_t rhs) { + assert((lhs == 0 || rhs <= std::numeric_limits::max() / lhs) && + "Integer overflow"); + return lhs * rhs; +} + +} // namespace detail +} // namespace sparse_tensor +} // namespace mlir + +#endif // MLIR_EXECUTIONENGINE_SPARSETENSOR_ARITHMETICUTILS_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/SparseTensor/COO.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/SparseTensor/COO.h new file mode 100644 index 0000000000000000000000000000000000000000..f6eb45defcc1cfd0ca78e2d02fb957a79b8635de --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/SparseTensor/COO.h @@ -0,0 +1,161 @@ +//===- COO.h - Coordinate-scheme sparse tensor representation ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file contains a coordinate-scheme representation of sparse tensors. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_EXECUTIONENGINE_SPARSETENSOR_COO_H +#define MLIR_EXECUTIONENGINE_SPARSETENSOR_COO_H + +#include +#include +#include +#include +#include + +namespace mlir { +namespace sparse_tensor { + +/// An element of a sparse tensor in coordinate-scheme representation +/// (i.e., a pair of coordinates and value). For example, a rank-1 +/// vector element would look like +/// ({i}, a[i]) +/// and a rank-5 tensor element would look like +/// ({i,j,k,l,m}, a[i,j,k,l,m]) +/// +/// The coordinates are represented as a (non-owning) pointer into a +/// shared pool of coordinates, rather than being stored directly in this +/// object. This significantly improves performance because it reduces the +/// per-element memory footprint and centralizes the memory management for +/// coordinates. The only downside is that the coordinates themselves cannot +/// be retrieved without knowing the rank of the tensor to which this element +/// belongs (and that rank is not stored in this object). +template +struct Element final { + Element(const uint64_t *coords, V val) : coords(coords), value(val){}; + const uint64_t *coords; // pointer into shared coordinates pool + V value; +}; + +/// Closure object for `operator<` on `Element` with a given rank. +template +struct ElementLT final { + ElementLT(uint64_t rank) : rank(rank) {} + bool operator()(const Element &e1, const Element &e2) const { + for (uint64_t d = 0; d < rank; ++d) { + if (e1.coords[d] == e2.coords[d]) + continue; + return e1.coords[d] < e2.coords[d]; + } + return false; + } + const uint64_t rank; +}; + +/// The type of callback functions which receive an element. +template +using ElementConsumer = + const std::function &, V)> &; + +/// A memory-resident sparse tensor in coordinate-scheme representation +/// (a collection of `Element`s). This data structure is used as +/// an intermediate representation; e.g., for reading sparse tensors +/// from external formats into memory, or for certain conversions between +/// different `SparseTensorStorage` formats. +template +class SparseTensorCOO final { +public: + using const_iterator = typename std::vector>::const_iterator; + + /// Constructs a new coordinate-scheme sparse tensor with the given + /// sizes and an optional initial storage capacity. + explicit SparseTensorCOO(const std::vector &dimSizes, + uint64_t capacity = 0) + : SparseTensorCOO(dimSizes.size(), dimSizes.data(), capacity) {} + + /// Constructs a new coordinate-scheme sparse tensor with the given + /// sizes and an optional initial storage capacity. The size of the + /// dimSizes array is determined by dimRank. + explicit SparseTensorCOO(uint64_t dimRank, const uint64_t *dimSizes, + uint64_t capacity = 0) + : dimSizes(dimSizes, dimSizes + dimRank), isSorted(true) { + assert(dimRank > 0 && "Trivial shape is not supported"); + for (uint64_t d = 0; d < dimRank; ++d) + assert(dimSizes[d] > 0 && "Dimension size zero has trivial storage"); + if (capacity) { + elements.reserve(capacity); + coordinates.reserve(capacity * dimRank); + } + } + + /// Gets the dimension-rank of the tensor. + uint64_t getRank() const { return dimSizes.size(); } + + /// Gets the dimension-sizes array. + const std::vector &getDimSizes() const { return dimSizes; } + + /// Gets the elements array. + const std::vector> &getElements() const { return elements; } + + /// Returns the `operator<` closure object for the COO's element type. + ElementLT getElementLT() const { return ElementLT(getRank()); } + + /// Adds an element to the tensor. This method invalidates all iterators. + void add(const std::vector &dimCoords, V val) { + const uint64_t *base = coordinates.data(); + const uint64_t size = coordinates.size(); + const uint64_t dimRank = getRank(); + assert(dimCoords.size() == dimRank && "Element rank mismatch"); + for (uint64_t d = 0; d < dimRank; ++d) { + assert(dimCoords[d] < dimSizes[d] && + "Coordinate is too large for the dimension"); + coordinates.push_back(dimCoords[d]); + } + // This base only changes if `coordinates` was reallocated. In which + // case, we need to correct all previous pointers into the vector. + // Note that this only happens if we did not set the initial capacity + // right, and then only for every internal vector reallocation (which + // with the doubling rule should only incur an amortized linear overhead). + const uint64_t *const newBase = coordinates.data(); + if (newBase != base) { + for (uint64_t i = 0, n = elements.size(); i < n; ++i) + elements[i].coords = newBase + (elements[i].coords - base); + base = newBase; + } + // Add the new element and update the sorted bit. + const Element addedElem(base + size, val); + if (!elements.empty() && isSorted) + isSorted = getElementLT()(elements.back(), addedElem); + elements.push_back(addedElem); + } + + const_iterator begin() const { return elements.cbegin(); } + const_iterator end() const { return elements.cend(); } + + /// Sorts elements lexicographically by coordinates. If a coordinate + /// is mapped to multiple values, then the relative order of those + /// values is unspecified. This method invalidates all iterators. + void sort() { + if (isSorted) + return; + std::sort(elements.begin(), elements.end(), getElementLT()); + isSorted = true; + } + +private: + const std::vector dimSizes; // per-dimension sizes + std::vector> elements; // all COO elements + std::vector coordinates; // shared coordinate pool + bool isSorted; +}; + +} // namespace sparse_tensor +} // namespace mlir + +#endif // MLIR_EXECUTIONENGINE_SPARSETENSOR_COO_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/SparseTensor/ErrorHandling.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/SparseTensor/ErrorHandling.h new file mode 100644 index 0000000000000000000000000000000000000000..6b39526211c77d758a80c84b4cd76a81afe9312a --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/SparseTensor/ErrorHandling.h @@ -0,0 +1,34 @@ +//===- ErrorHandling.h - Helpers for errors ---------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file defines an extremely lightweight API for fatal errors (not +// arising from assertions). The API does not attempt to be sophisticated +// in any way, it's just the usual "I give up" style of error reporting. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_EXECUTIONENGINE_SPARSETENSOR_ERRORHANDLING_H +#define MLIR_EXECUTIONENGINE_SPARSETENSOR_ERRORHANDLING_H + +#include +#include + +/// This macro helps minimize repetition of the printf-and-exit idiom, +/// as well as ensuring that we print some additional output indicating +/// where the error is coming from--- to make it easier to determine +/// whether some particular error is coming from the runtime library's +/// code vs from somewhere else in the MLIR stack. (Since that can be +/// hard to determine without the stacktraces provided by assertion failures.) +#define MLIR_SPARSETENSOR_FATAL(...) \ + do { \ + fprintf(stderr, "SparseTensorUtils: " __VA_ARGS__); \ + fprintf(stderr, "SparseTensorUtils: at %s:%d\n", __FILE__, __LINE__); \ + exit(1); \ + } while (0) + +#endif // MLIR_EXECUTIONENGINE_SPARSETENSOR_ERRORHANDLING_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/SparseTensor/File.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/SparseTensor/File.h new file mode 100644 index 0000000000000000000000000000000000000000..9157bfa7e77323983535403031c1bba8b2079c59 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/SparseTensor/File.h @@ -0,0 +1,390 @@ +//===- File.h - Reading/writing sparse tensors from/to files ----*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file implements reading and writing sparse tensor files in one of the +// following external formats: +// +// (1) Matrix Market Exchange (MME): *.mtx +// https://math.nist.gov/MatrixMarket/formats.html +// +// (2) Formidable Repository of Open Sparse Tensors and Tools (FROSTT): *.tns +// http://frostt.io/tensors/file-formats.html +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_EXECUTIONENGINE_SPARSETENSOR_FILE_H +#define MLIR_EXECUTIONENGINE_SPARSETENSOR_FILE_H + +#include "mlir/ExecutionEngine/SparseTensor/MapRef.h" +#include "mlir/ExecutionEngine/SparseTensor/Storage.h" + +#include + +namespace mlir { +namespace sparse_tensor { + +namespace detail { + +template +struct is_complex final : public std::false_type {}; + +template +struct is_complex> final : public std::true_type {}; + +/// Returns an element-value of non-complex type. If `IsPattern` is true, +/// then returns an arbitrary value. If `IsPattern` is false, then +/// reads the value from the current line buffer beginning at `linePtr`. +template +inline std::enable_if_t::value, V> readValue(char **linePtr) { + // The external formats always store these numerical values with the type + // double, but we cast these values to the sparse tensor object type. + // For a pattern tensor, we arbitrarily pick the value 1 for all entries. + if constexpr (IsPattern) + return 1.0; + return strtod(*linePtr, linePtr); +} + +/// Returns an element-value of complex type. If `IsPattern` is true, +/// then returns an arbitrary value. If `IsPattern` is false, then reads +/// the value from the current line buffer beginning at `linePtr`. +template +inline std::enable_if_t::value, V> readValue(char **linePtr) { + // Read two values to make a complex. The external formats always store + // numerical values with the type double, but we cast these values to the + // sparse tensor object type. For a pattern tensor, we arbitrarily pick the + // value 1 for all entries. + if constexpr (IsPattern) + return V(1.0, 1.0); + double re = strtod(*linePtr, linePtr); + double im = strtod(*linePtr, linePtr); + // Avoiding brace-notation since that forbids narrowing to `float`. + return V(re, im); +} + +/// Returns an element-value. If `isPattern` is true, then returns an +/// arbitrary value. If `isPattern` is false, then reads the value from +/// the current line buffer beginning at `linePtr`. +template +inline V readValue(char **linePtr, bool isPattern) { + return isPattern ? readValue(linePtr) : readValue(linePtr); +} + +} // namespace detail + +//===----------------------------------------------------------------------===// +// +// Reader class. +// +//===----------------------------------------------------------------------===// + +/// This class abstracts over the information stored in file headers, +/// as well as providing the buffers and methods for parsing those headers. +class SparseTensorReader final { +public: + enum class ValueKind : uint8_t { + // The value before calling `readHeader`. + kInvalid = 0, + // Values that can be set by `readMMEHeader`. + kPattern = 1, + kReal = 2, + kInteger = 3, + kComplex = 4, + // The value set by `readExtFROSTTHeader`. + kUndefined = 5 + }; + + explicit SparseTensorReader(const char *filename) : filename(filename) { + assert(filename && "Received nullptr for filename"); + } + + // Disallows copying, to avoid duplicating the `file` pointer. + SparseTensorReader(const SparseTensorReader &) = delete; + SparseTensorReader &operator=(const SparseTensorReader &) = delete; + + /// Factory method to allocate a new reader, open the file, read the + /// header, and validate that the actual contents of the file match + /// the expected `dimShape` and `valTp`. + static SparseTensorReader *create(const char *filename, uint64_t dimRank, + const uint64_t *dimShape, + PrimaryType valTp) { + SparseTensorReader *reader = new SparseTensorReader(filename); + reader->openFile(); + reader->readHeader(); + if (!reader->canReadAs(valTp)) + MLIR_SPARSETENSOR_FATAL( + "Tensor element type %d not compatible with values in file %s\n", + static_cast(valTp), filename); + reader->assertMatchesShape(dimRank, dimShape); + return reader; + } + + // This dtor tries to avoid leaking the `file`. (Though it's better + // to call `closeFile` explicitly when possible, since there are + // circumstances where dtors are not called reliably.) + ~SparseTensorReader() { closeFile(); } + + /// Opens the file for reading. + void openFile(); + + /// Closes the file. + void closeFile(); + + /// Reads and parses the file's header. + void readHeader(); + + /// Returns the stored value kind. + ValueKind getValueKind() const { return valueKind_; } + + /// Checks if a header has been successfully read. + bool isValid() const { return valueKind_ != ValueKind::kInvalid; } + + /// Checks if the file's ValueKind can be converted into the given + /// tensor PrimaryType. Is only valid after parsing the header. + bool canReadAs(PrimaryType valTy) const; + + /// Gets the MME "pattern" property setting. Is only valid after + /// parsing the header. + bool isPattern() const { + assert(isValid() && "Attempt to isPattern() before readHeader()"); + return valueKind_ == ValueKind::kPattern; + } + + /// Gets the MME "symmetric" property setting. Is only valid after + /// parsing the header. + bool isSymmetric() const { + assert(isValid() && "Attempt to isSymmetric() before readHeader()"); + return isSymmetric_; + } + + /// Gets the dimension-rank of the tensor. Is only valid after parsing + /// the header. + uint64_t getRank() const { + assert(isValid() && "Attempt to getRank() before readHeader()"); + return idata[0]; + } + + /// Gets the number of stored elements. Is only valid after parsing + /// the header. + uint64_t getNSE() const { + assert(isValid() && "Attempt to getNSE() before readHeader()"); + return idata[1]; + } + + /// Gets the dimension-sizes array. The pointer itself is always + /// valid; however, the values stored therein are only valid after + /// parsing the header. + const uint64_t *getDimSizes() const { return idata + 2; } + + /// Safely gets the size of the given dimension. Is only valid + /// after parsing the header. + uint64_t getDimSize(uint64_t d) const { + assert(d < getRank() && "Dimension out of bounds"); + return idata[2 + d]; + } + + /// Asserts the shape subsumes the actual dimension sizes. Is only + /// valid after parsing the header. + void assertMatchesShape(uint64_t rank, const uint64_t *shape) const; + + /// Allocates a new sparse-tensor storage object with the given encoding, + /// initializes it by reading all the elements from the file, and then + /// closes the file. Templated on P, I, and V. + template + SparseTensorStorage * + readSparseTensor(uint64_t lvlRank, const uint64_t *lvlSizes, + const DimLevelType *lvlTypes, const uint64_t *dim2lvl, + const uint64_t *lvl2dim) { + const uint64_t dimRank = getRank(); + MapRef map(dimRank, lvlRank, dim2lvl, lvl2dim); + auto *coo = readCOO(map, lvlSizes); + auto *tensor = SparseTensorStorage::newFromCOO( + dimRank, getDimSizes(), lvlRank, lvlTypes, lvl2dim, *coo); + delete coo; + return tensor; + } + + /// Reads the COO tensor from the file, stores the coordinates and values to + /// the given buffers, returns a boolean value to indicate whether the COO + /// elements are sorted. + template + bool readToBuffers(uint64_t lvlRank, const uint64_t *dim2lvl, + const uint64_t *lvl2dim, C *lvlCoordinates, V *values); + +private: + /// Attempts to read a line from the file. + void readLine(); + + /// Reads the next line of the input file and parses the coordinates + /// into the `dimCoords` argument. Returns the position in the `line` + /// buffer where the element's value should be parsed from. + template + char *readCoords(C *dimCoords) { + readLine(); + // Local variable for tracking the parser's position in the `line` buffer. + char *linePtr = line; + for (uint64_t dimRank = getRank(), d = 0; d < dimRank; ++d) { + // Parse the 1-based coordinate. + uint64_t c = strtoul(linePtr, &linePtr, 10); + // Store the 0-based coordinate. + dimCoords[d] = static_cast(c - 1); + } + return linePtr; + } + + /// Reads all the elements from the file while applying the given map. + template + SparseTensorCOO *readCOO(const MapRef &map, const uint64_t *lvlSizes); + + /// The implementation of `readCOO` that is templated `IsPattern` in order + /// to perform LICM without needing to duplicate the source code. + template + void readCOOLoop(const MapRef &map, SparseTensorCOO *coo); + + /// The internal implementation of `readToBuffers`. We template over + /// `IsPattern` in order to perform LICM without needing to duplicate + /// the source code. + template + bool readToBuffersLoop(const MapRef &map, C *lvlCoordinates, V *values); + + /// Reads the MME header of a general sparse matrix of type real. + void readMMEHeader(); + + /// Reads the "extended" FROSTT header. Although not part of the + /// documented format, we assume that the file starts with optional + /// comments followed by two lines that define the rank, the number of + /// nonzeros, and the dimensions sizes (one per rank) of the sparse tensor. + void readExtFROSTTHeader(); + + static constexpr int kColWidth = 1025; + const char *const filename; + FILE *file = nullptr; + ValueKind valueKind_ = ValueKind::kInvalid; + bool isSymmetric_ = false; + uint64_t idata[512]; + char line[kColWidth]; +}; + +//===----------------------------------------------------------------------===// +// +// Reader class methods. +// +//===----------------------------------------------------------------------===// + +template +SparseTensorCOO *SparseTensorReader::readCOO(const MapRef &map, + const uint64_t *lvlSizes) { + assert(isValid() && "Attempt to readCOO() before readHeader()"); + // Prepare a COO object with the number of stored elems as initial capacity. + auto *coo = new SparseTensorCOO(map.getLvlRank(), lvlSizes, getNSE()); + // Enter the reading loop. + if (isPattern()) + readCOOLoop(map, coo); + else + readCOOLoop(map, coo); + // Close the file and return the COO. + closeFile(); + return coo; +} + +template +void SparseTensorReader::readCOOLoop(const MapRef &map, + SparseTensorCOO *coo) { + const uint64_t dimRank = map.getDimRank(); + const uint64_t lvlRank = map.getLvlRank(); + assert(dimRank == getRank()); + std::vector dimCoords(dimRank); + std::vector lvlCoords(lvlRank); + for (uint64_t k = 0, nse = getNSE(); k < nse; k++) { + char *linePtr = readCoords(dimCoords.data()); + const V value = detail::readValue(&linePtr); + map.pushforward(dimCoords.data(), lvlCoords.data()); + coo->add(lvlCoords, value); + } +} + +template +bool SparseTensorReader::readToBuffers(uint64_t lvlRank, + const uint64_t *dim2lvl, + const uint64_t *lvl2dim, + C *lvlCoordinates, V *values) { + assert(isValid() && "Attempt to readCOO() before readHeader()"); + MapRef map(getRank(), lvlRank, dim2lvl, lvl2dim); + bool isSorted = + isPattern() ? readToBuffersLoop(map, lvlCoordinates, values) + : readToBuffersLoop(map, lvlCoordinates, values); + closeFile(); + return isSorted; +} + +template +bool SparseTensorReader::readToBuffersLoop(const MapRef &map, C *lvlCoordinates, + V *values) { + const uint64_t dimRank = map.getDimRank(); + const uint64_t lvlRank = map.getLvlRank(); + const uint64_t nse = getNSE(); + assert(dimRank == getRank()); + std::vector dimCoords(dimRank); + bool isSorted = false; + char *linePtr; + const auto readNextElement = [&]() { + linePtr = readCoords(dimCoords.data()); + map.pushforward(dimCoords.data(), lvlCoordinates); + *values = detail::readValue(&linePtr); + if (isSorted) { + // Note that isSorted is set to false when reading the first element, + // to guarantee the safeness of using prevLvlCoords. + C *prevLvlCoords = lvlCoordinates - lvlRank; + for (uint64_t l = 0; l < lvlRank; ++l) { + if (prevLvlCoords[l] != lvlCoordinates[l]) { + if (prevLvlCoords[l] > lvlCoordinates[l]) + isSorted = false; + break; + } + } + } + lvlCoordinates += lvlRank; + ++values; + }; + readNextElement(); + isSorted = true; + for (uint64_t n = 1; n < nse; ++n) + readNextElement(); + return isSorted; +} + +/// Writes the sparse tensor to `filename` in extended FROSTT format. +template +inline void writeExtFROSTT(const SparseTensorCOO &coo, + const char *filename) { + assert(filename && "Got nullptr for filename"); + const auto &dimSizes = coo.getDimSizes(); + const auto &elements = coo.getElements(); + const uint64_t dimRank = coo.getRank(); + const uint64_t nse = elements.size(); + std::fstream file; + file.open(filename, std::ios_base::out | std::ios_base::trunc); + assert(file.is_open()); + file << "; extended FROSTT format\n" << dimRank << " " << nse << std::endl; + for (uint64_t d = 0; d < dimRank - 1; ++d) + file << dimSizes[d] << " "; + file << dimSizes[dimRank - 1] << std::endl; + for (uint64_t i = 0; i < nse; ++i) { + const auto &coords = elements[i].coords; + for (uint64_t d = 0; d < dimRank; ++d) + file << (coords[d] + 1) << " "; + file << elements[i].value << std::endl; + } + file.flush(); + file.close(); + assert(file.good()); +} + +} // namespace sparse_tensor +} // namespace mlir + +#endif // MLIR_EXECUTIONENGINE_SPARSETENSOR_FILE_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/SparseTensor/MapRef.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/SparseTensor/MapRef.h new file mode 100644 index 0000000000000000000000000000000000000000..22ae70a61d95eff08d9cb1e60562aa26c33087e4 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/SparseTensor/MapRef.h @@ -0,0 +1,81 @@ +//===- MapRef.h - A dim2lvl/lvl2dim map encoding ----------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// A dim2lvl/lvl2dim map encoding class, with utility methods. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_EXECUTIONENGINE_SPARSETENSOR_MAPREF_H +#define MLIR_EXECUTIONENGINE_SPARSETENSOR_MAPREF_H + +#include + +#include +#include + +namespace mlir { +namespace sparse_tensor { + +/// A class for capturing the sparse tensor type map with a compact encoding. +/// +/// Currently, the following situations are supported: +/// (1) map is a permutation +/// (2) map has affine ops (restricted set) +/// +/// The pushforward/backward operations are fast for (1) but incur some obvious +/// overhead for situation (2). +/// +class MapRef final { +public: + MapRef(uint64_t d, uint64_t l, const uint64_t *d2l, const uint64_t *l2d); + + // + // Push forward maps from dimensions to levels. + // + + template + inline void pushforward(const T *in, T *out) const { + if (isPermutation) { + for (uint64_t i = 0; i < lvlRank; ++i) + out[i] = in[lvl2dim[i]]; + } else { + assert(0 && "coming soon"); + } + } + + // + // Push backward maps from levels to dimensions. + // + + template + inline void pushbackward(const T *in, T *out) const { + if (isPermutation) { + for (uint64_t i = 0; i < dimRank; ++i) + out[i] = in[dim2lvl[i]]; + } else { + assert(0 && "coming soon"); + } + } + + uint64_t getDimRank() const { return dimRank; } + uint64_t getLvlRank() const { return lvlRank; } + +private: + bool isPermutationMap() const; + + const uint64_t dimRank; + const uint64_t lvlRank; + const uint64_t *const dim2lvl; // non-owning pointer + const uint64_t *const lvl2dim; // non-owning pointer + const bool isPermutation; +}; + +} // namespace sparse_tensor +} // namespace mlir + +#endif // MLIR_EXECUTIONENGINE_SPARSETENSOR_MAPREF_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/SparseTensor/Storage.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/SparseTensor/Storage.h new file mode 100644 index 0000000000000000000000000000000000000000..0407bccaae8790ca340774b19bf7fddc13cb7712 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/SparseTensor/Storage.h @@ -0,0 +1,1214 @@ +//===- Storage.h - TACO-flavored sparse tensor representation ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file contains definitions for the following classes: +// +// * `SparseTensorStorageBase` +// * `SparseTensorStorage` +// * `SparseTensorEnumeratorBase` +// * `SparseTensorEnumerator` +// * `SparseTensorNNZ` +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_EXECUTIONENGINE_SPARSETENSOR_STORAGE_H +#define MLIR_EXECUTIONENGINE_SPARSETENSOR_STORAGE_H + +#include "mlir/Dialect/SparseTensor/IR/Enums.h" +#include "mlir/ExecutionEngine/Float16bits.h" +#include "mlir/ExecutionEngine/SparseTensor/ArithmeticUtils.h" +#include "mlir/ExecutionEngine/SparseTensor/COO.h" +#include "mlir/ExecutionEngine/SparseTensor/ErrorHandling.h" + +#define ASSERT_VALID_DIM(d) \ + assert(d < getDimRank() && "Dimension is out of bounds"); +#define ASSERT_VALID_LVL(l) \ + assert(l < getLvlRank() && "Level is out of bounds"); +#define ASSERT_COMPRESSED_LVL(l) \ + assert(isCompressedLvl(l) && "Level is not compressed"); +#define ASSERT_COMPRESSED_OR_SINGLETON_LVL(l) \ + do { \ + const DimLevelType dlt = getLvlType(l); \ + (void)dlt; \ + assert((isCompressedDLT(dlt) || isSingletonDLT(dlt)) && \ + "Level is neither compressed nor singleton"); \ + } while (false) +#define ASSERT_DENSE_DLT(dlt) assert(isDenseDLT(dlt) && "Level is not dense"); + +namespace mlir { +namespace sparse_tensor { + +// Forward references. +template +class SparseTensorEnumeratorBase; +template +class SparseTensorEnumerator; + +/// Abstract base class for `SparseTensorStorage`. This class +/// takes responsibility for all the ``-independent aspects +/// of the tensor (e.g., shape, sparsity, permutation). In addition, +/// we use function overloading to implement "partial" method +/// specialization, which the C-API relies on to catch type errors +/// arising from our use of opaque pointers. +/// +/// Because this class forms a bridge between the denotational semantics +/// of "tensors" and the operational semantics of how we store and +/// compute with them, it also distinguishes between two different +/// coordinate spaces (and their associated rank, shape, sizes, etc). +/// Denotationally, we have the *dimensions* of the tensor represented +/// by this object. Operationally, we have the *levels* of the storage +/// representation itself. We use this "dimension" vs "level" terminology +/// throughout, since alternative terminology like "tensor-dimension", +/// "original-dimension", "storage-dimension", etc, is both more verbose +/// and prone to introduce confusion whenever the qualifiers are dropped. +/// Where necessary, we use "axis" as the generic term. +/// +/// The *size* of an axis is the cardinality of possible coordinate +/// values along that axis (regardless of which coordinates have stored +/// element values). As such, each size must be non-zero since if any +/// axis has size-zero then the whole tensor would have trivial storage +/// (since there are no possible coordinates). Thus we use the plural +/// term *sizes* for a collection of non-zero cardinalities, and use +/// this term whenever referring to run-time cardinalities. Whereas we +/// use the term *shape* for a collection of compile-time cardinalities, +/// where zero is used to indicate cardinalities which are dynamic (i.e., +/// unknown/unspecified at compile-time). At run-time, these dynamic +/// cardinalities will be inferred from or checked against sizes otherwise +/// specified. Thus, dynamic cardinalities always have an "immutable but +/// unknown" value; so the term "dynamic" should not be taken to indicate +/// run-time mutability. +class SparseTensorStorageBase { +protected: + SparseTensorStorageBase(const SparseTensorStorageBase &) = default; + SparseTensorStorageBase &operator=(const SparseTensorStorageBase &) = delete; + +public: + /// Constructs a new sparse-tensor storage object with the given encoding. + /// + /// Preconditions: + /// * `dimSizes`, `lvlSizes`, `lvlTypes`, and `lvl2dim` must be nonnull. + /// * `dimSizes` must be valid for `dimRank`. + /// * `lvlSizes`, `lvlTypes`, and `lvl2dim` must be valid for `lvlRank`. + /// * `lvl2dim` must map `lvlSizes`-coordinates to `dimSizes`-coordinates. + /// + /// Asserts: + /// * `dimRank` and `lvlRank` are nonzero. + /// * `dimSizes` and `lvlSizes` contain only nonzero sizes. + SparseTensorStorageBase(uint64_t dimRank, const uint64_t *dimSizes, + uint64_t lvlRank, const uint64_t *lvlSizes, + const DimLevelType *lvlTypes, + const uint64_t *lvl2dim); + // NOTE: For the most part we only need the `dimRank`. But we need + // `dimSizes` for `toCOO` to support the identity permutation nicely + // (i.e., without the caller needing to already know the tensor's + // dimension-sizes; e.g., as in `fromMLIRSparseTensor`). + + virtual ~SparseTensorStorageBase() = default; + + /// Gets the number of tensor-dimensions. + uint64_t getDimRank() const { return dimSizes.size(); } + + /// Gets the number of storage-levels. + uint64_t getLvlRank() const { return lvlSizes.size(); } + + /// Gets the tensor-dimension sizes array. + const std::vector &getDimSizes() const { return dimSizes; } + + /// Safely looks up the size of the given tensor-dimension. + uint64_t getDimSize(uint64_t d) const { + ASSERT_VALID_DIM(d); + return dimSizes[d]; + } + + /// Gets the storage-level sizes array. + const std::vector &getLvlSizes() const { return lvlSizes; } + + /// Safely looks up the size of the given storage-level. + uint64_t getLvlSize(uint64_t l) const { + ASSERT_VALID_LVL(l); + return lvlSizes[l]; + } + + /// Gets the level-to-dimension mapping. + const std::vector &getLvl2Dim() const { return lvl2dim; } + + /// Gets the level-types array. + const std::vector &getLvlTypes() const { return lvlTypes; } + + /// Safely looks up the type of the given level. + DimLevelType getLvlType(uint64_t l) const { + ASSERT_VALID_LVL(l); + return lvlTypes[l]; + } + + /// Safely checks if the level uses dense storage. + bool isDenseLvl(uint64_t l) const { return isDenseDLT(getLvlType(l)); } + + /// Safely checks if the level uses compressed storage. + bool isCompressedLvl(uint64_t l) const { + return isCompressedDLT(getLvlType(l)); + } + + /// Safely checks if the level uses singleton storage. + bool isSingletonLvl(uint64_t l) const { + return isSingletonDLT(getLvlType(l)); + } + + /// Safely checks if the level is ordered. + bool isOrderedLvl(uint64_t l) const { return isOrderedDLT(getLvlType(l)); } + + /// Safely checks if the level is unique. + bool isUniqueLvl(uint64_t l) const { return isUniqueDLT(getLvlType(l)); } + + /// Allocates a new enumerator. Callers must make sure to delete + /// the enumerator when they're done with it. The first argument + /// is the out-parameter for storing the newly allocated enumerator; + /// all other arguments are passed along to the `SparseTensorEnumerator` + /// ctor and must satisfy the preconditions/assertions thereof. +#define DECL_NEWENUMERATOR(VNAME, V) \ + virtual void newEnumerator(SparseTensorEnumeratorBase **, uint64_t, \ + const uint64_t *, uint64_t, const uint64_t *) \ + const; + MLIR_SPARSETENSOR_FOREVERY_V(DECL_NEWENUMERATOR) +#undef DECL_NEWENUMERATOR + + /// Gets positions-overhead storage for the given level. +#define DECL_GETPOSITIONS(PNAME, P) \ + virtual void getPositions(std::vector

**, uint64_t); + MLIR_SPARSETENSOR_FOREVERY_FIXED_O(DECL_GETPOSITIONS) +#undef DECL_GETPOSITIONS + + /// Gets coordinates-overhead storage for the given level. +#define DECL_GETCOORDINATES(INAME, C) \ + virtual void getCoordinates(std::vector **, uint64_t); + MLIR_SPARSETENSOR_FOREVERY_FIXED_O(DECL_GETCOORDINATES) +#undef DECL_GETCOORDINATES + /// Gets the coordinate-value stored at the given level and position. + virtual uint64_t getCrd(uint64_t lvl, uint64_t pos) const = 0; + + /// Gets primary storage. +#define DECL_GETVALUES(VNAME, V) virtual void getValues(std::vector **); + MLIR_SPARSETENSOR_FOREVERY_V(DECL_GETVALUES) +#undef DECL_GETVALUES + + /// Element-wise insertion in lexicographic coordinate order. The first + /// argument is the level-coordinates for the value being inserted. +#define DECL_LEXINSERT(VNAME, V) virtual void lexInsert(const uint64_t *, V); + MLIR_SPARSETENSOR_FOREVERY_V(DECL_LEXINSERT) +#undef DECL_LEXINSERT + + /// Expanded insertion. Note that this method resets the + /// values/filled-switch array back to all-zero/false while only + /// iterating over the nonzero elements. + /// + /// Arguments: + /// * `lvlCoords` the level-coordinates shared by the values being inserted. + /// * `values` a map from last-level coordinates to their associated value. + /// * `filled` a map from last-level coordinates to bool, indicating + /// whether `values` contains a valid value to be inserted. + /// * `added` a map from `[0..count)` to last-level coordinates for + /// which `filled` is true and `values` contains the assotiated value. + /// * `count` the size of `added`. + /// * `expsz` the size of the expanded vector (verification only). +#define DECL_EXPINSERT(VNAME, V) \ + virtual void expInsert(uint64_t *, V *, bool *, uint64_t *, uint64_t, \ + uint64_t); + MLIR_SPARSETENSOR_FOREVERY_V(DECL_EXPINSERT) +#undef DECL_EXPINSERT + + /// Finishes insertion. + virtual void endInsert() = 0; + +private: + const std::vector dimSizes; + const std::vector lvlSizes; + const std::vector lvlTypes; + const std::vector lvl2dim; +}; + +/// A memory-resident sparse tensor using a storage scheme based on +/// per-level sparse/dense annotations. This data structure provides +/// a bufferized form of a sparse tensor type. In contrast to generating +/// setup methods for each differently annotated sparse tensor, this +/// method provides a convenient "one-size-fits-all" solution that simply +/// takes an input tensor and annotations to implement all required setup +/// in a general manner. +template +class SparseTensorStorage final : public SparseTensorStorageBase { + /// Private constructor to share code between the other constructors. + /// Beware that the object is not necessarily guaranteed to be in a + /// valid state after this constructor alone; e.g., `isCompressedLvl(l)` + /// doesn't entail `!(positions[l].empty())`. + /// + /// Preconditions/assertions are as per the `SparseTensorStorageBase` ctor. + SparseTensorStorage(uint64_t dimRank, const uint64_t *dimSizes, + uint64_t lvlRank, const uint64_t *lvlSizes, + const DimLevelType *lvlTypes, const uint64_t *lvl2dim) + : SparseTensorStorageBase(dimRank, dimSizes, lvlRank, lvlSizes, lvlTypes, + lvl2dim), + positions(lvlRank), coordinates(lvlRank), lvlCursor(lvlRank) {} + +public: + /// Constructs a sparse tensor with the given encoding, and allocates + /// overhead storage according to some simple heuristics. When the + /// `bool` argument is true and `lvlTypes` are all dense, then this + /// ctor will also initialize the values array with zeros. That + /// argument should be true when an empty tensor is intended; whereas + /// it should usually be false when the ctor will be followed up by + /// some other form of initialization. + /// + /// Preconditions/assertions are as per the `SparseTensorStorageBase` ctor. + SparseTensorStorage(uint64_t dimRank, const uint64_t *dimSizes, + uint64_t lvlRank, const uint64_t *lvlSizes, + const DimLevelType *lvlTypes, const uint64_t *lvl2dim, + bool initializeValuesIfAllDense); + + /// Constructs a sparse tensor with the given encoding, and initializes + /// the contents from the COO. This ctor performs the same heuristic + /// overhead-storage allocation as the ctor taking a `bool`, and + /// has the same preconditions/assertions (where we define `lvlSizes = + /// lvlCOO.getDimSizes().data()`), with the following addition: + /// + /// Asserts: + /// * `lvlRank == lvlCOO.getRank()`. + SparseTensorStorage(uint64_t dimRank, const uint64_t *dimSizes, + uint64_t lvlRank, const DimLevelType *lvlTypes, + const uint64_t *lvl2dim, SparseTensorCOO &lvlCOO); + + /// Constructs a sparse tensor with the given encoding, and initializes + /// the contents from the enumerator. This ctor allocates exactly + /// the required amount of overhead storage, not using any heuristics. + /// Preconditions/assertions are as per the `SparseTensorStorageBase` + /// ctor (where we define `lvlSizes = lvlEnumerator.getTrgSizes().data()`), + /// with the following addition: + /// + /// Asserts: + /// * `lvlRank == lvlEnumerator.getTrgRank()`. + SparseTensorStorage(uint64_t dimRank, const uint64_t *dimSizes, + uint64_t lvlRank, const DimLevelType *lvlTypes, + const uint64_t *lvl2dim, + SparseTensorEnumeratorBase &lvlEnumerator); + + /// Constructs a sparse tensor with the given encoding, and initializes + /// the contents from the level buffers. This ctor allocates exactly + /// the required amount of overhead storage, not using any heuristics. + /// It assumes that the data provided by `lvlBufs` can be directly used to + /// interpret the result sparse tensor and performs *NO* integrity test on the + /// input data. It also assume that the trailing COO coordinate buffer is + /// passed in as a single AoS memory. + SparseTensorStorage(uint64_t dimRank, const uint64_t *dimSizes, + uint64_t lvlRank, const uint64_t *lvlSizes, + const DimLevelType *lvlTypes, const uint64_t *lvl2dim, + const intptr_t *lvlBufs); + + /// Allocates a new empty sparse tensor. The preconditions/assertions + /// are as per the `SparseTensorStorageBase` ctor; which is to say, + /// the `dimSizes` and `lvlSizes` must both be "sizes" not "shapes", + /// since there's nowhere to reconstruct dynamic sizes from. + static SparseTensorStorage * + newEmpty(uint64_t dimRank, const uint64_t *dimSizes, uint64_t lvlRank, + const uint64_t *lvlSizes, const DimLevelType *lvlTypes, + const uint64_t *lvl2dim) { + return new SparseTensorStorage(dimRank, dimSizes, lvlRank, + lvlSizes, lvlTypes, lvl2dim, true); + } + + /// Allocates a new sparse tensor and initializes it from the given COO. + /// The preconditions are as per the `SparseTensorStorageBase` ctor + /// (where we define `lvlSizes = lvlCOO.getDimSizes().data()`), but + /// using the following assertions in lieu of the base ctor's assertions: + /// + /// Asserts: + /// * `dimRank` and `lvlRank` are nonzero. + /// * `lvlRank == lvlCOO.getRank()`. + /// * `lvlCOO.getDimSizes()` under the `lvl2dim` mapping is a refinement + /// of `dimShape`. + // + // TODO: The ability to reconstruct dynamic dimensions-sizes does not + // easily generalize to arbitrary `lvl2dim` mappings. When compiling + // MLIR programs to use this library, we should be able to generate + // code for effectively computing the reconstruction, but it's not clear + // that there's a feasible way to do so from within the library itself. + // Therefore, when we functionalize the `lvl2dim` mapping we'll have + // to update the type/preconditions of this factory too. + static SparseTensorStorage * + newFromCOO(uint64_t dimRank, const uint64_t *dimShape, uint64_t lvlRank, + const DimLevelType *lvlTypes, const uint64_t *lvl2dim, + SparseTensorCOO &lvlCOO); + + /// Allocates a new sparse tensor and initializes it with the contents + /// of another sparse tensor. + /// + /// Preconditions: + /// * as per the `SparseTensorStorageBase` ctor. + /// * `src2lvl` must be valid for `srcRank`, must map coordinates valid + /// for `source.getDimSizes()` to coordinates valid for `lvlSizes`, + /// and therefore must be the inverse of `lvl2dim`. + /// * `source` must have the same value type `V`. + /// + /// Asserts: + /// * `dimRank` and `lvlRank` are nonzero. + /// * `srcRank == source.getDimRank()`. + /// * `lvlSizes` contains only nonzero sizes. + /// * `source.getDimSizes()` is a refinement of `dimShape`. + // + // TODO: The `dimRank` and `dimShape` arguments are only used for + // verifying that the source tensor has the expected shape. So if we + // wanted to skip that verification, then we could remove those arguments. + // Alternatively, if we required the `dimShape` to be "sizes" instead, + // then that would remove any constraints on `source.getDimSizes()` + // (other than compatibility with `src2lvl`) as well as removing the + // requirement that `src2lvl` be the inverse of `lvl2dim`. Which would + // enable this factory to be used for performing a much larger class of + // transformations (which can already be handled by the `SparseTensorNNZ` + // implementation). + static SparseTensorStorage * + newFromSparseTensor(uint64_t dimRank, const uint64_t *dimShape, + uint64_t lvlRank, const uint64_t *lvlSizes, + const DimLevelType *lvlTypes, const uint64_t *lvl2dim, + uint64_t srcRank, const uint64_t *src2lvl, + const SparseTensorStorageBase &source); + + /// Allocates a new sparse tensor and initialize it with the data stored level + /// buffers directly. + /// + /// Precondition: + /// * as per the `SparseTensorStorageBase` ctor. + /// * the data integrity stored in `buffers` is guaranteed by users already. + static SparseTensorStorage * + packFromLvlBuffers(uint64_t dimRank, const uint64_t *dimShape, + uint64_t lvlRank, const uint64_t *lvlSizes, + const DimLevelType *lvlTypes, const uint64_t *lvl2dim, + uint64_t srcRank, const uint64_t *src2lvl, + const intptr_t *buffers); + + ~SparseTensorStorage() final = default; + + /// Partially specialize these getter methods based on template types. + void getPositions(std::vector

**out, uint64_t lvl) final { + assert(out && "Received nullptr for out parameter"); + ASSERT_VALID_LVL(lvl); + *out = &positions[lvl]; + } + void getCoordinates(std::vector **out, uint64_t lvl) final { + assert(out && "Received nullptr for out parameter"); + ASSERT_VALID_LVL(lvl); + *out = &coordinates[lvl]; + } + void getValues(std::vector **out) final { + assert(out && "Received nullptr for out parameter"); + *out = &values; + } + + uint64_t getCrd(uint64_t lvl, uint64_t pos) const final { + ASSERT_COMPRESSED_OR_SINGLETON_LVL(lvl); + assert(pos < coordinates[lvl].size() && "Position is out of bounds"); + return coordinates[lvl][pos]; // Converts the stored `C` into `uint64_t`. + } + + /// Partially specialize lexicographical insertions based on template types. + void lexInsert(const uint64_t *lvlCoords, V val) final { + assert(lvlCoords && "Received nullptr for level-coordinates"); + // First, wrap up pending insertion path. + uint64_t diffLvl = 0; + uint64_t full = 0; + if (!values.empty()) { + diffLvl = lexDiff(lvlCoords); + endPath(diffLvl + 1); + full = lvlCursor[diffLvl] + 1; + } + // Then continue with insertion path. + insPath(lvlCoords, diffLvl, full, val); + } + + /// Partially specialize expanded insertions based on template types. + void expInsert(uint64_t *lvlCoords, V *values, bool *filled, uint64_t *added, + uint64_t count, uint64_t expsz) final { + assert((lvlCoords && values && filled && added) && "Received nullptr"); + if (count == 0) + return; + // Sort. + std::sort(added, added + count); + // Restore insertion path for first insert. + const uint64_t lastLvl = getLvlRank() - 1; + uint64_t c = added[0]; + assert(c <= expsz); + assert(filled[c] && "added coordinate is not filled"); + lvlCoords[lastLvl] = c; + lexInsert(lvlCoords, values[c]); + values[c] = 0; + filled[c] = false; + // Subsequent insertions are quick. + for (uint64_t i = 1; i < count; ++i) { + assert(c < added[i] && "non-lexicographic insertion"); + c = added[i]; + assert(c <= expsz); + assert(filled[c] && "added coordinate is not filled"); + lvlCoords[lastLvl] = c; + insPath(lvlCoords, lastLvl, added[i - 1] + 1, values[c]); + values[c] = 0; + filled[c] = false; + } + } + + /// Finalizes lexicographic insertions. + void endInsert() final { + if (values.empty()) + finalizeSegment(0); + else + endPath(0); + } + + /// Allocates a new enumerator for this class's `` types and + /// erase the `` parts from the type. Callers must make sure to + /// delete the enumerator when they're done with it. + void newEnumerator(SparseTensorEnumeratorBase **out, uint64_t trgRank, + const uint64_t *trgSizes, uint64_t srcRank, + const uint64_t *src2trg) const final { + assert(out && "Received nullptr for out parameter"); + *out = new SparseTensorEnumerator(*this, trgRank, trgSizes, + srcRank, src2trg); + } + + /// Allocates a new COO object and initializes it with the contents + /// of this tensor under the given mapping from the `getDimSizes()` + /// coordinate-space to the `trgSizes` coordinate-space. Callers must + /// make sure to delete the COO when they're done with it. + /// + /// Preconditions/assertions are as per the `SparseTensorEnumerator` ctor. + SparseTensorCOO *toCOO(uint64_t trgRank, const uint64_t *trgSizes, + uint64_t srcRank, const uint64_t *src2trg) const { + // We inline `newEnumerator` to avoid virtual dispatch and allocation. + // TODO: use MapRef here too for the translation + SparseTensorEnumerator enumerator(*this, trgRank, trgSizes, + srcRank, src2trg); + auto *coo = new SparseTensorCOO(trgRank, trgSizes, values.size()); + enumerator.forallElements( + [&coo](const auto &trgCoords, V val) { coo->add(trgCoords, val); }); + // TODO: This assertion assumes there are no stored zeros, + // or if there are then that we don't filter them out. + // + assert(coo->getElements().size() == values.size()); + return coo; + } + +private: + /// Appends an arbitrary new position to `positions[lvl]`. This method + /// checks that `pos` is representable in the `P` type; however, it + /// does not check that `pos` is semantically valid (i.e., larger than + /// the previous position and smaller than `coordinates[lvl].capacity()`). + void appendPos(uint64_t lvl, uint64_t pos, uint64_t count = 1) { + ASSERT_COMPRESSED_LVL(lvl); + positions[lvl].insert(positions[lvl].end(), count, + detail::checkOverflowCast

(pos)); + } + + /// Appends coordinate `crd` to level `lvl`, in the semantically + /// general sense. For non-dense levels, that means appending to the + /// `coordinates[lvl]` array, checking that `crd` is representable in + /// the `C` type; however, we do not verify other semantic requirements + /// (e.g., that `crd` is in bounds for `lvlSizes[lvl]`, and not previously + /// occurring in the same segment). For dense levels, this method instead + /// appends the appropriate number of zeros to the `values` array, where + /// `full` is the number of "entries" already written to `values` for this + /// segment (aka one after the highest coordinate previously appended). + void appendCrd(uint64_t lvl, uint64_t full, uint64_t crd) { + const auto dlt = getLvlType(lvl); // Avoid redundant bounds checking. + if (isCompressedDLT(dlt) || isSingletonDLT(dlt)) { + coordinates[lvl].push_back(detail::checkOverflowCast(crd)); + } else { // Dense level. + ASSERT_DENSE_DLT(dlt); + assert(crd >= full && "Coordinate was already filled"); + if (crd == full) + return; // Short-circuit, since it'll be a nop. + if (lvl + 1 == getLvlRank()) + values.insert(values.end(), crd - full, 0); + else + finalizeSegment(lvl + 1, 0, crd - full); + } + } + + /// Writes the given coordinate to `coordinates[lvl][pos]`. This method + /// checks that `crd` is representable in the `C` type; however, it + /// does not check that `crd` is semantically valid (i.e., in bounds + /// for `dimSizes[lvl]` and not elsewhere occurring in the same segment). + void writeCrd(uint64_t lvl, uint64_t pos, uint64_t crd) { + ASSERT_COMPRESSED_OR_SINGLETON_LVL(lvl); + // Subscript assignment to `std::vector` requires that the `pos`-th + // entry has been initialized; thus we must be sure to check `size()` + // here, instead of `capacity()` as would be ideal. + assert(pos < coordinates[lvl].size() && "Position is out of bounds"); + coordinates[lvl][pos] = detail::checkOverflowCast(crd); + } + + /// Computes the assembled-size associated with the `l`-th level, + /// given the assembled-size associated with the `(l-1)`-th level. + /// "Assembled-sizes" correspond to the (nominal) sizes of overhead + /// storage, as opposed to "level-sizes" which are the cardinality + /// of possible coordinates for that level. + /// + /// Precondition: the `positions[l]` array must be fully initialized + /// before calling this method. + uint64_t assembledSize(uint64_t parentSz, uint64_t l) const { + const auto dlt = getLvlType(l); // Avoid redundant bounds checking. + if (isCompressedDLT(dlt)) + return positions[l][parentSz]; + if (isSingletonDLT(dlt)) + return parentSz; // New size is same as the parent. + if (isDenseDLT(dlt)) + return parentSz * getLvlSizes()[l]; + MLIR_SPARSETENSOR_FATAL("unsupported level type: %d\n", + static_cast(dlt)); + } + + /// Initializes sparse tensor storage scheme from a memory-resident sparse + /// tensor in coordinate scheme. This method prepares the positions and + /// coordinates arrays under the given per-level dense/sparse annotations. + /// + /// Preconditions: + /// * the `lvlElements` must be lexicographically sorted. + /// * the coordinates of every element are valid for `getLvlSizes()` + /// (i.e., equal rank and pointwise less-than). + void fromCOO(const std::vector> &lvlElements, uint64_t lo, + uint64_t hi, uint64_t l) { + const uint64_t lvlRank = getLvlRank(); + assert(l <= lvlRank && hi <= lvlElements.size()); + // Once levels are exhausted, insert the numerical values. + if (l == lvlRank) { + assert(lo < hi); + values.push_back(lvlElements[lo].value); + return; + } + // Visit all elements in this interval. + uint64_t full = 0; + while (lo < hi) { // If `hi` is unchanged, then `lo < lvlElements.size()`. + // Find segment in interval with same coordinate at this level. + const uint64_t c = lvlElements[lo].coords[l]; + uint64_t seg = lo + 1; + if (isUniqueLvl(l)) + while (seg < hi && lvlElements[seg].coords[l] == c) + ++seg; + // Handle segment in interval for sparse or dense level. + appendCrd(l, full, c); + full = c + 1; + fromCOO(lvlElements, lo, seg, l + 1); + // And move on to next segment in interval. + lo = seg; + } + // Finalize the sparse position structure at this level. + finalizeSegment(l, full); + } + + /// Finalizes the sparse position structure at this level. + void finalizeSegment(uint64_t l, uint64_t full = 0, uint64_t count = 1) { + if (count == 0) + return; // Short-circuit, since it'll be a nop. + const auto dlt = getLvlType(l); // Avoid redundant bounds checking. + if (isCompressedDLT(dlt)) { + appendPos(l, coordinates[l].size(), count); + } else if (isSingletonDLT(dlt)) { + return; // Nothing to finalize. + } else { // Dense dimension. + ASSERT_DENSE_DLT(dlt); + const uint64_t sz = getLvlSizes()[l]; + assert(sz >= full && "Segment is overfull"); + count = detail::checkedMul(count, sz - full); + // For dense storage we must enumerate all the remaining coordinates + // in this level (i.e., coordinates after the last non-zero + // element), and either fill in their zero values or else recurse + // to finalize some deeper level. + if (l + 1 == getLvlRank()) + values.insert(values.end(), count, 0); + else + finalizeSegment(l + 1, 0, count); + } + } + + /// Wraps up a single insertion path, inner to outer. + void endPath(uint64_t diffLvl) { + const uint64_t lvlRank = getLvlRank(); + const uint64_t lastLvl = lvlRank - 1; + assert(diffLvl <= lvlRank && "Level-diff is out of bounds"); + const uint64_t stop = lvlRank - diffLvl; + for (uint64_t i = 0; i < stop; ++i) { + const uint64_t l = lastLvl - i; + finalizeSegment(l, lvlCursor[l] + 1); + } + } + + /// Continues a single insertion path, outer to inner. The first + /// argument is the level-coordinates for the value being inserted. + void insPath(const uint64_t *lvlCoords, uint64_t diffLvl, uint64_t full, + V val) { + const uint64_t lvlRank = getLvlRank(); + assert(diffLvl <= lvlRank && "Level-diff is out of bounds"); + for (uint64_t l = diffLvl; l < lvlRank; ++l) { + const uint64_t c = lvlCoords[l]; + appendCrd(l, full, c); + full = 0; + lvlCursor[l] = c; + } + values.push_back(val); + } + + /// Finds the lexicographically first level where the level-coordinates + /// in the argument differ from those in the current cursor. + uint64_t lexDiff(const uint64_t *lvlCoords) const { + const uint64_t lvlRank = getLvlRank(); + for (uint64_t l = 0; l < lvlRank; ++l) { + const auto crd = lvlCoords[l]; + const auto cur = lvlCursor[l]; + if (crd > cur || (crd == cur && !isUniqueLvl(l)) || + (crd < cur && !isOrderedLvl(l))) { + return l; + } + + if (crd < cur) { + assert(false && "non-lexicographic insertion"); + return -1u; + } + } + assert(false && "duplicate insertion"); + return -1u; + } + + // Allow `SparseTensorEnumerator` to access the data-members (to avoid + // the cost of virtual-function dispatch in inner loops), without + // making them public to other client code. + friend class SparseTensorEnumerator; + + std::vector> positions; + std::vector> coordinates; + std::vector values; + std::vector lvlCursor; // cursor for lexicographic insertion. +}; + +#undef ASSERT_COMPRESSED_OR_SINGLETON_LVL +#undef ASSERT_COMPRESSED_LVL +#undef ASSERT_VALID_LVL +#undef ASSERT_VALID_DIM + +//===----------------------------------------------------------------------===// +/// A (higher-order) function object for enumerating the elements of some +/// `SparseTensorStorage` under a permutation. That is, the `forallElements` +/// method encapsulates the loop-nest for enumerating the elements of +/// the source tensor (in whatever order is best for the source tensor), +/// and applies a permutation to the coordinates before handing +/// each element to the callback. A single enumerator object can be +/// freely reused for several calls to `forallElements`, just so long +/// as each call is sequential with respect to one another. +/// +/// N.B., this class stores a reference to the `SparseTensorStorageBase` +/// passed to the constructor; thus, objects of this class must not +/// outlive the sparse tensor they depend on. +/// +/// Design Note: The reason we define this class instead of simply using +/// `SparseTensorEnumerator` is because we need to hide/generalize +/// the `` template parameters from MLIR client code (to simplify the +/// type parameters used for direct sparse-to-sparse conversion). And the +/// reason we define the `SparseTensorEnumerator` subclasses rather +/// than simply using this class, is to avoid the cost of virtual-method +/// dispatch within the loop-nest. +template +class SparseTensorEnumeratorBase { +public: + /// Constructs an enumerator which automatically applies the given + /// mapping from the source tensor's dimensions to the desired + /// target tensor dimensions. + /// + /// Preconditions: + /// * the `src` must have the same `V` value type. + /// * `trgSizes` must be valid for `trgRank`. + /// * `src2trg` must be valid for `srcRank`, and must map coordinates + /// valid for `src.getDimSizes()` to coordinates valid for `trgSizes`. + /// + /// Asserts: + /// * `trgSizes` must be nonnull and must contain only nonzero sizes. + /// * `srcRank == src.getDimRank()`. + /// * `src2trg` must be nonnull. + SparseTensorEnumeratorBase(const SparseTensorStorageBase &src, + uint64_t trgRank, const uint64_t *trgSizes, + uint64_t srcRank, const uint64_t *src2trg) + : src(src), trgSizes(trgSizes, trgSizes + trgRank), + lvl2trg(src.getLvlRank()), trgCursor(trgRank) { + assert(trgSizes && "Received nullptr for target-sizes"); + assert(src2trg && "Received nullptr for source-to-target mapping"); + assert(srcRank == src.getDimRank() && "Source-rank mismatch"); + for (uint64_t t = 0; t < trgRank; ++t) + assert(trgSizes[t] > 0 && "Target-size zero has trivial storage"); + const auto &lvl2src = src.getLvl2Dim(); + for (uint64_t lvlRank = src.getLvlRank(), l = 0; l < lvlRank; ++l) + lvl2trg[l] = src2trg[lvl2src[l]]; + } + + virtual ~SparseTensorEnumeratorBase() = default; + + // We disallow copying to help avoid leaking the `src` reference. + // (In addition to avoiding the problem of slicing.) + SparseTensorEnumeratorBase(const SparseTensorEnumeratorBase &) = delete; + SparseTensorEnumeratorBase & + operator=(const SparseTensorEnumeratorBase &) = delete; + + /// Gets the source's dimension-rank. + uint64_t getSrcDimRank() const { return src.getDimRank(); } + + /// Gets the target's dimension-/level-rank. (This is usually + /// "dimension-rank", though that may coincide with "level-rank" + /// depending on usage.) + uint64_t getTrgRank() const { return trgSizes.size(); } + + /// Gets the target's dimension-/level-sizes. (These are usually + /// "dimensions", though that may coincide with "level-rank" depending + /// on usage.) + const std::vector &getTrgSizes() const { return trgSizes; } + + /// Enumerates all elements of the source tensor, permutes their + /// coordinates, and passes the permuted element to the callback. + /// The callback must not store the cursor reference directly, + /// since this function reuses the storage. Instead, the callback + /// must copy it if they want to keep it. + virtual void forallElements(ElementConsumer yield) = 0; + +protected: + const SparseTensorStorageBase &src; + std::vector trgSizes; // in target order. + std::vector lvl2trg; // source-levels -> target-dims/lvls. + std::vector trgCursor; // in target order. +}; + +//===----------------------------------------------------------------------===// +template +class SparseTensorEnumerator final : public SparseTensorEnumeratorBase { + using Base = SparseTensorEnumeratorBase; + using StorageImpl = SparseTensorStorage; + +public: + /// Constructs an enumerator which automatically applies the given + /// mapping from the source tensor's dimensions to the desired + /// target tensor dimensions. + /// + /// Preconditions/assertions are as per the `SparseTensorEnumeratorBase` ctor. + SparseTensorEnumerator(const StorageImpl &src, uint64_t trgRank, + const uint64_t *trgSizes, uint64_t srcRank, + const uint64_t *src2trg) + : Base(src, trgRank, trgSizes, srcRank, src2trg) {} + + ~SparseTensorEnumerator() final = default; + + void forallElements(ElementConsumer yield) final { + forallElements(yield, 0, 0); + } + +private: + // TODO: Once we functionalize the mappings, then we'll no longer + // be able to use the current approach of constructing `lvl2trg` in the + // ctor and using it to incrementally fill the `trgCursor` cursor as we + // recurse through `forallElements`. Instead we'll want to incrementally + // fill a `lvlCursor` as we recurse, and then use `src.getLvl2Dim()` + // and `src2trg` to convert it just before yielding to the callback. + // It's probably most efficient to just store the `srcCursor` and + // `trgCursor` buffers in this object, but we may want to benchmark + // that against using `std::calloc` to stack-allocate them instead. + // + /// The recursive component of the public `forallElements`. + void forallElements(ElementConsumer yield, uint64_t parentPos, + uint64_t l) { + // Recover the `` type parameters of `src`. + const auto &src = static_cast(this->src); + if (l == src.getLvlRank()) { + assert(parentPos < src.values.size() && + "Value position is out of bounds"); + // TODO: + yield(this->trgCursor, src.values[parentPos]); + return; + } + uint64_t &cursorL = this->trgCursor[this->lvl2trg[l]]; + const auto dlt = src.getLvlType(l); // Avoid redundant bounds checking. + if (isCompressedDLT(dlt)) { + // Look up the bounds of the `l`-level segment determined by the + // `(l - 1)`-level position `parentPos`. + const std::vector

&positionsL = src.positions[l]; + assert(parentPos + 1 < positionsL.size() && + "Parent position is out of bounds"); + const uint64_t pstart = static_cast(positionsL[parentPos]); + const uint64_t pstop = static_cast(positionsL[parentPos + 1]); + // Loop-invariant code for looking up the `l`-level coordinates. + const std::vector &coordinatesL = src.coordinates[l]; + assert(pstop <= coordinatesL.size() && "Stop position is out of bounds"); + for (uint64_t pos = pstart; pos < pstop; ++pos) { + cursorL = static_cast(coordinatesL[pos]); + forallElements(yield, pos, l + 1); + } + } else if (isSingletonDLT(dlt)) { + cursorL = src.getCrd(l, parentPos); + forallElements(yield, parentPos, l + 1); + } else { // Dense level. + ASSERT_DENSE_DLT(dlt); + const uint64_t sz = src.getLvlSizes()[l]; + const uint64_t pstart = parentPos * sz; + for (uint64_t c = 0; c < sz; ++c) { + cursorL = c; + forallElements(yield, pstart + c, l + 1); + } + } + } +}; + +//===----------------------------------------------------------------------===// +/// Statistics regarding the number of nonzero subtensors in +/// a source tensor, for direct sparse=>sparse conversion a la +/// . +/// +/// N.B., this class stores references to the parameters passed to +/// the constructor; thus, objects of this class must not outlive +/// those parameters. +/// +/// This class does not have the "dimension" vs "level" distinction, but +/// since it is used for initializing the levels of a `SparseTensorStorage` +/// object, we use the "level" name throughout for the sake of consistency. +class SparseTensorNNZ final { +public: + /// Allocates the statistics structure for the desired target-tensor + /// level structure (i.e., sizes and types). This constructor does not + /// actually populate the statistics, however; for that see `initialize`. + /// + /// Precondition: `lvlSizes` must not contain zeros. + /// Asserts: `lvlSizes.size() == lvlTypes.size()`. + SparseTensorNNZ(const std::vector &lvlSizes, + const std::vector &lvlTypes); + + // We disallow copying to help avoid leaking the stored references. + SparseTensorNNZ(const SparseTensorNNZ &) = delete; + SparseTensorNNZ &operator=(const SparseTensorNNZ &) = delete; + + /// Gets the target-tensor's level-rank. + uint64_t getLvlRank() const { return lvlSizes.size(); } + + /// Enumerates the source tensor to fill in the statistics. + /// The enumerator should already incorporate the mapping from + /// the source tensor-dimensions to the target storage-levels. + /// + /// Asserts: + /// * `enumerator.getTrgRank() == getLvlRank()`. + /// * `enumerator.getTrgSizes() == lvlSizes`. + template + void initialize(SparseTensorEnumeratorBase &enumerator) { + assert(enumerator.getTrgRank() == getLvlRank() && "Tensor rank mismatch"); + assert(enumerator.getTrgSizes() == lvlSizes && "Tensor size mismatch"); + enumerator.forallElements( + [this](const std::vector &lvlCoords, V) { add(lvlCoords); }); + } + + /// The type of callback functions which receive an nnz-statistic. + using NNZConsumer = const std::function &; + + /// Lexicographically enumerates all coordinates for levels strictly + /// less than `stopLvl`, and passes their nnz statistic to the callback. + /// Since our use-case only requires the statistic not the coordinates + /// themselves, we do not bother to construct those coordinates. + void forallCoords(uint64_t stopLvl, NNZConsumer yield) const; + +private: + /// Adds a new element (i.e., increment its statistics). We use + /// a method rather than inlining into the lambda in `initialize`, + /// to avoid spurious templating over `V`. And this method is private + /// to avoid needing to re-assert validity of `lvlCoords` (which is + /// guaranteed by `forallElements`). + void add(const std::vector &lvlCoords); + + /// Recursive component of the public `forallCoords`. + void forallCoords(NNZConsumer yield, uint64_t stopLvl, uint64_t parentPos, + uint64_t l) const; + + // All of these are in the target storage-order. + const std::vector &lvlSizes; + const std::vector &lvlTypes; + std::vector> nnz; +}; + +//===----------------------------------------------------------------------===// +// Definitions of the ctors and factories of `SparseTensorStorage`. + +template +SparseTensorStorage *SparseTensorStorage::newFromCOO( + uint64_t dimRank, const uint64_t *dimShape, uint64_t lvlRank, + const DimLevelType *lvlTypes, const uint64_t *lvl2dim, + SparseTensorCOO &lvlCOO) { + assert(dimShape && "Got nullptr for dimension shape"); + assert(lvl2dim && "Got nullptr for level-to-dimension mapping"); + const auto &lvlSizes = lvlCOO.getDimSizes(); + assert(lvlRank == lvlSizes.size() && "Level-rank mismatch"); + // Must reconstruct `dimSizes` from `lvlSizes`. While this is easy + // enough to do when `lvl2dim` is a permutation, this approach will + // not work for more general mappings; so we will need to move this + // computation off to codegen. + std::vector dimSizes(dimRank); + for (uint64_t l = 0; l < lvlRank; ++l) { + const uint64_t d = lvl2dim[l]; + assert((dimShape[d] == 0 || dimShape[d] == lvlSizes[l]) && + "Dimension sizes do not match expected shape"); + dimSizes[d] = lvlSizes[l]; + } + return new SparseTensorStorage(dimRank, dimSizes.data(), lvlRank, + lvlTypes, lvl2dim, lvlCOO); +} + +template +SparseTensorStorage *SparseTensorStorage::newFromSparseTensor( + uint64_t dimRank, const uint64_t *dimShape, uint64_t lvlRank, + const uint64_t *lvlSizes, const DimLevelType *lvlTypes, + const uint64_t *lvl2dim, uint64_t srcRank, const uint64_t *src2lvl, + const SparseTensorStorageBase &source) { + // Verify that the `source` dimensions match the expected `dimShape`. + assert(dimShape && "Got nullptr for dimension shape"); + assert(dimRank == source.getDimRank() && "Dimension-rank mismatch"); + const auto &dimSizes = source.getDimSizes(); +#ifndef NDEBUG + for (uint64_t d = 0; d < dimRank; ++d) { + const uint64_t sz = dimShape[d]; + assert((sz == 0 || sz == dimSizes[d]) && + "Dimension-sizes do not match expected shape"); + } +#endif + SparseTensorEnumeratorBase *lvlEnumerator; + source.newEnumerator(&lvlEnumerator, lvlRank, lvlSizes, srcRank, src2lvl); + auto *tensor = new SparseTensorStorage( + dimRank, dimSizes.data(), lvlRank, lvlTypes, lvl2dim, *lvlEnumerator); + delete lvlEnumerator; + return tensor; +} + +template +SparseTensorStorage *SparseTensorStorage::packFromLvlBuffers( + uint64_t dimRank, const uint64_t *dimShape, uint64_t lvlRank, + const uint64_t *lvlSizes, const DimLevelType *lvlTypes, + const uint64_t *lvl2dim, uint64_t srcRank, const uint64_t *src2lvl, + const intptr_t *buffers) { + assert(dimShape && "Got nullptr for dimension shape"); + auto *tensor = new SparseTensorStorage( + dimRank, dimShape, lvlRank, lvlSizes, lvlTypes, lvl2dim, buffers); + return tensor; +} + +template +SparseTensorStorage::SparseTensorStorage( + uint64_t dimRank, const uint64_t *dimSizes, uint64_t lvlRank, + const uint64_t *lvlSizes, const DimLevelType *lvlTypes, + const uint64_t *lvl2dim, bool initializeValuesIfAllDense) + : SparseTensorStorage(dimRank, dimSizes, lvlRank, lvlSizes, lvlTypes, + lvl2dim) { + // Provide hints on capacity of positions and coordinates. + // TODO: needs much fine-tuning based on actual sparsity; currently + // we reserve position/coordinate space based on all previous dense + // levels, which works well up to first sparse level; but we should + // really use nnz and dense/sparse distribution. + bool allDense = true; + uint64_t sz = 1; + for (uint64_t l = 0; l < lvlRank; ++l) { + const DimLevelType dlt = lvlTypes[l]; // Avoid redundant bounds checking. + if (isCompressedDLT(dlt)) { + // TODO: Take a parameter between 1 and `lvlSizes[l]`, and multiply + // `sz` by that before reserving. (For now we just use 1.) + positions[l].reserve(sz + 1); + positions[l].push_back(0); + coordinates[l].reserve(sz); + sz = 1; + allDense = false; + } else if (isSingletonDLT(dlt)) { + coordinates[l].reserve(sz); + sz = 1; + allDense = false; + } else { // Dense level. + ASSERT_DENSE_DLT(dlt); + sz = detail::checkedMul(sz, lvlSizes[l]); + } + } + if (allDense && initializeValuesIfAllDense) + values.resize(sz, 0); +} + +template +SparseTensorStorage::SparseTensorStorage( // NOLINT + uint64_t dimRank, const uint64_t *dimSizes, uint64_t lvlRank, + const DimLevelType *lvlTypes, const uint64_t *lvl2dim, + SparseTensorCOO &lvlCOO) + : SparseTensorStorage(dimRank, dimSizes, lvlRank, + lvlCOO.getDimSizes().data(), lvlTypes, lvl2dim, + false) { + assert(lvlRank == lvlCOO.getDimSizes().size() && "Level-rank mismatch"); + // Ensure the preconditions of `fromCOO`. (One is already ensured by + // using `lvlSizes = lvlCOO.getDimSizes()` in the ctor above.) + lvlCOO.sort(); + // Now actually insert the `elements`. + const auto &elements = lvlCOO.getElements(); + const uint64_t nse = elements.size(); + values.reserve(nse); + fromCOO(elements, 0, nse, 0); +} + +template +SparseTensorStorage::SparseTensorStorage( + uint64_t dimRank, const uint64_t *dimSizes, uint64_t lvlRank, + const DimLevelType *lvlTypes, const uint64_t *lvl2dim, + SparseTensorEnumeratorBase &lvlEnumerator) + : SparseTensorStorage(dimRank, dimSizes, lvlRank, + lvlEnumerator.getTrgSizes().data(), lvlTypes, + lvl2dim) { + assert(lvlRank == lvlEnumerator.getTrgRank() && "Level-rank mismatch"); + { + // Initialize the statistics structure. + SparseTensorNNZ nnz(getLvlSizes(), getLvlTypes()); + nnz.initialize(lvlEnumerator); + // Initialize "positions" overhead (and allocate "coordinates", "values"). + uint64_t parentSz = 1; // assembled-size of the `(l - 1)`-level. + for (uint64_t l = 0; l < lvlRank; ++l) { + const auto dlt = lvlTypes[l]; // Avoid redundant bounds checking. + if (isCompressedDLT(dlt)) { + positions[l].reserve(parentSz + 1); + positions[l].push_back(0); + uint64_t currentPos = 0; + nnz.forallCoords(l, [this, ¤tPos, l](uint64_t n) { + currentPos += n; + appendPos(l, currentPos); + }); + assert(positions[l].size() == parentSz + 1 && + "Final positions size doesn't match allocated size"); + // That assertion entails `assembledSize(parentSz, l)` + // is now in a valid state. That is, `positions[l][parentSz]` + // equals the present value of `currentPos`, which is the + // correct assembled-size for `coordinates[l]`. + } + // Update assembled-size for the next iteration. + parentSz = assembledSize(parentSz, l); + // Ideally we need only `coordinates[l].reserve(parentSz)`, however + // the `std::vector` implementation forces us to initialize it too. + // That is, in the yieldPos loop we need random-access assignment + // to `coordinates[l]`; however, `std::vector`'s subscript-assignment + // only allows assigning to already-initialized positions. + if (isCompressedDLT(dlt) || isSingletonDLT(dlt)) + coordinates[l].resize(parentSz, 0); + else + ASSERT_DENSE_DLT(dlt); // Future-proofing. + } + values.resize(parentSz, 0); // Both allocate and zero-initialize. + } + // The yieldPos loop + lvlEnumerator.forallElements([this](const auto &lvlCoords, V val) { + uint64_t parentSz = 1, parentPos = 0; + for (uint64_t lvlRank = getLvlRank(), l = 0; l < lvlRank; ++l) { + const auto dlt = getLvlTypes()[l]; // Avoid redundant bounds checking. + if (isCompressedDLT(dlt)) { + // If `parentPos == parentSz` then it's valid as an array-lookup; + // however, it's semantically invalid here since that entry + // does not represent a segment of `coordinates[l]`. Moreover, that + // entry must be immutable for `assembledSize` to remain valid. + assert(parentPos < parentSz && "Parent position is out of bounds"); + const uint64_t currentPos = positions[l][parentPos]; + // This increment won't overflow the `P` type, since it can't + // exceed the original value of `positions[l][parentPos+1]` + // which was already verified to be within bounds for `P` + // when it was written to the array. + positions[l][parentPos]++; + writeCrd(l, currentPos, lvlCoords[l]); + parentPos = currentPos; + } else if (isSingletonDLT(dlt)) { + writeCrd(l, parentPos, lvlCoords[l]); + // the new parentPos equals the old parentPos. + } else { // Dense level. + ASSERT_DENSE_DLT(dlt); + parentPos = parentPos * getLvlSizes()[l] + lvlCoords[l]; + } + parentSz = assembledSize(parentSz, l); + } + assert(parentPos < values.size() && "Value position is out of bounds"); + values[parentPos] = val; + }); + // The finalizeYieldPos loop + for (uint64_t parentSz = 1, l = 0; l < lvlRank; ++l) { + const auto dlt = lvlTypes[l]; // Avoid redundant bounds checking. + if (isCompressedDLT(dlt)) { + assert(parentSz == positions[l].size() - 1 && + "Actual positions size doesn't match the expected size"); + // Can't check all of them, but at least we can check the last one. + assert(positions[l][parentSz - 1] == positions[l][parentSz] && + "Positions got corrupted"); + // TODO: optimize this by using `memmove` or similar. + for (uint64_t n = 0; n < parentSz; ++n) { + const uint64_t parentPos = parentSz - n; + positions[l][parentPos] = positions[l][parentPos - 1]; + } + positions[l][0] = 0; + } else { + // Both dense and singleton are no-ops for the finalizeYieldPos loop. + // This assertion is for future-proofing. + assert((isDenseDLT(dlt) || isSingletonDLT(dlt)) && + "Level is neither dense nor singleton"); + } + parentSz = assembledSize(parentSz, l); + } +} + +template +SparseTensorStorage::SparseTensorStorage( + uint64_t dimRank, const uint64_t *dimSizes, uint64_t lvlRank, + const uint64_t *lvlSizes, const DimLevelType *lvlTypes, + const uint64_t *lvl2dim, const intptr_t *lvlBufs) + : SparseTensorStorage(dimRank, dimSizes, lvlRank, lvlSizes, lvlTypes, + lvl2dim) { + uint64_t trailCOOLen = 0, parentSz = 1, bufIdx = 0; + for (uint64_t l = 0; l < lvlRank; l++) { + if (!isUniqueLvl(l) && isCompressedLvl(l)) { + // A `compressed_nu` level marks the start of trailing COO start level. + // Since the coordinate buffer used for trailing COO are passed in as AoS + // scheme, and SparseTensorStorage uses a SoA scheme, we can not simply + // copy the value from the provided buffers. + trailCOOLen = lvlRank - l; + break; + } + assert(!isSingletonLvl(l) && + "Singleton level not following a compressed_nu level"); + if (isCompressedLvl(l)) { + P *posPtr = reinterpret_cast

(lvlBufs[bufIdx++]); + C *crdPtr = reinterpret_cast(lvlBufs[bufIdx++]); + // Copies the lvlBuf into the vectors. The buffer can not be simply reused + // because the memory passed from users is not necessarily allocated on + // heap. + positions[l].assign(posPtr, posPtr + parentSz + 1); + coordinates[l].assign(crdPtr, crdPtr + positions[l][parentSz]); + } else { + assert(isDenseLvl(l) && "Level is not dense"); + } + parentSz = assembledSize(parentSz, l); + } + + if (trailCOOLen != 0) { + uint64_t cooStartLvl = lvlRank - trailCOOLen; + assert(!isUniqueLvl(cooStartLvl) && isCompressedLvl(cooStartLvl)); + P *posPtr = reinterpret_cast

(lvlBufs[bufIdx++]); + C *aosCrdPtr = reinterpret_cast(lvlBufs[bufIdx++]); + positions[cooStartLvl].assign(posPtr, posPtr + parentSz + 1); + P crdLen = positions[cooStartLvl][parentSz]; + for (uint64_t l = cooStartLvl; l < lvlRank; l++) { + coordinates[l].resize(crdLen); + for (uint64_t n = 0; n < crdLen; n++) { + coordinates[l][n] = *(aosCrdPtr + (l - cooStartLvl) + n * trailCOOLen); + } + } + parentSz = assembledSize(parentSz, cooStartLvl); + } + + V *valPtr = reinterpret_cast(lvlBufs[bufIdx]); + values.assign(valPtr, valPtr + parentSz); +} + +#undef ASSERT_DENSE_DLT + +} // namespace sparse_tensor +} // namespace mlir + +#endif // MLIR_EXECUTIONENGINE_SPARSETENSOR_STORAGE_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/SparseTensorRuntime.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/SparseTensorRuntime.h new file mode 100644 index 0000000000000000000000000000000000000000..e723a354345849d1afbb31d8873b9b3058e1f435 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/ExecutionEngine/SparseTensorRuntime.h @@ -0,0 +1,249 @@ +//===- SparseTensorRuntime.h - SparseTensor runtime support lib -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This header file provides the functions which comprise the public API of the +// sparse tensor runtime support library for the SparseTensor dialect. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_EXECUTIONENGINE_SPARSETENSORRUNTIME_H +#define MLIR_EXECUTIONENGINE_SPARSETENSORRUNTIME_H + +#include "mlir/Dialect/SparseTensor/IR/Enums.h" +#include "mlir/ExecutionEngine/CRunnerUtils.h" +#include "mlir/ExecutionEngine/Float16bits.h" + +#include +#include +#include + +using namespace mlir::sparse_tensor; + +using SparseTensorWriter = std::ostream; + +extern "C" { + +//===----------------------------------------------------------------------===// +// +// Public functions which operate on MLIR buffers (memrefs) to interact +// with sparse tensors (which are only visible as opaque pointers externally). +// Because these functions deal with memrefs, they should only be used +// by MLIR compiler-generated code (or code that is in sync with MLIR). +// +//===----------------------------------------------------------------------===// + +/// The @newSparseTensor function for constructing a new sparse tensor. +/// This is the "swiss army knife" method for materializing sparse +/// tensors into the computation. The types of the `ptr` argument and +/// the result depend on the action, as explained in the following table +/// (where "STS" means a sparse-tensor-storage object, "COO" means +/// a coordinate-scheme object, and "Iterator" means an iterator object). +/// +/// Action: `ptr`: Returns: +/// kEmpty unused STS, empty +/// kEmptyCOO unused COO, empty +/// kFromFile char* filename STS, read from the file +/// kFromCOO COO STS, copied from the COO source +/// kToCOO STS COO, copied from the STS source +/// kSparseToSparse STS STS, copied from the STS source +/// kToIterator STS Iterator, call @getNext to use and +/// @delSparseTensorIterator to free. +MLIR_CRUNNERUTILS_EXPORT void *_mlir_ciface_newSparseTensor( // NOLINT + StridedMemRefType *dimSizesRef, + StridedMemRefType *lvlSizesRef, + StridedMemRefType *lvlTypesRef, + StridedMemRefType *dim2lvlRef, + StridedMemRefType *lvl2dimRef, OverheadType posTp, + OverheadType crdTp, PrimaryType valTp, Action action, void *ptr); + +/// Tensor-storage method to obtain direct access to the values array. +#define DECL_SPARSEVALUES(VNAME, V) \ + MLIR_CRUNNERUTILS_EXPORT void _mlir_ciface_sparseValues##VNAME( \ + StridedMemRefType *out, void *tensor); +MLIR_SPARSETENSOR_FOREVERY_V(DECL_SPARSEVALUES) +#undef DECL_SPARSEVALUES + +/// Tensor-storage method to obtain direct access to the positions array +/// for the given level. +#define DECL_SPARSEPOSITIONS(PNAME, P) \ + MLIR_CRUNNERUTILS_EXPORT void _mlir_ciface_sparsePositions##PNAME( \ + StridedMemRefType *out, void *tensor, index_type lvl); +MLIR_SPARSETENSOR_FOREVERY_O(DECL_SPARSEPOSITIONS) +#undef DECL_SPARSEPOSITIONS + +/// Tensor-storage method to obtain direct access to the coordinates array +/// for the given level. +#define DECL_SPARSECOORDINATES(CNAME, C) \ + MLIR_CRUNNERUTILS_EXPORT void _mlir_ciface_sparseCoordinates##CNAME( \ + StridedMemRefType *out, void *tensor, index_type lvl); +MLIR_SPARSETENSOR_FOREVERY_O(DECL_SPARSECOORDINATES) +#undef DECL_SPARSECOORDINATES + +/// Coordinate-scheme method for adding a new element. +/// TODO: remove dim2lvl +#define DECL_ADDELT(VNAME, V) \ + MLIR_CRUNNERUTILS_EXPORT void *_mlir_ciface_addElt##VNAME( \ + void *lvlCOO, StridedMemRefType *vref, \ + StridedMemRefType *dimCoordsRef, \ + StridedMemRefType *dim2lvlRef); +MLIR_SPARSETENSOR_FOREVERY_V(DECL_ADDELT) +#undef DECL_ADDELT + +/// Coordinate-scheme method for getting the next element while iterating. +/// The `cref` argument uses the same coordinate-space as the `iter` (which +/// can be either dim- or lvl-coords, depending on context). +#define DECL_GETNEXT(VNAME, V) \ + MLIR_CRUNNERUTILS_EXPORT bool _mlir_ciface_getNext##VNAME( \ + void *iter, StridedMemRefType *cref, \ + StridedMemRefType *vref); +MLIR_SPARSETENSOR_FOREVERY_V(DECL_GETNEXT) +#undef DECL_GETNEXT + +/// Tensor-storage method to insert elements in lexicographical +/// level-coordinate order. +#define DECL_LEXINSERT(VNAME, V) \ + MLIR_CRUNNERUTILS_EXPORT void _mlir_ciface_lexInsert##VNAME( \ + void *tensor, StridedMemRefType *lvlCoordsRef, \ + StridedMemRefType *vref); +MLIR_SPARSETENSOR_FOREVERY_V(DECL_LEXINSERT) +#undef DECL_LEXINSERT + +/// Tensor-storage method to insert using expansion. +#define DECL_EXPINSERT(VNAME, V) \ + MLIR_CRUNNERUTILS_EXPORT void _mlir_ciface_expInsert##VNAME( \ + void *tensor, StridedMemRefType *lvlCoordsRef, \ + StridedMemRefType *vref, StridedMemRefType *fref, \ + StridedMemRefType *aref, index_type count); +MLIR_SPARSETENSOR_FOREVERY_V(DECL_EXPINSERT) +#undef DECL_EXPINSERT + +/// Constructs a new SparseTensorReader object, opens the file, reads the +/// header, and validates that the actual contents of the file match +/// the expected `dimShapeRef` and `valTp`. +MLIR_CRUNNERUTILS_EXPORT void *_mlir_ciface_createCheckedSparseTensorReader( + char *filename, StridedMemRefType *dimShapeRef, + PrimaryType valTp); + +/// Constructs a new sparse-tensor storage object with the given encoding, +/// initializes it by reading all the elements from the file, and then +/// closes the file. +MLIR_CRUNNERUTILS_EXPORT void *_mlir_ciface_newSparseTensorFromReader( + void *p, StridedMemRefType *lvlSizesRef, + StridedMemRefType *lvlTypesRef, + StridedMemRefType *dim2lvlRef, + StridedMemRefType *lvl2dimRef, OverheadType posTp, + OverheadType crdTp, PrimaryType valTp); + +/// SparseTensorReader method to obtain direct access to the +/// dimension-sizes array. +MLIR_CRUNNERUTILS_EXPORT void _mlir_ciface_getSparseTensorReaderDimSizes( + StridedMemRefType *out, void *p); + +/// Reads the sparse tensor, stores the coordinates and values to the given +/// memrefs. Returns a boolean to indicate whether the COO elements are sorted. +#define DECL_GETNEXT(VNAME, V, CNAME, C) \ + MLIR_CRUNNERUTILS_EXPORT bool \ + _mlir_ciface_getSparseTensorReaderReadToBuffers##CNAME##VNAME( \ + void *p, StridedMemRefType *dim2lvlRef, \ + StridedMemRefType *lvl2dimRef, \ + StridedMemRefType *cref, StridedMemRefType *vref) \ + MLIR_SPARSETENSOR_FOREVERY_V_O(DECL_GETNEXT) +#undef DECL_GETNEXT + +/// Outputs the sparse tensor dim-rank, nse, and dim-shape. +MLIR_CRUNNERUTILS_EXPORT void _mlir_ciface_outSparseTensorWriterMetaData( + void *p, index_type dimRank, index_type nse, + StridedMemRefType *dimSizesRef); + +/// Outputs an element for the sparse tensor. +#define DECL_OUTNEXT(VNAME, V) \ + MLIR_CRUNNERUTILS_EXPORT void _mlir_ciface_outSparseTensorWriterNext##VNAME( \ + void *p, index_type dimRank, \ + StridedMemRefType *dimCoordsRef, \ + StridedMemRefType *vref); +MLIR_SPARSETENSOR_FOREVERY_V(DECL_OUTNEXT) +#undef DECL_OUTNEXT + +//===----------------------------------------------------------------------===// +// +// Public functions which accept only C-style data structures to interact +// with sparse tensors (which are only visible as opaque pointers externally). +// These functions can be used both by MLIR compiler-generated code +// as well as by any external runtime that wants to interact with MLIR +// compiler-generated code. +// +//===----------------------------------------------------------------------===// + +/// Tensor-storage method to get the size of the given level. +MLIR_CRUNNERUTILS_EXPORT index_type sparseLvlSize(void *tensor, index_type l); + +/// Tensor-storage method to get the size of the given dimension. +MLIR_CRUNNERUTILS_EXPORT index_type sparseDimSize(void *tensor, index_type d); + +/// Tensor-storage method to finalize lexicographic insertions. +MLIR_CRUNNERUTILS_EXPORT void endInsert(void *tensor); + +/// Coordinate-scheme method to write to file in extended FROSTT format. +#define DECL_OUTSPARSETENSOR(VNAME, V) \ + MLIR_CRUNNERUTILS_EXPORT void outSparseTensor##VNAME(void *coo, void *dest, \ + bool sort); +MLIR_SPARSETENSOR_FOREVERY_V(DECL_OUTSPARSETENSOR) +#undef DECL_OUTSPARSETENSOR + +/// Releases the memory for the tensor-storage object. +MLIR_CRUNNERUTILS_EXPORT void delSparseTensor(void *tensor); + +/// Releases the memory for the coordinate-scheme object. +#define DECL_DELCOO(VNAME, V) \ + MLIR_CRUNNERUTILS_EXPORT void delSparseTensorCOO##VNAME(void *coo); +MLIR_SPARSETENSOR_FOREVERY_V(DECL_DELCOO) +#undef DECL_DELCOO + +/// Releases the memory for an iterator object. +#define DECL_DELITER(VNAME, V) \ + MLIR_CRUNNERUTILS_EXPORT void delSparseTensorIterator##VNAME(void *iter); +MLIR_SPARSETENSOR_FOREVERY_V(DECL_DELITER) +#undef DECL_DELITER + +/// Helper function to read a sparse tensor filename from the environment, +/// defined with the naming convention ${TENSOR0}, ${TENSOR1}, etc. +MLIR_CRUNNERUTILS_EXPORT char *getTensorFilename(index_type id); + +/// Helper function to read the header of a file and return the +/// shape/sizes, without parsing the elements of the file. +MLIR_CRUNNERUTILS_EXPORT void readSparseTensorShape(char *filename, + std::vector *out); + +/// Returns the rank of the sparse tensor being read. +MLIR_CRUNNERUTILS_EXPORT index_type getSparseTensorReaderRank(void *p); + +/// Returns the is_symmetric bit for the sparse tensor being read. +MLIR_CRUNNERUTILS_EXPORT bool getSparseTensorReaderIsSymmetric(void *p); + +/// Returns the number of stored elements for the sparse tensor being read. +MLIR_CRUNNERUTILS_EXPORT index_type getSparseTensorReaderNSE(void *p); + +/// Returns the size of a dimension for the sparse tensor being read. +MLIR_CRUNNERUTILS_EXPORT index_type getSparseTensorReaderDimSize(void *p, + index_type d); + +/// Releases the SparseTensorReader and closes the associated file. +MLIR_CRUNNERUTILS_EXPORT void delSparseTensorReader(void *p); + +/// Creates a SparseTensorWriter for outputting a sparse tensor to a file +/// with the given file name. When the file name is empty, std::cout is used. +/// Only the extended FROSTT format is supported currently. +MLIR_CRUNNERUTILS_EXPORT void *createSparseTensorWriter(char *filename); + +/// Finalizes the outputing of a sparse tensor to a file and releases the +/// SparseTensorWriter. +MLIR_CRUNNERUTILS_EXPORT void delSparseTensorWriter(void *p); + +} // extern "C" + +#endif // MLIR_EXECUTIONENGINE_SPARSETENSORRUNTIME_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/IR/Action.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/IR/Action.h new file mode 100644 index 0000000000000000000000000000000000000000..9359324dd609084cd10c248de518c90f7a9c5fbf --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/IR/Action.h @@ -0,0 +1,94 @@ +//===- Action.h - Action Support ---------------------*- C++ -*-=============// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file contains definitions for the action framework. This framework +// allows for external entities to control certain actions taken by the compiler +// by registering handler functions. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_IR_ACTION_H +#define MLIR_IR_ACTION_H + +#include "mlir/IR/Unit.h" +#include "mlir/Support/LogicalResult.h" +#include "mlir/Support/TypeID.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/Sequence.h" +#include "llvm/ADT/StringMap.h" +#include "llvm/Support/TypeName.h" +#include "llvm/Support/raw_ostream.h" +#include +#include + +namespace mlir { +namespace tracing { + +/// An action is a specific action that is to be taken by the compiler, +/// that can be toggled and controlled by an external user. There are no +/// constraints on the granularity of an action, it could be as simple as +/// "perform this fold" and as complex as "run this pass pipeline". +/// +/// This class represents the base class of the ActionImpl class (see below). +/// This holds the template-invariant elements of the Action class. +class Action { +public: + virtual ~Action() = default; + + /// Return the unique action id of this action, use for casting + /// functionality. + TypeID getActionID() const { return actionID; } + + /// Return a string "tag" which intends to uniquely identify this type of + /// action. For example "pass-application" or "pattern-rewrite". + virtual StringRef getTag() const = 0; + + virtual void print(raw_ostream &os) const { + os << "Action \"" << getTag() << "\""; + } + + /// Return the set of IR units that are associated with this action. + virtual ArrayRef getContextIRUnits() const { return irUnits; } + +protected: + Action(TypeID actionID, ArrayRef irUnits) + : actionID(actionID), irUnits(irUnits) {} + + /// The type of the derived action class, used for `isa`/`dyn_cast`. + TypeID actionID; + + /// Set of IR units (operations, regions, blocks, values) that are associated + /// with this action. + ArrayRef irUnits; +}; + +/// CRTP Implementation of an action. This class provides a base class for +/// implementing specific actions. +/// Derived classes are expected to provide the following: +/// * static constexpr StringLiteral tag = "..."; +/// - This method returns a unique string identifier, similar to a command +/// line flag or DEBUG_TYPE. +template +class ActionImpl : public Action { +public: + ActionImpl(ArrayRef irUnits = {}) + : Action(TypeID::get(), irUnits) {} + + /// Provide classof to allow casting between action types. + static bool classof(const Action *action) { + return action->getActionID() == TypeID::get(); + } + + /// Forward tag access to the derived class. + StringRef getTag() const final { return Derived::tag; } +}; + +} // namespace tracing +} // namespace mlir + +#endif // MLIR_IR_ACTION_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/IR/AffineExpr.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/IR/AffineExpr.h new file mode 100644 index 0000000000000000000000000000000000000000..8ced8770591ee8c468bb6c97e879b988a60bd762 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/IR/AffineExpr.h @@ -0,0 +1,381 @@ +//===- AffineExpr.h - MLIR Affine Expr Class --------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// An affine expression is an affine combination of dimension identifiers and +// symbols, including ceildiv/floordiv/mod by a constant integer. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_IR_AFFINEEXPR_H +#define MLIR_IR_AFFINEEXPR_H + +#include "mlir/Support/LLVM.h" +#include "llvm/ADT/DenseMapInfo.h" +#include "llvm/ADT/Hashing.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/Support/Casting.h" +#include +#include + +namespace mlir { + +class MLIRContext; +class AffineMap; +class IntegerSet; + +namespace detail { + +struct AffineExprStorage; +struct AffineBinaryOpExprStorage; +struct AffineDimExprStorage; +struct AffineConstantExprStorage; + +} // namespace detail + +enum class AffineExprKind { + Add, + /// RHS of mul is always a constant or a symbolic expression. + Mul, + /// RHS of mod is always a constant or a symbolic expression with a positive + /// value. + Mod, + /// RHS of floordiv is always a constant or a symbolic expression. + FloorDiv, + /// RHS of ceildiv is always a constant or a symbolic expression. + CeilDiv, + + /// This is a marker for the last affine binary op. The range of binary + /// op's is expected to be this element and earlier. + LAST_AFFINE_BINARY_OP = CeilDiv, + + /// Constant integer. + Constant, + /// Dimensional identifier. + DimId, + /// Symbolic identifier. + SymbolId, +}; + +/// Base type for affine expression. +/// AffineExpr's are immutable value types with intuitive operators to +/// operate on chainable, lightweight compositions. +/// An AffineExpr is an interface to the underlying storage type pointer. +class AffineExpr { +public: + using ImplType = detail::AffineExprStorage; + + constexpr AffineExpr() {} + /* implicit */ AffineExpr(const ImplType *expr) + : expr(const_cast(expr)) {} + + bool operator==(AffineExpr other) const { return expr == other.expr; } + bool operator!=(AffineExpr other) const { return !(*this == other); } + bool operator==(int64_t v) const; + bool operator!=(int64_t v) const { return !(*this == v); } + explicit operator bool() const { return expr; } + + bool operator!() const { return expr == nullptr; } + + template + constexpr bool isa() const; + template + U dyn_cast() const; + template + U dyn_cast_or_null() const; + template + U cast() const; + + MLIRContext *getContext() const; + + /// Return the classification for this type. + AffineExprKind getKind() const; + + void print(raw_ostream &os) const; + void dump() const; + + /// Returns true if this expression is made out of only symbols and + /// constants, i.e., it does not involve dimensional identifiers. + bool isSymbolicOrConstant() const; + + /// Returns true if this is a pure affine expression, i.e., multiplication, + /// floordiv, ceildiv, and mod is only allowed w.r.t constants. + bool isPureAffine() const; + + /// Returns the greatest known integral divisor of this affine expression. The + /// result is always positive. + int64_t getLargestKnownDivisor() const; + + /// Return true if the affine expression is a multiple of 'factor'. + bool isMultipleOf(int64_t factor) const; + + /// Return true if the affine expression involves AffineDimExpr `position`. + bool isFunctionOfDim(unsigned position) const; + + /// Return true if the affine expression involves AffineSymbolExpr `position`. + bool isFunctionOfSymbol(unsigned position) const; + + /// Walk all of the AffineExpr's in this expression in postorder. + void walk(std::function callback) const; + + /// This method substitutes any uses of dimensions and symbols (e.g. + /// dim#0 with dimReplacements[0]) and returns the modified expression tree. + /// This is a dense replacement method: a replacement must be specified for + /// every single dim and symbol. + AffineExpr replaceDimsAndSymbols(ArrayRef dimReplacements, + ArrayRef symReplacements) const; + + /// Dim-only version of replaceDimsAndSymbols. + AffineExpr replaceDims(ArrayRef dimReplacements) const; + + /// Symbol-only version of replaceDimsAndSymbols. + AffineExpr replaceSymbols(ArrayRef symReplacements) const; + + /// Sparse replace method. Replace `expr` by `replacement` and return the + /// modified expression tree. + AffineExpr replace(AffineExpr expr, AffineExpr replacement) const; + + /// Sparse replace method. If `*this` appears in `map` replaces it by + /// `map[*this]` and return the modified expression tree. Otherwise traverse + /// `*this` and apply replace with `map` on its subexpressions. + AffineExpr replace(const DenseMap &map) const; + + /// Replace dims[offset ... numDims) + /// by dims[offset + shift ... shift + numDims). + AffineExpr shiftDims(unsigned numDims, unsigned shift, + unsigned offset = 0) const; + + /// Replace symbols[offset ... numSymbols) + /// by symbols[offset + shift ... shift + numSymbols). + AffineExpr shiftSymbols(unsigned numSymbols, unsigned shift, + unsigned offset = 0) const; + + AffineExpr operator+(int64_t v) const; + AffineExpr operator+(AffineExpr other) const; + AffineExpr operator-() const; + AffineExpr operator-(int64_t v) const; + AffineExpr operator-(AffineExpr other) const; + AffineExpr operator*(int64_t v) const; + AffineExpr operator*(AffineExpr other) const; + AffineExpr floorDiv(uint64_t v) const; + AffineExpr floorDiv(AffineExpr other) const; + AffineExpr ceilDiv(uint64_t v) const; + AffineExpr ceilDiv(AffineExpr other) const; + AffineExpr operator%(uint64_t v) const; + AffineExpr operator%(AffineExpr other) const; + + /// Compose with an AffineMap. + /// Returns the composition of this AffineExpr with `map`. + /// + /// Prerequisites: + /// `this` and `map` are composable, i.e. that the number of AffineDimExpr of + /// `this` is smaller than the number of results of `map`. If a result of a + /// map does not have a corresponding AffineDimExpr, that result simply does + /// not appear in the produced AffineExpr. + /// + /// Example: + /// expr: `d0 + d2` + /// map: `(d0, d1, d2)[s0, s1] -> (d0 + s1, d1 + s0, d0 + d1 + d2)` + /// returned expr: `d0 * 2 + d1 + d2 + s1` + AffineExpr compose(AffineMap map) const; + + friend ::llvm::hash_code hash_value(AffineExpr arg); + + /// Methods supporting C API. + const void *getAsOpaquePointer() const { + return static_cast(expr); + } + static AffineExpr getFromOpaquePointer(const void *pointer) { + return AffineExpr( + reinterpret_cast(const_cast(pointer))); + } + +protected: + ImplType *expr{nullptr}; +}; + +/// Affine binary operation expression. An affine binary operation could be an +/// add, mul, floordiv, ceildiv, or a modulo operation. (Subtraction is +/// represented through a multiply by -1 and add.) These expressions are always +/// constructed in a simplified form. For eg., the LHS and RHS operands can't +/// both be constants. There are additional canonicalizing rules depending on +/// the op type: see checks in the constructor. +class AffineBinaryOpExpr : public AffineExpr { +public: + using ImplType = detail::AffineBinaryOpExprStorage; + /* implicit */ AffineBinaryOpExpr(AffineExpr::ImplType *ptr); + AffineExpr getLHS() const; + AffineExpr getRHS() const; +}; + +/// A dimensional identifier appearing in an affine expression. +class AffineDimExpr : public AffineExpr { +public: + using ImplType = detail::AffineDimExprStorage; + /* implicit */ AffineDimExpr(AffineExpr::ImplType *ptr); + unsigned getPosition() const; +}; + +/// A symbolic identifier appearing in an affine expression. +class AffineSymbolExpr : public AffineExpr { +public: + using ImplType = detail::AffineDimExprStorage; + /* implicit */ AffineSymbolExpr(AffineExpr::ImplType *ptr); + unsigned getPosition() const; +}; + +/// An integer constant appearing in affine expression. +class AffineConstantExpr : public AffineExpr { +public: + using ImplType = detail::AffineConstantExprStorage; + /* implicit */ AffineConstantExpr(AffineExpr::ImplType *ptr = nullptr); + int64_t getValue() const; +}; + +/// Make AffineExpr hashable. +inline ::llvm::hash_code hash_value(AffineExpr arg) { + return ::llvm::hash_value(arg.expr); +} + +inline AffineExpr operator+(int64_t val, AffineExpr expr) { return expr + val; } +inline AffineExpr operator*(int64_t val, AffineExpr expr) { return expr * val; } +inline AffineExpr operator-(int64_t val, AffineExpr expr) { + return expr * (-1) + val; +} + +/// These free functions allow clients of the API to not use classes in detail. +AffineExpr getAffineDimExpr(unsigned position, MLIRContext *context); +AffineExpr getAffineSymbolExpr(unsigned position, MLIRContext *context); +AffineExpr getAffineConstantExpr(int64_t constant, MLIRContext *context); +SmallVector getAffineConstantExprs(ArrayRef constants, + MLIRContext *context); +AffineExpr getAffineBinaryOpExpr(AffineExprKind kind, AffineExpr lhs, + AffineExpr rhs); + +/// Constructs an affine expression from a flat ArrayRef. If there are local +/// identifiers (neither dimensional nor symbolic) that appear in the sum of +/// products expression, 'localExprs' is expected to have the AffineExpr +/// for it, and is substituted into. The ArrayRef 'eq' is expected to be in the +/// format [dims, symbols, locals, constant term]. +AffineExpr getAffineExprFromFlatForm(ArrayRef flatExprs, + unsigned numDims, unsigned numSymbols, + ArrayRef localExprs, + MLIRContext *context); + +raw_ostream &operator<<(raw_ostream &os, AffineExpr expr); + +template +constexpr bool AffineExpr::isa() const { + if constexpr (std::is_same_v) + return getKind() <= AffineExprKind::LAST_AFFINE_BINARY_OP; + if constexpr (std::is_same_v) + return getKind() == AffineExprKind::DimId; + if constexpr (std::is_same_v) + return getKind() == AffineExprKind::SymbolId; + if constexpr (std::is_same_v) + return getKind() == AffineExprKind::Constant; +} +template +U AffineExpr::dyn_cast() const { + if (isa()) + return U(expr); + return U(nullptr); +} +template +U AffineExpr::dyn_cast_or_null() const { + return (!*this || !isa()) ? U(nullptr) : U(expr); +} +template +U AffineExpr::cast() const { + assert(isa()); + return U(expr); +} + +/// Simplify an affine expression by flattening and some amount of simple +/// analysis. This has complexity linear in the number of nodes in 'expr'. +/// Returns the simplified expression, which is the same as the input expression +/// if it can't be simplified. When `expr` is semi-affine, a simplified +/// semi-affine expression is constructed in the sorted order of dimension and +/// symbol positions. +AffineExpr simplifyAffineExpr(AffineExpr expr, unsigned numDims, + unsigned numSymbols); + +namespace detail { +template +void bindDims(MLIRContext *ctx) {} + +template +void bindDims(MLIRContext *ctx, AffineExprTy &e, AffineExprTy2 &...exprs) { + e = getAffineDimExpr(N, ctx); + bindDims(ctx, exprs...); +} + +template +void bindSymbols(MLIRContext *ctx) {} + +template +void bindSymbols(MLIRContext *ctx, AffineExprTy &e, AffineExprTy2 &...exprs) { + e = getAffineSymbolExpr(N, ctx); + bindSymbols(ctx, exprs...); +} + +} // namespace detail + +/// Bind a list of AffineExpr references to DimExpr at positions: +/// [0 .. sizeof...(exprs)] +template +void bindDims(MLIRContext *ctx, AffineExprTy &...exprs) { + detail::bindDims<0>(ctx, exprs...); +} + +template +void bindDimsList(MLIRContext *ctx, MutableArrayRef exprs) { + int idx = 0; + for (AffineExprTy &e : exprs) + e = getAffineDimExpr(idx++, ctx); +} + +/// Bind a list of AffineExpr references to SymbolExpr at positions: +/// [0 .. sizeof...(exprs)] +template +void bindSymbols(MLIRContext *ctx, AffineExprTy &...exprs) { + detail::bindSymbols<0>(ctx, exprs...); +} + +template +void bindSymbolsList(MLIRContext *ctx, MutableArrayRef exprs) { + int idx = 0; + for (AffineExprTy &e : exprs) + e = getAffineSymbolExpr(idx++, ctx); +} + +} // namespace mlir + +namespace llvm { + +// AffineExpr hash just like pointers +template <> +struct DenseMapInfo { + static mlir::AffineExpr getEmptyKey() { + auto *pointer = llvm::DenseMapInfo::getEmptyKey(); + return mlir::AffineExpr(static_cast(pointer)); + } + static mlir::AffineExpr getTombstoneKey() { + auto *pointer = llvm::DenseMapInfo::getTombstoneKey(); + return mlir::AffineExpr(static_cast(pointer)); + } + static unsigned getHashValue(mlir::AffineExpr val) { + return mlir::hash_value(val); + } + static bool isEqual(mlir::AffineExpr LHS, mlir::AffineExpr RHS) { + return LHS == RHS; + } +}; + +} // namespace llvm + +#endif // MLIR_IR_AFFINEEXPR_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/IR/AffineExprVisitor.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/IR/AffineExprVisitor.h new file mode 100644 index 0000000000000000000000000000000000000000..f6216614c2238e125acad5e04b981e5c86637dda --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/IR/AffineExprVisitor.h @@ -0,0 +1,346 @@ +//===- AffineExprVisitor.h - MLIR AffineExpr Visitor Class ------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file defines the AffineExpr visitor class. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_IR_AFFINEEXPRVISITOR_H +#define MLIR_IR_AFFINEEXPRVISITOR_H + +#include "mlir/IR/AffineExpr.h" +#include "llvm/ADT/ArrayRef.h" + +namespace mlir { + +/// Base class for AffineExpr visitors/walkers. +/// +/// AffineExpr visitors are used when you want to perform different actions +/// for different kinds of AffineExprs without having to use lots of casts +/// and a big switch instruction. +/// +/// To define your own visitor, inherit from this class, specifying your +/// new type for the 'SubClass' template parameter, and "override" visitXXX +/// functions in your class. This class is defined in terms of statically +/// resolved overloading, not virtual functions. +/// +/// For example, here is a visitor that counts the number of for AffineDimExprs +/// in an AffineExpr. +/// +/// /// Declare the class. Note that we derive from AffineExprVisitor +/// /// instantiated with our new subclasses_ type. +/// +/// struct DimExprCounter : public AffineExprVisitor { +/// unsigned numDimExprs; +/// DimExprCounter() : numDimExprs(0) {} +/// void visitDimExpr(AffineDimExpr expr) { ++numDimExprs; } +/// }; +/// +/// And this class would be used like this: +/// DimExprCounter dec; +/// dec.visit(affineExpr); +/// numDimExprs = dec.numDimExprs; +/// +/// AffineExprVisitor provides visit methods for the following binary affine +/// op expressions: +/// AffineBinaryAddOpExpr, AffineBinaryMulOpExpr, +/// AffineBinaryModOpExpr, AffineBinaryFloorDivOpExpr, +/// AffineBinaryCeilDivOpExpr. Note that default implementations of these +/// methods will call the general AffineBinaryOpExpr method. +/// +/// In addition, visit methods are provided for the following affine +// expressions: AffineConstantExpr, AffineDimExpr, and +// AffineSymbolExpr. +/// +/// Note that if you don't implement visitXXX for some affine expression type, +/// the visitXXX method for Instruction superclass will be invoked. +/// +/// Note that this class is specifically designed as a template to avoid +/// virtual function call overhead. Defining and using a AffineExprVisitor is +/// just as efficient as having your own switch instruction over the instruction +/// opcode. + +template +class AffineExprVisitor { + //===--------------------------------------------------------------------===// + // Interface code - This is the public interface of the AffineExprVisitor + // that you use to visit affine expressions... +public: + // Function to walk an AffineExpr (in post order). + RetTy walkPostOrder(AffineExpr expr) { + static_assert(std::is_base_of::value, + "Must instantiate with a derived type of AffineExprVisitor"); + switch (expr.getKind()) { + case AffineExprKind::Add: { + auto binOpExpr = expr.cast(); + walkOperandsPostOrder(binOpExpr); + return static_cast(this)->visitAddExpr(binOpExpr); + } + case AffineExprKind::Mul: { + auto binOpExpr = expr.cast(); + walkOperandsPostOrder(binOpExpr); + return static_cast(this)->visitMulExpr(binOpExpr); + } + case AffineExprKind::Mod: { + auto binOpExpr = expr.cast(); + walkOperandsPostOrder(binOpExpr); + return static_cast(this)->visitModExpr(binOpExpr); + } + case AffineExprKind::FloorDiv: { + auto binOpExpr = expr.cast(); + walkOperandsPostOrder(binOpExpr); + return static_cast(this)->visitFloorDivExpr(binOpExpr); + } + case AffineExprKind::CeilDiv: { + auto binOpExpr = expr.cast(); + walkOperandsPostOrder(binOpExpr); + return static_cast(this)->visitCeilDivExpr(binOpExpr); + } + case AffineExprKind::Constant: + return static_cast(this)->visitConstantExpr( + expr.cast()); + case AffineExprKind::DimId: + return static_cast(this)->visitDimExpr( + expr.cast()); + case AffineExprKind::SymbolId: + return static_cast(this)->visitSymbolExpr( + expr.cast()); + } + } + + // Function to visit an AffineExpr. + RetTy visit(AffineExpr expr) { + static_assert(std::is_base_of::value, + "Must instantiate with a derived type of AffineExprVisitor"); + switch (expr.getKind()) { + case AffineExprKind::Add: { + auto binOpExpr = expr.cast(); + return static_cast(this)->visitAddExpr(binOpExpr); + } + case AffineExprKind::Mul: { + auto binOpExpr = expr.cast(); + return static_cast(this)->visitMulExpr(binOpExpr); + } + case AffineExprKind::Mod: { + auto binOpExpr = expr.cast(); + return static_cast(this)->visitModExpr(binOpExpr); + } + case AffineExprKind::FloorDiv: { + auto binOpExpr = expr.cast(); + return static_cast(this)->visitFloorDivExpr(binOpExpr); + } + case AffineExprKind::CeilDiv: { + auto binOpExpr = expr.cast(); + return static_cast(this)->visitCeilDivExpr(binOpExpr); + } + case AffineExprKind::Constant: + return static_cast(this)->visitConstantExpr( + expr.cast()); + case AffineExprKind::DimId: + return static_cast(this)->visitDimExpr( + expr.cast()); + case AffineExprKind::SymbolId: + return static_cast(this)->visitSymbolExpr( + expr.cast()); + } + llvm_unreachable("Unknown AffineExpr"); + } + + //===--------------------------------------------------------------------===// + // Visitation functions... these functions provide default fallbacks in case + // the user does not specify what to do for a particular instruction type. + // The default behavior is to generalize the instruction type to its subtype + // and try visiting the subtype. All of this should be inlined perfectly, + // because there are no virtual functions to get in the way. + // + + // Default visit methods. Note that the default op-specific binary op visit + // methods call the general visitAffineBinaryOpExpr visit method. + RetTy visitAffineBinaryOpExpr(AffineBinaryOpExpr expr) { return RetTy(); } + RetTy visitAddExpr(AffineBinaryOpExpr expr) { + return static_cast(this)->visitAffineBinaryOpExpr(expr); + } + RetTy visitMulExpr(AffineBinaryOpExpr expr) { + return static_cast(this)->visitAffineBinaryOpExpr(expr); + } + RetTy visitModExpr(AffineBinaryOpExpr expr) { + return static_cast(this)->visitAffineBinaryOpExpr(expr); + } + RetTy visitFloorDivExpr(AffineBinaryOpExpr expr) { + return static_cast(this)->visitAffineBinaryOpExpr(expr); + } + RetTy visitCeilDivExpr(AffineBinaryOpExpr expr) { + return static_cast(this)->visitAffineBinaryOpExpr(expr); + } + RetTy visitConstantExpr(AffineConstantExpr expr) { return RetTy(); } + RetTy visitDimExpr(AffineDimExpr expr) { return RetTy(); } + RetTy visitSymbolExpr(AffineSymbolExpr expr) { return RetTy(); } + +private: + // Walk the operands - each operand is itself walked in post order. + RetTy walkOperandsPostOrder(AffineBinaryOpExpr expr) { + walkPostOrder(expr.getLHS()); + walkPostOrder(expr.getRHS()); + } +}; + +// This class is used to flatten a pure affine expression (AffineExpr, +// which is in a tree form) into a sum of products (w.r.t constants) when +// possible, and in that process simplifying the expression. For a modulo, +// floordiv, or a ceildiv expression, an additional identifier, called a local +// identifier, is introduced to rewrite the expression as a sum of product +// affine expression. Each local identifier is always and by construction a +// floordiv of a pure add/mul affine function of dimensional, symbolic, and +// other local identifiers, in a non-mutually recursive way. Hence, every local +// identifier can ultimately always be recovered as an affine function of +// dimensional and symbolic identifiers (involving floordiv's); note however +// that by AffineExpr construction, some floordiv combinations are converted to +// mod's. The result of the flattening is a flattened expression and a set of +// constraints involving just the local variables. +// +// d2 + (d0 + d1) floordiv 4 is flattened to d2 + q where 'q' is the local +// variable introduced, with localVarCst containing 4*q <= d0 + d1 <= 4*q + 3. +// +// The simplification performed includes the accumulation of contributions for +// each dimensional and symbolic identifier together, the simplification of +// floordiv/ceildiv/mod expressions and other simplifications that in turn +// happen as a result. A simplification that this flattening naturally performs +// is of simplifying the numerator and denominator of floordiv/ceildiv, and +// folding a modulo expression to a zero, if possible. Three examples are below: +// +// (d0 + 3 * d1) + d0) - 2 * d1) - d0 simplified to d0 + d1 +// (d0 - d0 mod 4 + 4) mod 4 simplified to 0 +// (3*d0 + 2*d1 + d0) floordiv 2 + d1 simplified to 2*d0 + 2*d1 +// +// The way the flattening works for the second example is as follows: d0 % 4 is +// replaced by d0 - 4*q with q being introduced: the expression then simplifies +// to: (d0 - (d0 - 4q) + 4) = 4q + 4, modulo of which w.r.t 4 simplifies to +// zero. Note that an affine expression may not always be expressible purely as +// a sum of products involving just the original dimensional and symbolic +// identifiers due to the presence of modulo/floordiv/ceildiv expressions that +// may not be eliminated after simplification; in such cases, the final +// expression can be reconstructed by replacing the local identifiers with their +// corresponding explicit form stored in 'localExprs' (note that each of the +// explicit forms itself would have been simplified). +// +// The expression walk method here performs a linear time post order walk that +// performs the above simplifications through visit methods, with partial +// results being stored in 'operandExprStack'. When a parent expr is visited, +// the flattened expressions corresponding to its two operands would already be +// on the stack - the parent expression looks at the two flattened expressions +// and combines the two. It pops off the operand expressions and pushes the +// combined result (although this is done in-place on its LHS operand expr). +// When the walk is completed, the flattened form of the top-level expression +// would be left on the stack. +// +// A flattener can be repeatedly used for multiple affine expressions that bind +// to the same operands, for example, for all result expressions of an +// AffineMap or AffineValueMap. In such cases, using it for multiple expressions +// is more efficient than creating a new flattener for each expression since +// common identical div and mod expressions appearing across different +// expressions are mapped to the same local identifier (same column position in +// 'localVarCst'). +class SimpleAffineExprFlattener + : public AffineExprVisitor { +public: + // Flattend expression layout: [dims, symbols, locals, constant] + // Stack that holds the LHS and RHS operands while visiting a binary op expr. + // In future, consider adding a prepass to determine how big the SmallVector's + // will be, and linearize this to std::vector to prevent + // SmallVector moves on re-allocation. + std::vector> operandExprStack; + + unsigned numDims; + unsigned numSymbols; + + // Number of newly introduced identifiers to flatten mod/floordiv/ceildiv's. + unsigned numLocals; + + // AffineExpr's corresponding to the floordiv/ceildiv/mod expressions for + // which new identifiers were introduced; if the latter do not get canceled + // out, these expressions can be readily used to reconstruct the AffineExpr + // (tree) form. Note that these expressions themselves would have been + // simplified (recursively) by this pass. Eg. d0 + (d0 + 2*d1 + d0) ceildiv 4 + // will be simplified to d0 + q, where q = (d0 + d1) ceildiv 2. (d0 + d1) + // ceildiv 2 would be the local expression stored for q. + SmallVector localExprs; + + SimpleAffineExprFlattener(unsigned numDims, unsigned numSymbols); + + virtual ~SimpleAffineExprFlattener() = default; + + // Visitor method overrides. + void visitMulExpr(AffineBinaryOpExpr expr); + void visitAddExpr(AffineBinaryOpExpr expr); + void visitDimExpr(AffineDimExpr expr); + void visitSymbolExpr(AffineSymbolExpr expr); + void visitConstantExpr(AffineConstantExpr expr); + void visitCeilDivExpr(AffineBinaryOpExpr expr); + void visitFloorDivExpr(AffineBinaryOpExpr expr); + + // + // t = expr mod c <=> t = expr - c*q and c*q <= expr <= c*q + c - 1 + // + // A mod expression "expr mod c" is thus flattened by introducing a new local + // variable q (= expr floordiv c), such that expr mod c is replaced with + // 'expr - c * q' and c * q <= expr <= c * q + c - 1 are added to localVarCst. + void visitModExpr(AffineBinaryOpExpr expr); + +protected: + // Add a local identifier (needed to flatten a mod, floordiv, ceildiv expr). + // The local identifier added is always a floordiv of a pure add/mul affine + // function of other identifiers, coefficients of which are specified in + // dividend and with respect to a positive constant divisor. localExpr is the + // simplified tree expression (AffineExpr) corresponding to the quantifier. + virtual void addLocalFloorDivId(ArrayRef dividend, int64_t divisor, + AffineExpr localExpr); + + /// Add a local identifier (needed to flatten a mod, floordiv, ceildiv, mul + /// expr) when the rhs is a symbolic expression. The local identifier added + /// may be a floordiv, ceildiv, mul or mod of a pure affine/semi-affine + /// function of other identifiers, coefficients of which are specified in the + /// lhs of the mod, floordiv, ceildiv or mul expression and with respect to a + /// symbolic rhs expression. `localExpr` is the simplified tree expression + /// (AffineExpr) corresponding to the quantifier. + virtual void addLocalIdSemiAffine(AffineExpr localExpr); + +private: + /// Adds `expr`, which may be mod, ceildiv, floordiv or mod expression + /// representing the affine expression corresponding to the quantifier + /// introduced as the local variable corresponding to `expr`. If the + /// quantifier is already present, we put the coefficient in the proper index + /// of `result`, otherwise we add a new local variable and put the coefficient + /// there. + void addLocalVariableSemiAffine(AffineExpr expr, + SmallVectorImpl &result, + unsigned long resultSize); + + // t = expr floordiv c <=> t = q, c * q <= expr <= c * q + c - 1 + // A floordiv is thus flattened by introducing a new local variable q, and + // replacing that expression with 'q' while adding the constraints + // c * q <= expr <= c * q + c - 1 to localVarCst (done by + // IntegerRelation::addLocalFloorDiv). + // + // A ceildiv is similarly flattened: + // t = expr ceildiv c <=> t = (expr + c - 1) floordiv c + void visitDivExpr(AffineBinaryOpExpr expr, bool isCeil); + + int findLocalId(AffineExpr localExpr); + + inline unsigned getNumCols() const { + return numDims + numSymbols + numLocals + 1; + } + inline unsigned getConstantIndex() const { return getNumCols() - 1; } + inline unsigned getLocalVarStartIndex() const { return numDims + numSymbols; } + inline unsigned getSymbolStartIndex() const { return numDims; } + inline unsigned getDimStartIndex() const { return 0; } +}; + +} // namespace mlir + +#endif // MLIR_IR_AFFINEEXPRVISITOR_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/IR/AffineMap.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/IR/AffineMap.h new file mode 100644 index 0000000000000000000000000000000000000000..3430db2b99c3f2e8f92e23c0bf2fa4d7833476d8 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/IR/AffineMap.h @@ -0,0 +1,685 @@ +//===- AffineMap.h - MLIR Affine Map Class ----------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Affine maps are mathematical functions which map a list of dimension +// identifiers and symbols, to multidimensional affine expressions. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_IR_AFFINEMAP_H +#define MLIR_IR_AFFINEMAP_H + +#include "mlir/IR/AffineExpr.h" +#include "mlir/Support/LLVM.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/DenseMapInfo.h" +#include "llvm/ADT/SmallBitVector.h" +#include "llvm/ADT/SmallVectorExtras.h" +#include + +namespace llvm { +class SmallBitVector; +} // namespace llvm + +namespace mlir { + +namespace detail { +struct AffineMapStorage; +} // namespace detail + +class Attribute; +struct LogicalResult; +class MLIRContext; + +/// A multi-dimensional affine map +/// Affine map's are immutable like Type's, and they are uniqued. +/// Eg: (d0, d1) -> (d0/128, d0 mod 128, d1) +/// The names used (d0, d1) don't matter - it's the mathematical function that +/// is unique to this affine map. +class AffineMap { +public: + using ImplType = detail::AffineMapStorage; + + constexpr AffineMap() = default; + explicit AffineMap(ImplType *map) : map(map) {} + + /// Returns a zero result affine map with no dimensions or symbols: () -> (). + static AffineMap get(MLIRContext *context); + + /// Returns a zero result affine map with `dimCount` dimensions and + /// `symbolCount` symbols, e.g.: `(...) -> ()`. + static AffineMap get(unsigned dimCount, unsigned symbolCount, + MLIRContext *context); + + /// Returns an affine map with `dimCount` dimensions and `symbolCount` mapping + /// to a single output dimension + static AffineMap get(unsigned dimCount, unsigned symbolCount, + AffineExpr result); + + /// Returns an affine map with `dimCount` dimensions and `symbolCount` mapping + /// to the given results. + static AffineMap get(unsigned dimCount, unsigned symbolCount, + ArrayRef results, MLIRContext *context); + + /// Returns a single constant result affine map. + static AffineMap getConstantMap(int64_t val, MLIRContext *context); + + /// Returns an AffineMap with 'numDims' identity result dim exprs. + static AffineMap getMultiDimIdentityMap(unsigned numDims, + MLIRContext *context); + + /// Returns an identity affine map (d0, ..., dn) -> (dp, ..., dn) on the most + /// minor dimensions. + static AffineMap getMinorIdentityMap(unsigned dims, unsigned results, + MLIRContext *context); + + /// Returns an identity affine map witn `numDims` input dimensions and + /// filtered results using `keepDimFilter`. If `keepDimFilter` returns true + /// for a dimension, the dimension is kept in the affine map results. + /// Otherwise, the dimension is dropped from the results. + /// + /// Examples: + /// * getFilteredIdentityMap(4, [false, true, false, true]) + /// -> affine_map<(d0, d1, d2, d3) -> (d1, d3)> + /// * getFilteredIdentityMap(3, [false, false, true]) + /// -> affine_map<(d0, d1, d2) -> (d2)> + static AffineMap + getFilteredIdentityMap(MLIRContext *ctx, unsigned numDims, + llvm::function_ref keepDimFilter); + + /// Returns an AffineMap representing a permutation. + /// The permutation is expressed as a non-empty vector of integers. + /// E.g. the permutation `(i,j,k) -> (j,k,i)` will be expressed with + /// `permutation = [1,2,0]`. All values in `permutation` must be + /// integers, in the range 0..`permutation.size()-1` without duplications + /// (i.e. `[1,1,2]` is an invalid permutation). + static AffineMap getPermutationMap(ArrayRef permutation, + MLIRContext *context); + + /// Returns a vector of AffineMaps; each with as many results as + /// `exprs.size()`, as many dims as the largest dim in `exprs` and as many + /// symbols as the largest symbol in `exprs`. + static SmallVector + inferFromExprList(ArrayRef> exprsList); + static SmallVector + inferFromExprList(ArrayRef> exprsList); + + MLIRContext *getContext() const; + + explicit operator bool() const { return map != nullptr; } + bool operator==(AffineMap other) const { return other.map == map; } + bool operator!=(AffineMap other) const { return !(other.map == map); } + + /// Returns true if this affine map is an identity affine map. + /// An identity affine map corresponds to an identity affine function on the + /// dimensional identifiers. + bool isIdentity() const; + + /// Returns true if this affine map is an identity affine map on the symbol + /// identifiers. + bool isSymbolIdentity() const; + + /// Returns true if this affine map is a minor identity, i.e. an identity + /// affine map (d0, ..., dn) -> (dp, ..., dn) on the most minor dimensions. + bool isMinorIdentity() const; + + /// Returns true if this affine map is a minor identity up to broadcasted + /// dimensions which are indicated by value 0 in the result. If + /// `broadcastedDims` is not null, it will be populated with the indices of + /// the broadcasted dimensions in the result array. + /// Example: affine_map<(d0, d1, d2, d3, d4) -> (0, d2, 0, d4)> + /// (`broadcastedDims` will contain [0, 2]) + bool isMinorIdentityWithBroadcasting( + SmallVectorImpl *broadcastedDims = nullptr) const; + + /// Return true if this affine map can be converted to a minor identity with + /// broadcast by doing a permute. Return a permutation (there may be + /// several) to apply to get to a minor identity with broadcasts. + /// Ex: + /// * (d0, d1, d2) -> (0, d1) maps to minor identity (d1, 0 = d2) with + /// perm = [1, 0] and broadcast d2 + /// * (d0, d1, d2) -> (d0, 0) cannot be mapped to a minor identity by + /// permutation + broadcast + /// * (d0, d1, d2, d3) -> (0, d1, d3) maps to minor identity (d1, 0 = d2, d3) + /// with perm = [1, 0, 2] and broadcast d2 + /// * (d0, d1) -> (d1, 0, 0, d0) maps to minor identity (d0, d1) with extra + /// leading broadcat dimensions. The map returned would be (0, 0, d0, d1) + /// with perm = [3, 0, 1, 2] + bool isPermutationOfMinorIdentityWithBroadcasting( + SmallVectorImpl &permutedDims) const; + + /// Returns true if this affine map is an empty map, i.e., () -> (). + bool isEmpty() const; + + /// Returns true if this affine map is a single result constant function. + bool isSingleConstant() const; + + /// Returns true if this affine map has only constant results. + bool isConstant() const; + + /// Returns the constant result of this map. This methods asserts that the map + /// has a single constant result. + int64_t getSingleConstantResult() const; + + /// Returns the constant results of this map. This method asserts that the map + /// has all constant results. + SmallVector getConstantResults() const; + + // Prints affine map to 'os'. + void print(raw_ostream &os) const; + void dump() const; + + unsigned getNumDims() const; + unsigned getNumSymbols() const; + unsigned getNumResults() const; + unsigned getNumInputs() const; + + ArrayRef getResults() const; + AffineExpr getResult(unsigned idx) const; + + /// Extracts the position of the dimensional expression at the given result, + /// when the caller knows it is safe to do so. + unsigned getDimPosition(unsigned idx) const; + + /// Extracts the first result position where `input` dimension resides. + /// Returns `std::nullopt` if `input` is not a dimension expression or cannot + /// be found in results. + std::optional getResultPosition(AffineExpr input) const; + + /// Return true if any affine expression involves AffineDimExpr `position`. + bool isFunctionOfDim(unsigned position) const { + return llvm::any_of(getResults(), [&](AffineExpr e) { + return e.isFunctionOfDim(position); + }); + } + + /// Return true if any affine expression involves AffineSymbolExpr `position`. + bool isFunctionOfSymbol(unsigned position) const { + return llvm::any_of(getResults(), [&](AffineExpr e) { + return e.isFunctionOfSymbol(position); + }); + } + + /// Walk all of the AffineExpr's in this mapping. Each node in an expression + /// tree is visited in postorder. + void walkExprs(llvm::function_ref callback) const; + + /// This method substitutes any uses of dimensions and symbols (e.g. + /// dim#0 with dimReplacements[0]) in subexpressions and returns the modified + /// expression mapping. Because this can be used to eliminate dims and + /// symbols, the client needs to specify the number of dims and symbols in + /// the result. The returned map always has the same number of results. + AffineMap replaceDimsAndSymbols(ArrayRef dimReplacements, + ArrayRef symReplacements, + unsigned numResultDims, + unsigned numResultSyms) const; + + /// Sparse replace method. Apply AffineExpr::replace(`expr`, `replacement`) to + /// each of the results and return a new AffineMap with the new results and + /// with the specified number of dims and symbols. + AffineMap replace(AffineExpr expr, AffineExpr replacement, + unsigned numResultDims, unsigned numResultSyms) const; + + /// Sparse replace method. Apply AffineExpr::replace(`map`) to each of the + /// results and return a new AffineMap with the new results and with inferred + /// number of dims and symbols. + AffineMap replace(const DenseMap &map) const; + + /// Sparse replace method. Apply AffineExpr::replace(`map`) to each of the + /// results and return a new AffineMap with the new results and with the + /// specified number of dims and symbols. + AffineMap replace(const DenseMap &map, + unsigned numResultDims, unsigned numResultSyms) const; + + /// Replace dims[offset ... numDims) + /// by dims[offset + shift ... shift + numDims). + AffineMap shiftDims(unsigned shift, unsigned offset = 0) const { + assert(offset <= getNumDims()); + return AffineMap::get(getNumDims() + shift, getNumSymbols(), + llvm::map_to_vector<4>( + getResults(), + [&](AffineExpr e) { + return e.shiftDims(getNumDims(), shift, offset); + }), + getContext()); + } + + /// Replace symbols[offset ... numSymbols) + /// by symbols[offset + shift ... shift + numSymbols). + AffineMap shiftSymbols(unsigned shift, unsigned offset = 0) const { + return AffineMap::get(getNumDims(), getNumSymbols() + shift, + llvm::map_to_vector<4>(getResults(), + [&](AffineExpr e) { + return e.shiftSymbols( + getNumSymbols(), shift, + offset); + }), + getContext()); + } + + /// Returns a new AffineMap with the same number of dims and symbols and one + /// less result at `pos`, dropped. + AffineMap dropResult(int64_t pos) const { + return dropResults(ArrayRef({pos})); + } + + // Returns a new AffineMap with the same number of dims and symbols, but all + // results in `positions` dropped. + AffineMap dropResults(ArrayRef positions) const { + SmallVector reverse_sorted_positions = llvm::to_vector(positions); + llvm::sort(reverse_sorted_positions, std::greater()); + + auto exprs = llvm::to_vector<4>(getResults()); + for (int64_t pos : reverse_sorted_positions) + exprs.erase(exprs.begin() + pos); + return AffineMap::get(getNumDims(), getNumSymbols(), exprs, getContext()); + } + + // Returns a new AffineMap with the same number of dims and symbols, but all + // results in `positions` dropped. + AffineMap dropResults(const llvm::SmallBitVector &positions) const; + + /// Returns a new AffineMap with the same number of dims and symbols and an + /// extra result inserted at `pos`. + AffineMap insertResult(AffineExpr expr, unsigned pos) const { + auto exprs = llvm::to_vector<4>(getResults()); + exprs.insert(exprs.begin() + pos, expr); + return AffineMap::get(getNumDims(), getNumSymbols(), exprs, getContext()); + } + + /// Folds the results of the application of an affine map on the provided + /// operands to a constant if possible. + LogicalResult constantFold(ArrayRef operandConstants, + SmallVectorImpl &results) const; + + /// Propagates the constant operands into this affine map. Operands are + /// allowed to be null, at which point they are treated as non-constant. This + /// does not change the number of symbols and dimensions. Returns a new map, + /// which may be equal to the old map if no folding happened. If `results` is + /// provided and if all expressions in the map were folded to constants, + /// `results` will contain the values of these constants. + AffineMap + partialConstantFold(ArrayRef operandConstants, + SmallVectorImpl *results = nullptr) const; + + /// Returns the AffineMap resulting from composing `this` with `map`. + /// The resulting AffineMap has as many AffineDimExpr as `map` and as many + /// AffineSymbolExpr as the concatenation of `this` and `map` (in which case + /// the symbols of `this` map come first). + /// + /// Prerequisites: + /// The maps are composable, i.e. that the number of AffineDimExpr of `this` + /// matches the number of results of `map`. + /// + /// Example: + /// map1: `(d0, d1)[s0, s1] -> (d0 + 1 + s1, d1 - 1 - s0)` + /// map2: `(d0)[s0] -> (d0 + s0, d0 - s0)` + /// map1.compose(map2): + /// `(d0)[s0, s1, s2] -> (d0 + s1 + s2 + 1, d0 - s0 - s2 - 1)` + AffineMap compose(AffineMap map) const; + + /// Applies composition by the dims of `this` to the integer `values` and + /// returns the resulting values. `this` must be symbol-less. + SmallVector compose(ArrayRef values) const; + + /// Returns true if the AffineMap represents a subset (i.e. a projection) of a + /// symbol-less permutation map. `allowZeroInResults` allows projected + /// permutation maps with constant zero result expressions. + /// TODO: Remove `allowZeroInResults` when constant zero result expressions + /// are broadly supported. + bool isProjectedPermutation(bool allowZeroInResults = false) const; + + /// Returns true if the AffineMap represents a symbol-less permutation map. + bool isPermutation() const; + + /// Returns the map consisting of the `resultPos` subset. + AffineMap getSubMap(ArrayRef resultPos) const; + + /// Returns the map consisting of `length` expressions starting from `start`. + AffineMap getSliceMap(unsigned start, unsigned length) const; + + /// Returns the map consisting of the most major `numResults` results. + /// Returns the null AffineMap if `numResults` == 0. + /// Returns `*this` if `numResults` >= `this->getNumResults()`. + AffineMap getMajorSubMap(unsigned numResults) const; + + /// Returns the map consisting of the most minor `numResults` results. + /// Returns the null AffineMap if `numResults` == 0. + /// Returns `*this` if `numResults` >= `this->getNumResults()`. + AffineMap getMinorSubMap(unsigned numResults) const; + + /// Get the largest known divisor of all map expressions. + /// For eg: for (d0, d1) -> (8*d0 + 4, 4*d1 + 2), the result is 2. + /// In the case of maps with no expressions or all zero constant expressions, + /// the largest known divisor is trivially the max uint64_t value. + uint64_t getLargestKnownDivisorOfMapExprs(); + + friend ::llvm::hash_code hash_value(AffineMap arg); + + /// Methods supporting C API. + const void *getAsOpaquePointer() const { + return static_cast(map); + } + static AffineMap getFromOpaquePointer(const void *pointer) { + return AffineMap(reinterpret_cast(const_cast(pointer))); + } + +private: + ImplType *map{nullptr}; + + static AffineMap getImpl(unsigned dimCount, unsigned symbolCount, + ArrayRef results, MLIRContext *context); +}; + +// Make AffineExpr hashable. +inline ::llvm::hash_code hash_value(AffineMap arg) { + return ::llvm::hash_value(arg.map); +} + +/// A mutable affine map. Its affine expressions are however unique. +struct MutableAffineMap { +public: + MutableAffineMap() = default; + MutableAffineMap(AffineMap map); + + ArrayRef getResults() const { return results; } + AffineExpr getResult(unsigned idx) const { return results[idx]; } + void setResult(unsigned idx, AffineExpr result) { results[idx] = result; } + unsigned getNumResults() const { return results.size(); } + unsigned getNumDims() const { return numDims; } + void setNumDims(unsigned d) { numDims = d; } + unsigned getNumSymbols() const { return numSymbols; } + void setNumSymbols(unsigned d) { numSymbols = d; } + MLIRContext *getContext() const { return context; } + + /// Returns true if the idx'th result expression is a multiple of factor. + bool isMultipleOf(unsigned idx, int64_t factor) const; + + /// Resets this MutableAffineMap with 'map'. + void reset(AffineMap map); + + /// Simplify the (result) expressions in this map using analysis (used by + //-simplify-affine-expr pass). + void simplify(); + /// Get the AffineMap corresponding to this MutableAffineMap. Note that an + /// AffineMap will be uniqued and stored in context, while a mutable one + /// isn't. + AffineMap getAffineMap() const; + +private: + // Same meaning as AffineMap's fields. + SmallVector results; + unsigned numDims = 0; + unsigned numSymbols = 0; + /// A pointer to the IR's context to store all newly created + /// AffineExprStorage's. + MLIRContext *context = nullptr; +}; + +/// Simplifies an affine map by simplifying its underlying AffineExpr results. +AffineMap simplifyAffineMap(AffineMap map); + +/// Drop the dims that are listed in `unusedDims`. +AffineMap compressDims(AffineMap map, const llvm::SmallBitVector &unusedDims); + +/// Drop the dims that are not used. +AffineMap compressUnusedDims(AffineMap map); + +/// Drop the dims that are not used by any of the individual maps in `maps`. +/// Asserts that all maps in `maps` are normalized to the same number of +/// dims and symbols. +SmallVector compressUnusedDims(ArrayRef maps); + +/// Drop the symbols that are listed in `unusedSymbols`. +AffineMap compressSymbols(AffineMap map, + const llvm::SmallBitVector &unusedSymbols); + +/// Drop the symbols that are not used. +AffineMap compressUnusedSymbols(AffineMap map); + +/// Drop the symbols that are not used by any of the individual maps in `maps`. +/// Asserts that all maps in `maps` are normalized to the same number of +/// dims and symbols. +SmallVector compressUnusedSymbols(ArrayRef maps); + +/// Returns a map with the same dimension and symbol count as `map`, but whose +/// results are the unique affine expressions of `map`. +AffineMap removeDuplicateExprs(AffineMap map); + +/// Returns a map of codomain to domain dimensions such that the first codomain +/// dimension for a particular domain dimension is selected. +/// Returns an empty map if the input map is empty. +/// Returns null map (not empty map) if `map` is not invertible (i.e. `map` does +/// not contain a subset that is a permutation of full domain rank). +/// +/// Prerequisites: +/// 1. `map` has no symbols. +/// +/// Example 1: +/// +/// ```mlir +/// (d0, d1, d2) -> (d1, d1, d0, d2, d1, d2, d1, d0) +/// 0 2 3 +/// ``` +/// +/// returns: +/// +/// ```mlir +/// (d0, d1, d2, d3, d4, d5, d6, d7) -> (d2, d0, d3) +/// ``` +/// +/// Example 2: +/// +/// ```mlir +/// (d0, d1, d2) -> (d1, d0 + d1, d0, d2, d1, d2, d1, d0) +/// 0 2 3 +/// ``` +/// +/// returns: +/// +/// ```mlir +/// (d0, d1, d2, d3, d4, d5, d6, d7) -> (d2, d0, d3) +/// ``` +AffineMap inversePermutation(AffineMap map); + +/// Return the reverse map of a projected permutation where the projected +/// dimensions are transformed into 0s. +/// +/// Prerequisites: `map` must be a projected permutation. +/// +/// Example 1: +/// +/// ```mlir +/// affine_map<(d0, d1, d2, d3) -> (d2, d0)> +/// ``` +/// +/// returns: +/// +/// ```mlir +/// affine_map<(d0, d1) -> (d1, 0, d0, 0)> +/// ``` +/// +/// Example 2: +/// +/// ```mlir +/// affine_map<(d0, d1, d2, d3) -> (d0, d3)> +/// ``` +/// +/// returns: +/// +/// ```mlir +/// affine_map<(d0, d1) -> (d0, 0, 0, d1)> +/// ``` +/// +/// Example 3: +/// +/// ```mlir +/// affine_map<(d0, d1, d2, d3) -> (d2)> +/// ``` +/// +/// returns: +/// +/// ```mlir +/// affine_map<(d0) -> (0, 0, d0, 0)> +/// ``` +/// Example 4: +/// +/// ```mlir +/// affine_map<(d0, d1, d2) -> (d0, 0)> +/// ``` +/// +/// returns: +/// +/// ```mlir +/// affine_map<(d0, d1) -> (d0, 0, 0)> +/// ``` +AffineMap inverseAndBroadcastProjectedPermutation(AffineMap map); + +/// Concatenates a list of `maps` into a single AffineMap, stepping over +/// potentially empty maps. Assumes each of the underlying map has 0 symbols. +/// The resulting map has a number of dims equal to the max of `maps`' dims and +/// the concatenated results as its results. +/// Returns an empty map if all input `maps` are empty. +/// +/// Example: +/// When applied to the following list of 3 affine maps, +/// +/// ```mlir +/// { +/// (i, j, k) -> (i, k), +/// (i, j, k) -> (k, j), +/// (i, j, k) -> (i, j) +/// } +/// ``` +/// +/// Returns the map: +/// +/// ```mlir +/// (i, j, k) -> (i, k, k, j, i, j) +/// ``` +AffineMap concatAffineMaps(ArrayRef maps); + +/// Returns the map that results from projecting out the dimensions specified in +/// `projectedDimensions`. The projected dimensions are set to 0. +/// +/// Example: +/// 1) map : affine_map<(d0, d1, d2) -> (d0, d1)> +/// projected_dimensions : {2} +/// result : affine_map<(d0, d1) -> (d0, d1)> +/// +/// 2) map : affine_map<(d0, d1) -> (d0 + d1)> +/// projected_dimensions : {1} +/// result : affine_map<(d0) -> (d0)> +/// +/// 3) map : affine_map<(d0, d1, d2) -> (d0, d1)> +/// projected_dimensions : {1} +/// result : affine_map<(d0, d1) -> (d0, 0)> +/// +/// This function also compresses the dims when the boolean flag is true. +AffineMap projectDims(AffineMap map, + const llvm::SmallBitVector &projectedDimensions, + bool compressDimsFlag = false); +/// Symbol counterpart of `projectDims`. +/// This function also compresses the symbols when the boolean flag is true. +AffineMap projectSymbols(AffineMap map, + const llvm::SmallBitVector &projectedSymbols, + bool compressSymbolsFlag = false); +/// Calls `projectDims(map, projectedDimensions, compressDimsFlag)`. +/// If `compressSymbolsFlag` is true, additionally call `compressUnusedSymbols`. +AffineMap getProjectedMap(AffineMap map, + const llvm::SmallBitVector &projectedDimensions, + bool compressDimsFlag = true, + bool compressSymbolsFlag = true); + +// Return a bitvector where each bit set indicates a dimension that is not used +// by any of the maps in the input array `maps`. +llvm::SmallBitVector getUnusedDimsBitVector(ArrayRef maps); + +// Return a bitvector where each bit set indicates a symbol that is not used +// by any of the maps in the input array `maps`. +llvm::SmallBitVector getUnusedSymbolsBitVector(ArrayRef maps); + +/// Expand `map` to operate on `rank` dims while projecting out the dims in +/// `projectedDimensions`. This amounts to composing `map` with +/// `id(rank).dropResults(projectedDimensions)`. +AffineMap expandDimsToRank(AffineMap map, int64_t rank, + const llvm::SmallBitVector &projectedDimensions); + +inline raw_ostream &operator<<(raw_ostream &os, AffineMap map) { + map.print(os); + return os; +} + +//===----------------------------------------------------------------------===// +// Templated helper functions. +//===----------------------------------------------------------------------===// + +/// Apply a permutation from `map` to `source` and return the result. +template +SmallVector applyPermutationMap(AffineMap map, llvm::ArrayRef source) { + assert(map.isProjectedPermutation()); + assert(map.getNumInputs() == source.size()); + SmallVector result; + result.reserve(map.getNumResults()); + for (AffineExpr expr : map.getResults()) { + if (auto dimExpr = expr.dyn_cast()) { + result.push_back(source[dimExpr.getPosition()]); + } else if (auto constExpr = expr.dyn_cast()) { + assert(constExpr.getValue() == 0 && + "Unexpected constant in projected permutation map"); + result.push_back(0); + } else { + llvm_unreachable("Unexpected result in projected permutation map"); + } + } + return result; +} + +/// Calculates maximum dimension and symbol positions from the expressions +/// in `exprsLists` and stores them in `maxDim` and `maxSym` respectively. +template +static void getMaxDimAndSymbol(ArrayRef exprsList, + int64_t &maxDim, int64_t &maxSym) { + for (const auto &exprs : exprsList) { + for (auto expr : exprs) { + expr.walk([&maxDim, &maxSym](AffineExpr e) { + if (auto d = e.dyn_cast()) + maxDim = std::max(maxDim, static_cast(d.getPosition())); + if (auto s = e.dyn_cast()) + maxSym = std::max(maxSym, static_cast(s.getPosition())); + }); + } + } +} + +} // namespace mlir + +namespace llvm { + +// AffineExpr hash just like pointers +template <> +struct DenseMapInfo { + static mlir::AffineMap getEmptyKey() { + auto *pointer = llvm::DenseMapInfo::getEmptyKey(); + return mlir::AffineMap(static_cast(pointer)); + } + static mlir::AffineMap getTombstoneKey() { + auto *pointer = llvm::DenseMapInfo::getTombstoneKey(); + return mlir::AffineMap(static_cast(pointer)); + } + static unsigned getHashValue(mlir::AffineMap val) { + return mlir::hash_value(val); + } + static bool isEqual(mlir::AffineMap LHS, mlir::AffineMap RHS) { + return LHS == RHS; + } +}; + +} // namespace llvm + +#endif // MLIR_IR_AFFINEMAP_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/IR/AsmState.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/IR/AsmState.h new file mode 100644 index 0000000000000000000000000000000000000000..42cbedcf9f88374a2f6e5708ff2566a4bed90d89 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/IR/AsmState.h @@ -0,0 +1,606 @@ +//===- AsmState.h - Assembly State Utilities --------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file defines various classes and utilites for interacting with the MLIR +// assembly formats. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_IR_ASMSTATE_H_ +#define MLIR_IR_ASMSTATE_H_ + +#include "mlir/Bytecode/BytecodeReaderConfig.h" +#include "mlir/IR/OperationSupport.h" +#include "mlir/Support/LLVM.h" +#include "llvm/ADT/MapVector.h" +#include "llvm/ADT/StringMap.h" + +#include +#include + +namespace mlir { +class AsmResourcePrinter; +class AsmDialectResourceHandle; +class Operation; + +namespace detail { +class AsmStateImpl; +} // namespace detail + +//===----------------------------------------------------------------------===// +// Resources +//===----------------------------------------------------------------------===// + +/// The following classes enable support for parsing and printing resources +/// within MLIR assembly formats. Resources are a mechanism by which dialects, +/// and external clients, may attach additional information when parsing or +/// printing IR without that information being encoded in the IR itself. +/// Resources are not uniqued within the MLIR context, are not attached directly +/// to any operation, and are solely intended to live and be processed outside +/// of the immediate IR. +/// +/// Resources are encoded using a key-value pair nested within dictionaries +/// anchored either on a dialect, or an externally registered entity. +/// Dictionaries anchored on dialects use the dialect namespace directly, and +/// dictionaries anchored on external entities use a provided unique identifier. +/// The resource key is an identifier used to disambiguate the data. The +/// resource value may be stored in various limited forms, but general encodings +/// use a string (human readable) or blob format (binary). Within the textual +/// format, an example may be of the form: +/// +/// {-# +/// // The `dialect_resources` section within the file-level metadata +/// // dictionary is used to contain any dialect resource entries. +/// dialect_resources: { +/// // Here is a dictionary anchored on "foo_dialect", which is a dialect +/// // namespace. +/// foo_dialect: { +/// // `some_dialect_resource` is a key to be interpreted by the dialect, +/// // and used to initialize/configure/etc. +/// some_dialect_resource: "Some important resource value" +/// } +/// }, +/// // The `external_resources` section within the file-level metadata +/// // dictionary is used to contain any non-dialect resource entries. +/// external_resources: { +/// // Here is a dictionary anchored on "mlir_reproducer", which is an +/// // external entity representing MLIR's crash reproducer functionality. +/// mlir_reproducer: { +/// // `pipeline` is an entry that holds a crash reproducer pipeline +/// // resource. +/// pipeline: "func.func(canonicalize,cse)" +/// } +/// } +/// #-} +/// + +//===----------------------------------------------------------------------===// +// Resource Entry + +/// This class represents a processed binary blob of data. A resource blob is +/// essentially a collection of data, potentially mutable, with an associated +/// deleter function (used if the data needs to be destroyed). +class AsmResourceBlob { +public: + /// A deleter function that frees a blob given the data, allocation size, and + /// allocation aligment. + using DeleterFn = + llvm::unique_function; + + //===--------------------------------------------------------------------===// + // Construction + //===--------------------------------------------------------------------===// + + AsmResourceBlob() = default; + AsmResourceBlob(ArrayRef data, size_t dataAlignment, DeleterFn deleter, + bool dataIsMutable) + : data(data), dataAlignment(dataAlignment), deleter(std::move(deleter)), + dataIsMutable(dataIsMutable) {} + /// Utility constructor that initializes a blob with a non-char type T. + template + AsmResourceBlob(ArrayRef data, DelT &&deleteFn, bool dataIsMutable) + : data((const char *)data.data(), data.size() * sizeof(T)), + dataAlignment(alignof(T)), + deleter([deleteFn = std::forward(deleteFn)]( + void *data, size_t size, size_t align) { + return deleteFn((T *)data, size, align); + }), + dataIsMutable(dataIsMutable) {} + AsmResourceBlob(AsmResourceBlob &&) = default; + AsmResourceBlob &operator=(AsmResourceBlob &&rhs) { + // Delete the current blob if necessary. + if (deleter) + deleter(const_cast(data.data()), data.size(), dataAlignment); + + // Take the data entries from rhs. + data = rhs.data; + dataAlignment = rhs.dataAlignment; + deleter = std::move(rhs.deleter); + dataIsMutable = rhs.dataIsMutable; + return *this; + } + AsmResourceBlob(const AsmResourceBlob &) = delete; + AsmResourceBlob &operator=(const AsmResourceBlob &) = delete; + ~AsmResourceBlob() { + if (deleter) + deleter(const_cast(data.data()), data.size(), dataAlignment); + } + + //===--------------------------------------------------------------------===// + // Data Access + //===--------------------------------------------------------------------===// + + /// Return the alignment of the underlying data. + size_t getDataAlignment() const { return dataAlignment; } + + /// Return the raw underlying data of this blob. + ArrayRef getData() const { return data; } + + /// Return the underlying data as an array of the given type. This is an + /// inherrently unsafe operation, and should only be used when the data is + /// known to be of the correct type. + template + ArrayRef getDataAs() const { + return llvm::ArrayRef((const T *)data.data(), data.size() / sizeof(T)); + } + + /// Return a mutable reference to the raw underlying data of this blob. + /// Asserts that the blob `isMutable`. + MutableArrayRef getMutableData() { + assert(isMutable() && + "cannot access mutable reference to non-mutable data"); + return MutableArrayRef(const_cast(data.data()), data.size()); + } + + /// Return if the data of this blob is mutable. + bool isMutable() const { return dataIsMutable; } + + /// Return the deleter function of this blob. + DeleterFn &getDeleter() { return deleter; } + const DeleterFn &getDeleter() const { return deleter; } + +private: + /// The raw, properly aligned, blob data. + ArrayRef data; + + /// The alignment of the data. + size_t dataAlignment = 0; + + /// An optional deleter function used to deallocate the underlying data when + /// necessary. + DeleterFn deleter; + + /// Whether the data is mutable. + bool dataIsMutable; +}; + +/// This class provides a simple utility wrapper for creating heap allocated +/// AsmResourceBlobs. +class HeapAsmResourceBlob { +public: + /// Create a new heap allocated blob with the given size and alignment. + /// `dataIsMutable` indicates if the allocated data can be mutated. By + /// default, we treat heap allocated blobs as mutable. + static AsmResourceBlob allocate(size_t size, size_t align, + bool dataIsMutable = true) { + return AsmResourceBlob( + ArrayRef((char *)llvm::allocate_buffer(size, align), size), align, + llvm::deallocate_buffer, dataIsMutable); + } + /// Create a new heap allocated blob and copy the provided data into it. + static AsmResourceBlob allocateAndCopyWithAlign(ArrayRef data, + size_t align, + bool dataIsMutable = true) { + AsmResourceBlob blob = allocate(data.size(), align, dataIsMutable); + std::memcpy(blob.getMutableData().data(), data.data(), data.size()); + return blob; + } + template + static AsmResourceBlob allocateAndCopyInferAlign(ArrayRef data, + bool dataIsMutable = true) { + return allocateAndCopyWithAlign( + ArrayRef((const char *)data.data(), data.size() * sizeof(T)), + alignof(T), dataIsMutable); + } +}; +/// This class provides a simple utility wrapper for creating "unmanaged" +/// AsmResourceBlobs. The lifetime of the data provided to these blobs is +/// guaranteed to persist beyond the lifetime of this reference. +class UnmanagedAsmResourceBlob { +public: + /// Create a new unmanaged resource directly referencing the provided data. + /// `dataIsMutable` indicates if the allocated data can be mutated. By + /// default, we treat unmanaged blobs as immutable. + static AsmResourceBlob + allocateWithAlign(ArrayRef data, size_t align, + AsmResourceBlob::DeleterFn deleter = {}, + bool dataIsMutable = false) { + return AsmResourceBlob(data, align, std::move(deleter), dataIsMutable); + } + template + static AsmResourceBlob + allocateInferAlign(ArrayRef data, AsmResourceBlob::DeleterFn deleter = {}, + bool dataIsMutable = false) { + return allocateWithAlign( + ArrayRef((const char *)data.data(), data.size() * sizeof(T)), + alignof(T), std::move(deleter), dataIsMutable); + } +}; + +/// This class is used to build resource entries for use by the printer. Each +/// resource entry is represented using a key/value pair. The provided key must +/// be unique within the current context, which allows for a client to provide +/// resource entries without worrying about overlap with other clients. +class AsmResourceBuilder { +public: + virtual ~AsmResourceBuilder(); + + /// Build a resource entry represented by the given bool. + virtual void buildBool(StringRef key, bool data) = 0; + + /// Build a resource entry represented by the given human-readable string + /// value. + virtual void buildString(StringRef key, StringRef data) = 0; + + /// Build an resource entry represented by the given binary blob data. + virtual void buildBlob(StringRef key, ArrayRef data, + uint32_t dataAlignment) = 0; + /// Build an resource entry represented by the given binary blob data. This is + /// a useful overload if the data type is known. Note that this does not + /// support `char` element types to avoid accidentally not providing the + /// expected alignment of data in situations that treat blobs generically. + template + std::enable_if_t::value> buildBlob(StringRef key, + ArrayRef data) { + buildBlob( + key, ArrayRef((const char *)data.data(), data.size() * sizeof(T)), + alignof(T)); + } + /// Build an resource entry represented by the given resource blob. This is + /// a useful overload if a blob already exists in-memory. + void buildBlob(StringRef key, const AsmResourceBlob &blob) { + buildBlob(key, blob.getData(), blob.getDataAlignment()); + } +}; + +/// This enum represents the different kinds of resource values. +enum class AsmResourceEntryKind { + /// A blob of data with an accompanying alignment. + Blob, + /// A boolean value. + Bool, + /// A string value. + String, +}; +StringRef toString(AsmResourceEntryKind kind); + +/// This class represents a single parsed resource entry. +class AsmParsedResourceEntry { +public: + virtual ~AsmParsedResourceEntry(); + + /// Return the key of the resource entry. + virtual StringRef getKey() const = 0; + + /// Emit an error at the location of this entry. + virtual InFlightDiagnostic emitError() const = 0; + + /// Return the kind of this value. + virtual AsmResourceEntryKind getKind() const = 0; + + /// Parse the resource entry represented by a boolean. Returns failure if the + /// entry does not correspond to a bool. + virtual FailureOr parseAsBool() const = 0; + + /// Parse the resource entry represented by a human-readable string. Returns + /// failure if the entry does not correspond to a string. + virtual FailureOr parseAsString() const = 0; + + /// An allocator function used to allocate memory for a blob when required. + /// The function is provided a size and alignment, and should return an + /// aligned allocation buffer. + using BlobAllocatorFn = + function_ref; + + /// Parse the resource entry represented by a binary blob. Returns failure if + /// the entry does not correspond to a blob. If the blob needed to be + /// allocated, the given allocator function is invoked. + virtual FailureOr + parseAsBlob(BlobAllocatorFn allocator) const = 0; + /// Parse the resource entry represented by a binary blob using heap + /// allocation. + FailureOr parseAsBlob() const { + return parseAsBlob([](size_t size, size_t align) { + return HeapAsmResourceBlob::allocate(size, align); + }); + } +}; + +//===----------------------------------------------------------------------===// +// Resource Parser/Printer + +/// This class represents an instance of a resource parser. This class should be +/// implemented by non-dialect clients that want to inject additional resources +/// into MLIR assembly formats. +class AsmResourceParser { +public: + /// Create a new parser with the given identifying name. This name uniquely + /// identifies the entries of this parser, and differentiates them from other + /// contexts. + AsmResourceParser(StringRef name) : name(name.str()) {} + virtual ~AsmResourceParser(); + + /// Return the name of this parser. + StringRef getName() const { return name; } + + /// Parse the given resource entry. Returns failure if the key/data were not + /// valid, or could otherwise not be processed correctly. Any necessary errors + /// should be emitted with the provided entry. + virtual LogicalResult parseResource(AsmParsedResourceEntry &entry) = 0; + + /// Return a resource parser implemented via the given callable, whose form + /// should match that of `parseResource` above. + template + static std::unique_ptr fromCallable(StringRef name, + CallableT &&parseFn) { + struct Processor : public AsmResourceParser { + Processor(StringRef name, CallableT &&parseFn) + : AsmResourceParser(name), parseFn(std::move(parseFn)) {} + LogicalResult parseResource(AsmParsedResourceEntry &entry) override { + return parseFn(entry); + } + + std::decay_t parseFn; + }; + return std::make_unique(name, std::forward(parseFn)); + } + +private: + std::string name; +}; + +/// This class represents an instance of a resource printer. This class should +/// be implemented by non-dialect clients that want to inject additional +/// resources into MLIR assembly formats. +class AsmResourcePrinter { +public: + /// Create a new printer with the given identifying name. This name uniquely + /// identifies the entries of this printer, and differentiates them from + /// other contexts. + AsmResourcePrinter(StringRef name) : name(name.str()) {} + virtual ~AsmResourcePrinter(); + + /// Return the name of this printer. + StringRef getName() const { return name; } + + /// Build any resources to include during printing, utilizing the given + /// top-level root operation to help determine what information to include. + /// Provided data should be registered in the form of a key/data pair, to the + /// given builder. + virtual void buildResources(Operation *op, + AsmResourceBuilder &builder) const = 0; + + /// Return a resource printer implemented via the given callable, whose form + /// should match that of `buildResources` above. + template + static std::unique_ptr fromCallable(StringRef name, + CallableT &&printFn) { + struct Printer : public AsmResourcePrinter { + Printer(StringRef name, CallableT &&printFn) + : AsmResourcePrinter(name), printFn(std::move(printFn)) {} + void buildResources(Operation *op, + AsmResourceBuilder &builder) const override { + printFn(op, builder); + } + + std::decay_t printFn; + }; + return std::make_unique(name, std::forward(printFn)); + } + +private: + std::string name; +}; + +/// A fallback map containing external resources not explicitly handled by +/// another parser/printer. +class FallbackAsmResourceMap { +public: + /// This class represents an opaque resource. + struct OpaqueAsmResource { + OpaqueAsmResource(StringRef key, + std::variant value) + : key(key.str()), value(std::move(value)) {} + + /// The key identifying the resource. + std::string key; + /// An opaque value for the resource, whose variant values align 1-1 with + /// the kinds defined in AsmResourceEntryKind. + std::variant value; + }; + + /// Return a parser than can be used for parsing entries for the given + /// identifier key. + AsmResourceParser &getParserFor(StringRef key); + + /// Build a set of resource printers to print the resources within this map. + std::vector> getPrinters(); + +private: + struct ResourceCollection : public AsmResourceParser { + ResourceCollection(StringRef name) : AsmResourceParser(name) {} + + /// Parse a resource into this collection. + LogicalResult parseResource(AsmParsedResourceEntry &entry) final; + + /// Build the resources held by this collection. + void buildResources(Operation *op, AsmResourceBuilder &builder) const; + + /// The set of resources parsed into this collection. + SmallVector resources; + }; + + /// The set of opaque resources. + llvm::MapVector, + llvm::StringMap> + keyToResources; +}; + +//===----------------------------------------------------------------------===// +// ParserConfig +//===----------------------------------------------------------------------===// + +/// This class represents a configuration for the MLIR assembly parser. It +/// contains all of the necessary state to parse a MLIR source file. +class ParserConfig { +public: + /// Construct a parser configuration with the given context. + /// `verifyAfterParse` indicates if the IR should be verified after parsing. + /// `fallbackResourceMap` is an optional fallback handler that can be used to + /// parse external resources not explicitly handled by another parser. + ParserConfig(MLIRContext *context, bool verifyAfterParse = true, + FallbackAsmResourceMap *fallbackResourceMap = nullptr) + : context(context), verifyAfterParse(verifyAfterParse), + fallbackResourceMap(fallbackResourceMap) { + assert(context && "expected valid MLIR context"); + } + + /// Return the MLIRContext to be used when parsing. + MLIRContext *getContext() const { return context; } + + /// Returns if the parser should verify the IR after parsing. + bool shouldVerifyAfterParse() const { return verifyAfterParse; } + + /// Returns the parsing configurations associated to the bytecode read. + BytecodeReaderConfig &getBytecodeReaderConfig() const { + return const_cast(bytecodeReaderConfig); + } + + /// Return the resource parser registered to the given name, or nullptr if no + /// parser with `name` is registered. + AsmResourceParser *getResourceParser(StringRef name) const { + auto it = resourceParsers.find(name); + if (it != resourceParsers.end()) + return it->second.get(); + if (fallbackResourceMap) + return &fallbackResourceMap->getParserFor(name); + return nullptr; + } + + /// Attach the given resource parser. + void attachResourceParser(std::unique_ptr parser) { + StringRef name = parser->getName(); + auto it = resourceParsers.try_emplace(name, std::move(parser)); + (void)it; + assert(it.second && + "resource parser already registered with the given name"); + } + + /// Attach the given callable resource parser with the given name. + template + std::enable_if_t>::value> + attachResourceParser(StringRef name, CallableT &&parserFn) { + attachResourceParser(AsmResourceParser::fromCallable( + name, std::forward(parserFn))); + } + +private: + MLIRContext *context; + bool verifyAfterParse; + DenseMap> resourceParsers; + FallbackAsmResourceMap *fallbackResourceMap; + BytecodeReaderConfig bytecodeReaderConfig; +}; + +//===----------------------------------------------------------------------===// +// AsmState +//===----------------------------------------------------------------------===// + +/// This class provides management for the lifetime of the state used when +/// printing the IR. It allows for alleviating the cost of recomputing the +/// internal state of the asm printer. +/// +/// The IR should not be mutated in-between invocations using this state, and +/// the IR being printed must not be an parent of the IR originally used to +/// initialize this state. This means that if a child operation is provided, a +/// parent operation cannot reuse this state. +class AsmState { +public: + /// This map represents the raw locations of operations within the output + /// stream. This maps the original pointer to the operation, to a pair of line + /// and column in the output stream. + using LocationMap = DenseMap>; + + /// Initialize the asm state at the level of the given operation. A location + /// map may optionally be provided to be populated when printing. `map` is an + /// optional fallback resource map, which when provided will attach resource + /// printers for the fallback resources within the map. + AsmState(Operation *op, + const OpPrintingFlags &printerFlags = OpPrintingFlags(), + LocationMap *locationMap = nullptr, + FallbackAsmResourceMap *map = nullptr); + AsmState(MLIRContext *ctx, + const OpPrintingFlags &printerFlags = OpPrintingFlags(), + LocationMap *locationMap = nullptr, + FallbackAsmResourceMap *map = nullptr); + ~AsmState(); + + /// Get the printer flags. + const OpPrintingFlags &getPrinterFlags() const; + + /// Return an instance of the internal implementation. Returns nullptr if the + /// state has not been initialized. + detail::AsmStateImpl &getImpl() { return *impl; } + + //===--------------------------------------------------------------------===// + // Resources + //===--------------------------------------------------------------------===// + + /// Attach the given resource printer to the AsmState. + void attachResourcePrinter(std::unique_ptr printer); + + /// Attach an resource printer, in the form of a callable, to the AsmState. + template + std::enable_if_t>::value> + attachResourcePrinter(StringRef name, CallableT &&printFn) { + attachResourcePrinter(AsmResourcePrinter::fromCallable( + name, std::forward(printFn))); + } + + /// Attach resource printers to the AsmState for the fallback resources + /// in the given map. + void attachFallbackResourcePrinter(FallbackAsmResourceMap &map) { + for (auto &printer : map.getPrinters()) + attachResourcePrinter(std::move(printer)); + } + + /// Returns a map of dialect resources that were referenced when using this + /// state to print IR. + DenseMap> & + getDialectResources() const; + +private: + AsmState() = delete; + + /// A pointer to allocated storage for the impl state. + std::unique_ptr impl; +}; + +//===----------------------------------------------------------------------===// +// AsmPrinter CommandLine Options +//===----------------------------------------------------------------------===// + +/// Register a set of useful command-line options that can be used to configure +/// various flags within the AsmPrinter. +void registerAsmPrinterCLOptions(); + +} // namespace mlir + +#endif // MLIR_IR_ASMSTATE_H_ diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/IR/AttrTypeSubElements.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/IR/AttrTypeSubElements.h new file mode 100644 index 0000000000000000000000000000000000000000..3105040b876317c3d31d8bf20caa3549ed8fa8ec --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/IR/AttrTypeSubElements.h @@ -0,0 +1,501 @@ +//===- AttrTypeSubElements.h - Attr and Type SubElements -------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file contains utilities for querying the sub elements of an attribute or +// type. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_IR_ATTRTYPESUBELEMENTS_H +#define MLIR_IR_ATTRTYPESUBELEMENTS_H + +#include "mlir/IR/MLIRContext.h" +#include "mlir/IR/Visitors.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/DenseMap.h" +#include + +namespace mlir { +class Attribute; +class Type; + +//===----------------------------------------------------------------------===// +/// AttrTypeWalker +//===----------------------------------------------------------------------===// + +/// This class provides a utility for walking attributes/types, and their sub +/// elements. Multiple walk functions may be registered. +class AttrTypeWalker { +public: + //===--------------------------------------------------------------------===// + // Application + //===--------------------------------------------------------------------===// + + /// Walk the given attribute/type, and recursively walk any sub elements. + template + WalkResult walk(T element) { + return walkImpl(element, Order); + } + template + WalkResult walk(T element) { + return walk(element); + } + + //===--------------------------------------------------------------------===// + // Registration + //===--------------------------------------------------------------------===// + + template + using WalkFn = std::function; + + /// Register a walk function for a given attribute or type. A walk function + /// must be convertible to any of the following forms(where `T` is a class + /// derived from `Type` or `Attribute`: + /// + /// * WalkResult(T) + /// - Returns a walk result, which can be used to control the walk + /// + /// * void(T) + /// - Returns void, i.e. the walk always continues. + /// + /// Note: When walking, the mostly recently added walk functions will be + /// invoked first. + void addWalk(WalkFn &&fn) { + attrWalkFns.emplace_back(std::move(fn)); + } + void addWalk(WalkFn &&fn) { typeWalkFns.push_back(std::move(fn)); } + + /// Register a replacement function that doesn't match the default signature, + /// either because it uses a derived parameter type, or it uses a simplified + /// result type. + template >::template arg_t<0>, + typename BaseT = std::conditional_t, + Attribute, Type>, + typename ResultT = std::invoke_result_t> + std::enable_if_t || std::is_same_v> + addWalk(FnT &&callback) { + addWalk([callback = std::forward(callback)](BaseT base) -> WalkResult { + if (auto derived = dyn_cast(base)) { + if constexpr (std::is_convertible_v) + return callback(derived); + else + callback(derived); + } + return WalkResult::advance(); + }); + } + +private: + WalkResult walkImpl(Attribute attr, WalkOrder order); + WalkResult walkImpl(Type type, WalkOrder order); + + /// Internal implementation of the `walk` methods above. + template + WalkResult walkImpl(T element, WalkFns &walkFns, WalkOrder order); + + /// Walk the sub elements of the given interface. + template + WalkResult walkSubElements(T interface, WalkOrder order); + + /// The set of walk functions that map sub elements. + std::vector> attrWalkFns; + std::vector> typeWalkFns; + + /// The set of visited attributes/types. + DenseMap, WalkResult> visitedAttrTypes; +}; + +//===----------------------------------------------------------------------===// +/// AttrTypeReplacer +//===----------------------------------------------------------------------===// + +/// This class provides a utility for replacing attributes/types, and their sub +/// elements. Multiple replacement functions may be registered. +class AttrTypeReplacer { +public: + //===--------------------------------------------------------------------===// + // Application + //===--------------------------------------------------------------------===// + + /// Replace the elements within the given operation. If `replaceAttrs` is + /// true, this updates the attribute dictionary of the operation. If + /// `replaceLocs` is true, this also updates its location, and the locations + /// of any nested block arguments. If `replaceTypes` is true, this also + /// updates the result types of the operation, and the types of any nested + /// block arguments. + void replaceElementsIn(Operation *op, bool replaceAttrs = true, + bool replaceLocs = false, bool replaceTypes = false); + + /// Replace the elements within the given operation, and all nested + /// operations. + void recursivelyReplaceElementsIn(Operation *op, bool replaceAttrs = true, + bool replaceLocs = false, + bool replaceTypes = false); + + /// Replace the given attribute/type, and recursively replace any sub + /// elements. Returns either the new attribute/type, or nullptr in the case of + /// failure. + Attribute replace(Attribute attr); + Type replace(Type type); + + //===--------------------------------------------------------------------===// + // Registration + //===--------------------------------------------------------------------===// + + /// A replacement mapping function, which returns either std::nullopt (to + /// signal the element wasn't handled), or a pair of the replacement element + /// and a WalkResult. + template + using ReplaceFnResult = std::optional>; + template + using ReplaceFn = std::function(T)>; + + /// Register a replacement function for mapping a given attribute or type. A + /// replacement function must be convertible to any of the following + /// forms(where `T` is a class derived from `Type` or `Attribute`, and `BaseT` + /// is either `Type` or `Attribute` respectively): + /// + /// * std::optional(T) + /// - This either returns a valid Attribute/Type in the case of success, + /// nullptr in the case of failure, or `std::nullopt` to signify that + /// additional replacement functions may be applied (i.e. this function + /// doesn't handle that instance). + /// + /// * std::optional>(T) + /// - Similar to the above, but also allows specifying a WalkResult to + /// control the replacement of sub elements of a given attribute or + /// type. Returning a `skip` result, for example, will not recursively + /// process the resultant attribute or type value. + /// + /// Note: When replacing, the mostly recently added replacement functions will + /// be invoked first. + void addReplacement(ReplaceFn fn); + void addReplacement(ReplaceFn fn); + + /// Register a replacement function that doesn't match the default signature, + /// either because it uses a derived parameter type, or it uses a simplified + /// result type. + template >::template arg_t<0>, + typename BaseT = std::conditional_t, + Attribute, Type>, + typename ResultT = std::invoke_result_t> + std::enable_if_t || + !std::is_convertible_v>> + addReplacement(FnT &&callback) { + addReplacement([callback = std::forward(callback)]( + BaseT base) -> ReplaceFnResult { + if (auto derived = dyn_cast(base)) { + if constexpr (std::is_convertible_v>) { + std::optional result = callback(derived); + return result ? std::make_pair(*result, WalkResult::advance()) + : ReplaceFnResult(); + } else { + return callback(derived); + } + } + return ReplaceFnResult(); + }); + } + +private: + /// Internal implementation of the `replace` methods above. + template + T replaceImpl(T element, ReplaceFns &replaceFns); + + /// Replace the sub elements of the given interface. + template + T replaceSubElements(T interface); + + /// The set of replacement functions that map sub elements. + std::vector> attrReplacementFns; + std::vector> typeReplacementFns; + + /// The set of cached mappings for attributes/types. + DenseMap attrTypeMap; +}; + +//===----------------------------------------------------------------------===// +/// AttrTypeSubElementHandler +//===----------------------------------------------------------------------===// + +/// This class is used by AttrTypeSubElementHandler instances to walking sub +/// attributes and types. +class AttrTypeImmediateSubElementWalker { +public: + AttrTypeImmediateSubElementWalker(function_ref walkAttrsFn, + function_ref walkTypesFn) + : walkAttrsFn(walkAttrsFn), walkTypesFn(walkTypesFn) {} + + /// Walk an attribute. + void walk(Attribute element); + /// Walk a type. + void walk(Type element); + /// Walk a range of attributes or types. + template + void walkRange(RangeT &&elements) { + for (auto element : elements) + walk(element); + } + +private: + function_ref walkAttrsFn; + function_ref walkTypesFn; +}; + +/// This class is used by AttrTypeSubElementHandler instances to process sub +/// element replacements. +template +class AttrTypeSubElementReplacements { +public: + AttrTypeSubElementReplacements(ArrayRef repls) : repls(repls) {} + + /// Take the first N replacements as an ArrayRef, dropping them from + /// this replacement list. + ArrayRef take_front(unsigned n) { + ArrayRef elements = repls.take_front(n); + repls = repls.drop_front(n); + return elements; + } + +private: + /// The current set of replacements. + ArrayRef repls; +}; +using AttrSubElementReplacements = AttrTypeSubElementReplacements; +using TypeSubElementReplacements = AttrTypeSubElementReplacements; + +/// This class provides support for interacting with the +/// SubElementInterfaces for different types of parameters. An +/// implementation of this class should be provided for any parameter class +/// that may contain an attribute or type. There are two main methods of +/// this class that need to be implemented: +/// +/// - walk +/// +/// This method should traverse into any sub elements of the parameter +/// using the provided walker, or by invoking handlers for sub-types. +/// +/// - replace +/// +/// This method should extract any necessary sub elements using the +/// provided replacer, or by invoking handlers for sub-types. The new +/// post-replacement parameter value should be returned. +/// +template +struct AttrTypeSubElementHandler { + /// Default walk implementation that does nothing. + static inline void walk(const T ¶m, + AttrTypeImmediateSubElementWalker &walker) {} + + /// Default replace implementation just forwards the parameter. + template + static inline decltype(auto) replace(ParamT &¶m, + AttrSubElementReplacements &attrRepls, + TypeSubElementReplacements &typeRepls) { + return std::forward(param); + } + + /// Tag indicating that this handler does not support sub-elements. + using DefaultHandlerTag = void; +}; + +/// Detect if any of the given parameter types has a sub-element handler. +namespace detail { +template +using has_default_sub_element_handler_t = decltype(T::DefaultHandlerTag); +} // namespace detail +template +inline constexpr bool has_sub_attr_or_type_v = + (!llvm::is_detected::value || + ...); + +/// Implementation for derived Attributes and Types. +template +struct AttrTypeSubElementHandler< + T, std::enable_if_t || + std::is_base_of_v>> { + static void walk(T param, AttrTypeImmediateSubElementWalker &walker) { + walker.walk(param); + } + static T replace(T param, AttrSubElementReplacements &attrRepls, + TypeSubElementReplacements &typeRepls) { + if (!param) + return T(); + if constexpr (std::is_base_of_v) { + return cast(attrRepls.take_front(1)[0]); + } else { + return cast(typeRepls.take_front(1)[0]); + } + } +}; +/// Implementation for derived ArrayRef. +template +struct AttrTypeSubElementHandler, + std::enable_if_t>> { + using EltHandler = AttrTypeSubElementHandler; + + static void walk(ArrayRef param, + AttrTypeImmediateSubElementWalker &walker) { + for (const T &subElement : param) + EltHandler::walk(subElement, walker); + } + static auto replace(ArrayRef param, AttrSubElementReplacements &attrRepls, + TypeSubElementReplacements &typeRepls) { + // Normal attributes/types can extract using the replacer directly. + if constexpr (std::is_base_of_v && + sizeof(T) == sizeof(void *)) { + ArrayRef attrs = attrRepls.take_front(param.size()); + return ArrayRef((const T *)attrs.data(), attrs.size()); + } else if constexpr (std::is_base_of_v && + sizeof(T) == sizeof(void *)) { + ArrayRef types = typeRepls.take_front(param.size()); + return ArrayRef((const T *)types.data(), types.size()); + } else { + // Otherwise, we need to allocate storage for the new elements. + SmallVector newElements; + for (const T &element : param) + newElements.emplace_back( + EltHandler::replace(element, attrRepls, typeRepls)); + return newElements; + } + } +}; +/// Implementation for Tuple. +template +struct AttrTypeSubElementHandler< + std::tuple, std::enable_if_t>> { + static void walk(const std::tuple ¶m, + AttrTypeImmediateSubElementWalker &walker) { + std::apply( + [&](const Ts &...params) { + (AttrTypeSubElementHandler::walk(params, walker), ...); + }, + param); + } + static auto replace(const std::tuple ¶m, + AttrSubElementReplacements &attrRepls, + TypeSubElementReplacements &typeRepls) { + return std::apply( + [&](const Ts &...params) + -> std::tuple::replace( + params, attrRepls, typeRepls))...> { + return {AttrTypeSubElementHandler::replace(params, attrRepls, + typeRepls)...}; + }, + param); + } +}; + +namespace detail { +template +struct is_tuple : public std::false_type {}; +template +struct is_tuple> : public std::true_type {}; + +template +struct is_pair : public std::false_type {}; +template +struct is_pair> : public std::true_type {}; + +template +using has_get_method = decltype(T::get(std::declval()...)); +template +using has_get_as_key = decltype(std::declval().getAsKey()); + +/// This function provides the underlying implementation for the +/// SubElementInterface walk method, using the key type of the derived +/// attribute/type to interact with the individual parameters. +template +void walkImmediateSubElementsImpl(T derived, + function_ref walkAttrsFn, + function_ref walkTypesFn) { + using ImplT = typename T::ImplType; + (void)derived; + (void)walkAttrsFn; + (void)walkTypesFn; + if constexpr (llvm::is_detected::value) { + auto key = static_cast(derived.getImpl())->getAsKey(); + + // If we don't have any sub-elements, there is nothing to do. + if constexpr (!has_sub_attr_or_type_v) + return; + AttrTypeImmediateSubElementWalker walker(walkAttrsFn, walkTypesFn); + AttrTypeSubElementHandler::walk(key, walker); + } +} + +/// This function invokes the proper `get` method for a type `T` with the given +/// values. +template +auto constructSubElementReplacement(MLIRContext *ctx, Ts &&...params) { + // Prefer a direct `get` method if one exists. + if constexpr (llvm::is_detected::value) { + (void)ctx; + return T::get(std::forward(params)...); + } else if constexpr (llvm::is_detected::value) { + return T::get(ctx, std::forward(params)...); + } else { + // Otherwise, pass to the base get. + return T::Base::get(ctx, std::forward(params)...); + } +} + +/// This function provides the underlying implementation for the +/// SubElementInterface replace method, using the key type of the derived +/// attribute/type to interact with the individual parameters. +template +auto replaceImmediateSubElementsImpl(T derived, ArrayRef &replAttrs, + ArrayRef &replTypes) { + using ImplT = typename T::ImplType; + if constexpr (llvm::is_detected::value) { + auto key = static_cast(derived.getImpl())->getAsKey(); + + // If we don't have any sub-elements, we can just return the original. + if constexpr (!has_sub_attr_or_type_v) { + return derived; + + // Otherwise, we need to replace any necessary sub-elements. + } else { + // Functor used to build the replacement on success. + auto buildReplacement = [&](auto newKey, MLIRContext *ctx) { + if constexpr (is_tuple::value || + is_pair::value) { + return std::apply( + [&](auto &&...params) { + return constructSubElementReplacement( + ctx, std::forward(params)...); + }, + newKey); + } else { + return constructSubElementReplacement(ctx, newKey); + } + }; + + AttrSubElementReplacements attrRepls(replAttrs); + TypeSubElementReplacements typeRepls(replTypes); + auto newKey = AttrTypeSubElementHandler::replace( + key, attrRepls, typeRepls); + MLIRContext *ctx = derived.getContext(); + if constexpr (std::is_convertible_v) + return succeeded(newKey) ? buildReplacement(*newKey, ctx) : nullptr; + else + return buildReplacement(newKey, ctx); + } + } else { + return derived; + } +} +} // namespace detail +} // namespace mlir + +#endif // MLIR_IR_ATTRTYPESUBELEMENTS_H diff --git a/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/IR/AttributeSupport.h b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/IR/AttributeSupport.h new file mode 100644 index 0000000000000000000000000000000000000000..75ea1ce24753c97565f8af2da2b17e64cdb3b501 --- /dev/null +++ b/miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/IR/AttributeSupport.h @@ -0,0 +1,315 @@ +//===- AttributeSupport.h ---------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file defines support types for registering dialect extended attributes. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_IR_ATTRIBUTESUPPORT_H +#define MLIR_IR_ATTRIBUTESUPPORT_H + +#include "mlir/IR/MLIRContext.h" +#include "mlir/IR/StorageUniquerSupport.h" +#include "mlir/IR/Types.h" +#include "llvm/ADT/PointerIntPair.h" +#include "llvm/ADT/Twine.h" + +namespace mlir { +//===----------------------------------------------------------------------===// +// AbstractAttribute +//===----------------------------------------------------------------------===// + +/// This class contains all of the static information common to all instances of +/// a registered Attribute. +class AbstractAttribute { +public: + using HasTraitFn = llvm::unique_function; + using WalkImmediateSubElementsFn = function_ref, function_ref)>; + using ReplaceImmediateSubElementsFn = + function_ref, ArrayRef)>; + + /// Look up the specified abstract attribute in the MLIRContext and return a + /// reference to it. + static const AbstractAttribute &lookup(TypeID typeID, MLIRContext *context); + + /// This method is used by Dialect objects when they register the list of + /// attributes they contain. + template + static AbstractAttribute get(Dialect &dialect) { + return AbstractAttribute(dialect, T::getInterfaceMap(), T::getHasTraitFn(), + T::getWalkImmediateSubElementsFn(), + T::getReplaceImmediateSubElementsFn(), + T::getTypeID()); + } + + /// This method is used by Dialect objects to register attributes with + /// custom TypeIDs. + /// The use of this method is in general discouraged in favor of + /// 'get(dialect)'. + static AbstractAttribute + get(Dialect &dialect, detail::InterfaceMap &&interfaceMap, + HasTraitFn &&hasTrait, + WalkImmediateSubElementsFn walkImmediateSubElementsFn, + ReplaceImmediateSubElementsFn replaceImmediateSubElementsFn, + TypeID typeID) { + return AbstractAttribute(dialect, std::move(interfaceMap), + std::move(hasTrait), walkImmediateSubElementsFn, + replaceImmediateSubElementsFn, typeID); + } + + /// Return the dialect this attribute was registered to. + Dialect &getDialect() const { return const_cast(dialect); } + + /// Returns an instance of the concept object for the given interface if it + /// was registered to this attribute, null otherwise. This should not be used + /// directly. + template + typename T::Concept *getInterface() const { + return interfaceMap.lookup(); + } + + /// Returns true if the attribute has the interface with the given ID + /// registered. + bool hasInterface(TypeID interfaceID) const { + return interfaceMap.contains(interfaceID); + } + + /// Returns true if the attribute has a particular trait. + template