Files
gps/tools/local/circt/include/mlir/Dialect/Bufferization/IR/BufferizationOps.cpp.inc
T
2026-07-12 11:01:51 +03:00

3006 lines
141 KiB
C++

/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
|* *|
|* Op Definitions *|
|* *|
|* Automatically generated file, do not edit! *|
|* From: BufferizationOps.td *|
|* *|
\*===----------------------------------------------------------------------===*/
#ifdef GET_OP_LIST
#undef GET_OP_LIST
::mlir::bufferization::AllocTensorOp,
::mlir::bufferization::CloneOp,
::mlir::bufferization::DeallocOp,
::mlir::bufferization::DeallocTensorOp,
::mlir::bufferization::MaterializeInDestinationOp,
::mlir::bufferization::ToBufferOp,
::mlir::bufferization::ToTensorOp
#endif // GET_OP_LIST
#ifdef GET_OP_CLASSES
#undef GET_OP_CLASSES
//===----------------------------------------------------------------------===//
// Local Utility Method Definitions
//===----------------------------------------------------------------------===//
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_BufferizationOps1(
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
unsigned valueIndex) {
if (!((::llvm::isa<::mlir::IndexType>(type)))) {
return op->emitOpError(valueKind) << " #" << valueIndex
<< " must be variadic of index, but got " << type;
}
return ::mlir::success();
}
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_BufferizationOps2(
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
unsigned valueIndex) {
if (!(((::llvm::isa<::mlir::TensorType>(type))) && ([](::mlir::Type elementType) { return !((::llvm::isa<::mlir::TokenType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) {
return op->emitOpError(valueKind) << " #" << valueIndex
<< " must be tensor of any non-token type values, but got " << type;
}
return ::mlir::success();
}
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_BufferizationOps3(
::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 ::llvm::LogicalResult __mlir_ods_local_type_constraint_BufferizationOps4(
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
unsigned valueIndex) {
if (!(((::llvm::isa<::mlir::BaseMemRefType>(type))) && ([](::mlir::Type elementType) { return !((::llvm::isa<::mlir::TokenType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) {
return op->emitOpError(valueKind) << " #" << valueIndex
<< " must be ranked or unranked memref of any non-token type values, but got " << type;
}
return ::mlir::success();
}
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_BufferizationOps5(
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
unsigned valueIndex) {
if (!(((::llvm::isa<::mlir::BaseMemRefType>(type))) && ([](::mlir::Type elementType) { return !((::llvm::isa<::mlir::TokenType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) {
return op->emitOpError(valueKind) << " #" << valueIndex
<< " must be variadic of ranked or unranked memref of any non-token type values, but got " << type;
}
return ::mlir::success();
}
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_BufferizationOps6(
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
unsigned valueIndex) {
if (!((type.isSignlessInteger(1)))) {
return op->emitOpError(valueKind) << " #" << valueIndex
<< " must be variadic of 1-bit signless integer, but got " << type;
}
return ::mlir::success();
}
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_BufferizationOps7(
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
unsigned valueIndex) {
if (!(((::llvm::isa<::mlir::ShapedType>(type))) && ([](::mlir::Type elementType) { return !((::llvm::isa<::mlir::TokenType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) {
return op->emitOpError(valueKind) << " #" << valueIndex
<< " must be shaped of any non-token type values, but got " << type;
}
return ::mlir::success();
}
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_BufferizationOps8(
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
unsigned valueIndex) {
if (!((::llvm::isa<::mlir::bufferization::TensorLikeType>(type)))) {
return op->emitOpError(valueKind) << " #" << valueIndex
<< " must be TensorLikeType instance, but got " << type;
}
return ::mlir::success();
}
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_BufferizationOps9(
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
unsigned valueIndex) {
if (!((::llvm::isa<::mlir::bufferization::BufferLikeType>(type)))) {
return op->emitOpError(valueKind) << " #" << valueIndex
<< " must be BufferLikeType instance, but got " << type;
}
return ::mlir::success();
}
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_BufferizationOps1(
::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 ::llvm::LogicalResult __mlir_ods_local_attr_constraint_BufferizationOps1(
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
return __mlir_ods_local_attr_constraint_BufferizationOps1(attr, attrName, [op]() {
return op->emitOpError();
});
}
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_BufferizationOps2(
::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 ::llvm::LogicalResult __mlir_ods_local_attr_constraint_BufferizationOps2(
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
return __mlir_ods_local_attr_constraint_BufferizationOps2(attr, attrName, [op]() {
return op->emitOpError();
});
}
namespace mlir::bufferization {
//===----------------------------------------------------------------------===//
// ::mlir::bufferization::AllocTensorOp definitions
//===----------------------------------------------------------------------===//
namespace detail {
AllocTensorOpGenericAdaptorBase::AllocTensorOpGenericAdaptorBase(AllocTensorOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
std::pair<unsigned, unsigned> AllocTensorOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
unsigned start = 0;
for (unsigned i = 0; i < index; ++i)
start += sizeAttr[i];
return {start, sizeAttr[index]};
}
::std::optional<::mlir::Attribute> AllocTensorOpGenericAdaptorBase::getMemorySpace() {
auto attr = getMemorySpaceAttr();
return attr ? ::std::optional<::mlir::Attribute>(attr) : (::std::nullopt);
}
} // namespace detail
AllocTensorOpAdaptor::AllocTensorOpAdaptor(AllocTensorOp op) : AllocTensorOpGenericAdaptor(op->getOperands(), op) {}
::llvm::LogicalResult AllocTensorOpAdaptor::verify(::mlir::Location loc) {
auto tblgen_memory_space = getProperties().memory_space; (void)tblgen_memory_space;
if (tblgen_memory_space && !((true)))
return emitError(loc, "'bufferization.alloc_tensor' op attribute 'memory_space' failed to satisfy constraint: any attribute");
return ::mlir::success();
}
std::pair<unsigned, unsigned> AllocTensorOp::getODSOperandIndexAndLength(unsigned index) {
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
unsigned start = 0;
for (unsigned i = 0; i < index; ++i)
start += sizeAttr[i];
return {start, sizeAttr[index]};
}
::mlir::MutableOperandRange AllocTensorOp::getDynamicSizesMutable() {
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 AllocTensorOp::getCopyMutable() {
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 AllocTensorOp::getSizeHintMutable() {
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;
}
::llvm::LogicalResult AllocTensorOp::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.memory_space;
auto attr = dict.get("memory_space");
if (attr) {
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
if (convertedAttr) {
propStorage = convertedAttr;
} else {
emitError() << "Invalid attribute `memory_space` in property conversion: " << attr;
return ::mlir::failure();
}
}
}
{
auto setFromAttr = [] (auto &propStorage, ::mlir::Attribute propAttr,
::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) -> ::mlir::LogicalResult {
return convertFromAttribute(propStorage, propAttr, emitError);
};
auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");;
;
if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() {
return emitError() << "for `operandSegmentSizes`: ";
})))
return ::mlir::failure();
}
return ::mlir::success();
}
::mlir::Attribute AllocTensorOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
::mlir::Builder odsBuilder{ctx};
{
const auto &propStorage = prop.memory_space;
if (propStorage)
attrs.push_back(odsBuilder.getNamedAttr("memory_space",
propStorage));
}
{
const auto &propStorage = prop.operandSegmentSizes;
auto attr = [&]() -> ::mlir::Attribute {
return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage);
}();
attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr));
}
if (!attrs.empty())
return odsBuilder.getDictionaryAttr(attrs);
return {};
}
llvm::hash_code AllocTensorOp::computePropertiesHash(const Properties &prop) {
auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code {
using ::llvm::hash_value;
return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));;
};
using llvm::hash_value;
return llvm::hash_combine(
llvm::hash_value(prop.memory_space.getAsOpaquePointer()),
hash_operandSegmentSizes_(prop.operandSegmentSizes));
}
std::optional<mlir::Attribute> AllocTensorOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
if (name == "memory_space")
return prop.memory_space;
if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }();
return std::nullopt;
}
void AllocTensorOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
if (name == "memory_space") {
prop.memory_space = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.memory_space)>>(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 AllocTensorOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
if (prop.memory_space) attrs.append("memory_space", prop.memory_space);
attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }());
}
::llvm::LogicalResult AllocTensorOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
{
::mlir::Attribute attr = attrs.get(getMemorySpaceAttrName(opName));
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_BufferizationOps1(attr, "memory_space", emitError)))
return ::mlir::failure();
}
return ::mlir::success();
}
::llvm::LogicalResult AllocTensorOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
if (::mlir::failed(reader.readOptionalAttribute(prop.memory_space)))
return ::mlir::failure();
if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) {
auto &propStorage = prop.operandSegmentSizes;
::mlir::DenseI32ArrayAttr attr;
if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure();
if (attr.size() > static_cast<int64_t>(sizeof(propStorage) / sizeof(int32_t))) {
reader.emitError("size mismatch for operand/result_segment_size");
return ::mlir::failure();
}
::llvm::copy(::llvm::ArrayRef<int32_t>(attr), propStorage.begin());
}
{
auto &propStorage = prop.operandSegmentSizes;
auto readProp = [&]() {
if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6)
return reader.readSparseArray(::llvm::MutableArrayRef(propStorage));
;
return ::mlir::success();
};
if (::mlir::failed(readProp()))
return ::mlir::failure();
}
return ::mlir::success();
}
void AllocTensorOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
auto &prop = getProperties(); (void)prop;
writer.writeOptionalAttribute(prop.memory_space);
if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) {
auto &propStorage = prop.operandSegmentSizes;
writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage));
}
{
auto &propStorage = prop.operandSegmentSizes;
if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6)
writer.writeSparseArray(::llvm::ArrayRef(propStorage));
;
}
}
::std::optional<::mlir::Attribute> AllocTensorOp::getMemorySpace() {
auto attr = getMemorySpaceAttr();
return attr ? ::std::optional<::mlir::Attribute>(attr) : (::std::nullopt);
}
AllocTensorOp AllocTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, RankedTensorType type, ValueRange dynamicSizes) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(type)>(type), std::forward<decltype(dynamicSizes)>(dynamicSizes));
auto __res__ = ::llvm::dyn_cast<AllocTensorOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
AllocTensorOp AllocTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, RankedTensorType type, ValueRange dynamicSizes) {
return create(builder, builder.getLoc(), std::forward<decltype(type)>(type), std::forward<decltype(dynamicSizes)>(dynamicSizes));
}
AllocTensorOp AllocTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, RankedTensorType type, ValueRange dynamicSizes, Value copy) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(type)>(type), std::forward<decltype(dynamicSizes)>(dynamicSizes), std::forward<decltype(copy)>(copy));
auto __res__ = ::llvm::dyn_cast<AllocTensorOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
AllocTensorOp AllocTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, RankedTensorType type, ValueRange dynamicSizes, Value copy) {
return create(builder, builder.getLoc(), std::forward<decltype(type)>(type), std::forward<decltype(dynamicSizes)>(dynamicSizes), std::forward<decltype(copy)>(copy));
}
AllocTensorOp AllocTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, TensorType type, ValueRange dynamicSizes, Value copy, IntegerAttr memory_space) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(type)>(type), std::forward<decltype(dynamicSizes)>(dynamicSizes), std::forward<decltype(copy)>(copy), std::forward<decltype(memory_space)>(memory_space));
auto __res__ = ::llvm::dyn_cast<AllocTensorOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
AllocTensorOp AllocTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, TensorType type, ValueRange dynamicSizes, Value copy, IntegerAttr memory_space) {
return create(builder, builder.getLoc(), std::forward<decltype(type)>(type), std::forward<decltype(dynamicSizes)>(dynamicSizes), std::forward<decltype(copy)>(copy), std::forward<decltype(memory_space)>(memory_space));
}
void AllocTensorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::ValueRange dynamic_sizes, /*optional*/::mlir::Value copy, /*optional*/::mlir::Value size_hint, /*optional*/::mlir::Attribute memory_space) {
odsState.addOperands(dynamic_sizes);
if (copy)
odsState.addOperands(copy);
if (size_hint)
odsState.addOperands(size_hint);
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(dynamic_sizes.size()), (copy ? 1 : 0), (size_hint ? 1 : 0)}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
if (memory_space) {
odsState.getOrAddProperties<Properties>().memory_space = memory_space;
}
odsState.addTypes(result);
}
AllocTensorOp AllocTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::ValueRange dynamic_sizes, /*optional*/::mlir::Value copy, /*optional*/::mlir::Value size_hint, /*optional*/::mlir::Attribute memory_space) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(result)>(result), std::forward<decltype(dynamic_sizes)>(dynamic_sizes), std::forward<decltype(copy)>(copy), std::forward<decltype(size_hint)>(size_hint), std::forward<decltype(memory_space)>(memory_space));
auto __res__ = ::llvm::dyn_cast<AllocTensorOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
AllocTensorOp AllocTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::ValueRange dynamic_sizes, /*optional*/::mlir::Value copy, /*optional*/::mlir::Value size_hint, /*optional*/::mlir::Attribute memory_space) {
return create(builder, builder.getLoc(), std::forward<decltype(result)>(result), std::forward<decltype(dynamic_sizes)>(dynamic_sizes), std::forward<decltype(copy)>(copy), std::forward<decltype(size_hint)>(size_hint), std::forward<decltype(memory_space)>(memory_space));
}
void AllocTensorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange dynamic_sizes, /*optional*/::mlir::Value copy, /*optional*/::mlir::Value size_hint, /*optional*/::mlir::Attribute memory_space) {
odsState.addOperands(dynamic_sizes);
if (copy)
odsState.addOperands(copy);
if (size_hint)
odsState.addOperands(size_hint);
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(dynamic_sizes.size()), (copy ? 1 : 0), (size_hint ? 1 : 0)}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
if (memory_space) {
odsState.getOrAddProperties<Properties>().memory_space = memory_space;
}
assert(resultTypes.size() == 1u && "mismatched number of results");
odsState.addTypes(resultTypes);
}
AllocTensorOp AllocTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange dynamic_sizes, /*optional*/::mlir::Value copy, /*optional*/::mlir::Value size_hint, /*optional*/::mlir::Attribute memory_space) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(dynamic_sizes)>(dynamic_sizes), std::forward<decltype(copy)>(copy), std::forward<decltype(size_hint)>(size_hint), std::forward<decltype(memory_space)>(memory_space));
auto __res__ = ::llvm::dyn_cast<AllocTensorOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
AllocTensorOp AllocTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange dynamic_sizes, /*optional*/::mlir::Value copy, /*optional*/::mlir::Value size_hint, /*optional*/::mlir::Attribute memory_space) {
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(dynamic_sizes)>(dynamic_sizes), std::forward<decltype(copy)>(copy), std::forward<decltype(size_hint)>(size_hint), std::forward<decltype(memory_space)>(memory_space));
}
void AllocTensorOp::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);
if (!attributes.empty()) {
(void)odsState.getOrAddProperties<AllocTensorOp::Properties>();
::mlir::PropertyRef properties = odsState.getRawProperties();
std::optional<::mlir::RegisteredOperationName> info =
odsState.name.getRegisteredInfo();
if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties,
odsState.attributes.getDictionary(odsState.getContext()), nullptr)))
::llvm::report_fatal_error("Property conversion failed.");
}
}
AllocTensorOp AllocTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
auto __res__ = ::llvm::dyn_cast<AllocTensorOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
AllocTensorOp AllocTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
}
void AllocTensorOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
odsState.addOperands(operands);
odsState.useProperties(const_cast<Properties&>(properties));
odsState.addAttributes(discardableAttributes);
assert(resultTypes.size() == 1u && "mismatched number of return types");
odsState.addTypes(resultTypes);
}
AllocTensorOp AllocTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
auto __res__ = ::llvm::dyn_cast<AllocTensorOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
AllocTensorOp AllocTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
}
::llvm::LogicalResult AllocTensorOp::verifyInvariantsImpl() {
auto tblgen_memory_space = getProperties().memory_space; (void)tblgen_memory_space;
if (::mlir::failed(__mlir_ods_local_attr_constraint_BufferizationOps1(*this, tblgen_memory_space, "memory_space")))
return ::mlir::failure();
{
unsigned index = 0; (void)index;
auto valueGroup0 = getODSOperands(0);
for (auto v : valueGroup0) {
if (::mlir::failed(__mlir_ods_local_type_constraint_BufferizationOps1(*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_BufferizationOps2(*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_BufferizationOps3(*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_BufferizationOps2(*this, v.getType(), "result", index++)))
return ::mlir::failure();
}
}
return ::mlir::success();
}
::llvm::LogicalResult AllocTensorOp::verifyInvariants() {
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
return ::mlir::success();
return ::mlir::failure();
}
::llvm::LogicalResult AllocTensorOp::setPropertiesFromParsedAttr(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();
}
// keep track of used keys in the input dictionary to be able to error out
// if there are some unknown ones.
::mlir::DenseSet<::mlir::StringAttr> usedKeys;
::mlir::MLIRContext *ctx = dict.getContext();
(void)ctx;
{
auto &propStorage = prop.memory_space;
auto memory_spaceAttrName = ::mlir::StringAttr::get(ctx, "memory_space");
auto attr = dict.get(memory_spaceAttrName);
usedKeys.insert(memory_spaceAttrName);
if (attr || /*isRequired=*/false) {
if (!attr) {
emitError() << "expected key entry for memory_space in DictionaryAttr to set "
"Properties.";
return ::mlir::failure();
}
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
if (convertedAttr) {
propStorage = convertedAttr;
} else {
emitError() << "Invalid attribute `memory_space` in property conversion: " << attr;
return ::mlir::failure();
}
}
}
for (::mlir::NamedAttribute attr : dict) {
if (!usedKeys.contains(attr.getName()))
return emitError() << "unknown key '" << attr.getName() <<
"' when parsing properties dictionary";
}
return ::mlir::success();
}
} // namespace mlir::bufferization
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::bufferization::AllocTensorOp)
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::bufferization::detail::AllocTensorOpGenericAdaptorBase::Properties)
namespace mlir::bufferization {
//===----------------------------------------------------------------------===//
// ::mlir::bufferization::CloneOp definitions
//===----------------------------------------------------------------------===//
namespace detail {
CloneOpGenericAdaptorBase::CloneOpGenericAdaptorBase(CloneOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
} // namespace detail
CloneOpAdaptor::CloneOpAdaptor(CloneOp op) : CloneOpGenericAdaptor(op->getOperands(), op) {}
::llvm::LogicalResult CloneOpAdaptor::verify(::mlir::Location loc) {
return ::mlir::success();
}
::llvm::LogicalResult CloneOp::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();
}
return ::mlir::success();
}
::mlir::Attribute CloneOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
::mlir::Builder odsBuilder{ctx};
if (!attrs.empty())
return odsBuilder.getDictionaryAttr(attrs);
return {};
}
llvm::hash_code CloneOp::computePropertiesHash(const Properties &prop) {
using llvm::hash_value;
return llvm::hash_combine();
}
std::optional<mlir::Attribute> CloneOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
return std::nullopt;
}
void CloneOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
}
void CloneOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
}
::llvm::LogicalResult CloneOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
return ::mlir::success();
}
void CloneOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value value) {
return build(odsBuilder, odsState, value.getType(), value);
}
CloneOp CloneOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Value value) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(value)>(value));
auto __res__ = ::llvm::dyn_cast<CloneOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
CloneOp CloneOp::create(::mlir::ImplicitLocOpBuilder &builder, Value value) {
return create(builder, builder.getLoc(), std::forward<decltype(value)>(value));
}
void CloneOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input) {
odsState.addOperands(input);
odsState.addTypes(output);
}
CloneOp CloneOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input));
auto __res__ = ::llvm::dyn_cast<CloneOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
CloneOp CloneOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input) {
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input));
}
void CloneOp::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);
}
CloneOp CloneOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input));
auto __res__ = ::llvm::dyn_cast<CloneOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
CloneOp CloneOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input) {
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input));
}
void CloneOp::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);
}
CloneOp CloneOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
auto __res__ = ::llvm::dyn_cast<CloneOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
CloneOp CloneOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
}
void CloneOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
assert(operands.size() == 1u && "mismatched number of parameters");
odsState.addOperands(operands);
odsState.useProperties(const_cast<Properties&>(properties));
odsState.addAttributes(discardableAttributes);
assert(resultTypes.size() == 1u && "mismatched number of return types");
odsState.addTypes(resultTypes);
}
CloneOp CloneOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
auto __res__ = ::llvm::dyn_cast<CloneOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
CloneOp CloneOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
}
::llvm::LogicalResult CloneOp::verifyInvariantsImpl() {
{
unsigned index = 0; (void)index;
auto valueGroup0 = getODSOperands(0);
for (auto v : valueGroup0) {
if (::mlir::failed(__mlir_ods_local_type_constraint_BufferizationOps4(*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_BufferizationOps4(*this, v.getType(), "result", index++)))
return ::mlir::failure();
}
}
return ::mlir::success();
}
::llvm::LogicalResult CloneOp::verifyInvariants() {
return verifyInvariantsImpl();
}
::mlir::ParseResult CloneOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
::mlir::OpAsmParser::UnresolvedOperand inputRawOperand{};
::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> inputOperands(&inputRawOperand, 1); ::llvm::SMLoc inputOperandsLoc;
(void)inputOperandsLoc;
::mlir::Type inputRawType{};
::llvm::ArrayRef<::mlir::Type> inputTypes(&inputRawType, 1);
::mlir::Type outputRawType{};
::llvm::ArrayRef<::mlir::Type> outputTypes(&outputRawType, 1);
inputOperandsLoc = parser.getCurrentLocation();
if (parser.parseOperand(inputRawOperand))
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::BaseMemRefType type;
if (parser.parseCustomTypeWithFallback(type))
return ::mlir::failure();
inputRawType = type;
}
if (parser.parseKeyword("to"))
return ::mlir::failure();
{
::mlir::BaseMemRefType type;
if (parser.parseCustomTypeWithFallback(type))
return ::mlir::failure();
outputRawType = type;
}
result.addTypes(outputTypes);
if (parser.resolveOperands(inputOperands, inputTypes, inputOperandsLoc, result.operands))
return ::mlir::failure();
return ::mlir::success();
}
void CloneOp::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::BaseMemRefType>(type))
_odsPrinter.printStrippedAttrOrType(validType);
else
_odsPrinter << type;
}
_odsPrinter << ' ' << "to";
_odsPrinter << ' ';
{
auto type = getOutput().getType();
if (auto validType = ::llvm::dyn_cast<::mlir::BaseMemRefType>(type))
_odsPrinter.printStrippedAttrOrType(validType);
else
_odsPrinter << type;
}
}
void CloneOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
{
auto valueRange = getODSOperandIndexAndLength(0);
for (unsigned idx = valueRange.first; idx < valueRange.first + valueRange.second; idx++) {
effects.emplace_back(::mlir::MemoryEffects::Read::get(), &getOperation()->getOpOperand(idx), 0, false, ::mlir::SideEffects::DefaultResource::get());
}
}
{
auto valueRange = getODSResultIndexAndLength(0);
for (unsigned idx = valueRange.first; idx < valueRange.first + valueRange.second; idx++) {
effects.emplace_back(::mlir::MemoryEffects::Write::get(), getOperation()->getOpResult(idx), 0, false, ::mlir::SideEffects::DefaultResource::get());
}
}
{
auto valueRange = getODSResultIndexAndLength(0);
for (unsigned idx = valueRange.first; idx < valueRange.first + valueRange.second; idx++) {
effects.emplace_back(::mlir::MemoryEffects::Allocate::get(), getOperation()->getOpResult(idx), 0, false, ::mlir::SideEffects::DefaultResource::get());
}
}
}
} // namespace mlir::bufferization
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::bufferization::CloneOp)
namespace mlir::bufferization {
//===----------------------------------------------------------------------===//
// ::mlir::bufferization::DeallocOp definitions
//===----------------------------------------------------------------------===//
namespace detail {
DeallocOpGenericAdaptorBase::DeallocOpGenericAdaptorBase(DeallocOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
std::pair<unsigned, unsigned> DeallocOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
unsigned start = 0;
for (unsigned i = 0; i < index; ++i)
start += sizeAttr[i];
return {start, sizeAttr[index]};
}
} // namespace detail
DeallocOpAdaptor::DeallocOpAdaptor(DeallocOp op) : DeallocOpGenericAdaptor(op->getOperands(), op) {}
::llvm::LogicalResult DeallocOpAdaptor::verify(::mlir::Location loc) {
return ::mlir::success();
}
std::pair<unsigned, unsigned> DeallocOp::getODSOperandIndexAndLength(unsigned index) {
::llvm::ArrayRef<int32_t> sizeAttr = getProperties().operandSegmentSizes;
unsigned start = 0;
for (unsigned i = 0; i < index; ++i)
start += sizeAttr[i];
return {start, sizeAttr[index]};
}
::mlir::MutableOperandRange DeallocOp::getMemrefsMutable() {
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 DeallocOp::getConditionsMutable() {
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 DeallocOp::getRetainedMutable() {
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<unsigned, unsigned> DeallocOp::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};
}
::llvm::LogicalResult DeallocOp::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) -> ::mlir::LogicalResult {
return convertFromAttribute(propStorage, propAttr, emitError);
};
auto attr = dict.get("operandSegmentSizes"); if (!attr) attr = dict.get("operand_segment_sizes");;
;
if (attr && ::mlir::failed(setFromAttr(prop.operandSegmentSizes, attr, [&]() {
return emitError() << "for `operandSegmentSizes`: ";
})))
return ::mlir::failure();
}
return ::mlir::success();
}
::mlir::Attribute DeallocOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
::mlir::Builder odsBuilder{ctx};
{
const auto &propStorage = prop.operandSegmentSizes;
auto attr = [&]() -> ::mlir::Attribute {
return ::mlir::DenseI32ArrayAttr::get(ctx, propStorage);
}();
attrs.push_back(odsBuilder.getNamedAttr("operandSegmentSizes", attr));
}
if (!attrs.empty())
return odsBuilder.getDictionaryAttr(attrs);
return {};
}
llvm::hash_code DeallocOp::computePropertiesHash(const Properties &prop) {
auto hash_operandSegmentSizes_ = [] (const auto &propStorage) -> llvm::hash_code {
using ::llvm::hash_value;
return ::llvm::hash_combine_range(std::begin(propStorage), std::end(propStorage));;
};
using llvm::hash_value;
return llvm::hash_combine(
hash_operandSegmentSizes_(prop.operandSegmentSizes));
}
std::optional<mlir::Attribute> DeallocOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
if (name == "operand_segment_sizes" || name == "operandSegmentSizes") return [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }();
return std::nullopt;
}
void DeallocOp::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 DeallocOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
attrs.append("operandSegmentSizes", [&]() -> ::mlir::Attribute { return ::mlir::DenseI32ArrayAttr::get(ctx, prop.operandSegmentSizes); }());
}
::llvm::LogicalResult DeallocOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
return ::mlir::success();
}
::llvm::LogicalResult DeallocOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
if (reader.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) {
auto &propStorage = prop.operandSegmentSizes;
::mlir::DenseI32ArrayAttr attr;
if (::mlir::failed(reader.readAttribute(attr))) return ::mlir::failure();
if (attr.size() > static_cast<int64_t>(sizeof(propStorage) / sizeof(int32_t))) {
reader.emitError("size mismatch for operand/result_segment_size");
return ::mlir::failure();
}
::llvm::copy(::llvm::ArrayRef<int32_t>(attr), propStorage.begin());
}
{
auto &propStorage = prop.operandSegmentSizes;
auto readProp = [&]() {
if (reader.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6)
return reader.readSparseArray(::llvm::MutableArrayRef(propStorage));
;
return ::mlir::success();
};
if (::mlir::failed(readProp()))
return ::mlir::failure();
}
return ::mlir::success();
}
void DeallocOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
auto &prop = getProperties(); (void)prop;
if (writer.getBytecodeVersion() < /*kNativePropertiesODSSegmentSize=*/6) {
auto &propStorage = prop.operandSegmentSizes;
writer.writeAttribute(::mlir::DenseI32ArrayAttr::get(this->getContext(), propStorage));
}
{
auto &propStorage = prop.operandSegmentSizes;
if (writer.getBytecodeVersion() >= /*kNativePropertiesODSSegmentSize=*/6)
writer.writeSparseArray(::llvm::ArrayRef(propStorage));
;
}
}
void DeallocOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange updatedConditions, ::mlir::ValueRange memrefs, ::mlir::ValueRange conditions, ::mlir::ValueRange retained) {
odsState.addOperands(memrefs);
odsState.addOperands(conditions);
odsState.addOperands(retained);
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(memrefs.size()), static_cast<int32_t>(conditions.size()), static_cast<int32_t>(retained.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
odsState.addTypes(updatedConditions);
}
DeallocOp DeallocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange updatedConditions, ::mlir::ValueRange memrefs, ::mlir::ValueRange conditions, ::mlir::ValueRange retained) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(updatedConditions)>(updatedConditions), std::forward<decltype(memrefs)>(memrefs), std::forward<decltype(conditions)>(conditions), std::forward<decltype(retained)>(retained));
auto __res__ = ::llvm::dyn_cast<DeallocOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
DeallocOp DeallocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange updatedConditions, ::mlir::ValueRange memrefs, ::mlir::ValueRange conditions, ::mlir::ValueRange retained) {
return create(builder, builder.getLoc(), std::forward<decltype(updatedConditions)>(updatedConditions), std::forward<decltype(memrefs)>(memrefs), std::forward<decltype(conditions)>(conditions), std::forward<decltype(retained)>(retained));
}
void DeallocOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange memrefs, ::mlir::ValueRange conditions, ::mlir::ValueRange retained) {
odsState.addOperands(memrefs);
odsState.addOperands(conditions);
odsState.addOperands(retained);
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(memrefs.size()), static_cast<int32_t>(conditions.size()), static_cast<int32_t>(retained.size())}), odsState.getOrAddProperties<Properties>().operandSegmentSizes.begin());
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
if (::mlir::succeeded(DeallocOp::inferReturnTypes(odsBuilder.getContext(),
odsState.location, odsState.operands,
odsState.attributes.getDictionary(odsState.getContext()),
odsState.getRawProperties(),
odsState.regions, inferredReturnTypes)))
odsState.addTypes(inferredReturnTypes);
else
::mlir::detail::reportFatalInferReturnTypesError(odsState);
}
DeallocOp DeallocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange memrefs, ::mlir::ValueRange conditions, ::mlir::ValueRange retained) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(memrefs)>(memrefs), std::forward<decltype(conditions)>(conditions), std::forward<decltype(retained)>(retained));
auto __res__ = ::llvm::dyn_cast<DeallocOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
DeallocOp DeallocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange memrefs, ::mlir::ValueRange conditions, ::mlir::ValueRange retained) {
return create(builder, builder.getLoc(), std::forward<decltype(memrefs)>(memrefs), std::forward<decltype(conditions)>(conditions), std::forward<decltype(retained)>(retained));
}
void DeallocOp::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);
if (!attributes.empty()) {
(void)odsState.getOrAddProperties<DeallocOp::Properties>();
::mlir::PropertyRef properties = odsState.getRawProperties();
std::optional<::mlir::RegisteredOperationName> info =
odsState.name.getRegisteredInfo();
if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties,
odsState.attributes.getDictionary(odsState.getContext()), nullptr)))
::llvm::report_fatal_error("Property conversion failed.");
}
}
DeallocOp DeallocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
auto __res__ = ::llvm::dyn_cast<DeallocOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
DeallocOp DeallocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
}
void DeallocOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
odsState.addOperands(operands);
odsState.addAttributes(attributes);
if (!attributes.empty()) {
(void)odsState.getOrAddProperties<DeallocOp::Properties>();
::mlir::PropertyRef properties = odsState.getRawProperties();
std::optional<::mlir::RegisteredOperationName> info =
odsState.name.getRegisteredInfo();
if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties,
odsState.attributes.getDictionary(odsState.getContext()), nullptr)))
::llvm::report_fatal_error("Property conversion failed.");
}
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
if (::mlir::succeeded(DeallocOp::inferReturnTypes(odsBuilder.getContext(),
odsState.location, 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).");
}
}
DeallocOp DeallocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
auto __res__ = ::llvm::dyn_cast<DeallocOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
DeallocOp DeallocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
return create(builder, builder.getLoc(), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
}
void DeallocOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
odsState.addOperands(operands);
odsState.useProperties(const_cast<Properties&>(properties));
odsState.addAttributes(discardableAttributes);
odsState.addTypes(resultTypes);
}
DeallocOp DeallocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
auto __res__ = ::llvm::dyn_cast<DeallocOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
DeallocOp DeallocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
}
void DeallocOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
odsState.addOperands(operands);
odsState.useProperties(const_cast<Properties &>(properties));
odsState.addAttributes(discardableAttributes);
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
if (::mlir::succeeded(DeallocOp::inferReturnTypes(odsBuilder.getContext(),
odsState.location, 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).");
}
}
DeallocOp DeallocOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
auto __res__ = ::llvm::dyn_cast<DeallocOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
DeallocOp DeallocOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
return create(builder, builder.getLoc(), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
}
::llvm::LogicalResult DeallocOp::verifyInvariantsImpl() {
{
unsigned index = 0; (void)index;
auto valueGroup0 = getODSOperands(0);
for (auto v : valueGroup0) {
if (::mlir::failed(__mlir_ods_local_type_constraint_BufferizationOps5(*this, v.getType(), "operand", index++)))
return ::mlir::failure();
}
auto valueGroup1 = getODSOperands(1);
for (auto v : valueGroup1) {
if (::mlir::failed(__mlir_ods_local_type_constraint_BufferizationOps6(*this, v.getType(), "operand", index++)))
return ::mlir::failure();
}
auto valueGroup2 = getODSOperands(2);
for (auto v : valueGroup2) {
if (::mlir::failed(__mlir_ods_local_type_constraint_BufferizationOps5(*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_BufferizationOps6(*this, v.getType(), "result", index++)))
return ::mlir::failure();
}
}
return ::mlir::success();
}
::llvm::LogicalResult DeallocOp::verifyInvariants() {
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
return ::mlir::success();
return ::mlir::failure();
}
::mlir::ParseResult DeallocOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> memrefsOperands;
::llvm::SMLoc memrefsOperandsLoc;
(void)memrefsOperandsLoc;
::llvm::SmallVector<::mlir::Type, 1> memrefsTypes;
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> conditionsOperands;
::llvm::SMLoc conditionsOperandsLoc;
(void)conditionsOperandsLoc;
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> retainedOperands;
::llvm::SMLoc retainedOperandsLoc;
(void)retainedOperandsLoc;
::llvm::SmallVector<::mlir::Type, 1> retainedTypes;
if (::mlir::succeeded(parser.parseOptionalLParen())) {
memrefsOperandsLoc = parser.getCurrentLocation();
if (parser.parseOperandList(memrefsOperands))
return ::mlir::failure();
if (parser.parseColon())
return ::mlir::failure();
if (parser.parseTypeList(memrefsTypes))
return ::mlir::failure();
if (parser.parseRParen())
return ::mlir::failure();
if (parser.parseKeyword("if"))
return ::mlir::failure();
if (parser.parseLParen())
return ::mlir::failure();
conditionsOperandsLoc = parser.getCurrentLocation();
if (parser.parseOperandList(conditionsOperands))
return ::mlir::failure();
if (parser.parseRParen())
return ::mlir::failure();
}
if (::mlir::succeeded(parser.parseOptionalKeyword("retain"))) {
if (parser.parseLParen())
return ::mlir::failure();
retainedOperandsLoc = parser.getCurrentLocation();
if (parser.parseOperandList(retainedOperands))
return ::mlir::failure();
if (parser.parseColon())
return ::mlir::failure();
if (parser.parseTypeList(retainedTypes))
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();
}
::llvm::copy(::llvm::ArrayRef<int32_t>({static_cast<int32_t>(memrefsOperands.size()), static_cast<int32_t>(conditionsOperands.size()), static_cast<int32_t>(retainedOperands.size())}), result.getOrAddProperties<DeallocOp::Properties>().operandSegmentSizes.begin());
::mlir::Type odsBuildableType0 = parser.getBuilder().getIntegerType(1);
if (parser.resolveOperands(memrefsOperands, memrefsTypes, memrefsOperandsLoc, result.operands))
return ::mlir::failure();
if (parser.resolveOperands(conditionsOperands, odsBuildableType0, conditionsOperandsLoc, result.operands))
return ::mlir::failure();
if (parser.resolveOperands(retainedOperands, retainedTypes, retainedOperandsLoc, result.operands))
return ::mlir::failure();
::llvm::SmallVector<::mlir::Type> inferredReturnTypes;
if (::mlir::failed(DeallocOp::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 DeallocOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
if (!getMemrefs().empty()) {
_odsPrinter << ' ';
_odsPrinter << "(";
_odsPrinter << getMemrefs();
_odsPrinter << ' ' << ":";
_odsPrinter << ' ';
_odsPrinter << getMemrefs().getTypes();
_odsPrinter << ")";
_odsPrinter << ' ' << "if";
_odsPrinter << ' ';
_odsPrinter << "(";
_odsPrinter << getConditions();
_odsPrinter << ")";
}
if (!getRetained().empty()) {
_odsPrinter << ' ' << "retain";
_odsPrinter << ' ';
_odsPrinter << "(";
_odsPrinter << getRetained();
_odsPrinter << ' ' << ":";
_odsPrinter << ' ';
_odsPrinter << getRetained().getTypes();
_odsPrinter << ")";
}
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
elidedAttrs.push_back("operandSegmentSizes");
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
}
} // namespace mlir::bufferization
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::bufferization::DeallocOp)
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::bufferization::detail::DeallocOpGenericAdaptorBase::Properties)
namespace mlir::bufferization {
//===----------------------------------------------------------------------===//
// ::mlir::bufferization::DeallocTensorOp definitions
//===----------------------------------------------------------------------===//
namespace detail {
DeallocTensorOpGenericAdaptorBase::DeallocTensorOpGenericAdaptorBase(DeallocTensorOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
} // namespace detail
DeallocTensorOpAdaptor::DeallocTensorOpAdaptor(DeallocTensorOp op) : DeallocTensorOpGenericAdaptor(op->getOperands(), op) {}
::llvm::LogicalResult DeallocTensorOpAdaptor::verify(::mlir::Location loc) {
return ::mlir::success();
}
::llvm::LogicalResult DeallocTensorOp::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();
}
return ::mlir::success();
}
::mlir::Attribute DeallocTensorOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
::mlir::Builder odsBuilder{ctx};
if (!attrs.empty())
return odsBuilder.getDictionaryAttr(attrs);
return {};
}
llvm::hash_code DeallocTensorOp::computePropertiesHash(const Properties &prop) {
using llvm::hash_value;
return llvm::hash_combine();
}
std::optional<mlir::Attribute> DeallocTensorOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
return std::nullopt;
}
void DeallocTensorOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
}
void DeallocTensorOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
}
::llvm::LogicalResult DeallocTensorOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
return ::mlir::success();
}
void DeallocTensorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value tensor) {
odsState.addOperands(tensor);
}
DeallocTensorOp DeallocTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value tensor) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(tensor)>(tensor));
auto __res__ = ::llvm::dyn_cast<DeallocTensorOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
DeallocTensorOp DeallocTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value tensor) {
return create(builder, builder.getLoc(), std::forward<decltype(tensor)>(tensor));
}
void DeallocTensorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tensor) {
odsState.addOperands(tensor);
assert(resultTypes.size() == 0u && "mismatched number of results");
odsState.addTypes(resultTypes);
}
DeallocTensorOp DeallocTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value tensor) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(tensor)>(tensor));
auto __res__ = ::llvm::dyn_cast<DeallocTensorOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
DeallocTensorOp DeallocTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value tensor) {
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(tensor)>(tensor));
}
void DeallocTensorOp::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);
}
DeallocTensorOp DeallocTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
auto __res__ = ::llvm::dyn_cast<DeallocTensorOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
DeallocTensorOp DeallocTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
}
void DeallocTensorOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
assert(operands.size() == 1u && "mismatched number of parameters");
odsState.addOperands(operands);
odsState.useProperties(const_cast<Properties&>(properties));
odsState.addAttributes(discardableAttributes);
assert(resultTypes.size() == 0u && "mismatched number of return types");
odsState.addTypes(resultTypes);
}
DeallocTensorOp DeallocTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
auto __res__ = ::llvm::dyn_cast<DeallocTensorOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
DeallocTensorOp DeallocTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
}
::llvm::LogicalResult DeallocTensorOp::verifyInvariantsImpl() {
{
unsigned index = 0; (void)index;
auto valueGroup0 = getODSOperands(0);
for (auto v : valueGroup0) {
if (::mlir::failed(__mlir_ods_local_type_constraint_BufferizationOps2(*this, v.getType(), "operand", index++)))
return ::mlir::failure();
}
}
return ::mlir::success();
}
::llvm::LogicalResult DeallocTensorOp::verifyInvariants() {
return verifyInvariantsImpl();
}
::mlir::ParseResult DeallocTensorOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
::mlir::OpAsmParser::UnresolvedOperand tensorRawOperand{};
::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> tensorOperands(&tensorRawOperand, 1); ::llvm::SMLoc tensorOperandsLoc;
(void)tensorOperandsLoc;
::mlir::Type tensorRawType{};
::llvm::ArrayRef<::mlir::Type> tensorTypes(&tensorRawType, 1);
tensorOperandsLoc = parser.getCurrentLocation();
if (parser.parseOperand(tensorRawOperand))
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();
tensorRawType = type;
}
if (parser.resolveOperands(tensorOperands, tensorTypes, tensorOperandsLoc, result.operands))
return ::mlir::failure();
return ::mlir::success();
}
void DeallocTensorOp::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;
}
}
} // namespace mlir::bufferization
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::bufferization::DeallocTensorOp)
namespace mlir::bufferization {
//===----------------------------------------------------------------------===//
// ::mlir::bufferization::MaterializeInDestinationOp definitions
//===----------------------------------------------------------------------===//
namespace detail {
MaterializeInDestinationOpGenericAdaptorBase::MaterializeInDestinationOpGenericAdaptorBase(MaterializeInDestinationOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
::mlir::UnitAttr MaterializeInDestinationOpGenericAdaptorBase::getRestrictAttr() {
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().restrict);
if (!attr)
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
return attr;
}
bool MaterializeInDestinationOpGenericAdaptorBase::getRestrict() {
auto attr = getRestrictAttr();
if (!attr)
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
return attr != nullptr;
}
::mlir::UnitAttr MaterializeInDestinationOpGenericAdaptorBase::getWritableAttr() {
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().writable);
if (!attr)
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
return attr;
}
bool MaterializeInDestinationOpGenericAdaptorBase::getWritable() {
auto attr = getWritableAttr();
if (!attr)
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
return attr != nullptr;
}
} // namespace detail
MaterializeInDestinationOpAdaptor::MaterializeInDestinationOpAdaptor(MaterializeInDestinationOp op) : MaterializeInDestinationOpGenericAdaptor(op->getOperands(), op) {}
::llvm::LogicalResult MaterializeInDestinationOpAdaptor::verify(::mlir::Location loc) {
auto tblgen_restrict = getProperties().restrict; (void)tblgen_restrict;
auto tblgen_writable = getProperties().writable; (void)tblgen_writable;
if (tblgen_restrict && !((::llvm::isa<::mlir::UnitAttr>(tblgen_restrict))))
return emitError(loc, "'bufferization.materialize_in_destination' op attribute 'restrict' failed to satisfy constraint: unit attribute");
if (tblgen_writable && !((::llvm::isa<::mlir::UnitAttr>(tblgen_writable))))
return emitError(loc, "'bufferization.materialize_in_destination' op attribute 'writable' failed to satisfy constraint: unit attribute");
return ::mlir::success();
}
std::pair<unsigned, unsigned> MaterializeInDestinationOp::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};
}
::llvm::LogicalResult MaterializeInDestinationOp::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.restrict;
auto attr = dict.get("restrict");
if (attr) {
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
if (convertedAttr) {
propStorage = convertedAttr;
} else {
emitError() << "Invalid attribute `restrict` in property conversion: " << attr;
return ::mlir::failure();
}
}
}
{
auto &propStorage = prop.writable;
auto attr = dict.get("writable");
if (attr) {
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
if (convertedAttr) {
propStorage = convertedAttr;
} else {
emitError() << "Invalid attribute `writable` in property conversion: " << attr;
return ::mlir::failure();
}
}
}
return ::mlir::success();
}
::mlir::Attribute MaterializeInDestinationOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
::mlir::Builder odsBuilder{ctx};
{
const auto &propStorage = prop.restrict;
if (propStorage)
attrs.push_back(odsBuilder.getNamedAttr("restrict",
propStorage));
}
{
const auto &propStorage = prop.writable;
if (propStorage)
attrs.push_back(odsBuilder.getNamedAttr("writable",
propStorage));
}
if (!attrs.empty())
return odsBuilder.getDictionaryAttr(attrs);
return {};
}
llvm::hash_code MaterializeInDestinationOp::computePropertiesHash(const Properties &prop) {
using llvm::hash_value;
return llvm::hash_combine(
llvm::hash_value(prop.restrict.getAsOpaquePointer()),
llvm::hash_value(prop.writable.getAsOpaquePointer()));
}
std::optional<mlir::Attribute> MaterializeInDestinationOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
if (name == "restrict")
return prop.restrict;
if (name == "writable")
return prop.writable;
return std::nullopt;
}
void MaterializeInDestinationOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
if (name == "restrict") {
prop.restrict = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.restrict)>>(value);
return;
}
if (name == "writable") {
prop.writable = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.writable)>>(value);
return;
}
}
void MaterializeInDestinationOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
if (prop.restrict) attrs.append("restrict", prop.restrict);
if (prop.writable) attrs.append("writable", prop.writable);
}
::llvm::LogicalResult MaterializeInDestinationOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
{
::mlir::Attribute attr = attrs.get(getRestrictAttrName(opName));
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_BufferizationOps2(attr, "restrict", emitError)))
return ::mlir::failure();
}
{
::mlir::Attribute attr = attrs.get(getWritableAttrName(opName));
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_BufferizationOps2(attr, "writable", emitError)))
return ::mlir::failure();
}
return ::mlir::success();
}
::llvm::LogicalResult MaterializeInDestinationOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
if (::mlir::failed(reader.readOptionalAttribute(prop.restrict)))
return ::mlir::failure();
if (::mlir::failed(reader.readOptionalAttribute(prop.writable)))
return ::mlir::failure();
return ::mlir::success();
}
void MaterializeInDestinationOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
auto &prop = getProperties(); (void)prop;
writer.writeOptionalAttribute(prop.restrict);
writer.writeOptionalAttribute(prop.writable);
}
bool MaterializeInDestinationOp::getRestrict() {
auto attr = getRestrictAttr();
if (!attr)
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
return attr != nullptr;
}
bool MaterializeInDestinationOp::getWritable() {
auto attr = getWritableAttr();
if (!attr)
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
return attr != nullptr;
}
void MaterializeInDestinationOp::setRestrict(bool attrValue) {
auto &odsProp = getProperties().restrict;
if (attrValue)
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
else
odsProp = nullptr;
}
void MaterializeInDestinationOp::setWritable(bool attrValue) {
auto &odsProp = getProperties().writable;
if (attrValue)
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
else
odsProp = nullptr;
}
MaterializeInDestinationOp MaterializeInDestinationOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Value source, Value dest) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(source)>(source), std::forward<decltype(dest)>(dest));
auto __res__ = ::llvm::dyn_cast<MaterializeInDestinationOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
MaterializeInDestinationOp MaterializeInDestinationOp::create(::mlir::ImplicitLocOpBuilder &builder, Value source, Value dest) {
return create(builder, builder.getLoc(), std::forward<decltype(source)>(source), std::forward<decltype(dest)>(dest));
}
void MaterializeInDestinationOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Type result, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::UnitAttr restrict, /*optional*/::mlir::UnitAttr writable) {
odsState.addOperands(source);
odsState.addOperands(dest);
if (restrict) {
odsState.getOrAddProperties<Properties>().restrict = restrict;
}
if (writable) {
odsState.getOrAddProperties<Properties>().writable = writable;
}
if (result)
odsState.addTypes(result);
}
MaterializeInDestinationOp MaterializeInDestinationOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::Type result, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::UnitAttr restrict, /*optional*/::mlir::UnitAttr writable) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(result)>(result), std::forward<decltype(source)>(source), std::forward<decltype(dest)>(dest), std::forward<decltype(restrict)>(restrict), std::forward<decltype(writable)>(writable));
auto __res__ = ::llvm::dyn_cast<MaterializeInDestinationOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
MaterializeInDestinationOp MaterializeInDestinationOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::Type result, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::UnitAttr restrict, /*optional*/::mlir::UnitAttr writable) {
return create(builder, builder.getLoc(), std::forward<decltype(result)>(result), std::forward<decltype(source)>(source), std::forward<decltype(dest)>(dest), std::forward<decltype(restrict)>(restrict), std::forward<decltype(writable)>(writable));
}
void MaterializeInDestinationOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::UnitAttr restrict, /*optional*/::mlir::UnitAttr writable) {
odsState.addOperands(source);
odsState.addOperands(dest);
if (restrict) {
odsState.getOrAddProperties<Properties>().restrict = restrict;
}
if (writable) {
odsState.getOrAddProperties<Properties>().writable = writable;
}
odsState.addTypes(resultTypes);
}
MaterializeInDestinationOp MaterializeInDestinationOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::UnitAttr restrict, /*optional*/::mlir::UnitAttr writable) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(source)>(source), std::forward<decltype(dest)>(dest), std::forward<decltype(restrict)>(restrict), std::forward<decltype(writable)>(writable));
auto __res__ = ::llvm::dyn_cast<MaterializeInDestinationOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
MaterializeInDestinationOp MaterializeInDestinationOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, /*optional*/::mlir::UnitAttr restrict, /*optional*/::mlir::UnitAttr writable) {
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(source)>(source), std::forward<decltype(dest)>(dest), std::forward<decltype(restrict)>(restrict), std::forward<decltype(writable)>(writable));
}
void MaterializeInDestinationOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, /*optional*/::mlir::Type result, ::mlir::Value source, ::mlir::Value dest, /*optional*/bool restrict, /*optional*/bool writable) {
odsState.addOperands(source);
odsState.addOperands(dest);
if (restrict) {
odsState.getOrAddProperties<Properties>().restrict = ((restrict) ? odsBuilder.getUnitAttr() : nullptr);
}
if (writable) {
odsState.getOrAddProperties<Properties>().writable = ((writable) ? odsBuilder.getUnitAttr() : nullptr);
}
if (result)
odsState.addTypes(result);
}
MaterializeInDestinationOp MaterializeInDestinationOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, /*optional*/::mlir::Type result, ::mlir::Value source, ::mlir::Value dest, /*optional*/bool restrict, /*optional*/bool writable) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(result)>(result), std::forward<decltype(source)>(source), std::forward<decltype(dest)>(dest), std::forward<decltype(restrict)>(restrict), std::forward<decltype(writable)>(writable));
auto __res__ = ::llvm::dyn_cast<MaterializeInDestinationOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
MaterializeInDestinationOp MaterializeInDestinationOp::create(::mlir::ImplicitLocOpBuilder &builder, /*optional*/::mlir::Type result, ::mlir::Value source, ::mlir::Value dest, /*optional*/bool restrict, /*optional*/bool writable) {
return create(builder, builder.getLoc(), std::forward<decltype(result)>(result), std::forward<decltype(source)>(source), std::forward<decltype(dest)>(dest), std::forward<decltype(restrict)>(restrict), std::forward<decltype(writable)>(writable));
}
void MaterializeInDestinationOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, /*optional*/bool restrict, /*optional*/bool writable) {
odsState.addOperands(source);
odsState.addOperands(dest);
if (restrict) {
odsState.getOrAddProperties<Properties>().restrict = ((restrict) ? odsBuilder.getUnitAttr() : nullptr);
}
if (writable) {
odsState.getOrAddProperties<Properties>().writable = ((writable) ? odsBuilder.getUnitAttr() : nullptr);
}
odsState.addTypes(resultTypes);
}
MaterializeInDestinationOp MaterializeInDestinationOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, /*optional*/bool restrict, /*optional*/bool writable) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(source)>(source), std::forward<decltype(dest)>(dest), std::forward<decltype(restrict)>(restrict), std::forward<decltype(writable)>(writable));
auto __res__ = ::llvm::dyn_cast<MaterializeInDestinationOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
MaterializeInDestinationOp MaterializeInDestinationOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value source, ::mlir::Value dest, /*optional*/bool restrict, /*optional*/bool writable) {
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(source)>(source), std::forward<decltype(dest)>(dest), std::forward<decltype(restrict)>(restrict), std::forward<decltype(writable)>(writable));
}
void MaterializeInDestinationOp::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);
if (!attributes.empty()) {
(void)odsState.getOrAddProperties<MaterializeInDestinationOp::Properties>();
::mlir::PropertyRef properties = odsState.getRawProperties();
std::optional<::mlir::RegisteredOperationName> info =
odsState.name.getRegisteredInfo();
if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties,
odsState.attributes.getDictionary(odsState.getContext()), nullptr)))
::llvm::report_fatal_error("Property conversion failed.");
}
}
MaterializeInDestinationOp MaterializeInDestinationOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
auto __res__ = ::llvm::dyn_cast<MaterializeInDestinationOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
MaterializeInDestinationOp MaterializeInDestinationOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
}
void MaterializeInDestinationOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
assert(operands.size() == 2u && "mismatched number of parameters");
odsState.addOperands(operands);
odsState.useProperties(const_cast<Properties&>(properties));
odsState.addAttributes(discardableAttributes);
odsState.addTypes(resultTypes);
}
MaterializeInDestinationOp MaterializeInDestinationOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
auto __res__ = ::llvm::dyn_cast<MaterializeInDestinationOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
MaterializeInDestinationOp MaterializeInDestinationOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
}
::llvm::LogicalResult MaterializeInDestinationOp::verifyInvariantsImpl() {
auto tblgen_restrict = getProperties().restrict; (void)tblgen_restrict;
auto tblgen_writable = getProperties().writable; (void)tblgen_writable;
if (::mlir::failed(__mlir_ods_local_attr_constraint_BufferizationOps2(*this, tblgen_restrict, "restrict")))
return ::mlir::failure();
if (::mlir::failed(__mlir_ods_local_attr_constraint_BufferizationOps2(*this, tblgen_writable, "writable")))
return ::mlir::failure();
{
unsigned index = 0; (void)index;
auto valueGroup0 = getODSOperands(0);
for (auto v : valueGroup0) {
if (::mlir::failed(__mlir_ods_local_type_constraint_BufferizationOps2(*this, v.getType(), "operand", index++)))
return ::mlir::failure();
}
auto valueGroup1 = getODSOperands(1);
for (auto v : valueGroup1) {
if (::mlir::failed(__mlir_ods_local_type_constraint_BufferizationOps7(*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_BufferizationOps2(*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");
return ::mlir::success();
}
::llvm::LogicalResult MaterializeInDestinationOp::verifyInvariants() {
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
return ::mlir::success();
return ::mlir::failure();
}
::mlir::ParseResult MaterializeInDestinationOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
::mlir::OpAsmParser::UnresolvedOperand sourceRawOperand{};
::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> sourceOperands(&sourceRawOperand, 1); ::llvm::SMLoc sourceOperandsLoc;
(void)sourceOperandsLoc;
::mlir::OpAsmParser::UnresolvedOperand destRawOperand{};
::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> destOperands(&destRawOperand, 1); ::llvm::SMLoc destOperandsLoc;
(void)destOperandsLoc;
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
::llvm::ArrayRef<::mlir::Type> allResultTypes;
sourceOperandsLoc = parser.getCurrentLocation();
if (parser.parseOperand(sourceRawOperand))
return ::mlir::failure();
if (parser.parseKeyword("in"))
return ::mlir::failure();
if (::mlir::succeeded(parser.parseOptionalKeyword("restrict"))) {
result.getOrAddProperties<MaterializeInDestinationOp::Properties>().restrict = parser.getBuilder().getUnitAttr(); }
if (::mlir::succeeded(parser.parseOptionalKeyword("writable"))) {
result.getOrAddProperties<MaterializeInDestinationOp::Properties>().writable = parser.getBuilder().getUnitAttr(); }
destOperandsLoc = parser.getCurrentLocation();
if (parser.parseOperand(destRawOperand))
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(::llvm::concat<const ::mlir::OpAsmParser::UnresolvedOperand>(sourceOperands, destOperands), allOperandTypes, parser.getNameLoc(), result.operands))
return ::mlir::failure();
return ::mlir::success();
}
void MaterializeInDestinationOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
_odsPrinter << ' ';
_odsPrinter << getSource();
_odsPrinter << ' ' << "in";
if ((getRestrictAttr() && getRestrictAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr))) {
_odsPrinter << ' ' << "restrict";
}
if ((getWritableAttr() && getWritableAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr))) {
_odsPrinter << ' ' << "writable";
}
_odsPrinter << ' ';
_odsPrinter << getDest();
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
elidedAttrs.push_back("restrict");
elidedAttrs.push_back("writable");
{
::mlir::Builder odsBuilder(getContext());
::mlir::Attribute attr = getRestrictAttr();
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
elidedAttrs.push_back("restrict");
}
{
::mlir::Builder odsBuilder(getContext());
::mlir::Attribute attr = getWritableAttr();
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
elidedAttrs.push_back("writable");
}
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
_odsPrinter << ' ' << ":";
_odsPrinter << ' ';
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
}
} // namespace mlir::bufferization
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::bufferization::MaterializeInDestinationOp)
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::bufferization::detail::MaterializeInDestinationOpGenericAdaptorBase::Properties)
namespace mlir::bufferization {
//===----------------------------------------------------------------------===//
// ::mlir::bufferization::ToBufferOp definitions
//===----------------------------------------------------------------------===//
namespace detail {
ToBufferOpGenericAdaptorBase::ToBufferOpGenericAdaptorBase(ToBufferOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
::mlir::UnitAttr ToBufferOpGenericAdaptorBase::getReadOnlyAttr() {
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().read_only);
if (!attr)
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
return attr;
}
bool ToBufferOpGenericAdaptorBase::getReadOnly() {
auto attr = getReadOnlyAttr();
if (!attr)
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
return attr != nullptr;
}
} // namespace detail
ToBufferOpAdaptor::ToBufferOpAdaptor(ToBufferOp op) : ToBufferOpGenericAdaptor(op->getOperands(), op) {}
::llvm::LogicalResult ToBufferOpAdaptor::verify(::mlir::Location loc) {
auto tblgen_read_only = getProperties().read_only; (void)tblgen_read_only;
if (tblgen_read_only && !((::llvm::isa<::mlir::UnitAttr>(tblgen_read_only))))
return emitError(loc, "'bufferization.to_buffer' op attribute 'read_only' failed to satisfy constraint: unit attribute");
return ::mlir::success();
}
::llvm::LogicalResult ToBufferOp::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.read_only;
auto attr = dict.get("read_only");
if (attr) {
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
if (convertedAttr) {
propStorage = convertedAttr;
} else {
emitError() << "Invalid attribute `read_only` in property conversion: " << attr;
return ::mlir::failure();
}
}
}
return ::mlir::success();
}
::mlir::Attribute ToBufferOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
::mlir::Builder odsBuilder{ctx};
{
const auto &propStorage = prop.read_only;
if (propStorage)
attrs.push_back(odsBuilder.getNamedAttr("read_only",
propStorage));
}
if (!attrs.empty())
return odsBuilder.getDictionaryAttr(attrs);
return {};
}
llvm::hash_code ToBufferOp::computePropertiesHash(const Properties &prop) {
using llvm::hash_value;
return llvm::hash_combine(
llvm::hash_value(prop.read_only.getAsOpaquePointer()));
}
std::optional<mlir::Attribute> ToBufferOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
if (name == "read_only")
return prop.read_only;
return std::nullopt;
}
void ToBufferOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
if (name == "read_only") {
prop.read_only = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.read_only)>>(value);
return;
}
}
void ToBufferOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
if (prop.read_only) attrs.append("read_only", prop.read_only);
}
::llvm::LogicalResult ToBufferOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
{
::mlir::Attribute attr = attrs.get(getReadOnlyAttrName(opName));
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_BufferizationOps2(attr, "read_only", emitError)))
return ::mlir::failure();
}
return ::mlir::success();
}
::llvm::LogicalResult ToBufferOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
if (::mlir::failed(reader.readOptionalAttribute(prop.read_only)))
return ::mlir::failure();
return ::mlir::success();
}
void ToBufferOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
auto &prop = getProperties(); (void)prop;
writer.writeOptionalAttribute(prop.read_only);
}
bool ToBufferOp::getReadOnly() {
auto attr = getReadOnlyAttr();
if (!attr)
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
return attr != nullptr;
}
void ToBufferOp::setReadOnly(bool attrValue) {
auto &odsProp = getProperties().read_only;
if (attrValue)
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
else
odsProp = nullptr;
}
void ToBufferOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type buffer, ::mlir::Value tensor, /*optional*/::mlir::UnitAttr read_only) {
odsState.addOperands(tensor);
if (read_only) {
odsState.getOrAddProperties<Properties>().read_only = read_only;
}
odsState.addTypes(buffer);
}
ToBufferOp ToBufferOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type buffer, ::mlir::Value tensor, /*optional*/::mlir::UnitAttr read_only) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(buffer)>(buffer), std::forward<decltype(tensor)>(tensor), std::forward<decltype(read_only)>(read_only));
auto __res__ = ::llvm::dyn_cast<ToBufferOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
ToBufferOp ToBufferOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type buffer, ::mlir::Value tensor, /*optional*/::mlir::UnitAttr read_only) {
return create(builder, builder.getLoc(), std::forward<decltype(buffer)>(buffer), std::forward<decltype(tensor)>(tensor), std::forward<decltype(read_only)>(read_only));
}
void ToBufferOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tensor, /*optional*/::mlir::UnitAttr read_only) {
odsState.addOperands(tensor);
if (read_only) {
odsState.getOrAddProperties<Properties>().read_only = read_only;
}
assert(resultTypes.size() == 1u && "mismatched number of results");
odsState.addTypes(resultTypes);
}
ToBufferOp ToBufferOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value tensor, /*optional*/::mlir::UnitAttr read_only) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(tensor)>(tensor), std::forward<decltype(read_only)>(read_only));
auto __res__ = ::llvm::dyn_cast<ToBufferOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
ToBufferOp ToBufferOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value tensor, /*optional*/::mlir::UnitAttr read_only) {
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(tensor)>(tensor), std::forward<decltype(read_only)>(read_only));
}
void ToBufferOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type buffer, ::mlir::Value tensor, /*optional*/bool read_only) {
odsState.addOperands(tensor);
if (read_only) {
odsState.getOrAddProperties<Properties>().read_only = ((read_only) ? odsBuilder.getUnitAttr() : nullptr);
}
odsState.addTypes(buffer);
}
ToBufferOp ToBufferOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type buffer, ::mlir::Value tensor, /*optional*/bool read_only) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(buffer)>(buffer), std::forward<decltype(tensor)>(tensor), std::forward<decltype(read_only)>(read_only));
auto __res__ = ::llvm::dyn_cast<ToBufferOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
ToBufferOp ToBufferOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type buffer, ::mlir::Value tensor, /*optional*/bool read_only) {
return create(builder, builder.getLoc(), std::forward<decltype(buffer)>(buffer), std::forward<decltype(tensor)>(tensor), std::forward<decltype(read_only)>(read_only));
}
void ToBufferOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value tensor, /*optional*/bool read_only) {
odsState.addOperands(tensor);
if (read_only) {
odsState.getOrAddProperties<Properties>().read_only = ((read_only) ? odsBuilder.getUnitAttr() : nullptr);
}
assert(resultTypes.size() == 1u && "mismatched number of results");
odsState.addTypes(resultTypes);
}
ToBufferOp ToBufferOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value tensor, /*optional*/bool read_only) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(tensor)>(tensor), std::forward<decltype(read_only)>(read_only));
auto __res__ = ::llvm::dyn_cast<ToBufferOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
ToBufferOp ToBufferOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value tensor, /*optional*/bool read_only) {
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(tensor)>(tensor), std::forward<decltype(read_only)>(read_only));
}
void ToBufferOp::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);
if (!attributes.empty()) {
(void)odsState.getOrAddProperties<ToBufferOp::Properties>();
::mlir::PropertyRef properties = odsState.getRawProperties();
std::optional<::mlir::RegisteredOperationName> info =
odsState.name.getRegisteredInfo();
if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties,
odsState.attributes.getDictionary(odsState.getContext()), nullptr)))
::llvm::report_fatal_error("Property conversion failed.");
}
}
ToBufferOp ToBufferOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
auto __res__ = ::llvm::dyn_cast<ToBufferOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
ToBufferOp ToBufferOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
}
void ToBufferOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
assert(operands.size() == 1u && "mismatched number of parameters");
odsState.addOperands(operands);
odsState.useProperties(const_cast<Properties&>(properties));
odsState.addAttributes(discardableAttributes);
assert(resultTypes.size() == 1u && "mismatched number of return types");
odsState.addTypes(resultTypes);
}
ToBufferOp ToBufferOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
auto __res__ = ::llvm::dyn_cast<ToBufferOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
ToBufferOp ToBufferOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
}
::llvm::LogicalResult ToBufferOp::verifyInvariantsImpl() {
auto tblgen_read_only = getProperties().read_only; (void)tblgen_read_only;
if (::mlir::failed(__mlir_ods_local_attr_constraint_BufferizationOps2(*this, tblgen_read_only, "read_only")))
return ::mlir::failure();
{
unsigned index = 0; (void)index;
auto valueGroup0 = getODSOperands(0);
for (auto v : valueGroup0) {
if (::mlir::failed(__mlir_ods_local_type_constraint_BufferizationOps8(*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_BufferizationOps9(*this, v.getType(), "result", index++)))
return ::mlir::failure();
}
}
if (!((::mlir::bufferization::detail::typesMatchAfterBufferization((*this->getOperation()), (*this->getODSOperands(0).begin()), (*this->getODSResults(0).begin())))))
return emitOpError("failed to verify that specified tensor and buffer types match");
return ::mlir::success();
}
::llvm::LogicalResult ToBufferOp::verifyInvariants() {
return verifyInvariantsImpl();
}
::mlir::ParseResult ToBufferOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
::mlir::OpAsmParser::UnresolvedOperand tensorRawOperand{};
::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> tensorOperands(&tensorRawOperand, 1); ::llvm::SMLoc tensorOperandsLoc;
(void)tensorOperandsLoc;
::mlir::Type tensorRawType{};
::llvm::ArrayRef<::mlir::Type> tensorTypes(&tensorRawType, 1);
::mlir::Type bufferRawType{};
::llvm::ArrayRef<::mlir::Type> bufferTypes(&bufferRawType, 1);
tensorOperandsLoc = parser.getCurrentLocation();
if (parser.parseOperand(tensorRawOperand))
return ::mlir::failure();
if (::mlir::succeeded(parser.parseOptionalKeyword("read_only"))) {
result.getOrAddProperties<ToBufferOp::Properties>().read_only = 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::bufferization::TensorLikeType type;
if (parser.parseCustomTypeWithFallback(type))
return ::mlir::failure();
tensorRawType = type;
}
if (parser.parseKeyword("to"))
return ::mlir::failure();
{
::mlir::bufferization::BufferLikeType type;
if (parser.parseCustomTypeWithFallback(type))
return ::mlir::failure();
bufferRawType = type;
}
result.addTypes(bufferTypes);
if (parser.resolveOperands(tensorOperands, tensorTypes, tensorOperandsLoc, result.operands))
return ::mlir::failure();
return ::mlir::success();
}
void ToBufferOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
_odsPrinter << ' ';
_odsPrinter << getTensor();
if ((getReadOnlyAttr() && getReadOnlyAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr))) {
_odsPrinter << ' ' << "read_only";
}
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
elidedAttrs.push_back("read_only");
{
::mlir::Builder odsBuilder(getContext());
::mlir::Attribute attr = getReadOnlyAttr();
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
elidedAttrs.push_back("read_only");
}
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
_odsPrinter << ' ' << ":";
_odsPrinter << ' ';
{
auto type = getTensor().getType();
if (auto validType = ::llvm::dyn_cast<::mlir::bufferization::TensorLikeType>(type))
_odsPrinter.printStrippedAttrOrType(validType);
else
_odsPrinter << type;
}
_odsPrinter << ' ' << "to";
_odsPrinter << ' ';
{
auto type = getBuffer().getType();
if (auto validType = ::llvm::dyn_cast<::mlir::bufferization::BufferLikeType>(type))
_odsPrinter.printStrippedAttrOrType(validType);
else
_odsPrinter << type;
}
}
void ToBufferOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
}
} // namespace mlir::bufferization
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::bufferization::ToBufferOp)
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::bufferization::detail::ToBufferOpGenericAdaptorBase::Properties)
namespace mlir::bufferization {
//===----------------------------------------------------------------------===//
// ::mlir::bufferization::ToTensorOp definitions
//===----------------------------------------------------------------------===//
namespace detail {
ToTensorOpGenericAdaptorBase::ToTensorOpGenericAdaptorBase(ToTensorOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
::mlir::UnitAttr ToTensorOpGenericAdaptorBase::getRestrictAttr() {
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().restrict);
if (!attr)
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
return attr;
}
bool ToTensorOpGenericAdaptorBase::getRestrict() {
auto attr = getRestrictAttr();
if (!attr)
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
return attr != nullptr;
}
::mlir::UnitAttr ToTensorOpGenericAdaptorBase::getWritableAttr() {
auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().writable);
if (!attr)
attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
return attr;
}
bool ToTensorOpGenericAdaptorBase::getWritable() {
auto attr = getWritableAttr();
if (!attr)
return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
return attr != nullptr;
}
} // namespace detail
ToTensorOpAdaptor::ToTensorOpAdaptor(ToTensorOp op) : ToTensorOpGenericAdaptor(op->getOperands(), op) {}
::llvm::LogicalResult ToTensorOpAdaptor::verify(::mlir::Location loc) {
auto tblgen_restrict = getProperties().restrict; (void)tblgen_restrict;
auto tblgen_writable = getProperties().writable; (void)tblgen_writable;
if (tblgen_restrict && !((::llvm::isa<::mlir::UnitAttr>(tblgen_restrict))))
return emitError(loc, "'bufferization.to_tensor' op attribute 'restrict' failed to satisfy constraint: unit attribute");
if (tblgen_writable && !((::llvm::isa<::mlir::UnitAttr>(tblgen_writable))))
return emitError(loc, "'bufferization.to_tensor' op attribute 'writable' failed to satisfy constraint: unit attribute");
return ::mlir::success();
}
::llvm::LogicalResult ToTensorOp::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.restrict;
auto attr = dict.get("restrict");
if (attr) {
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
if (convertedAttr) {
propStorage = convertedAttr;
} else {
emitError() << "Invalid attribute `restrict` in property conversion: " << attr;
return ::mlir::failure();
}
}
}
{
auto &propStorage = prop.writable;
auto attr = dict.get("writable");
if (attr) {
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
if (convertedAttr) {
propStorage = convertedAttr;
} else {
emitError() << "Invalid attribute `writable` in property conversion: " << attr;
return ::mlir::failure();
}
}
}
return ::mlir::success();
}
::mlir::Attribute ToTensorOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
::mlir::Builder odsBuilder{ctx};
{
const auto &propStorage = prop.restrict;
if (propStorage)
attrs.push_back(odsBuilder.getNamedAttr("restrict",
propStorage));
}
{
const auto &propStorage = prop.writable;
if (propStorage)
attrs.push_back(odsBuilder.getNamedAttr("writable",
propStorage));
}
if (!attrs.empty())
return odsBuilder.getDictionaryAttr(attrs);
return {};
}
llvm::hash_code ToTensorOp::computePropertiesHash(const Properties &prop) {
using llvm::hash_value;
return llvm::hash_combine(
llvm::hash_value(prop.restrict.getAsOpaquePointer()),
llvm::hash_value(prop.writable.getAsOpaquePointer()));
}
std::optional<mlir::Attribute> ToTensorOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
if (name == "restrict")
return prop.restrict;
if (name == "writable")
return prop.writable;
return std::nullopt;
}
void ToTensorOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
if (name == "restrict") {
prop.restrict = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.restrict)>>(value);
return;
}
if (name == "writable") {
prop.writable = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.writable)>>(value);
return;
}
}
void ToTensorOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
if (prop.restrict) attrs.append("restrict", prop.restrict);
if (prop.writable) attrs.append("writable", prop.writable);
}
::llvm::LogicalResult ToTensorOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
{
::mlir::Attribute attr = attrs.get(getRestrictAttrName(opName));
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_BufferizationOps2(attr, "restrict", emitError)))
return ::mlir::failure();
}
{
::mlir::Attribute attr = attrs.get(getWritableAttrName(opName));
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_BufferizationOps2(attr, "writable", emitError)))
return ::mlir::failure();
}
return ::mlir::success();
}
::llvm::LogicalResult ToTensorOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
if (::mlir::failed(reader.readOptionalAttribute(prop.restrict)))
return ::mlir::failure();
if (::mlir::failed(reader.readOptionalAttribute(prop.writable)))
return ::mlir::failure();
return ::mlir::success();
}
void ToTensorOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
auto &prop = getProperties(); (void)prop;
writer.writeOptionalAttribute(prop.restrict);
writer.writeOptionalAttribute(prop.writable);
}
bool ToTensorOp::getRestrict() {
auto attr = getRestrictAttr();
if (!attr)
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
return attr != nullptr;
}
bool ToTensorOp::getWritable() {
auto attr = getWritableAttr();
if (!attr)
return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
return attr != nullptr;
}
void ToTensorOp::setRestrict(bool attrValue) {
auto &odsProp = getProperties().restrict;
if (attrValue)
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
else
odsProp = nullptr;
}
void ToTensorOp::setWritable(bool attrValue) {
auto &odsProp = getProperties().writable;
if (attrValue)
odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr);
else
odsProp = nullptr;
}
void ToTensorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value buffer, /*optional*/::mlir::UnitAttr restrict, /*optional*/::mlir::UnitAttr writable) {
odsState.addOperands(buffer);
if (restrict) {
odsState.getOrAddProperties<Properties>().restrict = restrict;
}
if (writable) {
odsState.getOrAddProperties<Properties>().writable = writable;
}
odsState.addTypes(result);
}
ToTensorOp ToTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value buffer, /*optional*/::mlir::UnitAttr restrict, /*optional*/::mlir::UnitAttr writable) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(result)>(result), std::forward<decltype(buffer)>(buffer), std::forward<decltype(restrict)>(restrict), std::forward<decltype(writable)>(writable));
auto __res__ = ::llvm::dyn_cast<ToTensorOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
ToTensorOp ToTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value buffer, /*optional*/::mlir::UnitAttr restrict, /*optional*/::mlir::UnitAttr writable) {
return create(builder, builder.getLoc(), std::forward<decltype(result)>(result), std::forward<decltype(buffer)>(buffer), std::forward<decltype(restrict)>(restrict), std::forward<decltype(writable)>(writable));
}
void ToTensorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value buffer, /*optional*/::mlir::UnitAttr restrict, /*optional*/::mlir::UnitAttr writable) {
odsState.addOperands(buffer);
if (restrict) {
odsState.getOrAddProperties<Properties>().restrict = restrict;
}
if (writable) {
odsState.getOrAddProperties<Properties>().writable = writable;
}
assert(resultTypes.size() == 1u && "mismatched number of results");
odsState.addTypes(resultTypes);
}
ToTensorOp ToTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value buffer, /*optional*/::mlir::UnitAttr restrict, /*optional*/::mlir::UnitAttr writable) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(buffer)>(buffer), std::forward<decltype(restrict)>(restrict), std::forward<decltype(writable)>(writable));
auto __res__ = ::llvm::dyn_cast<ToTensorOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
ToTensorOp ToTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value buffer, /*optional*/::mlir::UnitAttr restrict, /*optional*/::mlir::UnitAttr writable) {
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(buffer)>(buffer), std::forward<decltype(restrict)>(restrict), std::forward<decltype(writable)>(writable));
}
void ToTensorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value buffer, /*optional*/bool restrict, /*optional*/bool writable) {
odsState.addOperands(buffer);
if (restrict) {
odsState.getOrAddProperties<Properties>().restrict = ((restrict) ? odsBuilder.getUnitAttr() : nullptr);
}
if (writable) {
odsState.getOrAddProperties<Properties>().writable = ((writable) ? odsBuilder.getUnitAttr() : nullptr);
}
odsState.addTypes(result);
}
ToTensorOp ToTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::Value buffer, /*optional*/bool restrict, /*optional*/bool writable) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(result)>(result), std::forward<decltype(buffer)>(buffer), std::forward<decltype(restrict)>(restrict), std::forward<decltype(writable)>(writable));
auto __res__ = ::llvm::dyn_cast<ToTensorOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
ToTensorOp ToTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::Value buffer, /*optional*/bool restrict, /*optional*/bool writable) {
return create(builder, builder.getLoc(), std::forward<decltype(result)>(result), std::forward<decltype(buffer)>(buffer), std::forward<decltype(restrict)>(restrict), std::forward<decltype(writable)>(writable));
}
void ToTensorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value buffer, /*optional*/bool restrict, /*optional*/bool writable) {
odsState.addOperands(buffer);
if (restrict) {
odsState.getOrAddProperties<Properties>().restrict = ((restrict) ? odsBuilder.getUnitAttr() : nullptr);
}
if (writable) {
odsState.getOrAddProperties<Properties>().writable = ((writable) ? odsBuilder.getUnitAttr() : nullptr);
}
assert(resultTypes.size() == 1u && "mismatched number of results");
odsState.addTypes(resultTypes);
}
ToTensorOp ToTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value buffer, /*optional*/bool restrict, /*optional*/bool writable) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(buffer)>(buffer), std::forward<decltype(restrict)>(restrict), std::forward<decltype(writable)>(writable));
auto __res__ = ::llvm::dyn_cast<ToTensorOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
ToTensorOp ToTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value buffer, /*optional*/bool restrict, /*optional*/bool writable) {
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(buffer)>(buffer), std::forward<decltype(restrict)>(restrict), std::forward<decltype(writable)>(writable));
}
void ToTensorOp::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);
if (!attributes.empty()) {
(void)odsState.getOrAddProperties<ToTensorOp::Properties>();
::mlir::PropertyRef properties = odsState.getRawProperties();
std::optional<::mlir::RegisteredOperationName> info =
odsState.name.getRegisteredInfo();
if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties,
odsState.attributes.getDictionary(odsState.getContext()), nullptr)))
::llvm::report_fatal_error("Property conversion failed.");
}
}
ToTensorOp ToTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
auto __res__ = ::llvm::dyn_cast<ToTensorOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
ToTensorOp ToTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
}
void ToTensorOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
assert(operands.size() == 1u && "mismatched number of parameters");
odsState.addOperands(operands);
odsState.useProperties(const_cast<Properties&>(properties));
odsState.addAttributes(discardableAttributes);
assert(resultTypes.size() == 1u && "mismatched number of return types");
odsState.addTypes(resultTypes);
}
ToTensorOp ToTensorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
::mlir::OperationState __state__(location, getOperationName());
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
auto __res__ = ::llvm::dyn_cast<ToTensorOp>(builder.create(__state__));
assert(__res__ && "builder didn't return the right type");
return __res__;
}
ToTensorOp ToTensorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
}
::llvm::LogicalResult ToTensorOp::verifyInvariantsImpl() {
auto tblgen_restrict = getProperties().restrict; (void)tblgen_restrict;
auto tblgen_writable = getProperties().writable; (void)tblgen_writable;
if (::mlir::failed(__mlir_ods_local_attr_constraint_BufferizationOps2(*this, tblgen_restrict, "restrict")))
return ::mlir::failure();
if (::mlir::failed(__mlir_ods_local_attr_constraint_BufferizationOps2(*this, tblgen_writable, "writable")))
return ::mlir::failure();
{
unsigned index = 0; (void)index;
auto valueGroup0 = getODSOperands(0);
for (auto v : valueGroup0) {
if (::mlir::failed(__mlir_ods_local_type_constraint_BufferizationOps9(*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_BufferizationOps8(*this, v.getType(), "result", index++)))
return ::mlir::failure();
}
}
if (!((::mlir::bufferization::detail::typesMatchAfterBufferization((*this->getOperation()), (*this->getODSResults(0).begin()), (*this->getODSOperands(0).begin())))))
return emitOpError("failed to verify that specified tensor and buffer types match");
return ::mlir::success();
}
::llvm::LogicalResult ToTensorOp::verifyInvariants() {
return verifyInvariantsImpl();
}
::mlir::ParseResult ToTensorOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
::mlir::OpAsmParser::UnresolvedOperand bufferRawOperand{};
::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> bufferOperands(&bufferRawOperand, 1); ::llvm::SMLoc bufferOperandsLoc;
(void)bufferOperandsLoc;
::mlir::Type bufferRawType{};
::llvm::ArrayRef<::mlir::Type> bufferTypes(&bufferRawType, 1);
::mlir::Type resultRawType{};
::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1);
bufferOperandsLoc = parser.getCurrentLocation();
if (parser.parseOperand(bufferRawOperand))
return ::mlir::failure();
if (::mlir::succeeded(parser.parseOptionalKeyword("restrict"))) {
result.getOrAddProperties<ToTensorOp::Properties>().restrict = parser.getBuilder().getUnitAttr(); }
if (::mlir::succeeded(parser.parseOptionalKeyword("writable"))) {
result.getOrAddProperties<ToTensorOp::Properties>().writable = 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::bufferization::BufferLikeType type;
if (parser.parseCustomTypeWithFallback(type))
return ::mlir::failure();
bufferRawType = type;
}
if (parser.parseKeyword("to"))
return ::mlir::failure();
{
::mlir::bufferization::TensorLikeType type;
if (parser.parseCustomTypeWithFallback(type))
return ::mlir::failure();
resultRawType = type;
}
result.addTypes(resultTypes);
if (parser.resolveOperands(bufferOperands, bufferTypes, bufferOperandsLoc, result.operands))
return ::mlir::failure();
return ::mlir::success();
}
void ToTensorOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
_odsPrinter << ' ';
_odsPrinter << getBuffer();
if ((getRestrictAttr() && getRestrictAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr))) {
_odsPrinter << ' ' << "restrict";
}
if ((getWritableAttr() && getWritableAttr() != ((false) ? ::mlir::OpBuilder((*this)->getContext()).getUnitAttr() : nullptr))) {
_odsPrinter << ' ' << "writable";
}
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
elidedAttrs.push_back("restrict");
elidedAttrs.push_back("writable");
{
::mlir::Builder odsBuilder(getContext());
::mlir::Attribute attr = getRestrictAttr();
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
elidedAttrs.push_back("restrict");
}
{
::mlir::Builder odsBuilder(getContext());
::mlir::Attribute attr = getWritableAttr();
if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
elidedAttrs.push_back("writable");
}
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
_odsPrinter << ' ' << ":";
_odsPrinter << ' ';
{
auto type = getBuffer().getType();
if (auto validType = ::llvm::dyn_cast<::mlir::bufferization::BufferLikeType>(type))
_odsPrinter.printStrippedAttrOrType(validType);
else
_odsPrinter << type;
}
_odsPrinter << ' ' << "to";
_odsPrinter << ' ';
{
auto type = getResult().getType();
if (auto validType = ::llvm::dyn_cast<::mlir::bufferization::TensorLikeType>(type))
_odsPrinter.printStrippedAttrOrType(validType);
else
_odsPrinter << type;
}
}
void ToTensorOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
{
auto valueRange = getODSOperandIndexAndLength(0);
for (unsigned idx = valueRange.first; idx < valueRange.first + valueRange.second; idx++) {
effects.emplace_back(::mlir::MemoryEffects::Read::get(), &getOperation()->getOpOperand(idx), 0, true, ::mlir::SideEffects::DefaultResource::get());
}
}
}
} // namespace mlir::bufferization
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::bufferization::ToTensorOp)
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::bufferization::detail::ToTensorOpGenericAdaptorBase::Properties)
#endif // GET_OP_CLASSES