32483 lines
1.6 MiB
Plaintext
32483 lines
1.6 MiB
Plaintext
/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
|
|
|* *|
|
|
|* Op Definitions *|
|
|
|* *|
|
|
|* Automatically generated file, do not edit! *|
|
|
|* From: TosaOps.td *|
|
|
|* *|
|
|
\*===----------------------------------------------------------------------===*/
|
|
|
|
#ifdef GET_OP_LIST
|
|
#undef GET_OP_LIST
|
|
|
|
mlir::tosa::AbsOp,
|
|
mlir::tosa::AddOp,
|
|
mlir::tosa::AddShapeOp,
|
|
mlir::tosa::ApplyScaleOp,
|
|
mlir::tosa::ArgMaxOp,
|
|
mlir::tosa::ArithmeticRightShiftOp,
|
|
mlir::tosa::AssertEqualShapeOp,
|
|
mlir::tosa::AvgPool2dAdaptiveOp,
|
|
mlir::tosa::AvgPool2dOp,
|
|
mlir::tosa::BitwiseAndOp,
|
|
mlir::tosa::BitwiseNotOp,
|
|
mlir::tosa::BitwiseOrOp,
|
|
mlir::tosa::BitwiseXorOp,
|
|
mlir::tosa::CastFromBlockScaledOp,
|
|
mlir::tosa::CastOp,
|
|
mlir::tosa::CastToBlockScaledOp,
|
|
mlir::tosa::CeilOp,
|
|
mlir::tosa::ClampOp,
|
|
mlir::tosa::ClzOp,
|
|
mlir::tosa::ConcatOp,
|
|
mlir::tosa::ConcatShapeOp,
|
|
mlir::tosa::ConstOp,
|
|
mlir::tosa::ConstShapeOp,
|
|
mlir::tosa::Conv2DBlockScaledOp,
|
|
mlir::tosa::Conv2DOp,
|
|
mlir::tosa::Conv3DOp,
|
|
mlir::tosa::CosOp,
|
|
mlir::tosa::CustomOp,
|
|
mlir::tosa::DepthwiseConv2DOp,
|
|
mlir::tosa::DimOp,
|
|
mlir::tosa::DivCeilShapeOp,
|
|
mlir::tosa::DivFloorShapeOp,
|
|
mlir::tosa::EqualOp,
|
|
mlir::tosa::ErfOp,
|
|
mlir::tosa::Exp2ShapeOp,
|
|
mlir::tosa::ExpOp,
|
|
mlir::tosa::FFT2dOp,
|
|
mlir::tosa::FloorOp,
|
|
mlir::tosa::GatherOp,
|
|
mlir::tosa::GreaterEqualOp,
|
|
mlir::tosa::GreaterOp,
|
|
mlir::tosa::IdentityOp,
|
|
mlir::tosa::IfOp,
|
|
mlir::tosa::IntDivOp,
|
|
mlir::tosa::Log2CeilShapeOp,
|
|
mlir::tosa::Log2FloorShapeOp,
|
|
mlir::tosa::LogOp,
|
|
mlir::tosa::LogicalAndOp,
|
|
mlir::tosa::LogicalLeftShiftOp,
|
|
mlir::tosa::LogicalNotOp,
|
|
mlir::tosa::LogicalOrOp,
|
|
mlir::tosa::LogicalRightShiftOp,
|
|
mlir::tosa::LogicalXorOp,
|
|
mlir::tosa::MatMulOp,
|
|
mlir::tosa::MatmulTBlockScaledOp,
|
|
mlir::tosa::MaxPool2dAdaptiveOp,
|
|
mlir::tosa::MaxPool2dOp,
|
|
mlir::tosa::MaxShapeOp,
|
|
mlir::tosa::MaximumOp,
|
|
mlir::tosa::MinShapeOp,
|
|
mlir::tosa::MinimumOp,
|
|
mlir::tosa::ModShapeOp,
|
|
mlir::tosa::MulOp,
|
|
mlir::tosa::MulShapeOp,
|
|
mlir::tosa::NegateOp,
|
|
mlir::tosa::PadOp,
|
|
mlir::tosa::PowOp,
|
|
mlir::tosa::RFFT2dOp,
|
|
mlir::tosa::ReciprocalOp,
|
|
mlir::tosa::ReduceAllOp,
|
|
mlir::tosa::ReduceAnyOp,
|
|
mlir::tosa::ReduceMaxOp,
|
|
mlir::tosa::ReduceMinOp,
|
|
mlir::tosa::ReduceProductOp,
|
|
mlir::tosa::ReduceSumOp,
|
|
mlir::tosa::RescaleOp,
|
|
mlir::tosa::ReshapeBlockScaledOp,
|
|
mlir::tosa::ReshapeOp,
|
|
mlir::tosa::ResizeOp,
|
|
mlir::tosa::ReverseOp,
|
|
mlir::tosa::RowGatherBlockScaledOp,
|
|
mlir::tosa::RowGatherOp,
|
|
mlir::tosa::RsqrtOp,
|
|
mlir::tosa::ScatterOp,
|
|
mlir::tosa::SelectOp,
|
|
mlir::tosa::SigmoidOp,
|
|
mlir::tosa::SinOp,
|
|
mlir::tosa::SliceOp,
|
|
mlir::tosa::SliceShapeOp,
|
|
mlir::tosa::SubOp,
|
|
mlir::tosa::SubShapeOp,
|
|
mlir::tosa::TableOp,
|
|
mlir::tosa::TanhOp,
|
|
mlir::tosa::TileOp,
|
|
mlir::tosa::TransposeConv2DOp,
|
|
mlir::tosa::TransposeOp,
|
|
mlir::tosa::VariableOp,
|
|
mlir::tosa::VariableReadOp,
|
|
mlir::tosa::VariableWriteOp,
|
|
mlir::tosa::WhileOp,
|
|
mlir::tosa::YieldOp
|
|
#endif // GET_OP_LIST
|
|
|
|
#ifdef GET_OP_CLASSES
|
|
#undef GET_OP_CLASSES
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// Local Utility Method Definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_TosaOps1(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((((::llvm::isa<::mlir::TensorType>(type))) && ((((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::all_of(::llvm::cast<::mlir::RankedTensorType>(type).getShape(), [](auto v) { return v != 0; })))) || ((::llvm::isa<::mlir::UnrankedTensorType>(type))))) && ([](::mlir::Type elementType) { return (((elementType.isUnsignedInteger())) || ((elementType.isSignlessInteger()))) || ((((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 4))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 16))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 32)))) || ((::llvm::isa<::mlir::FloatType>(elementType))) || ((::llvm::isa<mlir::tosa::mxint8Type>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be tosa-conformant tensor of number values, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_TosaOps2(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((::llvm::isa<mlir::tosa::shapeType>(type)))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be Shape with static rank and Index element type, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_TosaOps3(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((((type.isUnsignedInteger())) || ((type.isSignlessInteger()))) || (((::llvm::isa<::mlir::VectorType>(type))) && ([](::mlir::Type elementType) { return ((elementType.isUnsignedInteger())) || ((elementType.isSignlessInteger())); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((((::llvm::isa<::mlir::TensorType>(type))) && ((((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::all_of(::llvm::cast<::mlir::RankedTensorType>(type).getShape(), [](auto v) { return v != 0; })))) || ((::llvm::isa<::mlir::UnrankedTensorType>(type))))) && ([](::mlir::Type elementType) { return ((elementType.isUnsignedInteger())) || ((elementType.isSignlessInteger())); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be signless-integer-like, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_TosaOps4(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!(((type.isSignlessInteger(8))) || (((::llvm::isa<::mlir::VectorType>(type))) && ([](::mlir::Type elementType) { return (elementType.isSignlessInteger(8)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((((::llvm::isa<::mlir::TensorType>(type))) && ((((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::all_of(::llvm::cast<::mlir::RankedTensorType>(type).getShape(), [](auto v) { return v != 0; })))) || ((::llvm::isa<::mlir::UnrankedTensorType>(type))))) && ([](::mlir::Type elementType) { return (elementType.isSignlessInteger(8)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be signless-integer-8-bit-like, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_TosaOps5(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((((::llvm::isa<::mlir::UnrankedTensorType>(type))) && ([](::mlir::Type elementType) { return (((elementType.isUnsignedInteger())) || ((elementType.isSignlessInteger()))) || ((((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 4))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 16))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 32)))) || ((::llvm::isa<::mlir::FloatType>(elementType))) || ((::llvm::isa<mlir::tosa::mxint8Type>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((((::llvm::isa<::mlir::RankedTensorType>(type))) && (((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::all_of(::llvm::cast<::mlir::RankedTensorType>(type).getShape(), [](auto v) { return v != 0; })))) && (((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::cast<::mlir::RankedTensorType>(type).getRank() >= 1)))) && ([](::mlir::Type elementType) { return (((elementType.isUnsignedInteger())) || ((elementType.isSignlessInteger()))) || ((((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 4))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 16))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 32)))) || ((::llvm::isa<::mlir::FloatType>(elementType))) || ((::llvm::isa<mlir::tosa::mxint8Type>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be tosa-conformant tensor of at least rank 1, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_TosaOps6(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((((::llvm::isa<::mlir::UnrankedTensorType>(type))) && ([](::mlir::Type elementType) { return (((elementType.isUnsignedInteger())) || ((elementType.isSignlessInteger()))) || ((((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 4))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 16))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 32)))) || ((::llvm::isa<::mlir::FloatType>(elementType))) || ((::llvm::isa<mlir::tosa::mxint8Type>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((((::llvm::isa<::mlir::RankedTensorType>(type))) && (((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::all_of(::llvm::cast<::mlir::RankedTensorType>(type).getShape(), [](auto v) { return v != 0; })))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank()
|
|
== 4)))) && ([](::mlir::Type elementType) { return (((elementType.isUnsignedInteger())) || ((elementType.isSignlessInteger()))) || ((((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 4))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 16))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 32)))) || ((::llvm::isa<::mlir::FloatType>(elementType))) || ((::llvm::isa<mlir::tosa::mxint8Type>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be 4-d tosa-conformant tensor, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_TosaOps7(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((((::llvm::isa<::mlir::UnrankedTensorType>(type))) && ([](::mlir::Type elementType) { return (((elementType.isUnsignedInteger())) || ((elementType.isSignlessInteger()))) || ((::llvm::isa<::mlir::FloatType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((((::llvm::isa<::mlir::RankedTensorType>(type))) && (((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::all_of(::llvm::cast<::mlir::RankedTensorType>(type).getShape(), [](auto v) { return v != 0; })))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank()
|
|
== 1))) && (((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::all_of(::llvm::cast<::mlir::RankedTensorType>(type).getShape(), [](auto v) { return v == 1; }))))) && ([](::mlir::Type elementType) { return (((elementType.isUnsignedInteger())) || ((elementType.isSignlessInteger()))) || ((::llvm::isa<::mlir::FloatType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be tosa-conformant unranked tensor of unsigned integer or signless integer or floating-point values or tosa-conformant scalar tensor of unsigned integer or signless integer or floating-point values, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_TosaOps8(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!(((mlir::tosa::isa_tosa_shape_type(type))) && ((::llvm::cast<::mlir::tosa::shapeType>(type).getRank() == 2)))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be Tosa shape type of rank 2, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_TosaOps9(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!(((mlir::tosa::isa_tosa_shape_type(type))) && ((::llvm::cast<::mlir::tosa::shapeType>(type).getRank() == 4)))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be Tosa shape type of rank 4, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_TosaOps10(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((((::llvm::isa<::mlir::UnrankedTensorType>(type))) && ([](::mlir::Type elementType) { return ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<mlir::tosa::mxint8Type>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((((::llvm::isa<::mlir::RankedTensorType>(type))) && (((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::all_of(::llvm::cast<::mlir::RankedTensorType>(type).getShape(), [](auto v) { return v != 0; })))) && (((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::cast<::mlir::RankedTensorType>(type).getRank() >= 1)))) && ([](::mlir::Type elementType) { return ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<mlir::tosa::mxint8Type>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be tosa-conformant tensor of at least rank 1, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_TosaOps11(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((((::llvm::isa<::mlir::UnrankedTensorType>(type))) && ([](::mlir::Type elementType) { return (::llvm::isa<::mlir::Float8E8M0FNUType>(elementType)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((((::llvm::isa<::mlir::RankedTensorType>(type))) && (((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::all_of(::llvm::cast<::mlir::RankedTensorType>(type).getShape(), [](auto v) { return v != 0; })))) && (((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::cast<::mlir::RankedTensorType>(type).getRank() >= 1)))) && ([](::mlir::Type elementType) { return (::llvm::isa<::mlir::Float8E8M0FNUType>(elementType)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be tosa-conformant tensor of at least rank 1, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_TosaOps12(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((((::llvm::isa<::mlir::UnrankedTensorType>(type))) && ([](::mlir::Type elementType) { return (((elementType.isUnsignedInteger())) || ((elementType.isSignlessInteger()))) || ((((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 4))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 16))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 32)))) || ((::llvm::isa<::mlir::FloatType>(elementType))) || ((::llvm::isa<mlir::tosa::mxint8Type>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((((::llvm::isa<::mlir::RankedTensorType>(type))) && (((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::all_of(::llvm::cast<::mlir::RankedTensorType>(type).getShape(), [](auto v) { return v != 0; })))) && (((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::cast<::mlir::RankedTensorType>(type).getRank() >= 1)))) && ([](::mlir::Type elementType) { return (((elementType.isUnsignedInteger())) || ((elementType.isSignlessInteger()))) || ((((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 4))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 16))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 32)))) || ((::llvm::isa<::mlir::FloatType>(elementType))) || ((::llvm::isa<mlir::tosa::mxint8Type>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be variadic of tosa-conformant tensor of at least rank 1, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_TosaOps13(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((::llvm::isa<mlir::tosa::shapeType>(type)))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be variadic of Shape with static rank and Index element type, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_TosaOps14(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((((::llvm::isa<::mlir::UnrankedTensorType>(type))) && ([](::mlir::Type elementType) { return ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<mlir::tosa::mxint8Type>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((((::llvm::isa<::mlir::RankedTensorType>(type))) && (((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::all_of(::llvm::cast<::mlir::RankedTensorType>(type).getShape(), [](auto v) { return v != 0; })))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank()
|
|
== 4)))) && ([](::mlir::Type elementType) { return ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<mlir::tosa::mxint8Type>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be tosa-conformant unranked tensor of micro-scaling format number values or 4D tensor of micro-scaling format number values, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_TosaOps15(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((((::llvm::isa<::mlir::UnrankedTensorType>(type))) && ([](::mlir::Type elementType) { return (::llvm::isa<::mlir::Float8E8M0FNUType>(elementType)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((((::llvm::isa<::mlir::RankedTensorType>(type))) && (((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::all_of(::llvm::cast<::mlir::RankedTensorType>(type).getShape(), [](auto v) { return v != 0; })))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank()
|
|
== 4)))) && ([](::mlir::Type elementType) { return (::llvm::isa<::mlir::Float8E8M0FNUType>(elementType)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be tosa-conformant unranked tensor of micro-scaling format scale number values or 4D tensor of micro-scaling format scale number values, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_TosaOps16(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((((::llvm::isa<::mlir::UnrankedTensorType>(type))) && ([](::mlir::Type elementType) { return (((elementType.isUnsignedInteger())) || ((elementType.isSignlessInteger()))) || ((((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 4))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 16))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 32)))) || ((::llvm::isa<::mlir::FloatType>(elementType))) || ((::llvm::isa<mlir::tosa::mxint8Type>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((((::llvm::isa<::mlir::RankedTensorType>(type))) && (((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::all_of(::llvm::cast<::mlir::RankedTensorType>(type).getShape(), [](auto v) { return v != 0; })))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank()
|
|
== 1)))) && ([](::mlir::Type elementType) { return (((elementType.isUnsignedInteger())) || ((elementType.isSignlessInteger()))) || ((((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 4))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 16))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 32)))) || ((::llvm::isa<::mlir::FloatType>(elementType))) || ((::llvm::isa<mlir::tosa::mxint8Type>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be 1-d tosa-conformant tensor, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_TosaOps17(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((((::llvm::isa<::mlir::UnrankedTensorType>(type))) && ([](::mlir::Type elementType) { return (((elementType.isUnsignedInteger())) || ((elementType.isSignlessInteger()))) || ((((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 4))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 16))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 32)))) || ((::llvm::isa<::mlir::FloatType>(elementType))) || ((::llvm::isa<mlir::tosa::mxint8Type>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((((::llvm::isa<::mlir::RankedTensorType>(type))) && (((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::all_of(::llvm::cast<::mlir::RankedTensorType>(type).getShape(), [](auto v) { return v != 0; })))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank()
|
|
== 5)))) && ([](::mlir::Type elementType) { return (((elementType.isUnsignedInteger())) || ((elementType.isSignlessInteger()))) || ((((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 4))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 16))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 32)))) || ((::llvm::isa<::mlir::FloatType>(elementType))) || ((::llvm::isa<mlir::tosa::mxint8Type>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be 5-d tosa-conformant tensor, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_TosaOps18(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((((::llvm::isa<::mlir::TensorType>(type))) && ((((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::all_of(::llvm::cast<::mlir::RankedTensorType>(type).getShape(), [](auto v) { return v != 0; })))) || ((::llvm::isa<::mlir::UnrankedTensorType>(type))))) && ([](::mlir::Type elementType) { return (::llvm::isa<::mlir::FloatType>(elementType)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be tosa-conformant tensor of floating-point values, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_TosaOps19(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((((::llvm::isa<::mlir::TensorType>(type))) && ((((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::all_of(::llvm::cast<::mlir::RankedTensorType>(type).getShape(), [](auto v) { return v != 0; })))) || ((::llvm::isa<::mlir::UnrankedTensorType>(type))))) && ([](::mlir::Type elementType) { return (((elementType.isUnsignedInteger())) || ((elementType.isSignlessInteger()))) || ((((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 4))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 16))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 32)))) || ((::llvm::isa<::mlir::FloatType>(elementType))) || ((::llvm::isa<mlir::tosa::mxint8Type>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be variadic of tosa-conformant tensor of number values, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_TosaOps20(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((((::llvm::isa<::mlir::TensorType>(type))) && ((((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::all_of(::llvm::cast<::mlir::RankedTensorType>(type).getShape(), [](auto v) { return v != 0; })))) || ((::llvm::isa<::mlir::UnrankedTensorType>(type))))) && ([](::mlir::Type elementType) { return (elementType.isSignlessInteger(1)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be tosa-conformant tensor of 1-bit signless integer values, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_TosaOps21(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((((::llvm::isa<::mlir::UnrankedTensorType>(type))) && ([](::mlir::Type elementType) { return (((elementType.isUnsignedInteger())) || ((elementType.isSignlessInteger()))) || ((((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 4))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 16))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 32)))) || ((::llvm::isa<::mlir::FloatType>(elementType))) || ((::llvm::isa<mlir::tosa::mxint8Type>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((((::llvm::isa<::mlir::RankedTensorType>(type))) && (((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::all_of(::llvm::cast<::mlir::RankedTensorType>(type).getShape(), [](auto v) { return v != 0; })))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank()
|
|
== 3)))) && ([](::mlir::Type elementType) { return (((elementType.isUnsignedInteger())) || ((elementType.isSignlessInteger()))) || ((((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 4))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 16))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 32)))) || ((::llvm::isa<::mlir::FloatType>(elementType))) || ((::llvm::isa<mlir::tosa::mxint8Type>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be 3-d tosa-conformant tensor, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_TosaOps22(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((((::llvm::isa<::mlir::UnrankedTensorType>(type))) && ([](::mlir::Type elementType) { return (((elementType.isUnsignedInteger())) || ((elementType.isSignlessInteger()))) || ((((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 4))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 16))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 32)))) || ((::llvm::isa<::mlir::FloatType>(elementType))) || ((::llvm::isa<mlir::tosa::mxint8Type>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((((::llvm::isa<::mlir::RankedTensorType>(type))) && (((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::all_of(::llvm::cast<::mlir::RankedTensorType>(type).getShape(), [](auto v) { return v != 0; })))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank()
|
|
== 2)))) && ([](::mlir::Type elementType) { return ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be tosa-conformant unranked tensor of number values or 2D tensor of 32-bit signless integer or 64-bit signless integer values, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_TosaOps23(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((((::llvm::isa<::mlir::TensorType>(type))) && ((((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::all_of(::llvm::cast<::mlir::RankedTensorType>(type).getShape(), [](auto v) { return v != 0; })))) || ((::llvm::isa<::mlir::UnrankedTensorType>(type))))) && ([](::mlir::Type elementType) { return ((elementType.isSignlessInteger(32))) || ((elementType.isSignlessInteger(64))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be tosa-conformant tensor of 32-bit signless integer or 64-bit signless integer values, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_TosaOps24(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((((::llvm::isa<::mlir::UnrankedTensorType>(type))) && ([](::mlir::Type elementType) { return ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<mlir::tosa::mxint8Type>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((((::llvm::isa<::mlir::RankedTensorType>(type))) && (((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::all_of(::llvm::cast<::mlir::RankedTensorType>(type).getShape(), [](auto v) { return v != 0; })))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank()
|
|
== 3)))) && ([](::mlir::Type elementType) { return ((::llvm::isa<::mlir::Float8E4M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float8E5M2Type>(elementType))) || ((::llvm::isa<::mlir::Float4E2M1FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E2M3FNType>(elementType))) || ((::llvm::isa<::mlir::Float6E3M2FNType>(elementType))) || ((::llvm::isa<mlir::tosa::mxint8Type>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be tosa-conformant unranked tensor of micro-scaling format number values or 3D tensor of micro-scaling format number values, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_TosaOps25(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((((::llvm::isa<::mlir::UnrankedTensorType>(type))) && ([](::mlir::Type elementType) { return (::llvm::isa<::mlir::Float8E8M0FNUType>(elementType)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((((::llvm::isa<::mlir::RankedTensorType>(type))) && (((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::all_of(::llvm::cast<::mlir::RankedTensorType>(type).getShape(), [](auto v) { return v != 0; })))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank()
|
|
== 3)))) && ([](::mlir::Type elementType) { return (::llvm::isa<::mlir::Float8E8M0FNUType>(elementType)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be tosa-conformant unranked tensor of micro-scaling format scale number values or 3D tensor of micro-scaling format scale number values, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_TosaOps26(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((((::llvm::isa<::mlir::UnrankedTensorType>(type))) && ([](::mlir::Type elementType) { return (elementType.isSignlessInteger(8)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((((::llvm::isa<::mlir::RankedTensorType>(type))) && (((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::all_of(::llvm::cast<::mlir::RankedTensorType>(type).getShape(), [](auto v) { return v != 0; })))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank()
|
|
== 1))) && (((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::all_of(::llvm::cast<::mlir::RankedTensorType>(type).getShape(), [](auto v) { return v == 1; }))))) && ([](::mlir::Type elementType) { return (elementType.isSignlessInteger(8)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be tosa-conformant unranked tensor of 8-bit signless integer values or tosa-conformant scalar tensor of 8-bit signless integer values, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_TosaOps27(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((((::llvm::isa<::mlir::UnrankedTensorType>(type))) && ([](::mlir::Type elementType) { return (((elementType.isUnsignedInteger())) || ((elementType.isSignlessInteger()))) || ((::llvm::isa<::mlir::FloatType>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((((::llvm::isa<::mlir::RankedTensorType>(type))) && (((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::all_of(::llvm::cast<::mlir::RankedTensorType>(type).getShape(), [](auto v) { return v != 0; })))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank()
|
|
== 1))) && (((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::all_of(::llvm::cast<::mlir::RankedTensorType>(type).getShape(), [](auto v) { return v == 1; }))))) && ([](::mlir::Type elementType) { return (((elementType.isUnsignedInteger())) || ((elementType.isSignlessInteger()))) || ((((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 4))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 16))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 32)))) || ((::llvm::isa<::mlir::FloatType>(elementType))) || ((::llvm::isa<mlir::tosa::mxint8Type>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be tosa-conformant unranked tensor of unsigned integer or signless integer or floating-point values or tosa-conformant scalar tensor of number values, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_TosaOps28(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((((::llvm::isa<::mlir::RankedTensorType>(type))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank()
|
|
== 1)))) && ([](::mlir::Type elementType) { return ((elementType.isSignlessInteger(16))) || ((elementType.isSignlessInteger(32))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be 1D tensor of 16-bit signless integer or 32-bit signless integer values, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_TosaOps29(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((((::llvm::isa<::mlir::RankedTensorType>(type))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank()
|
|
== 1)))) && ([](::mlir::Type elementType) { return (elementType.isSignlessInteger(8)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType())))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be 1D tensor of 8-bit signless integer values, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_TosaOps30(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((((::llvm::isa<::mlir::UnrankedTensorType>(type))) && ([](::mlir::Type elementType) { return (((elementType.isUnsignedInteger())) || ((elementType.isSignlessInteger()))) || ((((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 4))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 16))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 32)))) || ((::llvm::isa<::mlir::FloatType>(elementType))) || ((::llvm::isa<mlir::tosa::mxint8Type>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((((::llvm::isa<::mlir::RankedTensorType>(type))) && (((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::all_of(::llvm::cast<::mlir::RankedTensorType>(type).getShape(), [](auto v) { return v != 0; })))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank()
|
|
== 3)))) && ([](::mlir::Type elementType) { return (((elementType.isUnsignedInteger())) || ((elementType.isSignlessInteger()))) || ((((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 4))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 8))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 16))) || (((::llvm::isa<mlir::quant::QuantizedType>(elementType))) && ((::llvm::cast<mlir::quant::QuantizedType>(elementType).getStorageTypeIntegralWidth() == 32)))) || ((::llvm::isa<::mlir::FloatType>(elementType))) || ((::llvm::isa<mlir::tosa::mxint8Type>(elementType))); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be variadic of 3-d tosa-conformant tensor, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_type_constraint_TosaOps31(
|
|
::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
|
|
unsigned valueIndex) {
|
|
if (!((((::llvm::isa<::mlir::UnrankedTensorType>(type))) && ([](::mlir::Type elementType) { return (elementType.isSignlessInteger(32)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))) || ((((::llvm::isa<::mlir::RankedTensorType>(type))) && (((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::all_of(::llvm::cast<::mlir::RankedTensorType>(type).getShape(), [](auto v) { return v != 0; })))) && (((::llvm::cast<::mlir::ShapedType>(type).hasRank())) && ((::llvm::cast<::mlir::ShapedType>(type).getRank()
|
|
== 1))) && (((::llvm::isa<::mlir::RankedTensorType>(type))) && ((::llvm::all_of(::llvm::cast<::mlir::RankedTensorType>(type).getShape(), [](auto v) { return v == 1; }))))) && ([](::mlir::Type elementType) { return (elementType.isSignlessInteger(32)); }(::llvm::cast<::mlir::ShapedType>(type).getElementType()))))) {
|
|
return op->emitOpError(valueKind) << " #" << valueIndex
|
|
<< " must be tosa-conformant unranked tensor of 32-bit signless integer values or tosa-conformant scalar tensor of 32-bit signless integer values, but got " << type;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_TosaOps1(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !((::llvm::isa<mlir::tosa::RoundingModeAttr>(attr))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: Supported rounding modes";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_TosaOps1(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_TosaOps1(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_TosaOps2(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !(((::llvm::isa<::mlir::IntegerAttr>(attr))) && ((::llvm::cast<::mlir::IntegerAttr>(attr).getType().isSignlessInteger(32)))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: 32-bit signless integer attribute";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_TosaOps2(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_TosaOps2(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_TosaOps3(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !((::llvm::isa<mlir::tosa::NanPropagationModeAttr>(attr))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: Supported NaN propagation strategies";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_TosaOps3(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_TosaOps3(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_TosaOps4(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !((::llvm::isa<::mlir::BoolAttr>(attr))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: bool attribute";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_TosaOps4(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_TosaOps4(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_TosaOps5(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !(((::llvm::isa<::mlir::TypeAttr>(attr))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(attr).getValue()))) && (((::llvm::cast<::mlir::TypeAttr>(attr).getValue().isSignlessInteger(32))) || ((::llvm::cast<::mlir::TypeAttr>(attr).getValue().isSignlessInteger(48))) || ((::llvm::cast<::mlir::TypeAttr>(attr).getValue().isF16())) || ((::llvm::cast<::mlir::TypeAttr>(attr).getValue().isF32())))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: type attribute of 32-bit signless integer or 48-bit signless integer or 16-bit float or 32-bit float";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_TosaOps5(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_TosaOps5(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_TosaOps6(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !(((::llvm::isa<::mlir::DenseI64ArrayAttr>(attr))) && ((::llvm::cast<::mlir::DenseArrayAttr>(attr).size() == 2))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: i64 dense array attribute with exactly 2 elements";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_TosaOps6(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_TosaOps6(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_TosaOps7(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !(((::llvm::isa<::mlir::DenseI64ArrayAttr>(attr))) && ((::llvm::cast<::mlir::DenseArrayAttr>(attr).size() == 4))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: i64 dense array attribute with exactly 4 elements";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_TosaOps7(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_TosaOps7(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_TosaOps8(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !((::llvm::isa<mlir::tosa::BlockSizeAttr>(attr))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: Block size for the block_scaled formats";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_TosaOps8(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_TosaOps8(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_TosaOps9(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !(((::llvm::isa<::mlir::IntegerAttr>(attr))) || ((::llvm::isa<::mlir::FloatAttr>(attr)))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: arbitrary integer attribute or arbitrary float attribute";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_TosaOps9(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_TosaOps9(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_TosaOps10(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !((::llvm::isa<::mlir::ElementsAttr>(attr))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: constant vector/tensor attribute";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_TosaOps10(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_TosaOps10(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_TosaOps11(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !(((::llvm::isa<::mlir::DenseIntElementsAttr>(attr))) && ((::llvm::cast<::mlir::DenseIntElementsAttr>(attr)
|
|
.getType()
|
|
.getElementType()
|
|
.isIndex()))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: index elements attribute";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_TosaOps11(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_TosaOps11(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_TosaOps12(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !(((::llvm::isa<::mlir::DenseI64ArrayAttr>(attr))) && ((::llvm::cast<::mlir::DenseArrayAttr>(attr).size() == 6))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: i64 dense array attribute with exactly 6 elements";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_TosaOps12(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_TosaOps12(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_TosaOps13(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !(((::llvm::isa<::mlir::DenseI64ArrayAttr>(attr))) && ((::llvm::cast<::mlir::DenseArrayAttr>(attr).size() == 3))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: i64 dense array attribute with exactly 3 elements";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_TosaOps13(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_TosaOps13(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_TosaOps14(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !((::llvm::isa<::mlir::StringAttr>(attr))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: string attribute";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_TosaOps14(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_TosaOps14(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_TosaOps15(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !((::llvm::isa<mlir::tosa::ResizeModeAttr>(attr))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: Supported resize/upsampling strategies";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_TosaOps15(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_TosaOps15(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_TosaOps16(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !((::llvm::isa<::mlir::DenseI32ArrayAttr>(attr))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: i32 dense array attribute";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_TosaOps16(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_TosaOps16(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_TosaOps17(
|
|
::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
if (attr && !(((::llvm::isa<::mlir::TypeAttr>(attr))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(attr).getValue()))) && ((true))))
|
|
return emitError() << "attribute '" << attrName
|
|
<< "' failed to satisfy constraint: any type attribute";
|
|
return ::mlir::success();
|
|
}
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_TosaOps17(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_TosaOps17(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_TosaOps18(
|
|
::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_TosaOps18(
|
|
::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
|
|
return __mlir_ods_local_attr_constraint_TosaOps18(attr, attrName, [op]() {
|
|
return op->emitOpError();
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult __mlir_ods_local_region_constraint_TosaOps1(
|
|
::mlir::Operation *op, ::mlir::Region ®ion, ::llvm::StringRef regionName,
|
|
unsigned regionIndex) {
|
|
if (!((::llvm::hasNItems(region, 1)))) {
|
|
return op->emitOpError("region #") << regionIndex
|
|
<< (regionName.empty() ? " " : " ('" + regionName + "') ")
|
|
<< "failed to verify constraint: region with 1 blocks";
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::AbsOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
AbsOpGenericAdaptorBase::AbsOpGenericAdaptorBase(AbsOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
AbsOpAdaptor::AbsOpAdaptor(AbsOp op) : AbsOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult AbsOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult AbsOp::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 AbsOp::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 AbsOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> AbsOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void AbsOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void AbsOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult AbsOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void AbsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1) {
|
|
odsState.addOperands(input1);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
AbsOp AbsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1));
|
|
auto __res__ = ::llvm::dyn_cast<AbsOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AbsOp AbsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1));
|
|
}
|
|
|
|
void AbsOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
odsState.addOperands(input1);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
AbsOp AbsOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1));
|
|
auto __res__ = ::llvm::dyn_cast<AbsOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AbsOp AbsOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1));
|
|
}
|
|
|
|
void AbsOp::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);
|
|
}
|
|
|
|
AbsOp AbsOp::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<AbsOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AbsOp AbsOp::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 AbsOp::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);
|
|
}
|
|
|
|
AbsOp AbsOp::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<AbsOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AbsOp AbsOp::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 AbsOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*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_TosaOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult AbsOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult AbsOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void AbsOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void AbsOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::AbsOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::AddOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
AddOpGenericAdaptorBase::AddOpGenericAdaptorBase(AddOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
AddOpAdaptor::AddOpAdaptor(AddOp op) : AddOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult AddOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult AddOp::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 AddOp::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 AddOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> AddOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void AddOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void AddOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult AddOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void AddOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
AddOp AddOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<AddOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AddOp AddOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void AddOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
AddOp AddOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<AddOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AddOp AddOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void AddOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
AddOp AddOp::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<AddOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AddOp AddOp::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 AddOp::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);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
AddOp AddOp::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<AddOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AddOp AddOp::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 AddOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*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_TosaOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult AddOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult AddOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void AddOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void AddOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::AddOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::AddShapeOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
AddShapeOpGenericAdaptorBase::AddShapeOpGenericAdaptorBase(AddShapeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
AddShapeOpAdaptor::AddShapeOpAdaptor(AddShapeOp op) : AddShapeOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult AddShapeOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult AddShapeOp::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 AddShapeOp::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 AddShapeOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> AddShapeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void AddShapeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void AddShapeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult AddShapeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void AddShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
AddShapeOp AddShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<AddShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AddShapeOp AddShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void AddShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
AddShapeOp AddShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<AddShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AddShapeOp AddShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void AddShapeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
AddShapeOp AddShapeOp::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<AddShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AddShapeOp AddShapeOp::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 AddShapeOp::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);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
AddShapeOp AddShapeOp::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<AddShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AddShapeOp AddShapeOp::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 AddShapeOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps2(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps2(*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_TosaOps2(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult AddShapeOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult AddShapeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void AddShapeOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void AddShapeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::AddShapeOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::ApplyScaleOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
ApplyScaleOpGenericAdaptorBase::ApplyScaleOpGenericAdaptorBase(ApplyScaleOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::mlir::tosa::RoundingMode ApplyScaleOpGenericAdaptorBase::getRoundingMode() {
|
|
auto attr = getRoundingModeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
ApplyScaleOpAdaptor::ApplyScaleOpAdaptor(ApplyScaleOp op) : ApplyScaleOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult ApplyScaleOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_rounding_mode = getProperties().rounding_mode; (void)tblgen_rounding_mode;
|
|
if (!tblgen_rounding_mode) return emitError(loc, "'tosa.apply_scale' op requires attribute 'rounding_mode'");
|
|
|
|
if (tblgen_rounding_mode && !((::llvm::isa<mlir::tosa::RoundingModeAttr>(tblgen_rounding_mode))))
|
|
return emitError(loc, "'tosa.apply_scale' op attribute 'rounding_mode' failed to satisfy constraint: Supported rounding modes");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ApplyScaleOp::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.rounding_mode;
|
|
auto attr = dict.get("rounding_mode");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `rounding_mode` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute ApplyScaleOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.rounding_mode;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("rounding_mode",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code ApplyScaleOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.rounding_mode.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> ApplyScaleOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "rounding_mode")
|
|
return prop.rounding_mode;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void ApplyScaleOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "rounding_mode") {
|
|
prop.rounding_mode = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.rounding_mode)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void ApplyScaleOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.rounding_mode) attrs.append("rounding_mode", prop.rounding_mode);
|
|
}
|
|
|
|
::llvm::LogicalResult ApplyScaleOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getRoundingModeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps1(attr, "rounding_mode", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ApplyScaleOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.rounding_mode)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ApplyScaleOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.rounding_mode);
|
|
}
|
|
|
|
::mlir::tosa::RoundingMode ApplyScaleOp::getRoundingMode() {
|
|
auto attr = getRoundingModeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
void ApplyScaleOp::setRoundingMode(::mlir::tosa::RoundingMode attrValue) {
|
|
getProperties().rounding_mode = ::mlir::tosa::RoundingModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue);
|
|
}
|
|
|
|
void ApplyScaleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value value, ::mlir::Value multiplier, ::mlir::Value shift, mlir::tosa::RoundingModeAttr rounding_mode) {
|
|
odsState.addOperands(value);
|
|
odsState.addOperands(multiplier);
|
|
odsState.addOperands(shift);
|
|
odsState.getOrAddProperties<Properties>().rounding_mode = rounding_mode;
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ApplyScaleOp ApplyScaleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value value, ::mlir::Value multiplier, ::mlir::Value shift, mlir::tosa::RoundingModeAttr rounding_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(value)>(value), std::forward<decltype(multiplier)>(multiplier), std::forward<decltype(shift)>(shift), std::forward<decltype(rounding_mode)>(rounding_mode));
|
|
auto __res__ = ::llvm::dyn_cast<ApplyScaleOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ApplyScaleOp ApplyScaleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value value, ::mlir::Value multiplier, ::mlir::Value shift, mlir::tosa::RoundingModeAttr rounding_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(value)>(value), std::forward<decltype(multiplier)>(multiplier), std::forward<decltype(shift)>(shift), std::forward<decltype(rounding_mode)>(rounding_mode));
|
|
}
|
|
|
|
void ApplyScaleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value value, ::mlir::Value multiplier, ::mlir::Value shift, mlir::tosa::RoundingModeAttr rounding_mode) {
|
|
odsState.addOperands(value);
|
|
odsState.addOperands(multiplier);
|
|
odsState.addOperands(shift);
|
|
odsState.getOrAddProperties<Properties>().rounding_mode = rounding_mode;
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ApplyScaleOp ApplyScaleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value value, ::mlir::Value multiplier, ::mlir::Value shift, mlir::tosa::RoundingModeAttr rounding_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(value)>(value), std::forward<decltype(multiplier)>(multiplier), std::forward<decltype(shift)>(shift), std::forward<decltype(rounding_mode)>(rounding_mode));
|
|
auto __res__ = ::llvm::dyn_cast<ApplyScaleOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ApplyScaleOp ApplyScaleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value value, ::mlir::Value multiplier, ::mlir::Value shift, mlir::tosa::RoundingModeAttr rounding_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(value)>(value), std::forward<decltype(multiplier)>(multiplier), std::forward<decltype(shift)>(shift), std::forward<decltype(rounding_mode)>(rounding_mode));
|
|
}
|
|
|
|
void ApplyScaleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value value, ::mlir::Value multiplier, ::mlir::Value shift, ::mlir::tosa::RoundingMode rounding_mode) {
|
|
odsState.addOperands(value);
|
|
odsState.addOperands(multiplier);
|
|
odsState.addOperands(shift);
|
|
odsState.getOrAddProperties<Properties>().rounding_mode = ::mlir::tosa::RoundingModeAttr::get(odsBuilder.getContext(), rounding_mode);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ApplyScaleOp ApplyScaleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value value, ::mlir::Value multiplier, ::mlir::Value shift, ::mlir::tosa::RoundingMode rounding_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(value)>(value), std::forward<decltype(multiplier)>(multiplier), std::forward<decltype(shift)>(shift), std::forward<decltype(rounding_mode)>(rounding_mode));
|
|
auto __res__ = ::llvm::dyn_cast<ApplyScaleOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ApplyScaleOp ApplyScaleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value value, ::mlir::Value multiplier, ::mlir::Value shift, ::mlir::tosa::RoundingMode rounding_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(value)>(value), std::forward<decltype(multiplier)>(multiplier), std::forward<decltype(shift)>(shift), std::forward<decltype(rounding_mode)>(rounding_mode));
|
|
}
|
|
|
|
void ApplyScaleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value value, ::mlir::Value multiplier, ::mlir::Value shift, ::mlir::tosa::RoundingMode rounding_mode) {
|
|
odsState.addOperands(value);
|
|
odsState.addOperands(multiplier);
|
|
odsState.addOperands(shift);
|
|
odsState.getOrAddProperties<Properties>().rounding_mode = ::mlir::tosa::RoundingModeAttr::get(odsBuilder.getContext(), rounding_mode);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ApplyScaleOp ApplyScaleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value value, ::mlir::Value multiplier, ::mlir::Value shift, ::mlir::tosa::RoundingMode rounding_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(value)>(value), std::forward<decltype(multiplier)>(multiplier), std::forward<decltype(shift)>(shift), std::forward<decltype(rounding_mode)>(rounding_mode));
|
|
auto __res__ = ::llvm::dyn_cast<ApplyScaleOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ApplyScaleOp ApplyScaleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value value, ::mlir::Value multiplier, ::mlir::Value shift, ::mlir::tosa::RoundingMode rounding_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(value)>(value), std::forward<decltype(multiplier)>(multiplier), std::forward<decltype(shift)>(shift), std::forward<decltype(rounding_mode)>(rounding_mode));
|
|
}
|
|
|
|
void ApplyScaleOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 3u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<ApplyScaleOp::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.");
|
|
}
|
|
}
|
|
|
|
ApplyScaleOp ApplyScaleOp::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<ApplyScaleOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ApplyScaleOp ApplyScaleOp::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 ApplyScaleOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
|
|
assert(operands.size() == 3u && "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);
|
|
}
|
|
|
|
ApplyScaleOp ApplyScaleOp::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<ApplyScaleOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ApplyScaleOp ApplyScaleOp::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 ApplyScaleOp::verifyInvariantsImpl() {
|
|
auto tblgen_rounding_mode = getProperties().rounding_mode; (void)tblgen_rounding_mode;
|
|
if (!tblgen_rounding_mode) return emitOpError("requires attribute 'rounding_mode'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps1(*this, tblgen_rounding_mode, "rounding_mode")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps3(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps3(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps4(*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_TosaOps3(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ApplyScaleOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::llvm::LogicalResult ApplyScaleOp::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.rounding_mode;
|
|
auto rounding_modeAttrName = ::mlir::StringAttr::get(ctx, "rounding_mode");
|
|
auto attr = dict.get(rounding_modeAttrName);
|
|
usedKeys.insert(rounding_modeAttrName);
|
|
if (attr || /*isRequired=*/true) {
|
|
if (!attr) {
|
|
emitError() << "expected key entry for rounding_mode 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 `rounding_mode` 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();
|
|
}
|
|
|
|
void ApplyScaleOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::ApplyScaleOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::ApplyScaleOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::ArgMaxOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
ArgMaxOpGenericAdaptorBase::ArgMaxOpGenericAdaptorBase(ArgMaxOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
uint32_t ArgMaxOpGenericAdaptorBase::getAxis() {
|
|
auto attr = getAxisAttr();
|
|
return attr.getValue().getZExtValue();
|
|
}
|
|
|
|
mlir::tosa::NanPropagationModeAttr ArgMaxOpGenericAdaptorBase::getNanModeAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<mlir::tosa::NanPropagationModeAttr>(getProperties().nan_mode);
|
|
return attr;
|
|
}
|
|
|
|
::mlir::tosa::NanPropagationMode ArgMaxOpGenericAdaptorBase::getNanMode() {
|
|
auto attr = getNanModeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
ArgMaxOpAdaptor::ArgMaxOpAdaptor(ArgMaxOp op) : ArgMaxOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult ArgMaxOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_axis = getProperties().axis; (void)tblgen_axis;
|
|
if (!tblgen_axis) return emitError(loc, "'tosa.argmax' op requires attribute 'axis'");
|
|
auto tblgen_nan_mode = getProperties().nan_mode; (void)tblgen_nan_mode;
|
|
|
|
if (tblgen_axis && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_axis))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_axis).getType().isSignlessInteger(32)))))
|
|
return emitError(loc, "'tosa.argmax' op attribute 'axis' failed to satisfy constraint: 32-bit signless integer attribute");
|
|
|
|
if (tblgen_nan_mode && !((::llvm::isa<mlir::tosa::NanPropagationModeAttr>(tblgen_nan_mode))))
|
|
return emitError(loc, "'tosa.argmax' op attribute 'nan_mode' failed to satisfy constraint: Supported NaN propagation strategies");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ArgMaxOp::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.axis;
|
|
auto attr = dict.get("axis");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `axis` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.nan_mode;
|
|
auto attr = dict.get("nan_mode");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `nan_mode` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute ArgMaxOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.axis;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("axis",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.nan_mode;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("nan_mode",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code ArgMaxOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.axis.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.nan_mode.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> ArgMaxOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "axis")
|
|
return prop.axis;
|
|
|
|
if (name == "nan_mode")
|
|
return prop.nan_mode;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void ArgMaxOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "axis") {
|
|
prop.axis = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.axis)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "nan_mode") {
|
|
prop.nan_mode = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.nan_mode)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void ArgMaxOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.axis) attrs.append("axis", prop.axis);
|
|
|
|
if (prop.nan_mode) attrs.append("nan_mode", prop.nan_mode);
|
|
}
|
|
|
|
::llvm::LogicalResult ArgMaxOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getAxisAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps2(attr, "axis", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getNanModeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps3(attr, "nan_mode", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ArgMaxOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.axis)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.nan_mode)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ArgMaxOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.axis);
|
|
|
|
writer.writeOptionalAttribute(prop.nan_mode);
|
|
}
|
|
|
|
uint32_t ArgMaxOp::getAxis() {
|
|
auto attr = getAxisAttr();
|
|
return attr.getValue().getZExtValue();
|
|
}
|
|
|
|
::mlir::tosa::NanPropagationMode ArgMaxOp::getNanMode() {
|
|
auto attr = getNanModeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
void ArgMaxOp::setAxis(uint32_t attrValue) {
|
|
getProperties().axis = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), attrValue);
|
|
}
|
|
|
|
void ArgMaxOp::setNanMode(::mlir::tosa::NanPropagationMode attrValue) {
|
|
getProperties().nan_mode = ::mlir::tosa::NanPropagationModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue);
|
|
}
|
|
|
|
void ArgMaxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, ::mlir::IntegerAttr axis, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = axis;
|
|
if (nan_mode) {
|
|
odsState.getOrAddProperties<Properties>().nan_mode = nan_mode;
|
|
}
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ArgMaxOp ArgMaxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, ::mlir::IntegerAttr axis, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<ArgMaxOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ArgMaxOp ArgMaxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, ::mlir::IntegerAttr axis, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void ArgMaxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::IntegerAttr axis, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = axis;
|
|
if (nan_mode) {
|
|
odsState.getOrAddProperties<Properties>().nan_mode = nan_mode;
|
|
}
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ArgMaxOp ArgMaxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::IntegerAttr axis, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<ArgMaxOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ArgMaxOp ArgMaxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::IntegerAttr axis, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void ArgMaxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, uint32_t axis, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), axis);
|
|
odsState.getOrAddProperties<Properties>().nan_mode = ::mlir::tosa::NanPropagationModeAttr::get(odsBuilder.getContext(), nan_mode);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ArgMaxOp ArgMaxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, uint32_t axis, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<ArgMaxOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ArgMaxOp ArgMaxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, uint32_t axis, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void ArgMaxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, uint32_t axis, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), axis);
|
|
odsState.getOrAddProperties<Properties>().nan_mode = ::mlir::tosa::NanPropagationModeAttr::get(odsBuilder.getContext(), nan_mode);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ArgMaxOp ArgMaxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, uint32_t axis, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<ArgMaxOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ArgMaxOp ArgMaxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, uint32_t axis, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void ArgMaxOp::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<ArgMaxOp::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.");
|
|
}
|
|
}
|
|
|
|
ArgMaxOp ArgMaxOp::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<ArgMaxOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ArgMaxOp ArgMaxOp::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 ArgMaxOp::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);
|
|
}
|
|
|
|
ArgMaxOp ArgMaxOp::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<ArgMaxOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ArgMaxOp ArgMaxOp::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 ArgMaxOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) {
|
|
::mlir::Builder odsBuilder(opName.getContext());
|
|
if (!properties.nan_mode)
|
|
properties.nan_mode = ::mlir::tosa::NanPropagationModeAttr::get(odsBuilder.getContext(), ::mlir::tosa::NanPropagationMode::PROPAGATE);
|
|
}
|
|
|
|
::llvm::LogicalResult ArgMaxOp::verifyInvariantsImpl() {
|
|
auto tblgen_axis = getProperties().axis; (void)tblgen_axis;
|
|
if (!tblgen_axis) return emitOpError("requires attribute 'axis'");
|
|
auto tblgen_nan_mode = getProperties().nan_mode; (void)tblgen_nan_mode;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps2(*this, tblgen_axis, "axis")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps3(*this, tblgen_nan_mode, "nan_mode")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps5(*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_TosaOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ArgMaxOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::llvm::LogicalResult ArgMaxOp::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.axis;
|
|
auto axisAttrName = ::mlir::StringAttr::get(ctx, "axis");
|
|
auto attr = dict.get(axisAttrName);
|
|
usedKeys.insert(axisAttrName);
|
|
if (attr || /*isRequired=*/true) {
|
|
if (!attr) {
|
|
emitError() << "expected key entry for axis 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 `axis` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
{
|
|
|
|
auto &propStorage = prop.nan_mode;
|
|
auto nan_modeAttrName = ::mlir::StringAttr::get(ctx, "nan_mode");
|
|
auto attr = dict.get(nan_modeAttrName);
|
|
usedKeys.insert(nan_modeAttrName);
|
|
if (attr || /*isRequired=*/false) {
|
|
if (!attr) {
|
|
emitError() << "expected key entry for nan_mode 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 `nan_mode` 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();
|
|
}
|
|
|
|
void ArgMaxOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
ArgMaxOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
ArgMaxOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return ArgMaxOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::ArgMaxOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::ArgMaxOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::ArithmeticRightShiftOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
ArithmeticRightShiftOpGenericAdaptorBase::ArithmeticRightShiftOpGenericAdaptorBase(ArithmeticRightShiftOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
bool ArithmeticRightShiftOpGenericAdaptorBase::getRound() {
|
|
auto attr = getRoundAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
ArithmeticRightShiftOpAdaptor::ArithmeticRightShiftOpAdaptor(ArithmeticRightShiftOp op) : ArithmeticRightShiftOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult ArithmeticRightShiftOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_round = getProperties().round; (void)tblgen_round;
|
|
if (!tblgen_round) return emitError(loc, "'tosa.arithmetic_right_shift' op requires attribute 'round'");
|
|
|
|
if (tblgen_round && !((::llvm::isa<::mlir::BoolAttr>(tblgen_round))))
|
|
return emitError(loc, "'tosa.arithmetic_right_shift' op attribute 'round' failed to satisfy constraint: bool attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ArithmeticRightShiftOp::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.round;
|
|
auto attr = dict.get("round");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `round` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute ArithmeticRightShiftOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.round;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("round",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code ArithmeticRightShiftOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.round.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> ArithmeticRightShiftOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "round")
|
|
return prop.round;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void ArithmeticRightShiftOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "round") {
|
|
prop.round = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.round)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void ArithmeticRightShiftOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.round) attrs.append("round", prop.round);
|
|
}
|
|
|
|
::llvm::LogicalResult ArithmeticRightShiftOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getRoundAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps4(attr, "round", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ArithmeticRightShiftOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.round)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ArithmeticRightShiftOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.round);
|
|
}
|
|
|
|
bool ArithmeticRightShiftOp::getRound() {
|
|
auto attr = getRoundAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
void ArithmeticRightShiftOp::setRound(bool attrValue) {
|
|
getProperties().round = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue);
|
|
}
|
|
|
|
void ArithmeticRightShiftOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2, ::mlir::BoolAttr round) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.getOrAddProperties<Properties>().round = round;
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ArithmeticRightShiftOp ArithmeticRightShiftOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2, ::mlir::BoolAttr round) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(round)>(round));
|
|
auto __res__ = ::llvm::dyn_cast<ArithmeticRightShiftOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ArithmeticRightShiftOp ArithmeticRightShiftOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2, ::mlir::BoolAttr round) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(round)>(round));
|
|
}
|
|
|
|
void ArithmeticRightShiftOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2, ::mlir::BoolAttr round) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.getOrAddProperties<Properties>().round = round;
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ArithmeticRightShiftOp ArithmeticRightShiftOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2, ::mlir::BoolAttr round) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(round)>(round));
|
|
auto __res__ = ::llvm::dyn_cast<ArithmeticRightShiftOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ArithmeticRightShiftOp ArithmeticRightShiftOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2, ::mlir::BoolAttr round) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(round)>(round));
|
|
}
|
|
|
|
void ArithmeticRightShiftOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2, bool round) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.getOrAddProperties<Properties>().round = odsBuilder.getBoolAttr(round);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ArithmeticRightShiftOp ArithmeticRightShiftOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2, bool round) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(round)>(round));
|
|
auto __res__ = ::llvm::dyn_cast<ArithmeticRightShiftOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ArithmeticRightShiftOp ArithmeticRightShiftOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2, bool round) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(round)>(round));
|
|
}
|
|
|
|
void ArithmeticRightShiftOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2, bool round) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.getOrAddProperties<Properties>().round = odsBuilder.getBoolAttr(round);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ArithmeticRightShiftOp ArithmeticRightShiftOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2, bool round) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(round)>(round));
|
|
auto __res__ = ::llvm::dyn_cast<ArithmeticRightShiftOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ArithmeticRightShiftOp ArithmeticRightShiftOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2, bool round) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(round)>(round));
|
|
}
|
|
|
|
void ArithmeticRightShiftOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<ArithmeticRightShiftOp::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.");
|
|
}
|
|
}
|
|
|
|
ArithmeticRightShiftOp ArithmeticRightShiftOp::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<ArithmeticRightShiftOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ArithmeticRightShiftOp ArithmeticRightShiftOp::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 ArithmeticRightShiftOp::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);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ArithmeticRightShiftOp ArithmeticRightShiftOp::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<ArithmeticRightShiftOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ArithmeticRightShiftOp ArithmeticRightShiftOp::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 ArithmeticRightShiftOp::verifyInvariantsImpl() {
|
|
auto tblgen_round = getProperties().round; (void)tblgen_round;
|
|
if (!tblgen_round) return emitOpError("requires attribute 'round'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps4(*this, tblgen_round, "round")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*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_TosaOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ArithmeticRightShiftOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult ArithmeticRightShiftOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ArithmeticRightShiftOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void ArithmeticRightShiftOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::ArithmeticRightShiftOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::ArithmeticRightShiftOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::AssertEqualShapeOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
AssertEqualShapeOpGenericAdaptorBase::AssertEqualShapeOpGenericAdaptorBase(AssertEqualShapeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
bool AssertEqualShapeOpGenericAdaptorBase::getAllowBroadcast() {
|
|
auto attr = getAllowBroadcastAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
AssertEqualShapeOpAdaptor::AssertEqualShapeOpAdaptor(AssertEqualShapeOp op) : AssertEqualShapeOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult AssertEqualShapeOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_allow_broadcast = getProperties().allow_broadcast; (void)tblgen_allow_broadcast;
|
|
if (!tblgen_allow_broadcast) return emitError(loc, "'tosa.assert_equal_shape' op requires attribute 'allow_broadcast'");
|
|
|
|
if (tblgen_allow_broadcast && !((::llvm::isa<::mlir::BoolAttr>(tblgen_allow_broadcast))))
|
|
return emitError(loc, "'tosa.assert_equal_shape' op attribute 'allow_broadcast' failed to satisfy constraint: bool attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult AssertEqualShapeOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
|
|
if (!dict) {
|
|
emitError() << "expected DictionaryAttr to set properties";
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.allow_broadcast;
|
|
auto attr = dict.get("allow_broadcast");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `allow_broadcast` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute AssertEqualShapeOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.allow_broadcast;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("allow_broadcast",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code AssertEqualShapeOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.allow_broadcast.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> AssertEqualShapeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "allow_broadcast")
|
|
return prop.allow_broadcast;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void AssertEqualShapeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "allow_broadcast") {
|
|
prop.allow_broadcast = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.allow_broadcast)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void AssertEqualShapeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.allow_broadcast) attrs.append("allow_broadcast", prop.allow_broadcast);
|
|
}
|
|
|
|
::llvm::LogicalResult AssertEqualShapeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getAllowBroadcastAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps4(attr, "allow_broadcast", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult AssertEqualShapeOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.allow_broadcast)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void AssertEqualShapeOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.allow_broadcast);
|
|
}
|
|
|
|
bool AssertEqualShapeOp::getAllowBroadcast() {
|
|
auto attr = getAllowBroadcastAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
void AssertEqualShapeOp::setAllowBroadcast(bool attrValue) {
|
|
getProperties().allow_broadcast = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue);
|
|
}
|
|
|
|
void AssertEqualShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value input1, ::mlir::Value input2, ::mlir::BoolAttr allow_broadcast) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.getOrAddProperties<Properties>().allow_broadcast = allow_broadcast;
|
|
}
|
|
|
|
AssertEqualShapeOp AssertEqualShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value input1, ::mlir::Value input2, ::mlir::BoolAttr allow_broadcast) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(allow_broadcast)>(allow_broadcast));
|
|
auto __res__ = ::llvm::dyn_cast<AssertEqualShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AssertEqualShapeOp AssertEqualShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value input1, ::mlir::Value input2, ::mlir::BoolAttr allow_broadcast) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(allow_broadcast)>(allow_broadcast));
|
|
}
|
|
|
|
void AssertEqualShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2, ::mlir::BoolAttr allow_broadcast) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.getOrAddProperties<Properties>().allow_broadcast = allow_broadcast;
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
AssertEqualShapeOp AssertEqualShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2, ::mlir::BoolAttr allow_broadcast) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(allow_broadcast)>(allow_broadcast));
|
|
auto __res__ = ::llvm::dyn_cast<AssertEqualShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AssertEqualShapeOp AssertEqualShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2, ::mlir::BoolAttr allow_broadcast) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(allow_broadcast)>(allow_broadcast));
|
|
}
|
|
|
|
void AssertEqualShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value input1, ::mlir::Value input2, bool allow_broadcast) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.getOrAddProperties<Properties>().allow_broadcast = odsBuilder.getBoolAttr(allow_broadcast);
|
|
}
|
|
|
|
AssertEqualShapeOp AssertEqualShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value input1, ::mlir::Value input2, bool allow_broadcast) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(allow_broadcast)>(allow_broadcast));
|
|
auto __res__ = ::llvm::dyn_cast<AssertEqualShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AssertEqualShapeOp AssertEqualShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value input1, ::mlir::Value input2, bool allow_broadcast) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(allow_broadcast)>(allow_broadcast));
|
|
}
|
|
|
|
void AssertEqualShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2, bool allow_broadcast) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.getOrAddProperties<Properties>().allow_broadcast = odsBuilder.getBoolAttr(allow_broadcast);
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
AssertEqualShapeOp AssertEqualShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2, bool allow_broadcast) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(allow_broadcast)>(allow_broadcast));
|
|
auto __res__ = ::llvm::dyn_cast<AssertEqualShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AssertEqualShapeOp AssertEqualShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2, bool allow_broadcast) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(allow_broadcast)>(allow_broadcast));
|
|
}
|
|
|
|
void AssertEqualShapeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 0u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<AssertEqualShapeOp::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.");
|
|
}
|
|
}
|
|
|
|
AssertEqualShapeOp AssertEqualShapeOp::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<AssertEqualShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AssertEqualShapeOp AssertEqualShapeOp::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 AssertEqualShapeOp::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);
|
|
assert(resultTypes.size() == 0u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
AssertEqualShapeOp AssertEqualShapeOp::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<AssertEqualShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AssertEqualShapeOp AssertEqualShapeOp::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 AssertEqualShapeOp::verifyInvariantsImpl() {
|
|
auto tblgen_allow_broadcast = getProperties().allow_broadcast; (void)tblgen_allow_broadcast;
|
|
if (!tblgen_allow_broadcast) return emitOpError("requires attribute 'allow_broadcast'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps4(*this, tblgen_allow_broadcast, "allow_broadcast")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps2(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps2(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult AssertEqualShapeOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult AssertEqualShapeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void AssertEqualShapeOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::AssertEqualShapeOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::AssertEqualShapeOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::AvgPool2dAdaptiveOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
AvgPool2dAdaptiveOpGenericAdaptorBase::AvgPool2dAdaptiveOpGenericAdaptorBase(AvgPool2dAdaptiveOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::mlir::Type AvgPool2dAdaptiveOpGenericAdaptorBase::getAccType() {
|
|
auto attr = getAccTypeAttr();
|
|
return ::llvm::cast<::mlir::Type>(attr.getValue());
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
AvgPool2dAdaptiveOpAdaptor::AvgPool2dAdaptiveOpAdaptor(AvgPool2dAdaptiveOp op) : AvgPool2dAdaptiveOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult AvgPool2dAdaptiveOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_acc_type = getProperties().acc_type; (void)tblgen_acc_type;
|
|
if (!tblgen_acc_type) return emitError(loc, "'tosa.avg_pool2d_adaptive' op requires attribute 'acc_type'");
|
|
|
|
if (tblgen_acc_type && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_acc_type))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_acc_type).getValue()))) && (((::llvm::cast<::mlir::TypeAttr>(tblgen_acc_type).getValue().isSignlessInteger(32))) || ((::llvm::cast<::mlir::TypeAttr>(tblgen_acc_type).getValue().isSignlessInteger(48))) || ((::llvm::cast<::mlir::TypeAttr>(tblgen_acc_type).getValue().isF16())) || ((::llvm::cast<::mlir::TypeAttr>(tblgen_acc_type).getValue().isF32())))))
|
|
return emitError(loc, "'tosa.avg_pool2d_adaptive' op attribute 'acc_type' failed to satisfy constraint: type attribute of 32-bit signless integer or 48-bit signless integer or 16-bit float or 32-bit float");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult AvgPool2dAdaptiveOp::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.acc_type;
|
|
auto attr = dict.get("acc_type");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `acc_type` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute AvgPool2dAdaptiveOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.acc_type;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("acc_type",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code AvgPool2dAdaptiveOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.acc_type.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> AvgPool2dAdaptiveOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "acc_type")
|
|
return prop.acc_type;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void AvgPool2dAdaptiveOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "acc_type") {
|
|
prop.acc_type = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.acc_type)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void AvgPool2dAdaptiveOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.acc_type) attrs.append("acc_type", prop.acc_type);
|
|
}
|
|
|
|
::llvm::LogicalResult AvgPool2dAdaptiveOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getAccTypeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps5(attr, "acc_type", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult AvgPool2dAdaptiveOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.acc_type)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void AvgPool2dAdaptiveOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.acc_type);
|
|
}
|
|
|
|
::mlir::Type AvgPool2dAdaptiveOp::getAccType() {
|
|
auto attr = getAccTypeAttr();
|
|
return ::llvm::cast<::mlir::Type>(attr.getValue());
|
|
}
|
|
|
|
void AvgPool2dAdaptiveOp::setAccType(::mlir::Type attrValue) {
|
|
getProperties().acc_type = ::mlir::TypeAttr::get(attrValue);
|
|
}
|
|
|
|
void AvgPool2dAdaptiveOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type outputType, ::mlir::Value input, ::mlir::DenseI64ArrayAttr kernel, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr pad, ::mlir::TypeAttr acc_type) {
|
|
buildAvgPool2dAdaptiveOpWithQuantInfo(odsBuilder, odsState, outputType,
|
|
input, kernel, stride, pad, acc_type);
|
|
|
|
}
|
|
|
|
AvgPool2dAdaptiveOp AvgPool2dAdaptiveOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type outputType, ::mlir::Value input, ::mlir::DenseI64ArrayAttr kernel, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr pad, ::mlir::TypeAttr acc_type) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(outputType)>(outputType), std::forward<decltype(input)>(input), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(acc_type)>(acc_type));
|
|
auto __res__ = ::llvm::dyn_cast<AvgPool2dAdaptiveOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AvgPool2dAdaptiveOp AvgPool2dAdaptiveOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type outputType, ::mlir::Value input, ::mlir::DenseI64ArrayAttr kernel, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr pad, ::mlir::TypeAttr acc_type) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(outputType)>(outputType), std::forward<decltype(input)>(input), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(acc_type)>(acc_type));
|
|
}
|
|
|
|
void AvgPool2dAdaptiveOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, ::mlir::Value input_zp, ::mlir::Value output_zp, ::mlir::Value kernel, ::mlir::Value stride, ::mlir::Value pad, ::mlir::TypeAttr acc_type) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(input_zp);
|
|
odsState.addOperands(output_zp);
|
|
odsState.addOperands(kernel);
|
|
odsState.addOperands(stride);
|
|
odsState.addOperands(pad);
|
|
odsState.getOrAddProperties<Properties>().acc_type = acc_type;
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
AvgPool2dAdaptiveOp AvgPool2dAdaptiveOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, ::mlir::Value input_zp, ::mlir::Value output_zp, ::mlir::Value kernel, ::mlir::Value stride, ::mlir::Value pad, ::mlir::TypeAttr acc_type) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(output_zp)>(output_zp), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(acc_type)>(acc_type));
|
|
auto __res__ = ::llvm::dyn_cast<AvgPool2dAdaptiveOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AvgPool2dAdaptiveOp AvgPool2dAdaptiveOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, ::mlir::Value input_zp, ::mlir::Value output_zp, ::mlir::Value kernel, ::mlir::Value stride, ::mlir::Value pad, ::mlir::TypeAttr acc_type) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(output_zp)>(output_zp), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(acc_type)>(acc_type));
|
|
}
|
|
|
|
void AvgPool2dAdaptiveOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value input_zp, ::mlir::Value output_zp, ::mlir::Value kernel, ::mlir::Value stride, ::mlir::Value pad, ::mlir::TypeAttr acc_type) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(input_zp);
|
|
odsState.addOperands(output_zp);
|
|
odsState.addOperands(kernel);
|
|
odsState.addOperands(stride);
|
|
odsState.addOperands(pad);
|
|
odsState.getOrAddProperties<Properties>().acc_type = acc_type;
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
AvgPool2dAdaptiveOp AvgPool2dAdaptiveOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value input_zp, ::mlir::Value output_zp, ::mlir::Value kernel, ::mlir::Value stride, ::mlir::Value pad, ::mlir::TypeAttr acc_type) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(output_zp)>(output_zp), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(acc_type)>(acc_type));
|
|
auto __res__ = ::llvm::dyn_cast<AvgPool2dAdaptiveOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AvgPool2dAdaptiveOp AvgPool2dAdaptiveOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value input_zp, ::mlir::Value output_zp, ::mlir::Value kernel, ::mlir::Value stride, ::mlir::Value pad, ::mlir::TypeAttr acc_type) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(output_zp)>(output_zp), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(acc_type)>(acc_type));
|
|
}
|
|
|
|
void AvgPool2dAdaptiveOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, ::mlir::Value input_zp, ::mlir::Value output_zp, ::mlir::Value kernel, ::mlir::Value stride, ::mlir::Value pad, ::mlir::Type acc_type) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(input_zp);
|
|
odsState.addOperands(output_zp);
|
|
odsState.addOperands(kernel);
|
|
odsState.addOperands(stride);
|
|
odsState.addOperands(pad);
|
|
odsState.getOrAddProperties<Properties>().acc_type = ::mlir::TypeAttr::get(acc_type);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
AvgPool2dAdaptiveOp AvgPool2dAdaptiveOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, ::mlir::Value input_zp, ::mlir::Value output_zp, ::mlir::Value kernel, ::mlir::Value stride, ::mlir::Value pad, ::mlir::Type acc_type) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(output_zp)>(output_zp), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(acc_type)>(acc_type));
|
|
auto __res__ = ::llvm::dyn_cast<AvgPool2dAdaptiveOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AvgPool2dAdaptiveOp AvgPool2dAdaptiveOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, ::mlir::Value input_zp, ::mlir::Value output_zp, ::mlir::Value kernel, ::mlir::Value stride, ::mlir::Value pad, ::mlir::Type acc_type) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(output_zp)>(output_zp), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(acc_type)>(acc_type));
|
|
}
|
|
|
|
void AvgPool2dAdaptiveOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value input_zp, ::mlir::Value output_zp, ::mlir::Value kernel, ::mlir::Value stride, ::mlir::Value pad, ::mlir::Type acc_type) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(input_zp);
|
|
odsState.addOperands(output_zp);
|
|
odsState.addOperands(kernel);
|
|
odsState.addOperands(stride);
|
|
odsState.addOperands(pad);
|
|
odsState.getOrAddProperties<Properties>().acc_type = ::mlir::TypeAttr::get(acc_type);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
AvgPool2dAdaptiveOp AvgPool2dAdaptiveOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value input_zp, ::mlir::Value output_zp, ::mlir::Value kernel, ::mlir::Value stride, ::mlir::Value pad, ::mlir::Type acc_type) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(output_zp)>(output_zp), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(acc_type)>(acc_type));
|
|
auto __res__ = ::llvm::dyn_cast<AvgPool2dAdaptiveOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AvgPool2dAdaptiveOp AvgPool2dAdaptiveOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value input_zp, ::mlir::Value output_zp, ::mlir::Value kernel, ::mlir::Value stride, ::mlir::Value pad, ::mlir::Type acc_type) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(output_zp)>(output_zp), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(acc_type)>(acc_type));
|
|
}
|
|
|
|
void AvgPool2dAdaptiveOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 6u && "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<AvgPool2dAdaptiveOp::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.");
|
|
}
|
|
}
|
|
|
|
AvgPool2dAdaptiveOp AvgPool2dAdaptiveOp::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<AvgPool2dAdaptiveOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AvgPool2dAdaptiveOp AvgPool2dAdaptiveOp::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 AvgPool2dAdaptiveOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
|
|
assert(operands.size() == 6u && "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);
|
|
}
|
|
|
|
AvgPool2dAdaptiveOp AvgPool2dAdaptiveOp::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<AvgPool2dAdaptiveOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AvgPool2dAdaptiveOp AvgPool2dAdaptiveOp::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 AvgPool2dAdaptiveOp::verifyInvariantsImpl() {
|
|
auto tblgen_acc_type = getProperties().acc_type; (void)tblgen_acc_type;
|
|
if (!tblgen_acc_type) return emitOpError("requires attribute 'acc_type'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps5(*this, tblgen_acc_type, "acc_type")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps6(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps7(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps7(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup3 = getODSOperands(3);
|
|
|
|
for (auto v : valueGroup3) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps8(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup4 = getODSOperands(4);
|
|
|
|
for (auto v : valueGroup4) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps8(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup5 = getODSOperands(5);
|
|
|
|
for (auto v : valueGroup5) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps9(*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_TosaOps6(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult AvgPool2dAdaptiveOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult AvgPool2dAdaptiveOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void AvgPool2dAdaptiveOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void AvgPool2dAdaptiveOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
AvgPool2dAdaptiveOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
AvgPool2dAdaptiveOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return AvgPool2dAdaptiveOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::AvgPool2dAdaptiveOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::AvgPool2dAdaptiveOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::AvgPool2dOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
AvgPool2dOpGenericAdaptorBase::AvgPool2dOpGenericAdaptorBase(AvgPool2dOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::llvm::ArrayRef<int64_t> AvgPool2dOpGenericAdaptorBase::getKernel() {
|
|
auto attr = getKernelAttr();
|
|
return attr;
|
|
}
|
|
|
|
::llvm::ArrayRef<int64_t> AvgPool2dOpGenericAdaptorBase::getStride() {
|
|
auto attr = getStrideAttr();
|
|
return attr;
|
|
}
|
|
|
|
::llvm::ArrayRef<int64_t> AvgPool2dOpGenericAdaptorBase::getPad() {
|
|
auto attr = getPadAttr();
|
|
return attr;
|
|
}
|
|
|
|
::mlir::Type AvgPool2dOpGenericAdaptorBase::getAccType() {
|
|
auto attr = getAccTypeAttr();
|
|
return ::llvm::cast<::mlir::Type>(attr.getValue());
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
AvgPool2dOpAdaptor::AvgPool2dOpAdaptor(AvgPool2dOp op) : AvgPool2dOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult AvgPool2dOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_acc_type = getProperties().acc_type; (void)tblgen_acc_type;
|
|
if (!tblgen_acc_type) return emitError(loc, "'tosa.avg_pool2d' op requires attribute 'acc_type'");
|
|
auto tblgen_kernel = getProperties().kernel; (void)tblgen_kernel;
|
|
if (!tblgen_kernel) return emitError(loc, "'tosa.avg_pool2d' op requires attribute 'kernel'");
|
|
auto tblgen_pad = getProperties().pad; (void)tblgen_pad;
|
|
if (!tblgen_pad) return emitError(loc, "'tosa.avg_pool2d' op requires attribute 'pad'");
|
|
auto tblgen_stride = getProperties().stride; (void)tblgen_stride;
|
|
if (!tblgen_stride) return emitError(loc, "'tosa.avg_pool2d' op requires attribute 'stride'");
|
|
|
|
if (tblgen_kernel && !(((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_kernel))) && ((::llvm::cast<::mlir::DenseArrayAttr>(tblgen_kernel).size() == 2))))
|
|
return emitError(loc, "'tosa.avg_pool2d' op attribute 'kernel' failed to satisfy constraint: i64 dense array attribute with exactly 2 elements");
|
|
|
|
if (tblgen_stride && !(((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_stride))) && ((::llvm::cast<::mlir::DenseArrayAttr>(tblgen_stride).size() == 2))))
|
|
return emitError(loc, "'tosa.avg_pool2d' op attribute 'stride' failed to satisfy constraint: i64 dense array attribute with exactly 2 elements");
|
|
|
|
if (tblgen_pad && !(((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_pad))) && ((::llvm::cast<::mlir::DenseArrayAttr>(tblgen_pad).size() == 4))))
|
|
return emitError(loc, "'tosa.avg_pool2d' op attribute 'pad' failed to satisfy constraint: i64 dense array attribute with exactly 4 elements");
|
|
|
|
if (tblgen_acc_type && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_acc_type))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_acc_type).getValue()))) && (((::llvm::cast<::mlir::TypeAttr>(tblgen_acc_type).getValue().isSignlessInteger(32))) || ((::llvm::cast<::mlir::TypeAttr>(tblgen_acc_type).getValue().isSignlessInteger(48))) || ((::llvm::cast<::mlir::TypeAttr>(tblgen_acc_type).getValue().isF16())) || ((::llvm::cast<::mlir::TypeAttr>(tblgen_acc_type).getValue().isF32())))))
|
|
return emitError(loc, "'tosa.avg_pool2d' op attribute 'acc_type' failed to satisfy constraint: type attribute of 32-bit signless integer or 48-bit signless integer or 16-bit float or 32-bit float");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult AvgPool2dOp::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.acc_type;
|
|
auto attr = dict.get("acc_type");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `acc_type` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.kernel;
|
|
auto attr = dict.get("kernel");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `kernel` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.pad;
|
|
auto attr = dict.get("pad");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `pad` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.stride;
|
|
auto attr = dict.get("stride");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `stride` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute AvgPool2dOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.acc_type;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("acc_type",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.kernel;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("kernel",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.pad;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("pad",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.stride;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("stride",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code AvgPool2dOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.acc_type.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.kernel.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.pad.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.stride.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> AvgPool2dOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "acc_type")
|
|
return prop.acc_type;
|
|
|
|
if (name == "kernel")
|
|
return prop.kernel;
|
|
|
|
if (name == "pad")
|
|
return prop.pad;
|
|
|
|
if (name == "stride")
|
|
return prop.stride;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void AvgPool2dOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "acc_type") {
|
|
prop.acc_type = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.acc_type)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "kernel") {
|
|
prop.kernel = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.kernel)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "pad") {
|
|
prop.pad = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.pad)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "stride") {
|
|
prop.stride = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.stride)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void AvgPool2dOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.acc_type) attrs.append("acc_type", prop.acc_type);
|
|
|
|
if (prop.kernel) attrs.append("kernel", prop.kernel);
|
|
|
|
if (prop.pad) attrs.append("pad", prop.pad);
|
|
|
|
if (prop.stride) attrs.append("stride", prop.stride);
|
|
}
|
|
|
|
::llvm::LogicalResult AvgPool2dOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getAccTypeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps5(attr, "acc_type", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getKernelAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps6(attr, "kernel", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getPadAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps7(attr, "pad", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getStrideAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps6(attr, "stride", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult AvgPool2dOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.acc_type)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readAttribute(prop.kernel)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readAttribute(prop.pad)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readAttribute(prop.stride)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void AvgPool2dOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.acc_type);
|
|
writer.writeAttribute(prop.kernel);
|
|
writer.writeAttribute(prop.pad);
|
|
writer.writeAttribute(prop.stride);
|
|
}
|
|
|
|
::llvm::ArrayRef<int64_t> AvgPool2dOp::getKernel() {
|
|
auto attr = getKernelAttr();
|
|
return attr;
|
|
}
|
|
|
|
::llvm::ArrayRef<int64_t> AvgPool2dOp::getStride() {
|
|
auto attr = getStrideAttr();
|
|
return attr;
|
|
}
|
|
|
|
::llvm::ArrayRef<int64_t> AvgPool2dOp::getPad() {
|
|
auto attr = getPadAttr();
|
|
return attr;
|
|
}
|
|
|
|
::mlir::Type AvgPool2dOp::getAccType() {
|
|
auto attr = getAccTypeAttr();
|
|
return ::llvm::cast<::mlir::Type>(attr.getValue());
|
|
}
|
|
|
|
void AvgPool2dOp::setKernel(::llvm::ArrayRef<int64_t> attrValue) {
|
|
getProperties().kernel = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue);
|
|
}
|
|
|
|
void AvgPool2dOp::setStride(::llvm::ArrayRef<int64_t> attrValue) {
|
|
getProperties().stride = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue);
|
|
}
|
|
|
|
void AvgPool2dOp::setPad(::llvm::ArrayRef<int64_t> attrValue) {
|
|
getProperties().pad = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue);
|
|
}
|
|
|
|
void AvgPool2dOp::setAccType(::mlir::Type attrValue) {
|
|
getProperties().acc_type = ::mlir::TypeAttr::get(attrValue);
|
|
}
|
|
|
|
void AvgPool2dOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type outputType, ::mlir::Value input, ::mlir::DenseI64ArrayAttr kernel, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr pad, ::mlir::TypeAttr acc_type) {
|
|
buildAvgPool2dOpWithQuantInfo(odsBuilder, odsState, outputType,
|
|
input, kernel, stride, pad, acc_type);
|
|
|
|
}
|
|
|
|
AvgPool2dOp AvgPool2dOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type outputType, ::mlir::Value input, ::mlir::DenseI64ArrayAttr kernel, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr pad, ::mlir::TypeAttr acc_type) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(outputType)>(outputType), std::forward<decltype(input)>(input), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(acc_type)>(acc_type));
|
|
auto __res__ = ::llvm::dyn_cast<AvgPool2dOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AvgPool2dOp AvgPool2dOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type outputType, ::mlir::Value input, ::mlir::DenseI64ArrayAttr kernel, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr pad, ::mlir::TypeAttr acc_type) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(outputType)>(outputType), std::forward<decltype(input)>(input), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(acc_type)>(acc_type));
|
|
}
|
|
|
|
void AvgPool2dOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, ::mlir::Value input_zp, ::mlir::Value output_zp, ::mlir::DenseI64ArrayAttr kernel, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr pad, ::mlir::TypeAttr acc_type) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(input_zp);
|
|
odsState.addOperands(output_zp);
|
|
odsState.getOrAddProperties<Properties>().kernel = kernel;
|
|
odsState.getOrAddProperties<Properties>().stride = stride;
|
|
odsState.getOrAddProperties<Properties>().pad = pad;
|
|
odsState.getOrAddProperties<Properties>().acc_type = acc_type;
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
AvgPool2dOp AvgPool2dOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, ::mlir::Value input_zp, ::mlir::Value output_zp, ::mlir::DenseI64ArrayAttr kernel, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr pad, ::mlir::TypeAttr acc_type) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(output_zp)>(output_zp), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(acc_type)>(acc_type));
|
|
auto __res__ = ::llvm::dyn_cast<AvgPool2dOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AvgPool2dOp AvgPool2dOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, ::mlir::Value input_zp, ::mlir::Value output_zp, ::mlir::DenseI64ArrayAttr kernel, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr pad, ::mlir::TypeAttr acc_type) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(output_zp)>(output_zp), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(acc_type)>(acc_type));
|
|
}
|
|
|
|
void AvgPool2dOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value input_zp, ::mlir::Value output_zp, ::mlir::DenseI64ArrayAttr kernel, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr pad, ::mlir::TypeAttr acc_type) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(input_zp);
|
|
odsState.addOperands(output_zp);
|
|
odsState.getOrAddProperties<Properties>().kernel = kernel;
|
|
odsState.getOrAddProperties<Properties>().stride = stride;
|
|
odsState.getOrAddProperties<Properties>().pad = pad;
|
|
odsState.getOrAddProperties<Properties>().acc_type = acc_type;
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
AvgPool2dOp AvgPool2dOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value input_zp, ::mlir::Value output_zp, ::mlir::DenseI64ArrayAttr kernel, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr pad, ::mlir::TypeAttr acc_type) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(output_zp)>(output_zp), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(acc_type)>(acc_type));
|
|
auto __res__ = ::llvm::dyn_cast<AvgPool2dOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AvgPool2dOp AvgPool2dOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value input_zp, ::mlir::Value output_zp, ::mlir::DenseI64ArrayAttr kernel, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr pad, ::mlir::TypeAttr acc_type) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(output_zp)>(output_zp), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(acc_type)>(acc_type));
|
|
}
|
|
|
|
void AvgPool2dOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, ::mlir::Value input_zp, ::mlir::Value output_zp, ::llvm::ArrayRef<int64_t> kernel, ::llvm::ArrayRef<int64_t> stride, ::llvm::ArrayRef<int64_t> pad, ::mlir::Type acc_type) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(input_zp);
|
|
odsState.addOperands(output_zp);
|
|
odsState.getOrAddProperties<Properties>().kernel = odsBuilder.getDenseI64ArrayAttr(kernel);
|
|
odsState.getOrAddProperties<Properties>().stride = odsBuilder.getDenseI64ArrayAttr(stride);
|
|
odsState.getOrAddProperties<Properties>().pad = odsBuilder.getDenseI64ArrayAttr(pad);
|
|
odsState.getOrAddProperties<Properties>().acc_type = ::mlir::TypeAttr::get(acc_type);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
AvgPool2dOp AvgPool2dOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, ::mlir::Value input_zp, ::mlir::Value output_zp, ::llvm::ArrayRef<int64_t> kernel, ::llvm::ArrayRef<int64_t> stride, ::llvm::ArrayRef<int64_t> pad, ::mlir::Type acc_type) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(output_zp)>(output_zp), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(acc_type)>(acc_type));
|
|
auto __res__ = ::llvm::dyn_cast<AvgPool2dOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AvgPool2dOp AvgPool2dOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, ::mlir::Value input_zp, ::mlir::Value output_zp, ::llvm::ArrayRef<int64_t> kernel, ::llvm::ArrayRef<int64_t> stride, ::llvm::ArrayRef<int64_t> pad, ::mlir::Type acc_type) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(output_zp)>(output_zp), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(acc_type)>(acc_type));
|
|
}
|
|
|
|
void AvgPool2dOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value input_zp, ::mlir::Value output_zp, ::llvm::ArrayRef<int64_t> kernel, ::llvm::ArrayRef<int64_t> stride, ::llvm::ArrayRef<int64_t> pad, ::mlir::Type acc_type) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(input_zp);
|
|
odsState.addOperands(output_zp);
|
|
odsState.getOrAddProperties<Properties>().kernel = odsBuilder.getDenseI64ArrayAttr(kernel);
|
|
odsState.getOrAddProperties<Properties>().stride = odsBuilder.getDenseI64ArrayAttr(stride);
|
|
odsState.getOrAddProperties<Properties>().pad = odsBuilder.getDenseI64ArrayAttr(pad);
|
|
odsState.getOrAddProperties<Properties>().acc_type = ::mlir::TypeAttr::get(acc_type);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
AvgPool2dOp AvgPool2dOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value input_zp, ::mlir::Value output_zp, ::llvm::ArrayRef<int64_t> kernel, ::llvm::ArrayRef<int64_t> stride, ::llvm::ArrayRef<int64_t> pad, ::mlir::Type acc_type) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(output_zp)>(output_zp), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(acc_type)>(acc_type));
|
|
auto __res__ = ::llvm::dyn_cast<AvgPool2dOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AvgPool2dOp AvgPool2dOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value input_zp, ::mlir::Value output_zp, ::llvm::ArrayRef<int64_t> kernel, ::llvm::ArrayRef<int64_t> stride, ::llvm::ArrayRef<int64_t> pad, ::mlir::Type acc_type) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(output_zp)>(output_zp), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(acc_type)>(acc_type));
|
|
}
|
|
|
|
void AvgPool2dOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 3u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<AvgPool2dOp::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.");
|
|
}
|
|
}
|
|
|
|
AvgPool2dOp AvgPool2dOp::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<AvgPool2dOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AvgPool2dOp AvgPool2dOp::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 AvgPool2dOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
|
|
assert(operands.size() == 3u && "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);
|
|
}
|
|
|
|
AvgPool2dOp AvgPool2dOp::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<AvgPool2dOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
AvgPool2dOp AvgPool2dOp::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 AvgPool2dOp::verifyInvariantsImpl() {
|
|
auto tblgen_acc_type = getProperties().acc_type; (void)tblgen_acc_type;
|
|
if (!tblgen_acc_type) return emitOpError("requires attribute 'acc_type'");
|
|
auto tblgen_kernel = getProperties().kernel; (void)tblgen_kernel;
|
|
if (!tblgen_kernel) return emitOpError("requires attribute 'kernel'");
|
|
auto tblgen_pad = getProperties().pad; (void)tblgen_pad;
|
|
if (!tblgen_pad) return emitOpError("requires attribute 'pad'");
|
|
auto tblgen_stride = getProperties().stride; (void)tblgen_stride;
|
|
if (!tblgen_stride) return emitOpError("requires attribute 'stride'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps6(*this, tblgen_kernel, "kernel")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps6(*this, tblgen_stride, "stride")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps7(*this, tblgen_pad, "pad")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps5(*this, tblgen_acc_type, "acc_type")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps6(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps7(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps7(*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_TosaOps6(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult AvgPool2dOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult AvgPool2dOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void AvgPool2dOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void AvgPool2dOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
AvgPool2dOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
AvgPool2dOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return AvgPool2dOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::AvgPool2dOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::AvgPool2dOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::BitwiseAndOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
BitwiseAndOpGenericAdaptorBase::BitwiseAndOpGenericAdaptorBase(BitwiseAndOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
BitwiseAndOpAdaptor::BitwiseAndOpAdaptor(BitwiseAndOp op) : BitwiseAndOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult BitwiseAndOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult BitwiseAndOp::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 BitwiseAndOp::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 BitwiseAndOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> BitwiseAndOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void BitwiseAndOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void BitwiseAndOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult BitwiseAndOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void BitwiseAndOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
BitwiseAndOp BitwiseAndOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<BitwiseAndOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
BitwiseAndOp BitwiseAndOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void BitwiseAndOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
BitwiseAndOp BitwiseAndOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<BitwiseAndOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
BitwiseAndOp BitwiseAndOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void BitwiseAndOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
BitwiseAndOp BitwiseAndOp::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<BitwiseAndOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
BitwiseAndOp BitwiseAndOp::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 BitwiseAndOp::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);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
BitwiseAndOp BitwiseAndOp::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<BitwiseAndOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
BitwiseAndOp BitwiseAndOp::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 BitwiseAndOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*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_TosaOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult BitwiseAndOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult BitwiseAndOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void BitwiseAndOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void BitwiseAndOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::BitwiseAndOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::BitwiseNotOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
BitwiseNotOpGenericAdaptorBase::BitwiseNotOpGenericAdaptorBase(BitwiseNotOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
BitwiseNotOpAdaptor::BitwiseNotOpAdaptor(BitwiseNotOp op) : BitwiseNotOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult BitwiseNotOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult BitwiseNotOp::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 BitwiseNotOp::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 BitwiseNotOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> BitwiseNotOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void BitwiseNotOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void BitwiseNotOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult BitwiseNotOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void BitwiseNotOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1) {
|
|
odsState.addOperands(input1);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
BitwiseNotOp BitwiseNotOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1));
|
|
auto __res__ = ::llvm::dyn_cast<BitwiseNotOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
BitwiseNotOp BitwiseNotOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1));
|
|
}
|
|
|
|
void BitwiseNotOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
odsState.addOperands(input1);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
BitwiseNotOp BitwiseNotOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1));
|
|
auto __res__ = ::llvm::dyn_cast<BitwiseNotOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
BitwiseNotOp BitwiseNotOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1));
|
|
}
|
|
|
|
void BitwiseNotOp::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);
|
|
}
|
|
|
|
BitwiseNotOp BitwiseNotOp::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<BitwiseNotOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
BitwiseNotOp BitwiseNotOp::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 BitwiseNotOp::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);
|
|
}
|
|
|
|
BitwiseNotOp BitwiseNotOp::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<BitwiseNotOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
BitwiseNotOp BitwiseNotOp::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 BitwiseNotOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*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_TosaOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult BitwiseNotOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult BitwiseNotOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void BitwiseNotOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void BitwiseNotOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::BitwiseNotOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::BitwiseOrOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
BitwiseOrOpGenericAdaptorBase::BitwiseOrOpGenericAdaptorBase(BitwiseOrOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
BitwiseOrOpAdaptor::BitwiseOrOpAdaptor(BitwiseOrOp op) : BitwiseOrOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult BitwiseOrOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult BitwiseOrOp::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 BitwiseOrOp::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 BitwiseOrOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> BitwiseOrOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void BitwiseOrOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void BitwiseOrOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult BitwiseOrOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void BitwiseOrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
BitwiseOrOp BitwiseOrOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<BitwiseOrOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
BitwiseOrOp BitwiseOrOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void BitwiseOrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
BitwiseOrOp BitwiseOrOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<BitwiseOrOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
BitwiseOrOp BitwiseOrOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void BitwiseOrOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
BitwiseOrOp BitwiseOrOp::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<BitwiseOrOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
BitwiseOrOp BitwiseOrOp::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 BitwiseOrOp::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);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
BitwiseOrOp BitwiseOrOp::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<BitwiseOrOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
BitwiseOrOp BitwiseOrOp::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 BitwiseOrOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*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_TosaOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult BitwiseOrOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult BitwiseOrOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void BitwiseOrOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void BitwiseOrOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::BitwiseOrOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::BitwiseXorOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
BitwiseXorOpGenericAdaptorBase::BitwiseXorOpGenericAdaptorBase(BitwiseXorOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
BitwiseXorOpAdaptor::BitwiseXorOpAdaptor(BitwiseXorOp op) : BitwiseXorOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult BitwiseXorOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult BitwiseXorOp::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 BitwiseXorOp::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 BitwiseXorOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> BitwiseXorOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void BitwiseXorOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void BitwiseXorOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult BitwiseXorOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void BitwiseXorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
BitwiseXorOp BitwiseXorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<BitwiseXorOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
BitwiseXorOp BitwiseXorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void BitwiseXorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
BitwiseXorOp BitwiseXorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<BitwiseXorOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
BitwiseXorOp BitwiseXorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void BitwiseXorOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
BitwiseXorOp BitwiseXorOp::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<BitwiseXorOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
BitwiseXorOp BitwiseXorOp::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 BitwiseXorOp::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);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
BitwiseXorOp BitwiseXorOp::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<BitwiseXorOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
BitwiseXorOp BitwiseXorOp::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 BitwiseXorOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*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_TosaOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult BitwiseXorOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult BitwiseXorOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void BitwiseXorOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void BitwiseXorOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::BitwiseXorOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::CastFromBlockScaledOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
CastFromBlockScaledOpGenericAdaptorBase::CastFromBlockScaledOpGenericAdaptorBase(CastFromBlockScaledOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::mlir::tosa::BlockSize CastFromBlockScaledOpGenericAdaptorBase::getBlockSize() {
|
|
auto attr = getBlockSizeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
CastFromBlockScaledOpAdaptor::CastFromBlockScaledOpAdaptor(CastFromBlockScaledOp op) : CastFromBlockScaledOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult CastFromBlockScaledOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_block_size = getProperties().block_size; (void)tblgen_block_size;
|
|
if (!tblgen_block_size) return emitError(loc, "'tosa.cast_from_block_scaled' op requires attribute 'block_size'");
|
|
|
|
if (tblgen_block_size && !((::llvm::isa<mlir::tosa::BlockSizeAttr>(tblgen_block_size))))
|
|
return emitError(loc, "'tosa.cast_from_block_scaled' op attribute 'block_size' failed to satisfy constraint: Block size for the block_scaled formats");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult CastFromBlockScaledOp::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.block_size;
|
|
auto attr = dict.get("block_size");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `block_size` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute CastFromBlockScaledOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.block_size;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("block_size",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code CastFromBlockScaledOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.block_size.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> CastFromBlockScaledOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "block_size")
|
|
return prop.block_size;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void CastFromBlockScaledOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "block_size") {
|
|
prop.block_size = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.block_size)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void CastFromBlockScaledOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.block_size) attrs.append("block_size", prop.block_size);
|
|
}
|
|
|
|
::llvm::LogicalResult CastFromBlockScaledOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getBlockSizeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps8(attr, "block_size", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult CastFromBlockScaledOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.block_size)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void CastFromBlockScaledOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.block_size);
|
|
}
|
|
|
|
::mlir::tosa::BlockSize CastFromBlockScaledOp::getBlockSize() {
|
|
auto attr = getBlockSizeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
void CastFromBlockScaledOp::setBlockSize(::mlir::tosa::BlockSize attrValue) {
|
|
getProperties().block_size = ::mlir::tosa::BlockSizeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue);
|
|
}
|
|
|
|
void CastFromBlockScaledOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output_data, ::mlir::Value input_data, ::mlir::Value input_scale, mlir::tosa::BlockSizeAttr block_size) {
|
|
odsState.addOperands(input_data);
|
|
odsState.addOperands(input_scale);
|
|
odsState.getOrAddProperties<Properties>().block_size = block_size;
|
|
odsState.addTypes(output_data);
|
|
}
|
|
|
|
CastFromBlockScaledOp CastFromBlockScaledOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output_data, ::mlir::Value input_data, ::mlir::Value input_scale, mlir::tosa::BlockSizeAttr block_size) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output_data)>(output_data), std::forward<decltype(input_data)>(input_data), std::forward<decltype(input_scale)>(input_scale), std::forward<decltype(block_size)>(block_size));
|
|
auto __res__ = ::llvm::dyn_cast<CastFromBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CastFromBlockScaledOp CastFromBlockScaledOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output_data, ::mlir::Value input_data, ::mlir::Value input_scale, mlir::tosa::BlockSizeAttr block_size) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output_data)>(output_data), std::forward<decltype(input_data)>(input_data), std::forward<decltype(input_scale)>(input_scale), std::forward<decltype(block_size)>(block_size));
|
|
}
|
|
|
|
void CastFromBlockScaledOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input_data, ::mlir::Value input_scale, mlir::tosa::BlockSizeAttr block_size) {
|
|
odsState.addOperands(input_data);
|
|
odsState.addOperands(input_scale);
|
|
odsState.getOrAddProperties<Properties>().block_size = block_size;
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
CastFromBlockScaledOp CastFromBlockScaledOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input_data, ::mlir::Value input_scale, mlir::tosa::BlockSizeAttr block_size) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input_data)>(input_data), std::forward<decltype(input_scale)>(input_scale), std::forward<decltype(block_size)>(block_size));
|
|
auto __res__ = ::llvm::dyn_cast<CastFromBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CastFromBlockScaledOp CastFromBlockScaledOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input_data, ::mlir::Value input_scale, mlir::tosa::BlockSizeAttr block_size) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input_data)>(input_data), std::forward<decltype(input_scale)>(input_scale), std::forward<decltype(block_size)>(block_size));
|
|
}
|
|
|
|
void CastFromBlockScaledOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output_data, ::mlir::Value input_data, ::mlir::Value input_scale, ::mlir::tosa::BlockSize block_size) {
|
|
odsState.addOperands(input_data);
|
|
odsState.addOperands(input_scale);
|
|
odsState.getOrAddProperties<Properties>().block_size = ::mlir::tosa::BlockSizeAttr::get(odsBuilder.getContext(), block_size);
|
|
odsState.addTypes(output_data);
|
|
}
|
|
|
|
CastFromBlockScaledOp CastFromBlockScaledOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output_data, ::mlir::Value input_data, ::mlir::Value input_scale, ::mlir::tosa::BlockSize block_size) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output_data)>(output_data), std::forward<decltype(input_data)>(input_data), std::forward<decltype(input_scale)>(input_scale), std::forward<decltype(block_size)>(block_size));
|
|
auto __res__ = ::llvm::dyn_cast<CastFromBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CastFromBlockScaledOp CastFromBlockScaledOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output_data, ::mlir::Value input_data, ::mlir::Value input_scale, ::mlir::tosa::BlockSize block_size) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output_data)>(output_data), std::forward<decltype(input_data)>(input_data), std::forward<decltype(input_scale)>(input_scale), std::forward<decltype(block_size)>(block_size));
|
|
}
|
|
|
|
void CastFromBlockScaledOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input_data, ::mlir::Value input_scale, ::mlir::tosa::BlockSize block_size) {
|
|
odsState.addOperands(input_data);
|
|
odsState.addOperands(input_scale);
|
|
odsState.getOrAddProperties<Properties>().block_size = ::mlir::tosa::BlockSizeAttr::get(odsBuilder.getContext(), block_size);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
CastFromBlockScaledOp CastFromBlockScaledOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input_data, ::mlir::Value input_scale, ::mlir::tosa::BlockSize block_size) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input_data)>(input_data), std::forward<decltype(input_scale)>(input_scale), std::forward<decltype(block_size)>(block_size));
|
|
auto __res__ = ::llvm::dyn_cast<CastFromBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CastFromBlockScaledOp CastFromBlockScaledOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input_data, ::mlir::Value input_scale, ::mlir::tosa::BlockSize block_size) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input_data)>(input_data), std::forward<decltype(input_scale)>(input_scale), std::forward<decltype(block_size)>(block_size));
|
|
}
|
|
|
|
void CastFromBlockScaledOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<CastFromBlockScaledOp::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.");
|
|
}
|
|
}
|
|
|
|
CastFromBlockScaledOp CastFromBlockScaledOp::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<CastFromBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CastFromBlockScaledOp CastFromBlockScaledOp::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 CastFromBlockScaledOp::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);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
CastFromBlockScaledOp CastFromBlockScaledOp::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<CastFromBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CastFromBlockScaledOp CastFromBlockScaledOp::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 CastFromBlockScaledOp::verifyInvariantsImpl() {
|
|
auto tblgen_block_size = getProperties().block_size; (void)tblgen_block_size;
|
|
if (!tblgen_block_size) return emitOpError("requires attribute 'block_size'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps8(*this, tblgen_block_size, "block_size")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps10(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps11(*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_TosaOps5(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult CastFromBlockScaledOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::llvm::LogicalResult CastFromBlockScaledOp::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.block_size;
|
|
auto block_sizeAttrName = ::mlir::StringAttr::get(ctx, "block_size");
|
|
auto attr = dict.get(block_sizeAttrName);
|
|
usedKeys.insert(block_sizeAttrName);
|
|
if (attr || /*isRequired=*/true) {
|
|
if (!attr) {
|
|
emitError() << "expected key entry for block_size 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 `block_size` 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();
|
|
}
|
|
|
|
void CastFromBlockScaledOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
CastFromBlockScaledOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
CastFromBlockScaledOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return CastFromBlockScaledOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::CastFromBlockScaledOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::CastFromBlockScaledOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::CastOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
CastOpGenericAdaptorBase::CastOpGenericAdaptorBase(CastOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
CastOpAdaptor::CastOpAdaptor(CastOp op) : CastOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult CastOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult CastOp::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 CastOp::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 CastOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> CastOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void CastOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void CastOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult CastOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void CastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input) {
|
|
odsState.addOperands(input);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
CastOp CastOp::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<CastOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CastOp CastOp::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 CastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input) {
|
|
odsState.addOperands(input);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
CastOp CastOp::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<CastOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CastOp CastOp::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 CastOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 1u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
CastOp CastOp::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<CastOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CastOp CastOp::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 CastOp::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);
|
|
}
|
|
|
|
CastOp CastOp::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<CastOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CastOp CastOp::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 CastOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*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_TosaOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult CastOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult CastOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void CastOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void CastOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::CastOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::CastToBlockScaledOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
CastToBlockScaledOpGenericAdaptorBase::CastToBlockScaledOpGenericAdaptorBase(CastToBlockScaledOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::mlir::tosa::BlockSize CastToBlockScaledOpGenericAdaptorBase::getBlockSize() {
|
|
auto attr = getBlockSizeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
CastToBlockScaledOpAdaptor::CastToBlockScaledOpAdaptor(CastToBlockScaledOp op) : CastToBlockScaledOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult CastToBlockScaledOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_block_size = getProperties().block_size; (void)tblgen_block_size;
|
|
if (!tblgen_block_size) return emitError(loc, "'tosa.cast_to_block_scaled' op requires attribute 'block_size'");
|
|
|
|
if (tblgen_block_size && !((::llvm::isa<mlir::tosa::BlockSizeAttr>(tblgen_block_size))))
|
|
return emitError(loc, "'tosa.cast_to_block_scaled' op attribute 'block_size' failed to satisfy constraint: Block size for the block_scaled formats");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void CastToBlockScaledOp::getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn) {
|
|
auto resultGroup0 = getODSResults(0);
|
|
if (!resultGroup0.empty())
|
|
setNameFn(*resultGroup0.begin(), "output_data");
|
|
auto resultGroup1 = getODSResults(1);
|
|
if (!resultGroup1.empty())
|
|
setNameFn(*resultGroup1.begin(), "output_scale");
|
|
}
|
|
|
|
::llvm::LogicalResult CastToBlockScaledOp::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.block_size;
|
|
auto attr = dict.get("block_size");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `block_size` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute CastToBlockScaledOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.block_size;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("block_size",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code CastToBlockScaledOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.block_size.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> CastToBlockScaledOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "block_size")
|
|
return prop.block_size;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void CastToBlockScaledOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "block_size") {
|
|
prop.block_size = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.block_size)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void CastToBlockScaledOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.block_size) attrs.append("block_size", prop.block_size);
|
|
}
|
|
|
|
::llvm::LogicalResult CastToBlockScaledOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getBlockSizeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps8(attr, "block_size", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult CastToBlockScaledOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.block_size)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void CastToBlockScaledOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.block_size);
|
|
}
|
|
|
|
::mlir::tosa::BlockSize CastToBlockScaledOp::getBlockSize() {
|
|
auto attr = getBlockSizeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
void CastToBlockScaledOp::setBlockSize(::mlir::tosa::BlockSize attrValue) {
|
|
getProperties().block_size = ::mlir::tosa::BlockSizeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue);
|
|
}
|
|
|
|
void CastToBlockScaledOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output_data, ::mlir::Type output_scale, ::mlir::Value input_data, mlir::tosa::BlockSizeAttr block_size) {
|
|
odsState.addOperands(input_data);
|
|
odsState.getOrAddProperties<Properties>().block_size = block_size;
|
|
odsState.addTypes(output_data);
|
|
odsState.addTypes(output_scale);
|
|
}
|
|
|
|
CastToBlockScaledOp CastToBlockScaledOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output_data, ::mlir::Type output_scale, ::mlir::Value input_data, mlir::tosa::BlockSizeAttr block_size) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output_data)>(output_data), std::forward<decltype(output_scale)>(output_scale), std::forward<decltype(input_data)>(input_data), std::forward<decltype(block_size)>(block_size));
|
|
auto __res__ = ::llvm::dyn_cast<CastToBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CastToBlockScaledOp CastToBlockScaledOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output_data, ::mlir::Type output_scale, ::mlir::Value input_data, mlir::tosa::BlockSizeAttr block_size) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output_data)>(output_data), std::forward<decltype(output_scale)>(output_scale), std::forward<decltype(input_data)>(input_data), std::forward<decltype(block_size)>(block_size));
|
|
}
|
|
|
|
void CastToBlockScaledOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input_data, mlir::tosa::BlockSizeAttr block_size) {
|
|
odsState.addOperands(input_data);
|
|
odsState.getOrAddProperties<Properties>().block_size = block_size;
|
|
assert(resultTypes.size() == 2u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
CastToBlockScaledOp CastToBlockScaledOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input_data, mlir::tosa::BlockSizeAttr block_size) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input_data)>(input_data), std::forward<decltype(block_size)>(block_size));
|
|
auto __res__ = ::llvm::dyn_cast<CastToBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CastToBlockScaledOp CastToBlockScaledOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input_data, mlir::tosa::BlockSizeAttr block_size) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input_data)>(input_data), std::forward<decltype(block_size)>(block_size));
|
|
}
|
|
|
|
void CastToBlockScaledOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output_data, ::mlir::Type output_scale, ::mlir::Value input_data, ::mlir::tosa::BlockSize block_size) {
|
|
odsState.addOperands(input_data);
|
|
odsState.getOrAddProperties<Properties>().block_size = ::mlir::tosa::BlockSizeAttr::get(odsBuilder.getContext(), block_size);
|
|
odsState.addTypes(output_data);
|
|
odsState.addTypes(output_scale);
|
|
}
|
|
|
|
CastToBlockScaledOp CastToBlockScaledOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output_data, ::mlir::Type output_scale, ::mlir::Value input_data, ::mlir::tosa::BlockSize block_size) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output_data)>(output_data), std::forward<decltype(output_scale)>(output_scale), std::forward<decltype(input_data)>(input_data), std::forward<decltype(block_size)>(block_size));
|
|
auto __res__ = ::llvm::dyn_cast<CastToBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CastToBlockScaledOp CastToBlockScaledOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output_data, ::mlir::Type output_scale, ::mlir::Value input_data, ::mlir::tosa::BlockSize block_size) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output_data)>(output_data), std::forward<decltype(output_scale)>(output_scale), std::forward<decltype(input_data)>(input_data), std::forward<decltype(block_size)>(block_size));
|
|
}
|
|
|
|
void CastToBlockScaledOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input_data, ::mlir::tosa::BlockSize block_size) {
|
|
odsState.addOperands(input_data);
|
|
odsState.getOrAddProperties<Properties>().block_size = ::mlir::tosa::BlockSizeAttr::get(odsBuilder.getContext(), block_size);
|
|
assert(resultTypes.size() == 2u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
CastToBlockScaledOp CastToBlockScaledOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input_data, ::mlir::tosa::BlockSize block_size) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input_data)>(input_data), std::forward<decltype(block_size)>(block_size));
|
|
auto __res__ = ::llvm::dyn_cast<CastToBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CastToBlockScaledOp CastToBlockScaledOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input_data, ::mlir::tosa::BlockSize block_size) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input_data)>(input_data), std::forward<decltype(block_size)>(block_size));
|
|
}
|
|
|
|
void CastToBlockScaledOp::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() == 2u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<CastToBlockScaledOp::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.");
|
|
}
|
|
}
|
|
|
|
CastToBlockScaledOp CastToBlockScaledOp::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<CastToBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CastToBlockScaledOp CastToBlockScaledOp::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 CastToBlockScaledOp::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() == 2u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
CastToBlockScaledOp CastToBlockScaledOp::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<CastToBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CastToBlockScaledOp CastToBlockScaledOp::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 CastToBlockScaledOp::verifyInvariantsImpl() {
|
|
auto tblgen_block_size = getProperties().block_size; (void)tblgen_block_size;
|
|
if (!tblgen_block_size) return emitOpError("requires attribute 'block_size'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps8(*this, tblgen_block_size, "block_size")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps5(*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_TosaOps10(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSResults(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps11(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult CastToBlockScaledOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::llvm::LogicalResult CastToBlockScaledOp::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.block_size;
|
|
auto block_sizeAttrName = ::mlir::StringAttr::get(ctx, "block_size");
|
|
auto attr = dict.get(block_sizeAttrName);
|
|
usedKeys.insert(block_sizeAttrName);
|
|
if (attr || /*isRequired=*/true) {
|
|
if (!attr) {
|
|
emitError() << "expected key entry for block_size 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 `block_size` 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();
|
|
}
|
|
|
|
void CastToBlockScaledOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
CastToBlockScaledOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
CastToBlockScaledOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return CastToBlockScaledOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::CastToBlockScaledOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::CastToBlockScaledOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::CeilOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
CeilOpGenericAdaptorBase::CeilOpGenericAdaptorBase(CeilOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
CeilOpAdaptor::CeilOpAdaptor(CeilOp op) : CeilOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult CeilOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult CeilOp::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 CeilOp::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 CeilOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> CeilOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void CeilOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void CeilOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult CeilOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void CeilOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1) {
|
|
odsState.addOperands(input1);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
CeilOp CeilOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1));
|
|
auto __res__ = ::llvm::dyn_cast<CeilOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CeilOp CeilOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1));
|
|
}
|
|
|
|
void CeilOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
odsState.addOperands(input1);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
CeilOp CeilOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1));
|
|
auto __res__ = ::llvm::dyn_cast<CeilOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CeilOp CeilOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1));
|
|
}
|
|
|
|
void CeilOp::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);
|
|
}
|
|
|
|
CeilOp CeilOp::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<CeilOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CeilOp CeilOp::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 CeilOp::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);
|
|
}
|
|
|
|
CeilOp CeilOp::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<CeilOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CeilOp CeilOp::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 CeilOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*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_TosaOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult CeilOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult CeilOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void CeilOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void CeilOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::CeilOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::ClampOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
ClampOpGenericAdaptorBase::ClampOpGenericAdaptorBase(ClampOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::mlir::Attribute ClampOpGenericAdaptorBase::getMinVal() {
|
|
auto attr = getMinValAttr();
|
|
return attr;
|
|
}
|
|
|
|
::mlir::Attribute ClampOpGenericAdaptorBase::getMaxVal() {
|
|
auto attr = getMaxValAttr();
|
|
return attr;
|
|
}
|
|
|
|
mlir::tosa::NanPropagationModeAttr ClampOpGenericAdaptorBase::getNanModeAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<mlir::tosa::NanPropagationModeAttr>(getProperties().nan_mode);
|
|
return attr;
|
|
}
|
|
|
|
::mlir::tosa::NanPropagationMode ClampOpGenericAdaptorBase::getNanMode() {
|
|
auto attr = getNanModeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
ClampOpAdaptor::ClampOpAdaptor(ClampOp op) : ClampOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult ClampOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_max_val = getProperties().max_val; (void)tblgen_max_val;
|
|
if (!tblgen_max_val) return emitError(loc, "'tosa.clamp' op requires attribute 'max_val'");
|
|
auto tblgen_min_val = getProperties().min_val; (void)tblgen_min_val;
|
|
if (!tblgen_min_val) return emitError(loc, "'tosa.clamp' op requires attribute 'min_val'");
|
|
auto tblgen_nan_mode = getProperties().nan_mode; (void)tblgen_nan_mode;
|
|
|
|
if (tblgen_min_val && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_min_val))) || ((::llvm::isa<::mlir::FloatAttr>(tblgen_min_val)))))
|
|
return emitError(loc, "'tosa.clamp' op attribute 'min_val' failed to satisfy constraint: arbitrary integer attribute or arbitrary float attribute");
|
|
|
|
if (tblgen_max_val && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_max_val))) || ((::llvm::isa<::mlir::FloatAttr>(tblgen_max_val)))))
|
|
return emitError(loc, "'tosa.clamp' op attribute 'max_val' failed to satisfy constraint: arbitrary integer attribute or arbitrary float attribute");
|
|
|
|
if (tblgen_nan_mode && !((::llvm::isa<mlir::tosa::NanPropagationModeAttr>(tblgen_nan_mode))))
|
|
return emitError(loc, "'tosa.clamp' op attribute 'nan_mode' failed to satisfy constraint: Supported NaN propagation strategies");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ClampOp::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.max_val;
|
|
auto attr = dict.get("max_val");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `max_val` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.min_val;
|
|
auto attr = dict.get("min_val");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `min_val` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.nan_mode;
|
|
auto attr = dict.get("nan_mode");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `nan_mode` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute ClampOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.max_val;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("max_val",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.min_val;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("min_val",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.nan_mode;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("nan_mode",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code ClampOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.max_val.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.min_val.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.nan_mode.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> ClampOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "max_val")
|
|
return prop.max_val;
|
|
|
|
if (name == "min_val")
|
|
return prop.min_val;
|
|
|
|
if (name == "nan_mode")
|
|
return prop.nan_mode;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void ClampOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "max_val") {
|
|
prop.max_val = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.max_val)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "min_val") {
|
|
prop.min_val = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.min_val)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "nan_mode") {
|
|
prop.nan_mode = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.nan_mode)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void ClampOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.max_val) attrs.append("max_val", prop.max_val);
|
|
|
|
if (prop.min_val) attrs.append("min_val", prop.min_val);
|
|
|
|
if (prop.nan_mode) attrs.append("nan_mode", prop.nan_mode);
|
|
}
|
|
|
|
::llvm::LogicalResult ClampOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getMaxValAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps9(attr, "max_val", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getMinValAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps9(attr, "min_val", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getNanModeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps3(attr, "nan_mode", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ClampOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.max_val)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readAttribute(prop.min_val)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.nan_mode)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ClampOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.max_val);
|
|
writer.writeAttribute(prop.min_val);
|
|
|
|
writer.writeOptionalAttribute(prop.nan_mode);
|
|
}
|
|
|
|
::mlir::Attribute ClampOp::getMinVal() {
|
|
auto attr = getMinValAttr();
|
|
return attr;
|
|
}
|
|
|
|
::mlir::Attribute ClampOp::getMaxVal() {
|
|
auto attr = getMaxValAttr();
|
|
return attr;
|
|
}
|
|
|
|
::mlir::tosa::NanPropagationMode ClampOp::getNanMode() {
|
|
auto attr = getNanModeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
void ClampOp::setNanMode(::mlir::tosa::NanPropagationMode attrValue) {
|
|
getProperties().nan_mode = ::mlir::tosa::NanPropagationModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue);
|
|
}
|
|
|
|
void ClampOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, ::mlir::Attribute min_val, ::mlir::Attribute max_val, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().min_val = min_val;
|
|
odsState.getOrAddProperties<Properties>().max_val = max_val;
|
|
if (nan_mode) {
|
|
odsState.getOrAddProperties<Properties>().nan_mode = nan_mode;
|
|
}
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ClampOp ClampOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, ::mlir::Attribute min_val, ::mlir::Attribute max_val, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(min_val)>(min_val), std::forward<decltype(max_val)>(max_val), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<ClampOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ClampOp ClampOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, ::mlir::Attribute min_val, ::mlir::Attribute max_val, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(min_val)>(min_val), std::forward<decltype(max_val)>(max_val), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void ClampOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Attribute min_val, ::mlir::Attribute max_val, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().min_val = min_val;
|
|
odsState.getOrAddProperties<Properties>().max_val = max_val;
|
|
if (nan_mode) {
|
|
odsState.getOrAddProperties<Properties>().nan_mode = nan_mode;
|
|
}
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ClampOp ClampOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Attribute min_val, ::mlir::Attribute max_val, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(min_val)>(min_val), std::forward<decltype(max_val)>(max_val), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<ClampOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ClampOp ClampOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Attribute min_val, ::mlir::Attribute max_val, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(min_val)>(min_val), std::forward<decltype(max_val)>(max_val), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void ClampOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, ::mlir::Attribute min_val, ::mlir::Attribute max_val, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().min_val = min_val;
|
|
odsState.getOrAddProperties<Properties>().max_val = max_val;
|
|
odsState.getOrAddProperties<Properties>().nan_mode = ::mlir::tosa::NanPropagationModeAttr::get(odsBuilder.getContext(), nan_mode);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ClampOp ClampOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, ::mlir::Attribute min_val, ::mlir::Attribute max_val, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(min_val)>(min_val), std::forward<decltype(max_val)>(max_val), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<ClampOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ClampOp ClampOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, ::mlir::Attribute min_val, ::mlir::Attribute max_val, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(min_val)>(min_val), std::forward<decltype(max_val)>(max_val), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void ClampOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Attribute min_val, ::mlir::Attribute max_val, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().min_val = min_val;
|
|
odsState.getOrAddProperties<Properties>().max_val = max_val;
|
|
odsState.getOrAddProperties<Properties>().nan_mode = ::mlir::tosa::NanPropagationModeAttr::get(odsBuilder.getContext(), nan_mode);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ClampOp ClampOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Attribute min_val, ::mlir::Attribute max_val, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(min_val)>(min_val), std::forward<decltype(max_val)>(max_val), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<ClampOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ClampOp ClampOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Attribute min_val, ::mlir::Attribute max_val, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(min_val)>(min_val), std::forward<decltype(max_val)>(max_val), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void ClampOp::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<ClampOp::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.");
|
|
}
|
|
}
|
|
|
|
ClampOp ClampOp::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<ClampOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ClampOp ClampOp::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 ClampOp::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);
|
|
}
|
|
|
|
ClampOp ClampOp::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<ClampOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ClampOp ClampOp::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 ClampOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) {
|
|
::mlir::Builder odsBuilder(opName.getContext());
|
|
if (!properties.nan_mode)
|
|
properties.nan_mode = ::mlir::tosa::NanPropagationModeAttr::get(odsBuilder.getContext(), ::mlir::tosa::NanPropagationMode::PROPAGATE);
|
|
}
|
|
|
|
::llvm::LogicalResult ClampOp::verifyInvariantsImpl() {
|
|
auto tblgen_max_val = getProperties().max_val; (void)tblgen_max_val;
|
|
if (!tblgen_max_val) return emitOpError("requires attribute 'max_val'");
|
|
auto tblgen_min_val = getProperties().min_val; (void)tblgen_min_val;
|
|
if (!tblgen_min_val) return emitOpError("requires attribute 'min_val'");
|
|
auto tblgen_nan_mode = getProperties().nan_mode; (void)tblgen_nan_mode;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps9(*this, tblgen_min_val, "min_val")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps9(*this, tblgen_max_val, "max_val")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps3(*this, tblgen_nan_mode, "nan_mode")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*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_TosaOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ClampOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::llvm::LogicalResult ClampOp::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.min_val;
|
|
auto min_valAttrName = ::mlir::StringAttr::get(ctx, "min_val");
|
|
auto attr = dict.get(min_valAttrName);
|
|
usedKeys.insert(min_valAttrName);
|
|
if (attr || /*isRequired=*/true) {
|
|
if (!attr) {
|
|
emitError() << "expected key entry for min_val 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 `min_val` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
{
|
|
|
|
auto &propStorage = prop.max_val;
|
|
auto max_valAttrName = ::mlir::StringAttr::get(ctx, "max_val");
|
|
auto attr = dict.get(max_valAttrName);
|
|
usedKeys.insert(max_valAttrName);
|
|
if (attr || /*isRequired=*/true) {
|
|
if (!attr) {
|
|
emitError() << "expected key entry for max_val 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 `max_val` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
{
|
|
|
|
auto &propStorage = prop.nan_mode;
|
|
auto nan_modeAttrName = ::mlir::StringAttr::get(ctx, "nan_mode");
|
|
auto attr = dict.get(nan_modeAttrName);
|
|
usedKeys.insert(nan_modeAttrName);
|
|
if (attr || /*isRequired=*/false) {
|
|
if (!attr) {
|
|
emitError() << "expected key entry for nan_mode 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 `nan_mode` 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();
|
|
}
|
|
|
|
void ClampOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::ClampOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::ClampOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::ClzOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
ClzOpGenericAdaptorBase::ClzOpGenericAdaptorBase(ClzOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
ClzOpAdaptor::ClzOpAdaptor(ClzOp op) : ClzOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult ClzOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ClzOp::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 ClzOp::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 ClzOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> ClzOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void ClzOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void ClzOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult ClzOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ClzOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1) {
|
|
odsState.addOperands(input1);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ClzOp ClzOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1));
|
|
auto __res__ = ::llvm::dyn_cast<ClzOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ClzOp ClzOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1));
|
|
}
|
|
|
|
void ClzOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
odsState.addOperands(input1);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ClzOp ClzOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1));
|
|
auto __res__ = ::llvm::dyn_cast<ClzOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ClzOp ClzOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1));
|
|
}
|
|
|
|
void ClzOp::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);
|
|
}
|
|
|
|
ClzOp ClzOp::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<ClzOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ClzOp ClzOp::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 ClzOp::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);
|
|
}
|
|
|
|
ClzOp ClzOp::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<ClzOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ClzOp ClzOp::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 ClzOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*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_TosaOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ClzOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult ClzOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ClzOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void ClzOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::ClzOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::ConcatOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
ConcatOpGenericAdaptorBase::ConcatOpGenericAdaptorBase(ConcatOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> ConcatOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
bool isVariadic[] = {true};
|
|
int prevVariadicCount = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
if (isVariadic[i]) ++prevVariadicCount;
|
|
|
|
// Calculate how many dynamic values a static variadic operand corresponds to.
|
|
// This assumes all static variadic operands have the same dynamic value count.
|
|
int variadicSize = (odsOperandsSize - 0) / 1;
|
|
// `index` passed in as the parameter is the static index which counts each
|
|
// operand (variadic or not) as size 1. So here for each previous static variadic
|
|
// operand, we need to offset by (variadicSize - 1) to get where the dynamic
|
|
// value pack for this static operand starts.
|
|
int start = index + (variadicSize - 1) * prevVariadicCount;
|
|
int size = isVariadic[index] ? variadicSize : 1;
|
|
return {start, size};
|
|
}
|
|
|
|
uint32_t ConcatOpGenericAdaptorBase::getAxis() {
|
|
auto attr = getAxisAttr();
|
|
return attr.getValue().getZExtValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
ConcatOpAdaptor::ConcatOpAdaptor(ConcatOp op) : ConcatOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult ConcatOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_axis = getProperties().axis; (void)tblgen_axis;
|
|
if (!tblgen_axis) return emitError(loc, "'tosa.concat' op requires attribute 'axis'");
|
|
|
|
if (tblgen_axis && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_axis))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_axis).getType().isSignlessInteger(32)))))
|
|
return emitError(loc, "'tosa.concat' op attribute 'axis' failed to satisfy constraint: 32-bit signless integer attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> ConcatOp::getODSOperandIndexAndLength(unsigned index) {
|
|
bool isVariadic[] = {true};
|
|
int prevVariadicCount = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
if (isVariadic[i]) ++prevVariadicCount;
|
|
|
|
// Calculate how many dynamic values a static variadic operand corresponds to.
|
|
// This assumes all static variadic operands have the same dynamic value count.
|
|
int variadicSize = (getOperation()->getNumOperands() - 0) / 1;
|
|
// `index` passed in as the parameter is the static index which counts each
|
|
// operand (variadic or not) as size 1. So here for each previous static variadic
|
|
// operand, we need to offset by (variadicSize - 1) to get where the dynamic
|
|
// value pack for this static operand starts.
|
|
int start = index + (variadicSize - 1) * prevVariadicCount;
|
|
int size = isVariadic[index] ? variadicSize : 1;
|
|
return {start, size};
|
|
}
|
|
|
|
::mlir::MutableOperandRange ConcatOp::getInput1Mutable() {
|
|
auto range = getODSOperandIndexAndLength(0);
|
|
auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
|
|
return mutableRange;
|
|
}
|
|
|
|
::llvm::LogicalResult ConcatOp::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.axis;
|
|
auto attr = dict.get("axis");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `axis` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute ConcatOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.axis;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("axis",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code ConcatOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.axis.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> ConcatOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "axis")
|
|
return prop.axis;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void ConcatOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "axis") {
|
|
prop.axis = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.axis)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void ConcatOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.axis) attrs.append("axis", prop.axis);
|
|
}
|
|
|
|
::llvm::LogicalResult ConcatOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getAxisAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps2(attr, "axis", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ConcatOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.axis)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ConcatOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.axis);
|
|
}
|
|
|
|
uint32_t ConcatOp::getAxis() {
|
|
auto attr = getAxisAttr();
|
|
return attr.getValue().getZExtValue();
|
|
}
|
|
|
|
void ConcatOp::setAxis(uint32_t attrValue) {
|
|
getProperties().axis = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), attrValue);
|
|
}
|
|
|
|
void ConcatOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::ValueRange input1, ::mlir::IntegerAttr axis) {
|
|
odsState.addOperands(input1);
|
|
odsState.getOrAddProperties<Properties>().axis = axis;
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ConcatOp ConcatOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::ValueRange input1, ::mlir::IntegerAttr axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<ConcatOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ConcatOp ConcatOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::ValueRange input1, ::mlir::IntegerAttr axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void ConcatOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange input1, ::mlir::IntegerAttr axis) {
|
|
odsState.addOperands(input1);
|
|
odsState.getOrAddProperties<Properties>().axis = axis;
|
|
|
|
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
|
|
if (::mlir::succeeded(ConcatOp::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);
|
|
|
|
}
|
|
|
|
ConcatOp ConcatOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange input1, ::mlir::IntegerAttr axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(input1)>(input1), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<ConcatOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ConcatOp ConcatOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange input1, ::mlir::IntegerAttr axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(input1)>(input1), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void ConcatOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange input1, ::mlir::IntegerAttr axis) {
|
|
odsState.addOperands(input1);
|
|
odsState.getOrAddProperties<Properties>().axis = axis;
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ConcatOp ConcatOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange input1, ::mlir::IntegerAttr axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<ConcatOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ConcatOp ConcatOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange input1, ::mlir::IntegerAttr axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void ConcatOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::ValueRange input1, uint32_t axis) {
|
|
odsState.addOperands(input1);
|
|
odsState.getOrAddProperties<Properties>().axis = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), axis);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ConcatOp ConcatOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::ValueRange input1, uint32_t axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<ConcatOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ConcatOp ConcatOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::ValueRange input1, uint32_t axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void ConcatOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange input1, uint32_t axis) {
|
|
odsState.addOperands(input1);
|
|
odsState.getOrAddProperties<Properties>().axis = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), axis);
|
|
|
|
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
|
|
if (::mlir::succeeded(ConcatOp::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);
|
|
|
|
}
|
|
|
|
ConcatOp ConcatOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange input1, uint32_t axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(input1)>(input1), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<ConcatOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ConcatOp ConcatOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange input1, uint32_t axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(input1)>(input1), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void ConcatOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange input1, uint32_t axis) {
|
|
odsState.addOperands(input1);
|
|
odsState.getOrAddProperties<Properties>().axis = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), axis);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ConcatOp ConcatOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange input1, uint32_t axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<ConcatOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ConcatOp ConcatOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange input1, uint32_t axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void ConcatOp::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<ConcatOp::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.");
|
|
}
|
|
}
|
|
|
|
ConcatOp ConcatOp::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<ConcatOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ConcatOp ConcatOp::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 ConcatOp::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<ConcatOp::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(ConcatOp::inferReturnTypes(odsBuilder.getContext(),
|
|
odsState.location, operands,
|
|
odsState.attributes.getDictionary(odsState.getContext()),
|
|
odsState.getRawProperties(),
|
|
odsState.regions, inferredReturnTypes))) {
|
|
assert(inferredReturnTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(inferredReturnTypes);
|
|
} else {
|
|
::llvm::report_fatal_error("Failed to infer result type(s).");
|
|
}
|
|
}
|
|
|
|
ConcatOp ConcatOp::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<ConcatOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ConcatOp ConcatOp::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 ConcatOp::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);
|
|
}
|
|
|
|
ConcatOp ConcatOp::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<ConcatOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ConcatOp ConcatOp::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 ConcatOp::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(ConcatOp::inferReturnTypes(odsBuilder.getContext(),
|
|
odsState.location, operands,
|
|
odsState.attributes.getDictionary(odsState.getContext()),
|
|
odsState.getRawProperties(),
|
|
odsState.regions, inferredReturnTypes))) {
|
|
assert(inferredReturnTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(inferredReturnTypes);
|
|
} else {
|
|
::llvm::report_fatal_error("Failed to infer result type(s).");
|
|
}
|
|
}
|
|
|
|
ConcatOp ConcatOp::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<ConcatOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ConcatOp ConcatOp::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 ConcatOp::verifyInvariantsImpl() {
|
|
auto tblgen_axis = getProperties().axis; (void)tblgen_axis;
|
|
if (!tblgen_axis) return emitOpError("requires attribute 'axis'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps2(*this, tblgen_axis, "axis")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps12(*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_TosaOps5(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ConcatOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult ConcatOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ConcatOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void ConcatOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
ConcatOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
ConcatOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return ConcatOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
LogicalResult
|
|
ConcatOp::inferReturnTypes(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) {
|
|
SmallVector<ShapedTypeComponents, 2> retComponents;
|
|
if (failed(ConcatOp::inferReturnTypeComponents(context, location,
|
|
operands, attributes, properties, regions,
|
|
retComponents)))
|
|
return failure();
|
|
return ::mlir::detail::inferReturnTensorTypes(retComponents,
|
|
inferredReturnTypes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::ConcatOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::ConcatOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::ConcatShapeOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
ConcatShapeOpGenericAdaptorBase::ConcatShapeOpGenericAdaptorBase(ConcatShapeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> ConcatShapeOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
bool isVariadic[] = {true};
|
|
int prevVariadicCount = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
if (isVariadic[i]) ++prevVariadicCount;
|
|
|
|
// Calculate how many dynamic values a static variadic operand corresponds to.
|
|
// This assumes all static variadic operands have the same dynamic value count.
|
|
int variadicSize = (odsOperandsSize - 0) / 1;
|
|
// `index` passed in as the parameter is the static index which counts each
|
|
// operand (variadic or not) as size 1. So here for each previous static variadic
|
|
// operand, we need to offset by (variadicSize - 1) to get where the dynamic
|
|
// value pack for this static operand starts.
|
|
int start = index + (variadicSize - 1) * prevVariadicCount;
|
|
int size = isVariadic[index] ? variadicSize : 1;
|
|
return {start, size};
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
ConcatShapeOpAdaptor::ConcatShapeOpAdaptor(ConcatShapeOp op) : ConcatShapeOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult ConcatShapeOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> ConcatShapeOp::getODSOperandIndexAndLength(unsigned index) {
|
|
bool isVariadic[] = {true};
|
|
int prevVariadicCount = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
if (isVariadic[i]) ++prevVariadicCount;
|
|
|
|
// Calculate how many dynamic values a static variadic operand corresponds to.
|
|
// This assumes all static variadic operands have the same dynamic value count.
|
|
int variadicSize = (getOperation()->getNumOperands() - 0) / 1;
|
|
// `index` passed in as the parameter is the static index which counts each
|
|
// operand (variadic or not) as size 1. So here for each previous static variadic
|
|
// operand, we need to offset by (variadicSize - 1) to get where the dynamic
|
|
// value pack for this static operand starts.
|
|
int start = index + (variadicSize - 1) * prevVariadicCount;
|
|
int size = isVariadic[index] ? variadicSize : 1;
|
|
return {start, size};
|
|
}
|
|
|
|
::mlir::MutableOperandRange ConcatShapeOp::getInputMutable() {
|
|
auto range = getODSOperandIndexAndLength(0);
|
|
auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
|
|
return mutableRange;
|
|
}
|
|
|
|
::llvm::LogicalResult ConcatShapeOp::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 ConcatShapeOp::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 ConcatShapeOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> ConcatShapeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void ConcatShapeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void ConcatShapeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult ConcatShapeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ConcatShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::ValueRange input) {
|
|
odsState.addOperands(input);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ConcatShapeOp ConcatShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::ValueRange input) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input));
|
|
auto __res__ = ::llvm::dyn_cast<ConcatShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ConcatShapeOp ConcatShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::ValueRange input) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input));
|
|
}
|
|
|
|
void ConcatShapeOp::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);
|
|
}
|
|
|
|
ConcatShapeOp ConcatShapeOp::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<ConcatShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ConcatShapeOp ConcatShapeOp::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 ConcatShapeOp::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);
|
|
}
|
|
|
|
ConcatShapeOp ConcatShapeOp::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<ConcatShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ConcatShapeOp ConcatShapeOp::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 ConcatShapeOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps13(*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_TosaOps2(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ConcatShapeOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult ConcatShapeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ConcatShapeOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void ConcatShapeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::ConcatShapeOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::ConstOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
ConstOpGenericAdaptorBase::ConstOpGenericAdaptorBase(ConstOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::mlir::ElementsAttr ConstOpGenericAdaptorBase::getValues() {
|
|
auto attr = getValuesAttr();
|
|
return attr;
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
ConstOpAdaptor::ConstOpAdaptor(ConstOp op) : ConstOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult ConstOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_values = getProperties().values; (void)tblgen_values;
|
|
if (!tblgen_values) return emitError(loc, "'tosa.const' op requires attribute 'values'");
|
|
|
|
if (tblgen_values && !((::llvm::isa<::mlir::ElementsAttr>(tblgen_values))))
|
|
return emitError(loc, "'tosa.const' op attribute 'values' failed to satisfy constraint: constant vector/tensor attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ConstOp::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.values;
|
|
auto attr = dict.get("values");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `values` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute ConstOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.values;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("values",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code ConstOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.values.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> ConstOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "values")
|
|
return prop.values;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void ConstOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "values") {
|
|
prop.values = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.values)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void ConstOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.values) attrs.append("values", prop.values);
|
|
}
|
|
|
|
::llvm::LogicalResult ConstOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getValuesAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps10(attr, "values", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ConstOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.values)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ConstOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.values);
|
|
}
|
|
|
|
::mlir::ElementsAttr ConstOp::getValues() {
|
|
auto attr = getValuesAttr();
|
|
return attr;
|
|
}
|
|
|
|
void ConstOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::ElementsAttr values) {
|
|
odsState.getOrAddProperties<Properties>().values = values;
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ConstOp ConstOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::ElementsAttr values) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(values)>(values));
|
|
auto __res__ = ::llvm::dyn_cast<ConstOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ConstOp ConstOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::ElementsAttr values) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(values)>(values));
|
|
}
|
|
|
|
void ConstOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ElementsAttr values) {
|
|
odsState.getOrAddProperties<Properties>().values = values;
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ConstOp ConstOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ElementsAttr values) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(values)>(values));
|
|
auto __res__ = ::llvm::dyn_cast<ConstOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ConstOp ConstOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ElementsAttr values) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(values)>(values));
|
|
}
|
|
|
|
void ConstOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 0u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<ConstOp::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.");
|
|
}
|
|
}
|
|
|
|
ConstOp ConstOp::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<ConstOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ConstOp ConstOp::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 ConstOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
|
|
assert(operands.size() == 0u && "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);
|
|
}
|
|
|
|
ConstOp ConstOp::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<ConstOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ConstOp ConstOp::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 ConstOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
::mlir::Attribute typeAttr;
|
|
auto attrName = getValuesAttrName(odsState.name);
|
|
for (auto attr : attributes) {
|
|
if (attr.getName() == attrName) {
|
|
typeAttr = attr.getValue();
|
|
break;
|
|
}
|
|
}
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
odsState.addTypes({::llvm::cast<::mlir::TypedAttr>(typeAttr).getType()});
|
|
}
|
|
|
|
ConstOp ConstOp::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<ConstOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ConstOp ConstOp::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 ConstOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
|
|
::mlir::Attribute typeAttr = properties.getValues();
|
|
odsState.addOperands(operands);
|
|
odsState.useProperties(const_cast<Properties&>(properties));
|
|
odsState.addAttributes(discardableAttributes);
|
|
odsState.addTypes({::llvm::cast<::mlir::TypedAttr>(typeAttr).getType()});
|
|
}
|
|
|
|
ConstOp ConstOp::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<ConstOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ConstOp ConstOp::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 ConstOp::verifyInvariantsImpl() {
|
|
auto tblgen_values = getProperties().values; (void)tblgen_values;
|
|
if (!tblgen_values) return emitOpError("requires attribute 'values'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps10(*this, tblgen_values, "values")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSResults(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
if (!(((::llvm::cast<::mlir::ShapedType>(getValues().getType()).getShape()) == (::llvm::cast<::mlir::ShapedType>((*this->getODSResults(0).begin()).getType()).getShape()) && (::llvm::cast<::mlir::ShapedType>((*this->getODSResults(0).begin()).getType()).getShape()) == (::llvm::cast<::mlir::ShapedType>(getValues().getType()).getShape()))))
|
|
return emitOpError("failed to verify that all of {values, output} have same shape");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ConstOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::llvm::LogicalResult ConstOp::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.values;
|
|
auto valuesAttrName = ::mlir::StringAttr::get(ctx, "values");
|
|
auto attr = dict.get(valuesAttrName);
|
|
usedKeys.insert(valuesAttrName);
|
|
if (attr || /*isRequired=*/true) {
|
|
if (!attr) {
|
|
emitError() << "expected key entry for values 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 `values` 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();
|
|
}
|
|
|
|
void ConstOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::ConstOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::ConstOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::ConstShapeOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
ConstShapeOpGenericAdaptorBase::ConstShapeOpGenericAdaptorBase(ConstShapeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::mlir::DenseIntElementsAttr ConstShapeOpGenericAdaptorBase::getValues() {
|
|
auto attr = getValuesAttr();
|
|
return attr;
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
ConstShapeOpAdaptor::ConstShapeOpAdaptor(ConstShapeOp op) : ConstShapeOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult ConstShapeOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_values = getProperties().values; (void)tblgen_values;
|
|
if (!tblgen_values) return emitError(loc, "'tosa.const_shape' op requires attribute 'values'");
|
|
|
|
if (tblgen_values && !(((::llvm::isa<::mlir::DenseIntElementsAttr>(tblgen_values))) && ((::llvm::cast<::mlir::DenseIntElementsAttr>(tblgen_values)
|
|
.getType()
|
|
.getElementType()
|
|
.isIndex()))))
|
|
return emitError(loc, "'tosa.const_shape' op attribute 'values' failed to satisfy constraint: index elements attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ConstShapeOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
|
|
if (!dict) {
|
|
emitError() << "expected DictionaryAttr to set properties";
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.values;
|
|
auto attr = dict.get("values");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `values` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute ConstShapeOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.values;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("values",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code ConstShapeOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.values.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> ConstShapeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "values")
|
|
return prop.values;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void ConstShapeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "values") {
|
|
prop.values = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.values)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void ConstShapeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.values) attrs.append("values", prop.values);
|
|
}
|
|
|
|
::llvm::LogicalResult ConstShapeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getValuesAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps11(attr, "values", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ConstShapeOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.values)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ConstShapeOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.values);
|
|
}
|
|
|
|
::mlir::DenseIntElementsAttr ConstShapeOp::getValues() {
|
|
auto attr = getValuesAttr();
|
|
return attr;
|
|
}
|
|
|
|
void ConstShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::DenseIntElementsAttr values) {
|
|
odsState.getOrAddProperties<Properties>().values = values;
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ConstShapeOp ConstShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::DenseIntElementsAttr values) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(values)>(values));
|
|
auto __res__ = ::llvm::dyn_cast<ConstShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ConstShapeOp ConstShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::DenseIntElementsAttr values) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(values)>(values));
|
|
}
|
|
|
|
void ConstShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::DenseIntElementsAttr values) {
|
|
odsState.getOrAddProperties<Properties>().values = values;
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ConstShapeOp ConstShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::DenseIntElementsAttr values) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(values)>(values));
|
|
auto __res__ = ::llvm::dyn_cast<ConstShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ConstShapeOp ConstShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::DenseIntElementsAttr values) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(values)>(values));
|
|
}
|
|
|
|
void ConstShapeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 0u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<ConstShapeOp::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.");
|
|
}
|
|
}
|
|
|
|
ConstShapeOp ConstShapeOp::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<ConstShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ConstShapeOp ConstShapeOp::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 ConstShapeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
|
|
assert(operands.size() == 0u && "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);
|
|
}
|
|
|
|
ConstShapeOp ConstShapeOp::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<ConstShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ConstShapeOp ConstShapeOp::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 ConstShapeOp::verifyInvariantsImpl() {
|
|
auto tblgen_values = getProperties().values; (void)tblgen_values;
|
|
if (!tblgen_values) return emitOpError("requires attribute 'values'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps11(*this, tblgen_values, "values")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSResults(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps2(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ConstShapeOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult ConstShapeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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);
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ConstShapeOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void ConstShapeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::ConstShapeOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::ConstShapeOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::Conv2DBlockScaledOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
Conv2DBlockScaledOpGenericAdaptorBase::Conv2DBlockScaledOpGenericAdaptorBase(Conv2DBlockScaledOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::mlir::tosa::BlockSize Conv2DBlockScaledOpGenericAdaptorBase::getBlockSize() {
|
|
auto attr = getBlockSizeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
Conv2DBlockScaledOpAdaptor::Conv2DBlockScaledOpAdaptor(Conv2DBlockScaledOp op) : Conv2DBlockScaledOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult Conv2DBlockScaledOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_block_size = getProperties().block_size; (void)tblgen_block_size;
|
|
if (!tblgen_block_size) return emitError(loc, "'tosa.conv2d_block_scaled' op requires attribute 'block_size'");
|
|
|
|
if (tblgen_block_size && !((::llvm::isa<mlir::tosa::BlockSizeAttr>(tblgen_block_size))))
|
|
return emitError(loc, "'tosa.conv2d_block_scaled' op attribute 'block_size' failed to satisfy constraint: Block size for the block_scaled formats");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult Conv2DBlockScaledOp::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.block_size;
|
|
auto attr = dict.get("block_size");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `block_size` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute Conv2DBlockScaledOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.block_size;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("block_size",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code Conv2DBlockScaledOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.block_size.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> Conv2DBlockScaledOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "block_size")
|
|
return prop.block_size;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void Conv2DBlockScaledOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "block_size") {
|
|
prop.block_size = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.block_size)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void Conv2DBlockScaledOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.block_size) attrs.append("block_size", prop.block_size);
|
|
}
|
|
|
|
::llvm::LogicalResult Conv2DBlockScaledOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getBlockSizeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps8(attr, "block_size", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult Conv2DBlockScaledOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.block_size)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void Conv2DBlockScaledOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.block_size);
|
|
}
|
|
|
|
::mlir::tosa::BlockSize Conv2DBlockScaledOp::getBlockSize() {
|
|
auto attr = getBlockSizeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
void Conv2DBlockScaledOp::setBlockSize(::mlir::tosa::BlockSize attrValue) {
|
|
getProperties().block_size = ::mlir::tosa::BlockSizeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue);
|
|
}
|
|
|
|
void Conv2DBlockScaledOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input_data, ::mlir::Value input_scale, ::mlir::Value weight_data, ::mlir::Value weight_scale, ::mlir::Value bias, ::mlir::Value pad, ::mlir::Value stride, ::mlir::Value dilation, mlir::tosa::BlockSizeAttr block_size) {
|
|
odsState.addOperands(input_data);
|
|
odsState.addOperands(input_scale);
|
|
odsState.addOperands(weight_data);
|
|
odsState.addOperands(weight_scale);
|
|
odsState.addOperands(bias);
|
|
odsState.addOperands(pad);
|
|
odsState.addOperands(stride);
|
|
odsState.addOperands(dilation);
|
|
odsState.getOrAddProperties<Properties>().block_size = block_size;
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
Conv2DBlockScaledOp Conv2DBlockScaledOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input_data, ::mlir::Value input_scale, ::mlir::Value weight_data, ::mlir::Value weight_scale, ::mlir::Value bias, ::mlir::Value pad, ::mlir::Value stride, ::mlir::Value dilation, mlir::tosa::BlockSizeAttr block_size) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input_data)>(input_data), std::forward<decltype(input_scale)>(input_scale), std::forward<decltype(weight_data)>(weight_data), std::forward<decltype(weight_scale)>(weight_scale), std::forward<decltype(bias)>(bias), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(block_size)>(block_size));
|
|
auto __res__ = ::llvm::dyn_cast<Conv2DBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
Conv2DBlockScaledOp Conv2DBlockScaledOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input_data, ::mlir::Value input_scale, ::mlir::Value weight_data, ::mlir::Value weight_scale, ::mlir::Value bias, ::mlir::Value pad, ::mlir::Value stride, ::mlir::Value dilation, mlir::tosa::BlockSizeAttr block_size) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input_data)>(input_data), std::forward<decltype(input_scale)>(input_scale), std::forward<decltype(weight_data)>(weight_data), std::forward<decltype(weight_scale)>(weight_scale), std::forward<decltype(bias)>(bias), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(block_size)>(block_size));
|
|
}
|
|
|
|
void Conv2DBlockScaledOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input_data, ::mlir::Value input_scale, ::mlir::Value weight_data, ::mlir::Value weight_scale, ::mlir::Value bias, ::mlir::Value pad, ::mlir::Value stride, ::mlir::Value dilation, mlir::tosa::BlockSizeAttr block_size) {
|
|
odsState.addOperands(input_data);
|
|
odsState.addOperands(input_scale);
|
|
odsState.addOperands(weight_data);
|
|
odsState.addOperands(weight_scale);
|
|
odsState.addOperands(bias);
|
|
odsState.addOperands(pad);
|
|
odsState.addOperands(stride);
|
|
odsState.addOperands(dilation);
|
|
odsState.getOrAddProperties<Properties>().block_size = block_size;
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
Conv2DBlockScaledOp Conv2DBlockScaledOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input_data, ::mlir::Value input_scale, ::mlir::Value weight_data, ::mlir::Value weight_scale, ::mlir::Value bias, ::mlir::Value pad, ::mlir::Value stride, ::mlir::Value dilation, mlir::tosa::BlockSizeAttr block_size) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input_data)>(input_data), std::forward<decltype(input_scale)>(input_scale), std::forward<decltype(weight_data)>(weight_data), std::forward<decltype(weight_scale)>(weight_scale), std::forward<decltype(bias)>(bias), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(block_size)>(block_size));
|
|
auto __res__ = ::llvm::dyn_cast<Conv2DBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
Conv2DBlockScaledOp Conv2DBlockScaledOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input_data, ::mlir::Value input_scale, ::mlir::Value weight_data, ::mlir::Value weight_scale, ::mlir::Value bias, ::mlir::Value pad, ::mlir::Value stride, ::mlir::Value dilation, mlir::tosa::BlockSizeAttr block_size) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input_data)>(input_data), std::forward<decltype(input_scale)>(input_scale), std::forward<decltype(weight_data)>(weight_data), std::forward<decltype(weight_scale)>(weight_scale), std::forward<decltype(bias)>(bias), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(block_size)>(block_size));
|
|
}
|
|
|
|
void Conv2DBlockScaledOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input_data, ::mlir::Value input_scale, ::mlir::Value weight_data, ::mlir::Value weight_scale, ::mlir::Value bias, ::mlir::Value pad, ::mlir::Value stride, ::mlir::Value dilation, ::mlir::tosa::BlockSize block_size) {
|
|
odsState.addOperands(input_data);
|
|
odsState.addOperands(input_scale);
|
|
odsState.addOperands(weight_data);
|
|
odsState.addOperands(weight_scale);
|
|
odsState.addOperands(bias);
|
|
odsState.addOperands(pad);
|
|
odsState.addOperands(stride);
|
|
odsState.addOperands(dilation);
|
|
odsState.getOrAddProperties<Properties>().block_size = ::mlir::tosa::BlockSizeAttr::get(odsBuilder.getContext(), block_size);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
Conv2DBlockScaledOp Conv2DBlockScaledOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input_data, ::mlir::Value input_scale, ::mlir::Value weight_data, ::mlir::Value weight_scale, ::mlir::Value bias, ::mlir::Value pad, ::mlir::Value stride, ::mlir::Value dilation, ::mlir::tosa::BlockSize block_size) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input_data)>(input_data), std::forward<decltype(input_scale)>(input_scale), std::forward<decltype(weight_data)>(weight_data), std::forward<decltype(weight_scale)>(weight_scale), std::forward<decltype(bias)>(bias), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(block_size)>(block_size));
|
|
auto __res__ = ::llvm::dyn_cast<Conv2DBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
Conv2DBlockScaledOp Conv2DBlockScaledOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input_data, ::mlir::Value input_scale, ::mlir::Value weight_data, ::mlir::Value weight_scale, ::mlir::Value bias, ::mlir::Value pad, ::mlir::Value stride, ::mlir::Value dilation, ::mlir::tosa::BlockSize block_size) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input_data)>(input_data), std::forward<decltype(input_scale)>(input_scale), std::forward<decltype(weight_data)>(weight_data), std::forward<decltype(weight_scale)>(weight_scale), std::forward<decltype(bias)>(bias), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(block_size)>(block_size));
|
|
}
|
|
|
|
void Conv2DBlockScaledOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input_data, ::mlir::Value input_scale, ::mlir::Value weight_data, ::mlir::Value weight_scale, ::mlir::Value bias, ::mlir::Value pad, ::mlir::Value stride, ::mlir::Value dilation, ::mlir::tosa::BlockSize block_size) {
|
|
odsState.addOperands(input_data);
|
|
odsState.addOperands(input_scale);
|
|
odsState.addOperands(weight_data);
|
|
odsState.addOperands(weight_scale);
|
|
odsState.addOperands(bias);
|
|
odsState.addOperands(pad);
|
|
odsState.addOperands(stride);
|
|
odsState.addOperands(dilation);
|
|
odsState.getOrAddProperties<Properties>().block_size = ::mlir::tosa::BlockSizeAttr::get(odsBuilder.getContext(), block_size);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
Conv2DBlockScaledOp Conv2DBlockScaledOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input_data, ::mlir::Value input_scale, ::mlir::Value weight_data, ::mlir::Value weight_scale, ::mlir::Value bias, ::mlir::Value pad, ::mlir::Value stride, ::mlir::Value dilation, ::mlir::tosa::BlockSize block_size) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input_data)>(input_data), std::forward<decltype(input_scale)>(input_scale), std::forward<decltype(weight_data)>(weight_data), std::forward<decltype(weight_scale)>(weight_scale), std::forward<decltype(bias)>(bias), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(block_size)>(block_size));
|
|
auto __res__ = ::llvm::dyn_cast<Conv2DBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
Conv2DBlockScaledOp Conv2DBlockScaledOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input_data, ::mlir::Value input_scale, ::mlir::Value weight_data, ::mlir::Value weight_scale, ::mlir::Value bias, ::mlir::Value pad, ::mlir::Value stride, ::mlir::Value dilation, ::mlir::tosa::BlockSize block_size) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input_data)>(input_data), std::forward<decltype(input_scale)>(input_scale), std::forward<decltype(weight_data)>(weight_data), std::forward<decltype(weight_scale)>(weight_scale), std::forward<decltype(bias)>(bias), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(block_size)>(block_size));
|
|
}
|
|
|
|
void Conv2DBlockScaledOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 8u && "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<Conv2DBlockScaledOp::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.");
|
|
}
|
|
}
|
|
|
|
Conv2DBlockScaledOp Conv2DBlockScaledOp::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<Conv2DBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
Conv2DBlockScaledOp Conv2DBlockScaledOp::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 Conv2DBlockScaledOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
|
|
assert(operands.size() == 8u && "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);
|
|
}
|
|
|
|
Conv2DBlockScaledOp Conv2DBlockScaledOp::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<Conv2DBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
Conv2DBlockScaledOp Conv2DBlockScaledOp::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 Conv2DBlockScaledOp::verifyInvariantsImpl() {
|
|
auto tblgen_block_size = getProperties().block_size; (void)tblgen_block_size;
|
|
if (!tblgen_block_size) return emitOpError("requires attribute 'block_size'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps8(*this, tblgen_block_size, "block_size")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps14(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps15(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps14(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup3 = getODSOperands(3);
|
|
|
|
for (auto v : valueGroup3) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps15(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup4 = getODSOperands(4);
|
|
|
|
for (auto v : valueGroup4) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps16(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup5 = getODSOperands(5);
|
|
|
|
for (auto v : valueGroup5) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps9(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup6 = getODSOperands(6);
|
|
|
|
for (auto v : valueGroup6) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps8(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup7 = getODSOperands(7);
|
|
|
|
for (auto v : valueGroup7) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps8(*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_TosaOps6(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult Conv2DBlockScaledOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::llvm::LogicalResult Conv2DBlockScaledOp::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.block_size;
|
|
auto block_sizeAttrName = ::mlir::StringAttr::get(ctx, "block_size");
|
|
auto attr = dict.get(block_sizeAttrName);
|
|
usedKeys.insert(block_sizeAttrName);
|
|
if (attr || /*isRequired=*/true) {
|
|
if (!attr) {
|
|
emitError() << "expected key entry for block_size 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 `block_size` 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();
|
|
}
|
|
|
|
void Conv2DBlockScaledOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
Conv2DBlockScaledOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
Conv2DBlockScaledOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return Conv2DBlockScaledOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::Conv2DBlockScaledOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::Conv2DBlockScaledOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::Conv2DOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
Conv2DOpGenericAdaptorBase::Conv2DOpGenericAdaptorBase(Conv2DOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::llvm::ArrayRef<int64_t> Conv2DOpGenericAdaptorBase::getPad() {
|
|
auto attr = getPadAttr();
|
|
return attr;
|
|
}
|
|
|
|
::llvm::ArrayRef<int64_t> Conv2DOpGenericAdaptorBase::getStride() {
|
|
auto attr = getStrideAttr();
|
|
return attr;
|
|
}
|
|
|
|
::llvm::ArrayRef<int64_t> Conv2DOpGenericAdaptorBase::getDilation() {
|
|
auto attr = getDilationAttr();
|
|
return attr;
|
|
}
|
|
|
|
::mlir::Type Conv2DOpGenericAdaptorBase::getAccType() {
|
|
auto attr = getAccTypeAttr();
|
|
return ::llvm::cast<::mlir::Type>(attr.getValue());
|
|
}
|
|
|
|
::mlir::BoolAttr Conv2DOpGenericAdaptorBase::getLocalBoundAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().local_bound);
|
|
if (!attr)
|
|
attr = ::mlir::Builder(odsAttrs.getContext()).getBoolAttr(false);
|
|
return attr;
|
|
}
|
|
|
|
bool Conv2DOpGenericAdaptorBase::getLocalBound() {
|
|
auto attr = getLocalBoundAttr();
|
|
if (!attr)
|
|
return ::mlir::Builder(odsAttrs.getContext()).getBoolAttr(false).getValue();
|
|
return attr.getValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
Conv2DOpAdaptor::Conv2DOpAdaptor(Conv2DOp op) : Conv2DOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult Conv2DOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_acc_type = getProperties().acc_type; (void)tblgen_acc_type;
|
|
if (!tblgen_acc_type) return emitError(loc, "'tosa.conv2d' op requires attribute 'acc_type'");
|
|
auto tblgen_dilation = getProperties().dilation; (void)tblgen_dilation;
|
|
if (!tblgen_dilation) return emitError(loc, "'tosa.conv2d' op requires attribute 'dilation'");
|
|
auto tblgen_local_bound = getProperties().local_bound; (void)tblgen_local_bound;
|
|
auto tblgen_pad = getProperties().pad; (void)tblgen_pad;
|
|
if (!tblgen_pad) return emitError(loc, "'tosa.conv2d' op requires attribute 'pad'");
|
|
auto tblgen_stride = getProperties().stride; (void)tblgen_stride;
|
|
if (!tblgen_stride) return emitError(loc, "'tosa.conv2d' op requires attribute 'stride'");
|
|
|
|
if (tblgen_pad && !(((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_pad))) && ((::llvm::cast<::mlir::DenseArrayAttr>(tblgen_pad).size() == 4))))
|
|
return emitError(loc, "'tosa.conv2d' op attribute 'pad' failed to satisfy constraint: i64 dense array attribute with exactly 4 elements");
|
|
|
|
if (tblgen_stride && !(((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_stride))) && ((::llvm::cast<::mlir::DenseArrayAttr>(tblgen_stride).size() == 2))))
|
|
return emitError(loc, "'tosa.conv2d' op attribute 'stride' failed to satisfy constraint: i64 dense array attribute with exactly 2 elements");
|
|
|
|
if (tblgen_dilation && !(((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_dilation))) && ((::llvm::cast<::mlir::DenseArrayAttr>(tblgen_dilation).size() == 2))))
|
|
return emitError(loc, "'tosa.conv2d' op attribute 'dilation' failed to satisfy constraint: i64 dense array attribute with exactly 2 elements");
|
|
|
|
if (tblgen_acc_type && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_acc_type))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_acc_type).getValue()))) && (((::llvm::cast<::mlir::TypeAttr>(tblgen_acc_type).getValue().isSignlessInteger(32))) || ((::llvm::cast<::mlir::TypeAttr>(tblgen_acc_type).getValue().isSignlessInteger(48))) || ((::llvm::cast<::mlir::TypeAttr>(tblgen_acc_type).getValue().isF16())) || ((::llvm::cast<::mlir::TypeAttr>(tblgen_acc_type).getValue().isF32())))))
|
|
return emitError(loc, "'tosa.conv2d' op attribute 'acc_type' failed to satisfy constraint: type attribute of 32-bit signless integer or 48-bit signless integer or 16-bit float or 32-bit float");
|
|
|
|
if (tblgen_local_bound && !((::llvm::isa<::mlir::BoolAttr>(tblgen_local_bound))))
|
|
return emitError(loc, "'tosa.conv2d' op attribute 'local_bound' failed to satisfy constraint: bool attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult Conv2DOp::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.acc_type;
|
|
auto attr = dict.get("acc_type");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `acc_type` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.dilation;
|
|
auto attr = dict.get("dilation");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `dilation` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.local_bound;
|
|
auto attr = dict.get("local_bound");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `local_bound` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.pad;
|
|
auto attr = dict.get("pad");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `pad` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.stride;
|
|
auto attr = dict.get("stride");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `stride` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute Conv2DOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.acc_type;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("acc_type",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.dilation;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("dilation",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.local_bound;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("local_bound",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.pad;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("pad",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.stride;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("stride",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code Conv2DOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.acc_type.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.dilation.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.local_bound.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.pad.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.stride.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> Conv2DOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "acc_type")
|
|
return prop.acc_type;
|
|
|
|
if (name == "dilation")
|
|
return prop.dilation;
|
|
|
|
if (name == "local_bound")
|
|
return prop.local_bound;
|
|
|
|
if (name == "pad")
|
|
return prop.pad;
|
|
|
|
if (name == "stride")
|
|
return prop.stride;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void Conv2DOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "acc_type") {
|
|
prop.acc_type = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.acc_type)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "dilation") {
|
|
prop.dilation = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.dilation)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "local_bound") {
|
|
prop.local_bound = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.local_bound)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "pad") {
|
|
prop.pad = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.pad)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "stride") {
|
|
prop.stride = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.stride)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void Conv2DOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.acc_type) attrs.append("acc_type", prop.acc_type);
|
|
|
|
if (prop.dilation) attrs.append("dilation", prop.dilation);
|
|
|
|
if (prop.local_bound) attrs.append("local_bound", prop.local_bound);
|
|
|
|
if (prop.pad) attrs.append("pad", prop.pad);
|
|
|
|
if (prop.stride) attrs.append("stride", prop.stride);
|
|
}
|
|
|
|
::llvm::LogicalResult Conv2DOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getAccTypeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps5(attr, "acc_type", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getDilationAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps6(attr, "dilation", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getLocalBoundAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps4(attr, "local_bound", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getPadAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps7(attr, "pad", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getStrideAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps6(attr, "stride", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult Conv2DOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.acc_type)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readAttribute(prop.dilation)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.local_bound)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readAttribute(prop.pad)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readAttribute(prop.stride)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void Conv2DOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.acc_type);
|
|
writer.writeAttribute(prop.dilation);
|
|
|
|
writer.writeOptionalAttribute(prop.local_bound);
|
|
writer.writeAttribute(prop.pad);
|
|
writer.writeAttribute(prop.stride);
|
|
}
|
|
|
|
::llvm::ArrayRef<int64_t> Conv2DOp::getPad() {
|
|
auto attr = getPadAttr();
|
|
return attr;
|
|
}
|
|
|
|
::llvm::ArrayRef<int64_t> Conv2DOp::getStride() {
|
|
auto attr = getStrideAttr();
|
|
return attr;
|
|
}
|
|
|
|
::llvm::ArrayRef<int64_t> Conv2DOp::getDilation() {
|
|
auto attr = getDilationAttr();
|
|
return attr;
|
|
}
|
|
|
|
::mlir::Type Conv2DOp::getAccType() {
|
|
auto attr = getAccTypeAttr();
|
|
return ::llvm::cast<::mlir::Type>(attr.getValue());
|
|
}
|
|
|
|
bool Conv2DOp::getLocalBound() {
|
|
auto attr = getLocalBoundAttr();
|
|
if (!attr)
|
|
return ::mlir::Builder((*this)->getContext()).getBoolAttr(false).getValue();
|
|
return attr.getValue();
|
|
}
|
|
|
|
void Conv2DOp::setPad(::llvm::ArrayRef<int64_t> attrValue) {
|
|
getProperties().pad = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue);
|
|
}
|
|
|
|
void Conv2DOp::setStride(::llvm::ArrayRef<int64_t> attrValue) {
|
|
getProperties().stride = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue);
|
|
}
|
|
|
|
void Conv2DOp::setDilation(::llvm::ArrayRef<int64_t> attrValue) {
|
|
getProperties().dilation = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue);
|
|
}
|
|
|
|
void Conv2DOp::setAccType(::mlir::Type attrValue) {
|
|
getProperties().acc_type = ::mlir::TypeAttr::get(attrValue);
|
|
}
|
|
|
|
void Conv2DOp::setLocalBound(::std::optional<bool> attrValue) {
|
|
auto &odsProp = getProperties().local_bound;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getBoolAttr(*attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void Conv2DOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type outputType, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::DenseI64ArrayAttr pad, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr dilation, ::mlir::TypeAttr acc_type) {
|
|
buildConvOpWithQuantInfo(odsBuilder, odsState, outputType,
|
|
input, weight, bias,
|
|
pad, stride, dilation, acc_type);
|
|
|
|
}
|
|
|
|
Conv2DOp Conv2DOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type outputType, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::DenseI64ArrayAttr pad, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr dilation, ::mlir::TypeAttr acc_type) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(outputType)>(outputType), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(acc_type)>(acc_type));
|
|
auto __res__ = ::llvm::dyn_cast<Conv2DOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
Conv2DOp Conv2DOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type outputType, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::DenseI64ArrayAttr pad, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr dilation, ::mlir::TypeAttr acc_type) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(outputType)>(outputType), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(acc_type)>(acc_type));
|
|
}
|
|
|
|
void Conv2DOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::mlir::DenseI64ArrayAttr pad, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr dilation, ::mlir::TypeAttr acc_type, /*optional*/::mlir::BoolAttr local_bound) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(weight);
|
|
odsState.addOperands(bias);
|
|
odsState.addOperands(input_zp);
|
|
odsState.addOperands(weight_zp);
|
|
odsState.getOrAddProperties<Properties>().pad = pad;
|
|
odsState.getOrAddProperties<Properties>().stride = stride;
|
|
odsState.getOrAddProperties<Properties>().dilation = dilation;
|
|
odsState.getOrAddProperties<Properties>().acc_type = acc_type;
|
|
if (local_bound) {
|
|
odsState.getOrAddProperties<Properties>().local_bound = local_bound;
|
|
}
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
Conv2DOp Conv2DOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::mlir::DenseI64ArrayAttr pad, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr dilation, ::mlir::TypeAttr acc_type, /*optional*/::mlir::BoolAttr local_bound) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(weight_zp)>(weight_zp), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(acc_type)>(acc_type), std::forward<decltype(local_bound)>(local_bound));
|
|
auto __res__ = ::llvm::dyn_cast<Conv2DOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
Conv2DOp Conv2DOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::mlir::DenseI64ArrayAttr pad, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr dilation, ::mlir::TypeAttr acc_type, /*optional*/::mlir::BoolAttr local_bound) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(weight_zp)>(weight_zp), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(acc_type)>(acc_type), std::forward<decltype(local_bound)>(local_bound));
|
|
}
|
|
|
|
void Conv2DOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::mlir::DenseI64ArrayAttr pad, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr dilation, ::mlir::TypeAttr acc_type, /*optional*/::mlir::BoolAttr local_bound) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(weight);
|
|
odsState.addOperands(bias);
|
|
odsState.addOperands(input_zp);
|
|
odsState.addOperands(weight_zp);
|
|
odsState.getOrAddProperties<Properties>().pad = pad;
|
|
odsState.getOrAddProperties<Properties>().stride = stride;
|
|
odsState.getOrAddProperties<Properties>().dilation = dilation;
|
|
odsState.getOrAddProperties<Properties>().acc_type = acc_type;
|
|
if (local_bound) {
|
|
odsState.getOrAddProperties<Properties>().local_bound = local_bound;
|
|
}
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
Conv2DOp Conv2DOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::mlir::DenseI64ArrayAttr pad, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr dilation, ::mlir::TypeAttr acc_type, /*optional*/::mlir::BoolAttr local_bound) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(weight_zp)>(weight_zp), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(acc_type)>(acc_type), std::forward<decltype(local_bound)>(local_bound));
|
|
auto __res__ = ::llvm::dyn_cast<Conv2DOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
Conv2DOp Conv2DOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::mlir::DenseI64ArrayAttr pad, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr dilation, ::mlir::TypeAttr acc_type, /*optional*/::mlir::BoolAttr local_bound) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(weight_zp)>(weight_zp), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(acc_type)>(acc_type), std::forward<decltype(local_bound)>(local_bound));
|
|
}
|
|
|
|
void Conv2DOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::llvm::ArrayRef<int64_t> pad, ::llvm::ArrayRef<int64_t> stride, ::llvm::ArrayRef<int64_t> dilation, ::mlir::Type acc_type, /*optional*/bool local_bound) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(weight);
|
|
odsState.addOperands(bias);
|
|
odsState.addOperands(input_zp);
|
|
odsState.addOperands(weight_zp);
|
|
odsState.getOrAddProperties<Properties>().pad = odsBuilder.getDenseI64ArrayAttr(pad);
|
|
odsState.getOrAddProperties<Properties>().stride = odsBuilder.getDenseI64ArrayAttr(stride);
|
|
odsState.getOrAddProperties<Properties>().dilation = odsBuilder.getDenseI64ArrayAttr(dilation);
|
|
odsState.getOrAddProperties<Properties>().acc_type = ::mlir::TypeAttr::get(acc_type);
|
|
odsState.getOrAddProperties<Properties>().local_bound = odsBuilder.getBoolAttr(local_bound);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
Conv2DOp Conv2DOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::llvm::ArrayRef<int64_t> pad, ::llvm::ArrayRef<int64_t> stride, ::llvm::ArrayRef<int64_t> dilation, ::mlir::Type acc_type, /*optional*/bool local_bound) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(weight_zp)>(weight_zp), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(acc_type)>(acc_type), std::forward<decltype(local_bound)>(local_bound));
|
|
auto __res__ = ::llvm::dyn_cast<Conv2DOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
Conv2DOp Conv2DOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::llvm::ArrayRef<int64_t> pad, ::llvm::ArrayRef<int64_t> stride, ::llvm::ArrayRef<int64_t> dilation, ::mlir::Type acc_type, /*optional*/bool local_bound) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(weight_zp)>(weight_zp), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(acc_type)>(acc_type), std::forward<decltype(local_bound)>(local_bound));
|
|
}
|
|
|
|
void Conv2DOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::llvm::ArrayRef<int64_t> pad, ::llvm::ArrayRef<int64_t> stride, ::llvm::ArrayRef<int64_t> dilation, ::mlir::Type acc_type, /*optional*/bool local_bound) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(weight);
|
|
odsState.addOperands(bias);
|
|
odsState.addOperands(input_zp);
|
|
odsState.addOperands(weight_zp);
|
|
odsState.getOrAddProperties<Properties>().pad = odsBuilder.getDenseI64ArrayAttr(pad);
|
|
odsState.getOrAddProperties<Properties>().stride = odsBuilder.getDenseI64ArrayAttr(stride);
|
|
odsState.getOrAddProperties<Properties>().dilation = odsBuilder.getDenseI64ArrayAttr(dilation);
|
|
odsState.getOrAddProperties<Properties>().acc_type = ::mlir::TypeAttr::get(acc_type);
|
|
odsState.getOrAddProperties<Properties>().local_bound = odsBuilder.getBoolAttr(local_bound);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
Conv2DOp Conv2DOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::llvm::ArrayRef<int64_t> pad, ::llvm::ArrayRef<int64_t> stride, ::llvm::ArrayRef<int64_t> dilation, ::mlir::Type acc_type, /*optional*/bool local_bound) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(weight_zp)>(weight_zp), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(acc_type)>(acc_type), std::forward<decltype(local_bound)>(local_bound));
|
|
auto __res__ = ::llvm::dyn_cast<Conv2DOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
Conv2DOp Conv2DOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::llvm::ArrayRef<int64_t> pad, ::llvm::ArrayRef<int64_t> stride, ::llvm::ArrayRef<int64_t> dilation, ::mlir::Type acc_type, /*optional*/bool local_bound) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(weight_zp)>(weight_zp), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(acc_type)>(acc_type), std::forward<decltype(local_bound)>(local_bound));
|
|
}
|
|
|
|
void Conv2DOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 5u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<Conv2DOp::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.");
|
|
}
|
|
}
|
|
|
|
Conv2DOp Conv2DOp::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<Conv2DOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
Conv2DOp Conv2DOp::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 Conv2DOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
|
|
assert(operands.size() == 5u && "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);
|
|
}
|
|
|
|
Conv2DOp Conv2DOp::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<Conv2DOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
Conv2DOp Conv2DOp::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 Conv2DOp::verifyInvariantsImpl() {
|
|
auto tblgen_acc_type = getProperties().acc_type; (void)tblgen_acc_type;
|
|
if (!tblgen_acc_type) return emitOpError("requires attribute 'acc_type'");
|
|
auto tblgen_dilation = getProperties().dilation; (void)tblgen_dilation;
|
|
if (!tblgen_dilation) return emitOpError("requires attribute 'dilation'");
|
|
auto tblgen_local_bound = getProperties().local_bound; (void)tblgen_local_bound;
|
|
auto tblgen_pad = getProperties().pad; (void)tblgen_pad;
|
|
if (!tblgen_pad) return emitOpError("requires attribute 'pad'");
|
|
auto tblgen_stride = getProperties().stride; (void)tblgen_stride;
|
|
if (!tblgen_stride) return emitOpError("requires attribute 'stride'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps7(*this, tblgen_pad, "pad")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps6(*this, tblgen_stride, "stride")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps6(*this, tblgen_dilation, "dilation")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps5(*this, tblgen_acc_type, "acc_type")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps4(*this, tblgen_local_bound, "local_bound")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps6(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps6(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps16(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup3 = getODSOperands(3);
|
|
|
|
for (auto v : valueGroup3) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps7(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup4 = getODSOperands(4);
|
|
|
|
for (auto v : valueGroup4) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps7(*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_TosaOps6(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult Conv2DOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult Conv2DOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void Conv2DOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getLocalBoundAttr();
|
|
if(attr && (attr == odsBuilder.getBoolAttr(false)))
|
|
elidedAttrs.push_back("local_bound");
|
|
}
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void Conv2DOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
Conv2DOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
Conv2DOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return Conv2DOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::Conv2DOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::Conv2DOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::Conv3DOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
Conv3DOpGenericAdaptorBase::Conv3DOpGenericAdaptorBase(Conv3DOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::llvm::ArrayRef<int64_t> Conv3DOpGenericAdaptorBase::getPad() {
|
|
auto attr = getPadAttr();
|
|
return attr;
|
|
}
|
|
|
|
::llvm::ArrayRef<int64_t> Conv3DOpGenericAdaptorBase::getStride() {
|
|
auto attr = getStrideAttr();
|
|
return attr;
|
|
}
|
|
|
|
::llvm::ArrayRef<int64_t> Conv3DOpGenericAdaptorBase::getDilation() {
|
|
auto attr = getDilationAttr();
|
|
return attr;
|
|
}
|
|
|
|
::mlir::Type Conv3DOpGenericAdaptorBase::getAccType() {
|
|
auto attr = getAccTypeAttr();
|
|
return ::llvm::cast<::mlir::Type>(attr.getValue());
|
|
}
|
|
|
|
::mlir::BoolAttr Conv3DOpGenericAdaptorBase::getLocalBoundAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().local_bound);
|
|
if (!attr)
|
|
attr = ::mlir::Builder(odsAttrs.getContext()).getBoolAttr(false);
|
|
return attr;
|
|
}
|
|
|
|
bool Conv3DOpGenericAdaptorBase::getLocalBound() {
|
|
auto attr = getLocalBoundAttr();
|
|
if (!attr)
|
|
return ::mlir::Builder(odsAttrs.getContext()).getBoolAttr(false).getValue();
|
|
return attr.getValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
Conv3DOpAdaptor::Conv3DOpAdaptor(Conv3DOp op) : Conv3DOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult Conv3DOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_acc_type = getProperties().acc_type; (void)tblgen_acc_type;
|
|
if (!tblgen_acc_type) return emitError(loc, "'tosa.conv3d' op requires attribute 'acc_type'");
|
|
auto tblgen_dilation = getProperties().dilation; (void)tblgen_dilation;
|
|
if (!tblgen_dilation) return emitError(loc, "'tosa.conv3d' op requires attribute 'dilation'");
|
|
auto tblgen_local_bound = getProperties().local_bound; (void)tblgen_local_bound;
|
|
auto tblgen_pad = getProperties().pad; (void)tblgen_pad;
|
|
if (!tblgen_pad) return emitError(loc, "'tosa.conv3d' op requires attribute 'pad'");
|
|
auto tblgen_stride = getProperties().stride; (void)tblgen_stride;
|
|
if (!tblgen_stride) return emitError(loc, "'tosa.conv3d' op requires attribute 'stride'");
|
|
|
|
if (tblgen_pad && !(((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_pad))) && ((::llvm::cast<::mlir::DenseArrayAttr>(tblgen_pad).size() == 6))))
|
|
return emitError(loc, "'tosa.conv3d' op attribute 'pad' failed to satisfy constraint: i64 dense array attribute with exactly 6 elements");
|
|
|
|
if (tblgen_stride && !(((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_stride))) && ((::llvm::cast<::mlir::DenseArrayAttr>(tblgen_stride).size() == 3))))
|
|
return emitError(loc, "'tosa.conv3d' op attribute 'stride' failed to satisfy constraint: i64 dense array attribute with exactly 3 elements");
|
|
|
|
if (tblgen_dilation && !(((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_dilation))) && ((::llvm::cast<::mlir::DenseArrayAttr>(tblgen_dilation).size() == 3))))
|
|
return emitError(loc, "'tosa.conv3d' op attribute 'dilation' failed to satisfy constraint: i64 dense array attribute with exactly 3 elements");
|
|
|
|
if (tblgen_acc_type && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_acc_type))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_acc_type).getValue()))) && (((::llvm::cast<::mlir::TypeAttr>(tblgen_acc_type).getValue().isSignlessInteger(32))) || ((::llvm::cast<::mlir::TypeAttr>(tblgen_acc_type).getValue().isSignlessInteger(48))) || ((::llvm::cast<::mlir::TypeAttr>(tblgen_acc_type).getValue().isF16())) || ((::llvm::cast<::mlir::TypeAttr>(tblgen_acc_type).getValue().isF32())))))
|
|
return emitError(loc, "'tosa.conv3d' op attribute 'acc_type' failed to satisfy constraint: type attribute of 32-bit signless integer or 48-bit signless integer or 16-bit float or 32-bit float");
|
|
|
|
if (tblgen_local_bound && !((::llvm::isa<::mlir::BoolAttr>(tblgen_local_bound))))
|
|
return emitError(loc, "'tosa.conv3d' op attribute 'local_bound' failed to satisfy constraint: bool attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult Conv3DOp::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.acc_type;
|
|
auto attr = dict.get("acc_type");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `acc_type` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.dilation;
|
|
auto attr = dict.get("dilation");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `dilation` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.local_bound;
|
|
auto attr = dict.get("local_bound");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `local_bound` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.pad;
|
|
auto attr = dict.get("pad");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `pad` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.stride;
|
|
auto attr = dict.get("stride");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `stride` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute Conv3DOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.acc_type;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("acc_type",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.dilation;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("dilation",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.local_bound;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("local_bound",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.pad;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("pad",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.stride;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("stride",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code Conv3DOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.acc_type.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.dilation.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.local_bound.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.pad.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.stride.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> Conv3DOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "acc_type")
|
|
return prop.acc_type;
|
|
|
|
if (name == "dilation")
|
|
return prop.dilation;
|
|
|
|
if (name == "local_bound")
|
|
return prop.local_bound;
|
|
|
|
if (name == "pad")
|
|
return prop.pad;
|
|
|
|
if (name == "stride")
|
|
return prop.stride;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void Conv3DOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "acc_type") {
|
|
prop.acc_type = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.acc_type)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "dilation") {
|
|
prop.dilation = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.dilation)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "local_bound") {
|
|
prop.local_bound = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.local_bound)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "pad") {
|
|
prop.pad = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.pad)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "stride") {
|
|
prop.stride = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.stride)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void Conv3DOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.acc_type) attrs.append("acc_type", prop.acc_type);
|
|
|
|
if (prop.dilation) attrs.append("dilation", prop.dilation);
|
|
|
|
if (prop.local_bound) attrs.append("local_bound", prop.local_bound);
|
|
|
|
if (prop.pad) attrs.append("pad", prop.pad);
|
|
|
|
if (prop.stride) attrs.append("stride", prop.stride);
|
|
}
|
|
|
|
::llvm::LogicalResult Conv3DOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getAccTypeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps5(attr, "acc_type", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getDilationAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps13(attr, "dilation", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getLocalBoundAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps4(attr, "local_bound", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getPadAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps12(attr, "pad", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getStrideAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps13(attr, "stride", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult Conv3DOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.acc_type)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readAttribute(prop.dilation)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.local_bound)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readAttribute(prop.pad)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readAttribute(prop.stride)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void Conv3DOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.acc_type);
|
|
writer.writeAttribute(prop.dilation);
|
|
|
|
writer.writeOptionalAttribute(prop.local_bound);
|
|
writer.writeAttribute(prop.pad);
|
|
writer.writeAttribute(prop.stride);
|
|
}
|
|
|
|
::llvm::ArrayRef<int64_t> Conv3DOp::getPad() {
|
|
auto attr = getPadAttr();
|
|
return attr;
|
|
}
|
|
|
|
::llvm::ArrayRef<int64_t> Conv3DOp::getStride() {
|
|
auto attr = getStrideAttr();
|
|
return attr;
|
|
}
|
|
|
|
::llvm::ArrayRef<int64_t> Conv3DOp::getDilation() {
|
|
auto attr = getDilationAttr();
|
|
return attr;
|
|
}
|
|
|
|
::mlir::Type Conv3DOp::getAccType() {
|
|
auto attr = getAccTypeAttr();
|
|
return ::llvm::cast<::mlir::Type>(attr.getValue());
|
|
}
|
|
|
|
bool Conv3DOp::getLocalBound() {
|
|
auto attr = getLocalBoundAttr();
|
|
if (!attr)
|
|
return ::mlir::Builder((*this)->getContext()).getBoolAttr(false).getValue();
|
|
return attr.getValue();
|
|
}
|
|
|
|
void Conv3DOp::setPad(::llvm::ArrayRef<int64_t> attrValue) {
|
|
getProperties().pad = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue);
|
|
}
|
|
|
|
void Conv3DOp::setStride(::llvm::ArrayRef<int64_t> attrValue) {
|
|
getProperties().stride = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue);
|
|
}
|
|
|
|
void Conv3DOp::setDilation(::llvm::ArrayRef<int64_t> attrValue) {
|
|
getProperties().dilation = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue);
|
|
}
|
|
|
|
void Conv3DOp::setAccType(::mlir::Type attrValue) {
|
|
getProperties().acc_type = ::mlir::TypeAttr::get(attrValue);
|
|
}
|
|
|
|
void Conv3DOp::setLocalBound(::std::optional<bool> attrValue) {
|
|
auto &odsProp = getProperties().local_bound;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getBoolAttr(*attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void Conv3DOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type outputType, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::DenseI64ArrayAttr pad, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr dilation, ::mlir::TypeAttr acc_type) {
|
|
buildConvOpWithQuantInfo(odsBuilder, odsState, outputType,
|
|
input, weight, bias,
|
|
pad, stride, dilation, acc_type);
|
|
|
|
}
|
|
|
|
Conv3DOp Conv3DOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type outputType, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::DenseI64ArrayAttr pad, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr dilation, ::mlir::TypeAttr acc_type) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(outputType)>(outputType), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(acc_type)>(acc_type));
|
|
auto __res__ = ::llvm::dyn_cast<Conv3DOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
Conv3DOp Conv3DOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type outputType, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::DenseI64ArrayAttr pad, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr dilation, ::mlir::TypeAttr acc_type) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(outputType)>(outputType), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(acc_type)>(acc_type));
|
|
}
|
|
|
|
void Conv3DOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::mlir::DenseI64ArrayAttr pad, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr dilation, ::mlir::TypeAttr acc_type, /*optional*/::mlir::BoolAttr local_bound) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(weight);
|
|
odsState.addOperands(bias);
|
|
odsState.addOperands(input_zp);
|
|
odsState.addOperands(weight_zp);
|
|
odsState.getOrAddProperties<Properties>().pad = pad;
|
|
odsState.getOrAddProperties<Properties>().stride = stride;
|
|
odsState.getOrAddProperties<Properties>().dilation = dilation;
|
|
odsState.getOrAddProperties<Properties>().acc_type = acc_type;
|
|
if (local_bound) {
|
|
odsState.getOrAddProperties<Properties>().local_bound = local_bound;
|
|
}
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
Conv3DOp Conv3DOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::mlir::DenseI64ArrayAttr pad, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr dilation, ::mlir::TypeAttr acc_type, /*optional*/::mlir::BoolAttr local_bound) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(weight_zp)>(weight_zp), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(acc_type)>(acc_type), std::forward<decltype(local_bound)>(local_bound));
|
|
auto __res__ = ::llvm::dyn_cast<Conv3DOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
Conv3DOp Conv3DOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::mlir::DenseI64ArrayAttr pad, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr dilation, ::mlir::TypeAttr acc_type, /*optional*/::mlir::BoolAttr local_bound) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(weight_zp)>(weight_zp), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(acc_type)>(acc_type), std::forward<decltype(local_bound)>(local_bound));
|
|
}
|
|
|
|
void Conv3DOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::mlir::DenseI64ArrayAttr pad, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr dilation, ::mlir::TypeAttr acc_type, /*optional*/::mlir::BoolAttr local_bound) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(weight);
|
|
odsState.addOperands(bias);
|
|
odsState.addOperands(input_zp);
|
|
odsState.addOperands(weight_zp);
|
|
odsState.getOrAddProperties<Properties>().pad = pad;
|
|
odsState.getOrAddProperties<Properties>().stride = stride;
|
|
odsState.getOrAddProperties<Properties>().dilation = dilation;
|
|
odsState.getOrAddProperties<Properties>().acc_type = acc_type;
|
|
if (local_bound) {
|
|
odsState.getOrAddProperties<Properties>().local_bound = local_bound;
|
|
}
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
Conv3DOp Conv3DOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::mlir::DenseI64ArrayAttr pad, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr dilation, ::mlir::TypeAttr acc_type, /*optional*/::mlir::BoolAttr local_bound) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(weight_zp)>(weight_zp), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(acc_type)>(acc_type), std::forward<decltype(local_bound)>(local_bound));
|
|
auto __res__ = ::llvm::dyn_cast<Conv3DOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
Conv3DOp Conv3DOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::mlir::DenseI64ArrayAttr pad, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr dilation, ::mlir::TypeAttr acc_type, /*optional*/::mlir::BoolAttr local_bound) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(weight_zp)>(weight_zp), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(acc_type)>(acc_type), std::forward<decltype(local_bound)>(local_bound));
|
|
}
|
|
|
|
void Conv3DOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::llvm::ArrayRef<int64_t> pad, ::llvm::ArrayRef<int64_t> stride, ::llvm::ArrayRef<int64_t> dilation, ::mlir::Type acc_type, /*optional*/bool local_bound) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(weight);
|
|
odsState.addOperands(bias);
|
|
odsState.addOperands(input_zp);
|
|
odsState.addOperands(weight_zp);
|
|
odsState.getOrAddProperties<Properties>().pad = odsBuilder.getDenseI64ArrayAttr(pad);
|
|
odsState.getOrAddProperties<Properties>().stride = odsBuilder.getDenseI64ArrayAttr(stride);
|
|
odsState.getOrAddProperties<Properties>().dilation = odsBuilder.getDenseI64ArrayAttr(dilation);
|
|
odsState.getOrAddProperties<Properties>().acc_type = ::mlir::TypeAttr::get(acc_type);
|
|
odsState.getOrAddProperties<Properties>().local_bound = odsBuilder.getBoolAttr(local_bound);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
Conv3DOp Conv3DOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::llvm::ArrayRef<int64_t> pad, ::llvm::ArrayRef<int64_t> stride, ::llvm::ArrayRef<int64_t> dilation, ::mlir::Type acc_type, /*optional*/bool local_bound) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(weight_zp)>(weight_zp), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(acc_type)>(acc_type), std::forward<decltype(local_bound)>(local_bound));
|
|
auto __res__ = ::llvm::dyn_cast<Conv3DOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
Conv3DOp Conv3DOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::llvm::ArrayRef<int64_t> pad, ::llvm::ArrayRef<int64_t> stride, ::llvm::ArrayRef<int64_t> dilation, ::mlir::Type acc_type, /*optional*/bool local_bound) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(weight_zp)>(weight_zp), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(acc_type)>(acc_type), std::forward<decltype(local_bound)>(local_bound));
|
|
}
|
|
|
|
void Conv3DOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::llvm::ArrayRef<int64_t> pad, ::llvm::ArrayRef<int64_t> stride, ::llvm::ArrayRef<int64_t> dilation, ::mlir::Type acc_type, /*optional*/bool local_bound) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(weight);
|
|
odsState.addOperands(bias);
|
|
odsState.addOperands(input_zp);
|
|
odsState.addOperands(weight_zp);
|
|
odsState.getOrAddProperties<Properties>().pad = odsBuilder.getDenseI64ArrayAttr(pad);
|
|
odsState.getOrAddProperties<Properties>().stride = odsBuilder.getDenseI64ArrayAttr(stride);
|
|
odsState.getOrAddProperties<Properties>().dilation = odsBuilder.getDenseI64ArrayAttr(dilation);
|
|
odsState.getOrAddProperties<Properties>().acc_type = ::mlir::TypeAttr::get(acc_type);
|
|
odsState.getOrAddProperties<Properties>().local_bound = odsBuilder.getBoolAttr(local_bound);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
Conv3DOp Conv3DOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::llvm::ArrayRef<int64_t> pad, ::llvm::ArrayRef<int64_t> stride, ::llvm::ArrayRef<int64_t> dilation, ::mlir::Type acc_type, /*optional*/bool local_bound) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(weight_zp)>(weight_zp), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(acc_type)>(acc_type), std::forward<decltype(local_bound)>(local_bound));
|
|
auto __res__ = ::llvm::dyn_cast<Conv3DOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
Conv3DOp Conv3DOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::llvm::ArrayRef<int64_t> pad, ::llvm::ArrayRef<int64_t> stride, ::llvm::ArrayRef<int64_t> dilation, ::mlir::Type acc_type, /*optional*/bool local_bound) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(weight_zp)>(weight_zp), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(acc_type)>(acc_type), std::forward<decltype(local_bound)>(local_bound));
|
|
}
|
|
|
|
void Conv3DOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 5u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<Conv3DOp::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.");
|
|
}
|
|
}
|
|
|
|
Conv3DOp Conv3DOp::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<Conv3DOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
Conv3DOp Conv3DOp::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 Conv3DOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
|
|
assert(operands.size() == 5u && "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);
|
|
}
|
|
|
|
Conv3DOp Conv3DOp::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<Conv3DOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
Conv3DOp Conv3DOp::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 Conv3DOp::verifyInvariantsImpl() {
|
|
auto tblgen_acc_type = getProperties().acc_type; (void)tblgen_acc_type;
|
|
if (!tblgen_acc_type) return emitOpError("requires attribute 'acc_type'");
|
|
auto tblgen_dilation = getProperties().dilation; (void)tblgen_dilation;
|
|
if (!tblgen_dilation) return emitOpError("requires attribute 'dilation'");
|
|
auto tblgen_local_bound = getProperties().local_bound; (void)tblgen_local_bound;
|
|
auto tblgen_pad = getProperties().pad; (void)tblgen_pad;
|
|
if (!tblgen_pad) return emitOpError("requires attribute 'pad'");
|
|
auto tblgen_stride = getProperties().stride; (void)tblgen_stride;
|
|
if (!tblgen_stride) return emitOpError("requires attribute 'stride'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps12(*this, tblgen_pad, "pad")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps13(*this, tblgen_stride, "stride")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps13(*this, tblgen_dilation, "dilation")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps5(*this, tblgen_acc_type, "acc_type")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps4(*this, tblgen_local_bound, "local_bound")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps17(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps17(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps16(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup3 = getODSOperands(3);
|
|
|
|
for (auto v : valueGroup3) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps7(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup4 = getODSOperands(4);
|
|
|
|
for (auto v : valueGroup4) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps7(*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_TosaOps17(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult Conv3DOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult Conv3DOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void Conv3DOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getLocalBoundAttr();
|
|
if(attr && (attr == odsBuilder.getBoolAttr(false)))
|
|
elidedAttrs.push_back("local_bound");
|
|
}
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void Conv3DOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
Conv3DOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
Conv3DOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return Conv3DOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::Conv3DOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::Conv3DOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::CosOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
CosOpGenericAdaptorBase::CosOpGenericAdaptorBase(CosOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
CosOpAdaptor::CosOpAdaptor(CosOp op) : CosOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult CosOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult CosOp::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 CosOp::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 CosOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> CosOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void CosOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void CosOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult CosOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void CosOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1) {
|
|
odsState.addOperands(input1);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
CosOp CosOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1));
|
|
auto __res__ = ::llvm::dyn_cast<CosOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CosOp CosOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1));
|
|
}
|
|
|
|
void CosOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
odsState.addOperands(input1);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
CosOp CosOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1));
|
|
auto __res__ = ::llvm::dyn_cast<CosOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CosOp CosOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1));
|
|
}
|
|
|
|
void CosOp::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);
|
|
}
|
|
|
|
CosOp CosOp::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<CosOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CosOp CosOp::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 CosOp::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);
|
|
}
|
|
|
|
CosOp CosOp::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<CosOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CosOp CosOp::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 CosOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps18(*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_TosaOps18(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult CosOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult CosOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void CosOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void CosOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::CosOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::CustomOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
CustomOpGenericAdaptorBase::CustomOpGenericAdaptorBase(CustomOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> CustomOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
bool isVariadic[] = {true};
|
|
int prevVariadicCount = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
if (isVariadic[i]) ++prevVariadicCount;
|
|
|
|
// Calculate how many dynamic values a static variadic operand corresponds to.
|
|
// This assumes all static variadic operands have the same dynamic value count.
|
|
int variadicSize = (odsOperandsSize - 0) / 1;
|
|
// `index` passed in as the parameter is the static index which counts each
|
|
// operand (variadic or not) as size 1. So here for each previous static variadic
|
|
// operand, we need to offset by (variadicSize - 1) to get where the dynamic
|
|
// value pack for this static operand starts.
|
|
int start = index + (variadicSize - 1) * prevVariadicCount;
|
|
int size = isVariadic[index] ? variadicSize : 1;
|
|
return {start, size};
|
|
}
|
|
|
|
::llvm::StringRef CustomOpGenericAdaptorBase::getOperatorName() {
|
|
auto attr = getOperatorNameAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
::llvm::StringRef CustomOpGenericAdaptorBase::getDomainName() {
|
|
auto attr = getDomainNameAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
::llvm::StringRef CustomOpGenericAdaptorBase::getImplementationAttrs() {
|
|
auto attr = getImplementationAttrsAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
CustomOpAdaptor::CustomOpAdaptor(CustomOp op) : CustomOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult CustomOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_domain_name = getProperties().domain_name; (void)tblgen_domain_name;
|
|
if (!tblgen_domain_name) return emitError(loc, "'tosa.custom' op requires attribute 'domain_name'");
|
|
auto tblgen_implementation_attrs = getProperties().implementation_attrs; (void)tblgen_implementation_attrs;
|
|
if (!tblgen_implementation_attrs) return emitError(loc, "'tosa.custom' op requires attribute 'implementation_attrs'");
|
|
auto tblgen_operator_name = getProperties().operator_name; (void)tblgen_operator_name;
|
|
if (!tblgen_operator_name) return emitError(loc, "'tosa.custom' op requires attribute 'operator_name'");
|
|
|
|
if (tblgen_operator_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_operator_name))))
|
|
return emitError(loc, "'tosa.custom' op attribute 'operator_name' failed to satisfy constraint: string attribute");
|
|
|
|
if (tblgen_domain_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_domain_name))))
|
|
return emitError(loc, "'tosa.custom' op attribute 'domain_name' failed to satisfy constraint: string attribute");
|
|
|
|
if (tblgen_implementation_attrs && !((::llvm::isa<::mlir::StringAttr>(tblgen_implementation_attrs))))
|
|
return emitError(loc, "'tosa.custom' op attribute 'implementation_attrs' failed to satisfy constraint: string attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> CustomOp::getODSOperandIndexAndLength(unsigned index) {
|
|
bool isVariadic[] = {true};
|
|
int prevVariadicCount = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
if (isVariadic[i]) ++prevVariadicCount;
|
|
|
|
// Calculate how many dynamic values a static variadic operand corresponds to.
|
|
// This assumes all static variadic operands have the same dynamic value count.
|
|
int variadicSize = (getOperation()->getNumOperands() - 0) / 1;
|
|
// `index` passed in as the parameter is the static index which counts each
|
|
// operand (variadic or not) as size 1. So here for each previous static variadic
|
|
// operand, we need to offset by (variadicSize - 1) to get where the dynamic
|
|
// value pack for this static operand starts.
|
|
int start = index + (variadicSize - 1) * prevVariadicCount;
|
|
int size = isVariadic[index] ? variadicSize : 1;
|
|
return {start, size};
|
|
}
|
|
|
|
::mlir::MutableOperandRange CustomOp::getInputListMutable() {
|
|
auto range = getODSOperandIndexAndLength(0);
|
|
auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
|
|
return mutableRange;
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> CustomOp::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 CustomOp::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.domain_name;
|
|
auto attr = dict.get("domain_name");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `domain_name` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.implementation_attrs;
|
|
auto attr = dict.get("implementation_attrs");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `implementation_attrs` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.operator_name;
|
|
auto attr = dict.get("operator_name");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `operator_name` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute CustomOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.domain_name;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("domain_name",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.implementation_attrs;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("implementation_attrs",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.operator_name;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("operator_name",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code CustomOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.domain_name.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.implementation_attrs.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.operator_name.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> CustomOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "domain_name")
|
|
return prop.domain_name;
|
|
|
|
if (name == "implementation_attrs")
|
|
return prop.implementation_attrs;
|
|
|
|
if (name == "operator_name")
|
|
return prop.operator_name;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void CustomOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "domain_name") {
|
|
prop.domain_name = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.domain_name)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "implementation_attrs") {
|
|
prop.implementation_attrs = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.implementation_attrs)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "operator_name") {
|
|
prop.operator_name = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.operator_name)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void CustomOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.domain_name) attrs.append("domain_name", prop.domain_name);
|
|
|
|
if (prop.implementation_attrs) attrs.append("implementation_attrs", prop.implementation_attrs);
|
|
|
|
if (prop.operator_name) attrs.append("operator_name", prop.operator_name);
|
|
}
|
|
|
|
::llvm::LogicalResult CustomOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getDomainNameAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps14(attr, "domain_name", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getImplementationAttrsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps14(attr, "implementation_attrs", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getOperatorNameAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps14(attr, "operator_name", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult CustomOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.domain_name)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readAttribute(prop.implementation_attrs)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readAttribute(prop.operator_name)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void CustomOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.domain_name);
|
|
writer.writeAttribute(prop.implementation_attrs);
|
|
writer.writeAttribute(prop.operator_name);
|
|
}
|
|
|
|
::llvm::StringRef CustomOp::getOperatorName() {
|
|
auto attr = getOperatorNameAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
::llvm::StringRef CustomOp::getDomainName() {
|
|
auto attr = getDomainNameAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
::llvm::StringRef CustomOp::getImplementationAttrs() {
|
|
auto attr = getImplementationAttrsAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
void CustomOp::setOperatorName(::llvm::StringRef attrValue) {
|
|
getProperties().operator_name = ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue);
|
|
}
|
|
|
|
void CustomOp::setDomainName(::llvm::StringRef attrValue) {
|
|
getProperties().domain_name = ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue);
|
|
}
|
|
|
|
void CustomOp::setImplementationAttrs(::llvm::StringRef attrValue) {
|
|
getProperties().implementation_attrs = ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue);
|
|
}
|
|
|
|
void CustomOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange output_list, ::mlir::StringAttr operator_name, ::mlir::StringAttr domain_name, ::mlir::StringAttr implementation_attrs, ::mlir::ValueRange input_list) {
|
|
odsState.addOperands(input_list);
|
|
odsState.getOrAddProperties<Properties>().operator_name = operator_name;
|
|
odsState.getOrAddProperties<Properties>().domain_name = domain_name;
|
|
odsState.getOrAddProperties<Properties>().implementation_attrs = implementation_attrs;
|
|
odsState.addTypes(output_list);
|
|
}
|
|
|
|
CustomOp CustomOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange output_list, ::mlir::StringAttr operator_name, ::mlir::StringAttr domain_name, ::mlir::StringAttr implementation_attrs, ::mlir::ValueRange input_list) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output_list)>(output_list), std::forward<decltype(operator_name)>(operator_name), std::forward<decltype(domain_name)>(domain_name), std::forward<decltype(implementation_attrs)>(implementation_attrs), std::forward<decltype(input_list)>(input_list));
|
|
auto __res__ = ::llvm::dyn_cast<CustomOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CustomOp CustomOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange output_list, ::mlir::StringAttr operator_name, ::mlir::StringAttr domain_name, ::mlir::StringAttr implementation_attrs, ::mlir::ValueRange input_list) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output_list)>(output_list), std::forward<decltype(operator_name)>(operator_name), std::forward<decltype(domain_name)>(domain_name), std::forward<decltype(implementation_attrs)>(implementation_attrs), std::forward<decltype(input_list)>(input_list));
|
|
}
|
|
|
|
void CustomOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange output_list, ::llvm::StringRef operator_name, ::llvm::StringRef domain_name, ::llvm::StringRef implementation_attrs, ::mlir::ValueRange input_list) {
|
|
odsState.addOperands(input_list);
|
|
odsState.getOrAddProperties<Properties>().operator_name = odsBuilder.getStringAttr(operator_name);
|
|
odsState.getOrAddProperties<Properties>().domain_name = odsBuilder.getStringAttr(domain_name);
|
|
odsState.getOrAddProperties<Properties>().implementation_attrs = odsBuilder.getStringAttr(implementation_attrs);
|
|
odsState.addTypes(output_list);
|
|
}
|
|
|
|
CustomOp CustomOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange output_list, ::llvm::StringRef operator_name, ::llvm::StringRef domain_name, ::llvm::StringRef implementation_attrs, ::mlir::ValueRange input_list) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output_list)>(output_list), std::forward<decltype(operator_name)>(operator_name), std::forward<decltype(domain_name)>(domain_name), std::forward<decltype(implementation_attrs)>(implementation_attrs), std::forward<decltype(input_list)>(input_list));
|
|
auto __res__ = ::llvm::dyn_cast<CustomOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CustomOp CustomOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange output_list, ::llvm::StringRef operator_name, ::llvm::StringRef domain_name, ::llvm::StringRef implementation_attrs, ::mlir::ValueRange input_list) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output_list)>(output_list), std::forward<decltype(operator_name)>(operator_name), std::forward<decltype(domain_name)>(domain_name), std::forward<decltype(implementation_attrs)>(implementation_attrs), std::forward<decltype(input_list)>(input_list));
|
|
}
|
|
|
|
void CustomOp::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<CustomOp::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.");
|
|
}
|
|
}
|
|
|
|
CustomOp CustomOp::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<CustomOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CustomOp CustomOp::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 CustomOp::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);
|
|
}
|
|
|
|
CustomOp CustomOp::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<CustomOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
CustomOp CustomOp::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 CustomOp::verifyInvariantsImpl() {
|
|
auto tblgen_domain_name = getProperties().domain_name; (void)tblgen_domain_name;
|
|
if (!tblgen_domain_name) return emitOpError("requires attribute 'domain_name'");
|
|
auto tblgen_implementation_attrs = getProperties().implementation_attrs; (void)tblgen_implementation_attrs;
|
|
if (!tblgen_implementation_attrs) return emitOpError("requires attribute 'implementation_attrs'");
|
|
auto tblgen_operator_name = getProperties().operator_name; (void)tblgen_operator_name;
|
|
if (!tblgen_operator_name) return emitOpError("requires attribute 'operator_name'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps14(*this, tblgen_operator_name, "operator_name")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps14(*this, tblgen_domain_name, "domain_name")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps14(*this, tblgen_implementation_attrs, "implementation_attrs")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps19(*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_TosaOps19(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult CustomOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult CustomOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void CustomOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::CustomOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::CustomOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::DepthwiseConv2DOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
DepthwiseConv2DOpGenericAdaptorBase::DepthwiseConv2DOpGenericAdaptorBase(DepthwiseConv2DOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::llvm::ArrayRef<int64_t> DepthwiseConv2DOpGenericAdaptorBase::getPad() {
|
|
auto attr = getPadAttr();
|
|
return attr;
|
|
}
|
|
|
|
::llvm::ArrayRef<int64_t> DepthwiseConv2DOpGenericAdaptorBase::getStride() {
|
|
auto attr = getStrideAttr();
|
|
return attr;
|
|
}
|
|
|
|
::llvm::ArrayRef<int64_t> DepthwiseConv2DOpGenericAdaptorBase::getDilation() {
|
|
auto attr = getDilationAttr();
|
|
return attr;
|
|
}
|
|
|
|
::mlir::Type DepthwiseConv2DOpGenericAdaptorBase::getAccType() {
|
|
auto attr = getAccTypeAttr();
|
|
return ::llvm::cast<::mlir::Type>(attr.getValue());
|
|
}
|
|
|
|
::mlir::BoolAttr DepthwiseConv2DOpGenericAdaptorBase::getLocalBoundAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().local_bound);
|
|
if (!attr)
|
|
attr = ::mlir::Builder(odsAttrs.getContext()).getBoolAttr(false);
|
|
return attr;
|
|
}
|
|
|
|
bool DepthwiseConv2DOpGenericAdaptorBase::getLocalBound() {
|
|
auto attr = getLocalBoundAttr();
|
|
if (!attr)
|
|
return ::mlir::Builder(odsAttrs.getContext()).getBoolAttr(false).getValue();
|
|
return attr.getValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
DepthwiseConv2DOpAdaptor::DepthwiseConv2DOpAdaptor(DepthwiseConv2DOp op) : DepthwiseConv2DOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult DepthwiseConv2DOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_acc_type = getProperties().acc_type; (void)tblgen_acc_type;
|
|
if (!tblgen_acc_type) return emitError(loc, "'tosa.depthwise_conv2d' op requires attribute 'acc_type'");
|
|
auto tblgen_dilation = getProperties().dilation; (void)tblgen_dilation;
|
|
if (!tblgen_dilation) return emitError(loc, "'tosa.depthwise_conv2d' op requires attribute 'dilation'");
|
|
auto tblgen_local_bound = getProperties().local_bound; (void)tblgen_local_bound;
|
|
auto tblgen_pad = getProperties().pad; (void)tblgen_pad;
|
|
if (!tblgen_pad) return emitError(loc, "'tosa.depthwise_conv2d' op requires attribute 'pad'");
|
|
auto tblgen_stride = getProperties().stride; (void)tblgen_stride;
|
|
if (!tblgen_stride) return emitError(loc, "'tosa.depthwise_conv2d' op requires attribute 'stride'");
|
|
|
|
if (tblgen_pad && !(((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_pad))) && ((::llvm::cast<::mlir::DenseArrayAttr>(tblgen_pad).size() == 4))))
|
|
return emitError(loc, "'tosa.depthwise_conv2d' op attribute 'pad' failed to satisfy constraint: i64 dense array attribute with exactly 4 elements");
|
|
|
|
if (tblgen_stride && !(((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_stride))) && ((::llvm::cast<::mlir::DenseArrayAttr>(tblgen_stride).size() == 2))))
|
|
return emitError(loc, "'tosa.depthwise_conv2d' op attribute 'stride' failed to satisfy constraint: i64 dense array attribute with exactly 2 elements");
|
|
|
|
if (tblgen_dilation && !(((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_dilation))) && ((::llvm::cast<::mlir::DenseArrayAttr>(tblgen_dilation).size() == 2))))
|
|
return emitError(loc, "'tosa.depthwise_conv2d' op attribute 'dilation' failed to satisfy constraint: i64 dense array attribute with exactly 2 elements");
|
|
|
|
if (tblgen_acc_type && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_acc_type))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_acc_type).getValue()))) && (((::llvm::cast<::mlir::TypeAttr>(tblgen_acc_type).getValue().isSignlessInteger(32))) || ((::llvm::cast<::mlir::TypeAttr>(tblgen_acc_type).getValue().isSignlessInteger(48))) || ((::llvm::cast<::mlir::TypeAttr>(tblgen_acc_type).getValue().isF16())) || ((::llvm::cast<::mlir::TypeAttr>(tblgen_acc_type).getValue().isF32())))))
|
|
return emitError(loc, "'tosa.depthwise_conv2d' op attribute 'acc_type' failed to satisfy constraint: type attribute of 32-bit signless integer or 48-bit signless integer or 16-bit float or 32-bit float");
|
|
|
|
if (tblgen_local_bound && !((::llvm::isa<::mlir::BoolAttr>(tblgen_local_bound))))
|
|
return emitError(loc, "'tosa.depthwise_conv2d' op attribute 'local_bound' failed to satisfy constraint: bool attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult DepthwiseConv2DOp::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.acc_type;
|
|
auto attr = dict.get("acc_type");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `acc_type` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.dilation;
|
|
auto attr = dict.get("dilation");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `dilation` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.local_bound;
|
|
auto attr = dict.get("local_bound");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `local_bound` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.pad;
|
|
auto attr = dict.get("pad");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `pad` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.stride;
|
|
auto attr = dict.get("stride");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `stride` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute DepthwiseConv2DOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.acc_type;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("acc_type",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.dilation;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("dilation",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.local_bound;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("local_bound",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.pad;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("pad",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.stride;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("stride",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code DepthwiseConv2DOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.acc_type.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.dilation.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.local_bound.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.pad.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.stride.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> DepthwiseConv2DOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "acc_type")
|
|
return prop.acc_type;
|
|
|
|
if (name == "dilation")
|
|
return prop.dilation;
|
|
|
|
if (name == "local_bound")
|
|
return prop.local_bound;
|
|
|
|
if (name == "pad")
|
|
return prop.pad;
|
|
|
|
if (name == "stride")
|
|
return prop.stride;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void DepthwiseConv2DOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "acc_type") {
|
|
prop.acc_type = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.acc_type)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "dilation") {
|
|
prop.dilation = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.dilation)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "local_bound") {
|
|
prop.local_bound = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.local_bound)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "pad") {
|
|
prop.pad = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.pad)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "stride") {
|
|
prop.stride = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.stride)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void DepthwiseConv2DOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.acc_type) attrs.append("acc_type", prop.acc_type);
|
|
|
|
if (prop.dilation) attrs.append("dilation", prop.dilation);
|
|
|
|
if (prop.local_bound) attrs.append("local_bound", prop.local_bound);
|
|
|
|
if (prop.pad) attrs.append("pad", prop.pad);
|
|
|
|
if (prop.stride) attrs.append("stride", prop.stride);
|
|
}
|
|
|
|
::llvm::LogicalResult DepthwiseConv2DOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getAccTypeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps5(attr, "acc_type", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getDilationAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps6(attr, "dilation", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getLocalBoundAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps4(attr, "local_bound", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getPadAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps7(attr, "pad", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getStrideAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps6(attr, "stride", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult DepthwiseConv2DOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.acc_type)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readAttribute(prop.dilation)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.local_bound)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readAttribute(prop.pad)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readAttribute(prop.stride)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void DepthwiseConv2DOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.acc_type);
|
|
writer.writeAttribute(prop.dilation);
|
|
|
|
writer.writeOptionalAttribute(prop.local_bound);
|
|
writer.writeAttribute(prop.pad);
|
|
writer.writeAttribute(prop.stride);
|
|
}
|
|
|
|
::llvm::ArrayRef<int64_t> DepthwiseConv2DOp::getPad() {
|
|
auto attr = getPadAttr();
|
|
return attr;
|
|
}
|
|
|
|
::llvm::ArrayRef<int64_t> DepthwiseConv2DOp::getStride() {
|
|
auto attr = getStrideAttr();
|
|
return attr;
|
|
}
|
|
|
|
::llvm::ArrayRef<int64_t> DepthwiseConv2DOp::getDilation() {
|
|
auto attr = getDilationAttr();
|
|
return attr;
|
|
}
|
|
|
|
::mlir::Type DepthwiseConv2DOp::getAccType() {
|
|
auto attr = getAccTypeAttr();
|
|
return ::llvm::cast<::mlir::Type>(attr.getValue());
|
|
}
|
|
|
|
bool DepthwiseConv2DOp::getLocalBound() {
|
|
auto attr = getLocalBoundAttr();
|
|
if (!attr)
|
|
return ::mlir::Builder((*this)->getContext()).getBoolAttr(false).getValue();
|
|
return attr.getValue();
|
|
}
|
|
|
|
void DepthwiseConv2DOp::setPad(::llvm::ArrayRef<int64_t> attrValue) {
|
|
getProperties().pad = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue);
|
|
}
|
|
|
|
void DepthwiseConv2DOp::setStride(::llvm::ArrayRef<int64_t> attrValue) {
|
|
getProperties().stride = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue);
|
|
}
|
|
|
|
void DepthwiseConv2DOp::setDilation(::llvm::ArrayRef<int64_t> attrValue) {
|
|
getProperties().dilation = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue);
|
|
}
|
|
|
|
void DepthwiseConv2DOp::setAccType(::mlir::Type attrValue) {
|
|
getProperties().acc_type = ::mlir::TypeAttr::get(attrValue);
|
|
}
|
|
|
|
void DepthwiseConv2DOp::setLocalBound(::std::optional<bool> attrValue) {
|
|
auto &odsProp = getProperties().local_bound;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getBoolAttr(*attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void DepthwiseConv2DOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type outputType, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::DenseI64ArrayAttr pad, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr dilation, ::mlir::TypeAttr acc_type) {
|
|
buildConvOpWithQuantInfo(odsBuilder, odsState, outputType,
|
|
input, weight, bias,
|
|
pad, stride, dilation, acc_type);
|
|
|
|
}
|
|
|
|
DepthwiseConv2DOp DepthwiseConv2DOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type outputType, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::DenseI64ArrayAttr pad, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr dilation, ::mlir::TypeAttr acc_type) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(outputType)>(outputType), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(acc_type)>(acc_type));
|
|
auto __res__ = ::llvm::dyn_cast<DepthwiseConv2DOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DepthwiseConv2DOp DepthwiseConv2DOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type outputType, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::DenseI64ArrayAttr pad, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr dilation, ::mlir::TypeAttr acc_type) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(outputType)>(outputType), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(acc_type)>(acc_type));
|
|
}
|
|
|
|
void DepthwiseConv2DOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::mlir::DenseI64ArrayAttr pad, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr dilation, ::mlir::TypeAttr acc_type, /*optional*/::mlir::BoolAttr local_bound) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(weight);
|
|
odsState.addOperands(bias);
|
|
odsState.addOperands(input_zp);
|
|
odsState.addOperands(weight_zp);
|
|
odsState.getOrAddProperties<Properties>().pad = pad;
|
|
odsState.getOrAddProperties<Properties>().stride = stride;
|
|
odsState.getOrAddProperties<Properties>().dilation = dilation;
|
|
odsState.getOrAddProperties<Properties>().acc_type = acc_type;
|
|
if (local_bound) {
|
|
odsState.getOrAddProperties<Properties>().local_bound = local_bound;
|
|
}
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
DepthwiseConv2DOp DepthwiseConv2DOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::mlir::DenseI64ArrayAttr pad, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr dilation, ::mlir::TypeAttr acc_type, /*optional*/::mlir::BoolAttr local_bound) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(weight_zp)>(weight_zp), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(acc_type)>(acc_type), std::forward<decltype(local_bound)>(local_bound));
|
|
auto __res__ = ::llvm::dyn_cast<DepthwiseConv2DOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DepthwiseConv2DOp DepthwiseConv2DOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::mlir::DenseI64ArrayAttr pad, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr dilation, ::mlir::TypeAttr acc_type, /*optional*/::mlir::BoolAttr local_bound) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(weight_zp)>(weight_zp), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(acc_type)>(acc_type), std::forward<decltype(local_bound)>(local_bound));
|
|
}
|
|
|
|
void DepthwiseConv2DOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::mlir::DenseI64ArrayAttr pad, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr dilation, ::mlir::TypeAttr acc_type, /*optional*/::mlir::BoolAttr local_bound) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(weight);
|
|
odsState.addOperands(bias);
|
|
odsState.addOperands(input_zp);
|
|
odsState.addOperands(weight_zp);
|
|
odsState.getOrAddProperties<Properties>().pad = pad;
|
|
odsState.getOrAddProperties<Properties>().stride = stride;
|
|
odsState.getOrAddProperties<Properties>().dilation = dilation;
|
|
odsState.getOrAddProperties<Properties>().acc_type = acc_type;
|
|
if (local_bound) {
|
|
odsState.getOrAddProperties<Properties>().local_bound = local_bound;
|
|
}
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
DepthwiseConv2DOp DepthwiseConv2DOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::mlir::DenseI64ArrayAttr pad, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr dilation, ::mlir::TypeAttr acc_type, /*optional*/::mlir::BoolAttr local_bound) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(weight_zp)>(weight_zp), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(acc_type)>(acc_type), std::forward<decltype(local_bound)>(local_bound));
|
|
auto __res__ = ::llvm::dyn_cast<DepthwiseConv2DOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DepthwiseConv2DOp DepthwiseConv2DOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::mlir::DenseI64ArrayAttr pad, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr dilation, ::mlir::TypeAttr acc_type, /*optional*/::mlir::BoolAttr local_bound) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(weight_zp)>(weight_zp), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(acc_type)>(acc_type), std::forward<decltype(local_bound)>(local_bound));
|
|
}
|
|
|
|
void DepthwiseConv2DOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::llvm::ArrayRef<int64_t> pad, ::llvm::ArrayRef<int64_t> stride, ::llvm::ArrayRef<int64_t> dilation, ::mlir::Type acc_type, /*optional*/bool local_bound) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(weight);
|
|
odsState.addOperands(bias);
|
|
odsState.addOperands(input_zp);
|
|
odsState.addOperands(weight_zp);
|
|
odsState.getOrAddProperties<Properties>().pad = odsBuilder.getDenseI64ArrayAttr(pad);
|
|
odsState.getOrAddProperties<Properties>().stride = odsBuilder.getDenseI64ArrayAttr(stride);
|
|
odsState.getOrAddProperties<Properties>().dilation = odsBuilder.getDenseI64ArrayAttr(dilation);
|
|
odsState.getOrAddProperties<Properties>().acc_type = ::mlir::TypeAttr::get(acc_type);
|
|
odsState.getOrAddProperties<Properties>().local_bound = odsBuilder.getBoolAttr(local_bound);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
DepthwiseConv2DOp DepthwiseConv2DOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::llvm::ArrayRef<int64_t> pad, ::llvm::ArrayRef<int64_t> stride, ::llvm::ArrayRef<int64_t> dilation, ::mlir::Type acc_type, /*optional*/bool local_bound) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(weight_zp)>(weight_zp), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(acc_type)>(acc_type), std::forward<decltype(local_bound)>(local_bound));
|
|
auto __res__ = ::llvm::dyn_cast<DepthwiseConv2DOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DepthwiseConv2DOp DepthwiseConv2DOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::llvm::ArrayRef<int64_t> pad, ::llvm::ArrayRef<int64_t> stride, ::llvm::ArrayRef<int64_t> dilation, ::mlir::Type acc_type, /*optional*/bool local_bound) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(weight_zp)>(weight_zp), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(acc_type)>(acc_type), std::forward<decltype(local_bound)>(local_bound));
|
|
}
|
|
|
|
void DepthwiseConv2DOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::llvm::ArrayRef<int64_t> pad, ::llvm::ArrayRef<int64_t> stride, ::llvm::ArrayRef<int64_t> dilation, ::mlir::Type acc_type, /*optional*/bool local_bound) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(weight);
|
|
odsState.addOperands(bias);
|
|
odsState.addOperands(input_zp);
|
|
odsState.addOperands(weight_zp);
|
|
odsState.getOrAddProperties<Properties>().pad = odsBuilder.getDenseI64ArrayAttr(pad);
|
|
odsState.getOrAddProperties<Properties>().stride = odsBuilder.getDenseI64ArrayAttr(stride);
|
|
odsState.getOrAddProperties<Properties>().dilation = odsBuilder.getDenseI64ArrayAttr(dilation);
|
|
odsState.getOrAddProperties<Properties>().acc_type = ::mlir::TypeAttr::get(acc_type);
|
|
odsState.getOrAddProperties<Properties>().local_bound = odsBuilder.getBoolAttr(local_bound);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
DepthwiseConv2DOp DepthwiseConv2DOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::llvm::ArrayRef<int64_t> pad, ::llvm::ArrayRef<int64_t> stride, ::llvm::ArrayRef<int64_t> dilation, ::mlir::Type acc_type, /*optional*/bool local_bound) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(weight_zp)>(weight_zp), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(acc_type)>(acc_type), std::forward<decltype(local_bound)>(local_bound));
|
|
auto __res__ = ::llvm::dyn_cast<DepthwiseConv2DOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DepthwiseConv2DOp DepthwiseConv2DOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::llvm::ArrayRef<int64_t> pad, ::llvm::ArrayRef<int64_t> stride, ::llvm::ArrayRef<int64_t> dilation, ::mlir::Type acc_type, /*optional*/bool local_bound) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(weight_zp)>(weight_zp), std::forward<decltype(pad)>(pad), std::forward<decltype(stride)>(stride), std::forward<decltype(dilation)>(dilation), std::forward<decltype(acc_type)>(acc_type), std::forward<decltype(local_bound)>(local_bound));
|
|
}
|
|
|
|
void DepthwiseConv2DOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 5u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<DepthwiseConv2DOp::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.");
|
|
}
|
|
}
|
|
|
|
DepthwiseConv2DOp DepthwiseConv2DOp::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<DepthwiseConv2DOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DepthwiseConv2DOp DepthwiseConv2DOp::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 DepthwiseConv2DOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
|
|
assert(operands.size() == 5u && "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);
|
|
}
|
|
|
|
DepthwiseConv2DOp DepthwiseConv2DOp::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<DepthwiseConv2DOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DepthwiseConv2DOp DepthwiseConv2DOp::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 DepthwiseConv2DOp::verifyInvariantsImpl() {
|
|
auto tblgen_acc_type = getProperties().acc_type; (void)tblgen_acc_type;
|
|
if (!tblgen_acc_type) return emitOpError("requires attribute 'acc_type'");
|
|
auto tblgen_dilation = getProperties().dilation; (void)tblgen_dilation;
|
|
if (!tblgen_dilation) return emitOpError("requires attribute 'dilation'");
|
|
auto tblgen_local_bound = getProperties().local_bound; (void)tblgen_local_bound;
|
|
auto tblgen_pad = getProperties().pad; (void)tblgen_pad;
|
|
if (!tblgen_pad) return emitOpError("requires attribute 'pad'");
|
|
auto tblgen_stride = getProperties().stride; (void)tblgen_stride;
|
|
if (!tblgen_stride) return emitOpError("requires attribute 'stride'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps7(*this, tblgen_pad, "pad")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps6(*this, tblgen_stride, "stride")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps6(*this, tblgen_dilation, "dilation")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps5(*this, tblgen_acc_type, "acc_type")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps4(*this, tblgen_local_bound, "local_bound")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps6(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps6(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps16(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup3 = getODSOperands(3);
|
|
|
|
for (auto v : valueGroup3) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps7(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup4 = getODSOperands(4);
|
|
|
|
for (auto v : valueGroup4) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps7(*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_TosaOps6(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult DepthwiseConv2DOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult DepthwiseConv2DOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void DepthwiseConv2DOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getLocalBoundAttr();
|
|
if(attr && (attr == odsBuilder.getBoolAttr(false)))
|
|
elidedAttrs.push_back("local_bound");
|
|
}
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void DepthwiseConv2DOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
DepthwiseConv2DOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
DepthwiseConv2DOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return DepthwiseConv2DOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::DepthwiseConv2DOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::DepthwiseConv2DOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::DimOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
DimOpGenericAdaptorBase::DimOpGenericAdaptorBase(DimOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
uint32_t DimOpGenericAdaptorBase::getAxis() {
|
|
auto attr = getAxisAttr();
|
|
return attr.getValue().getZExtValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
DimOpAdaptor::DimOpAdaptor(DimOp op) : DimOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult DimOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_axis = getProperties().axis; (void)tblgen_axis;
|
|
if (!tblgen_axis) return emitError(loc, "'tosa.dim' op requires attribute 'axis'");
|
|
|
|
if (tblgen_axis && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_axis))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_axis).getType().isSignlessInteger(32)))))
|
|
return emitError(loc, "'tosa.dim' op attribute 'axis' failed to satisfy constraint: 32-bit signless integer attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult DimOp::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.axis;
|
|
auto attr = dict.get("axis");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `axis` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute DimOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.axis;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("axis",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code DimOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.axis.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> DimOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "axis")
|
|
return prop.axis;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void DimOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "axis") {
|
|
prop.axis = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.axis)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void DimOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.axis) attrs.append("axis", prop.axis);
|
|
}
|
|
|
|
::llvm::LogicalResult DimOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getAxisAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps2(attr, "axis", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult DimOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.axis)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void DimOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.axis);
|
|
}
|
|
|
|
uint32_t DimOp::getAxis() {
|
|
auto attr = getAxisAttr();
|
|
return attr.getValue().getZExtValue();
|
|
}
|
|
|
|
void DimOp::setAxis(uint32_t attrValue) {
|
|
getProperties().axis = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), attrValue);
|
|
}
|
|
|
|
void DimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::IntegerAttr axis) {
|
|
odsState.addOperands(input1);
|
|
odsState.getOrAddProperties<Properties>().axis = axis;
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
DimOp DimOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::IntegerAttr axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<DimOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DimOp DimOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::IntegerAttr axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void DimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::IntegerAttr axis) {
|
|
odsState.addOperands(input1);
|
|
odsState.getOrAddProperties<Properties>().axis = axis;
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
DimOp DimOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::IntegerAttr axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<DimOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DimOp DimOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::IntegerAttr axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void DimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, uint32_t axis) {
|
|
odsState.addOperands(input1);
|
|
odsState.getOrAddProperties<Properties>().axis = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), axis);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
DimOp DimOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, uint32_t axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<DimOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DimOp DimOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, uint32_t axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void DimOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, uint32_t axis) {
|
|
odsState.addOperands(input1);
|
|
odsState.getOrAddProperties<Properties>().axis = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), axis);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
DimOp DimOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, uint32_t axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<DimOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DimOp DimOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, uint32_t axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void DimOp::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<DimOp::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.");
|
|
}
|
|
}
|
|
|
|
DimOp DimOp::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<DimOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DimOp DimOp::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 DimOp::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);
|
|
}
|
|
|
|
DimOp DimOp::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<DimOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DimOp DimOp::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 DimOp::verifyInvariantsImpl() {
|
|
auto tblgen_axis = getProperties().axis; (void)tblgen_axis;
|
|
if (!tblgen_axis) return emitOpError("requires attribute 'axis'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps2(*this, tblgen_axis, "axis")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps5(*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_TosaOps2(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult DimOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult DimOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void DimOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void DimOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::DimOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::DimOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::DivCeilShapeOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
DivCeilShapeOpGenericAdaptorBase::DivCeilShapeOpGenericAdaptorBase(DivCeilShapeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
DivCeilShapeOpAdaptor::DivCeilShapeOpAdaptor(DivCeilShapeOp op) : DivCeilShapeOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult DivCeilShapeOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult DivCeilShapeOp::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 DivCeilShapeOp::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 DivCeilShapeOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> DivCeilShapeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void DivCeilShapeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void DivCeilShapeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult DivCeilShapeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void DivCeilShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
DivCeilShapeOp DivCeilShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<DivCeilShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DivCeilShapeOp DivCeilShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void DivCeilShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
DivCeilShapeOp DivCeilShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<DivCeilShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DivCeilShapeOp DivCeilShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void DivCeilShapeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
DivCeilShapeOp DivCeilShapeOp::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<DivCeilShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DivCeilShapeOp DivCeilShapeOp::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 DivCeilShapeOp::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);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
DivCeilShapeOp DivCeilShapeOp::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<DivCeilShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DivCeilShapeOp DivCeilShapeOp::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 DivCeilShapeOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps2(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps2(*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_TosaOps2(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult DivCeilShapeOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult DivCeilShapeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void DivCeilShapeOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void DivCeilShapeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::DivCeilShapeOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::DivFloorShapeOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
DivFloorShapeOpGenericAdaptorBase::DivFloorShapeOpGenericAdaptorBase(DivFloorShapeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
DivFloorShapeOpAdaptor::DivFloorShapeOpAdaptor(DivFloorShapeOp op) : DivFloorShapeOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult DivFloorShapeOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult DivFloorShapeOp::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 DivFloorShapeOp::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 DivFloorShapeOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> DivFloorShapeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void DivFloorShapeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void DivFloorShapeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult DivFloorShapeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void DivFloorShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
DivFloorShapeOp DivFloorShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<DivFloorShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DivFloorShapeOp DivFloorShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void DivFloorShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
DivFloorShapeOp DivFloorShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<DivFloorShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DivFloorShapeOp DivFloorShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void DivFloorShapeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
DivFloorShapeOp DivFloorShapeOp::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<DivFloorShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DivFloorShapeOp DivFloorShapeOp::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 DivFloorShapeOp::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);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
DivFloorShapeOp DivFloorShapeOp::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<DivFloorShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
DivFloorShapeOp DivFloorShapeOp::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 DivFloorShapeOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps2(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps2(*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_TosaOps2(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult DivFloorShapeOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult DivFloorShapeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void DivFloorShapeOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void DivFloorShapeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::DivFloorShapeOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::EqualOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
EqualOpGenericAdaptorBase::EqualOpGenericAdaptorBase(EqualOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
EqualOpAdaptor::EqualOpAdaptor(EqualOp op) : EqualOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult EqualOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult EqualOp::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 EqualOp::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 EqualOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> EqualOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void EqualOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void EqualOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult EqualOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void EqualOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
EqualOp EqualOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<EqualOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
EqualOp EqualOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void EqualOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
|
|
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
|
|
if (::mlir::succeeded(EqualOp::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);
|
|
|
|
}
|
|
|
|
EqualOp EqualOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<EqualOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
EqualOp EqualOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void EqualOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
EqualOp EqualOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<EqualOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
EqualOp EqualOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void EqualOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
EqualOp EqualOp::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<EqualOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
EqualOp EqualOp::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 EqualOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
|
|
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
|
|
if (::mlir::succeeded(EqualOp::inferReturnTypes(odsBuilder.getContext(),
|
|
odsState.location, operands,
|
|
odsState.attributes.getDictionary(odsState.getContext()),
|
|
odsState.getRawProperties(),
|
|
odsState.regions, inferredReturnTypes))) {
|
|
assert(inferredReturnTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(inferredReturnTypes);
|
|
} else {
|
|
::llvm::report_fatal_error("Failed to infer result type(s).");
|
|
}
|
|
}
|
|
|
|
EqualOp EqualOp::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<EqualOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
EqualOp EqualOp::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 EqualOp::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);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
EqualOp EqualOp::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<EqualOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
EqualOp EqualOp::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 EqualOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::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);
|
|
|
|
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
|
|
if (::mlir::succeeded(EqualOp::inferReturnTypes(odsBuilder.getContext(),
|
|
odsState.location, operands,
|
|
odsState.attributes.getDictionary(odsState.getContext()),
|
|
odsState.getRawProperties(),
|
|
odsState.regions, inferredReturnTypes))) {
|
|
assert(inferredReturnTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(inferredReturnTypes);
|
|
} else {
|
|
::llvm::report_fatal_error("Failed to infer result type(s).");
|
|
}
|
|
}
|
|
|
|
EqualOp EqualOp::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<EqualOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
EqualOp EqualOp::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 EqualOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*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_TosaOps20(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult EqualOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult EqualOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void EqualOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void EqualOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
EqualOp::inferReturnTypes(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) {
|
|
::llvm::SmallVector<::mlir::ShapedTypeComponents, 2> retComponents;
|
|
if (failed(EqualOp::inferReturnTypeComponents(context, location,
|
|
operands, attributes, properties, regions,
|
|
retComponents)))
|
|
return failure();
|
|
return ::mlir::detail::inferReturnTensorTypes(retComponents,
|
|
inferredReturnTypes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::EqualOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::ErfOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
ErfOpGenericAdaptorBase::ErfOpGenericAdaptorBase(ErfOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
ErfOpAdaptor::ErfOpAdaptor(ErfOp op) : ErfOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult ErfOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ErfOp::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 ErfOp::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 ErfOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> ErfOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void ErfOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void ErfOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult ErfOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ErfOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input) {
|
|
odsState.addOperands(input);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ErfOp ErfOp::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<ErfOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ErfOp ErfOp::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 ErfOp::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);
|
|
}
|
|
|
|
ErfOp ErfOp::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<ErfOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ErfOp ErfOp::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 ErfOp::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);
|
|
}
|
|
|
|
ErfOp ErfOp::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<ErfOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ErfOp ErfOp::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 ErfOp::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);
|
|
}
|
|
|
|
ErfOp ErfOp::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<ErfOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ErfOp ErfOp::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 ErfOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*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_TosaOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ErfOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult ErfOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ErfOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void ErfOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::ErfOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::Exp2ShapeOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
Exp2ShapeOpGenericAdaptorBase::Exp2ShapeOpGenericAdaptorBase(Exp2ShapeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
Exp2ShapeOpAdaptor::Exp2ShapeOpAdaptor(Exp2ShapeOp op) : Exp2ShapeOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult Exp2ShapeOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult Exp2ShapeOp::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 Exp2ShapeOp::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 Exp2ShapeOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> Exp2ShapeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void Exp2ShapeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void Exp2ShapeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult Exp2ShapeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void Exp2ShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input) {
|
|
odsState.addOperands(input);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
Exp2ShapeOp Exp2ShapeOp::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<Exp2ShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
Exp2ShapeOp Exp2ShapeOp::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 Exp2ShapeOp::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);
|
|
}
|
|
|
|
Exp2ShapeOp Exp2ShapeOp::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<Exp2ShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
Exp2ShapeOp Exp2ShapeOp::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 Exp2ShapeOp::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);
|
|
}
|
|
|
|
Exp2ShapeOp Exp2ShapeOp::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<Exp2ShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
Exp2ShapeOp Exp2ShapeOp::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 Exp2ShapeOp::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);
|
|
}
|
|
|
|
Exp2ShapeOp Exp2ShapeOp::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<Exp2ShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
Exp2ShapeOp Exp2ShapeOp::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 Exp2ShapeOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps2(*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_TosaOps2(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult Exp2ShapeOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult Exp2ShapeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void Exp2ShapeOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void Exp2ShapeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::Exp2ShapeOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::ExpOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
ExpOpGenericAdaptorBase::ExpOpGenericAdaptorBase(ExpOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
ExpOpAdaptor::ExpOpAdaptor(ExpOp op) : ExpOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult ExpOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ExpOp::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 ExpOp::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 ExpOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> ExpOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void ExpOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void ExpOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult ExpOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ExpOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1) {
|
|
odsState.addOperands(input1);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ExpOp ExpOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1));
|
|
auto __res__ = ::llvm::dyn_cast<ExpOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ExpOp ExpOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1));
|
|
}
|
|
|
|
void ExpOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
odsState.addOperands(input1);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ExpOp ExpOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1));
|
|
auto __res__ = ::llvm::dyn_cast<ExpOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ExpOp ExpOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1));
|
|
}
|
|
|
|
void ExpOp::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);
|
|
}
|
|
|
|
ExpOp ExpOp::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<ExpOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ExpOp ExpOp::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 ExpOp::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);
|
|
}
|
|
|
|
ExpOp ExpOp::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<ExpOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ExpOp ExpOp::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 ExpOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*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_TosaOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ExpOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult ExpOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ExpOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void ExpOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::ExpOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::FFT2dOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
FFT2dOpGenericAdaptorBase::FFT2dOpGenericAdaptorBase(FFT2dOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
bool FFT2dOpGenericAdaptorBase::getInverse() {
|
|
auto attr = getInverseAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
::mlir::BoolAttr FFT2dOpGenericAdaptorBase::getLocalBoundAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().local_bound);
|
|
if (!attr)
|
|
attr = ::mlir::Builder(odsAttrs.getContext()).getBoolAttr(false);
|
|
return attr;
|
|
}
|
|
|
|
bool FFT2dOpGenericAdaptorBase::getLocalBound() {
|
|
auto attr = getLocalBoundAttr();
|
|
if (!attr)
|
|
return ::mlir::Builder(odsAttrs.getContext()).getBoolAttr(false).getValue();
|
|
return attr.getValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
FFT2dOpAdaptor::FFT2dOpAdaptor(FFT2dOp op) : FFT2dOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult FFT2dOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_inverse = getProperties().inverse; (void)tblgen_inverse;
|
|
if (!tblgen_inverse) return emitError(loc, "'tosa.fft2d' op requires attribute 'inverse'");
|
|
auto tblgen_local_bound = getProperties().local_bound; (void)tblgen_local_bound;
|
|
|
|
if (tblgen_inverse && !((::llvm::isa<::mlir::BoolAttr>(tblgen_inverse))))
|
|
return emitError(loc, "'tosa.fft2d' op attribute 'inverse' failed to satisfy constraint: bool attribute");
|
|
|
|
if (tblgen_local_bound && !((::llvm::isa<::mlir::BoolAttr>(tblgen_local_bound))))
|
|
return emitError(loc, "'tosa.fft2d' op attribute 'local_bound' failed to satisfy constraint: bool attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void FFT2dOp::getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn) {
|
|
auto resultGroup0 = getODSResults(0);
|
|
if (!resultGroup0.empty())
|
|
setNameFn(*resultGroup0.begin(), "output_real");
|
|
auto resultGroup1 = getODSResults(1);
|
|
if (!resultGroup1.empty())
|
|
setNameFn(*resultGroup1.begin(), "output_imag");
|
|
}
|
|
|
|
::llvm::LogicalResult FFT2dOp::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.inverse;
|
|
auto attr = dict.get("inverse");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `inverse` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.local_bound;
|
|
auto attr = dict.get("local_bound");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `local_bound` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute FFT2dOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.inverse;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("inverse",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.local_bound;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("local_bound",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code FFT2dOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.inverse.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.local_bound.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> FFT2dOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "inverse")
|
|
return prop.inverse;
|
|
|
|
if (name == "local_bound")
|
|
return prop.local_bound;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void FFT2dOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "inverse") {
|
|
prop.inverse = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.inverse)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "local_bound") {
|
|
prop.local_bound = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.local_bound)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void FFT2dOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.inverse) attrs.append("inverse", prop.inverse);
|
|
|
|
if (prop.local_bound) attrs.append("local_bound", prop.local_bound);
|
|
}
|
|
|
|
::llvm::LogicalResult FFT2dOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getInverseAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps4(attr, "inverse", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getLocalBoundAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps4(attr, "local_bound", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult FFT2dOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.inverse)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.local_bound)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void FFT2dOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.inverse);
|
|
|
|
writer.writeOptionalAttribute(prop.local_bound);
|
|
}
|
|
|
|
bool FFT2dOp::getInverse() {
|
|
auto attr = getInverseAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
bool FFT2dOp::getLocalBound() {
|
|
auto attr = getLocalBoundAttr();
|
|
if (!attr)
|
|
return ::mlir::Builder((*this)->getContext()).getBoolAttr(false).getValue();
|
|
return attr.getValue();
|
|
}
|
|
|
|
void FFT2dOp::setInverse(bool attrValue) {
|
|
getProperties().inverse = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue);
|
|
}
|
|
|
|
void FFT2dOp::setLocalBound(::std::optional<bool> attrValue) {
|
|
auto &odsProp = getProperties().local_bound;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getBoolAttr(*attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void FFT2dOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output_real, ::mlir::Type output_imag, ::mlir::Value input_real, ::mlir::Value input_imag, ::mlir::BoolAttr inverse, /*optional*/::mlir::BoolAttr local_bound) {
|
|
odsState.addOperands(input_real);
|
|
odsState.addOperands(input_imag);
|
|
odsState.getOrAddProperties<Properties>().inverse = inverse;
|
|
if (local_bound) {
|
|
odsState.getOrAddProperties<Properties>().local_bound = local_bound;
|
|
}
|
|
odsState.addTypes(output_real);
|
|
odsState.addTypes(output_imag);
|
|
}
|
|
|
|
FFT2dOp FFT2dOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output_real, ::mlir::Type output_imag, ::mlir::Value input_real, ::mlir::Value input_imag, ::mlir::BoolAttr inverse, /*optional*/::mlir::BoolAttr local_bound) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output_real)>(output_real), std::forward<decltype(output_imag)>(output_imag), std::forward<decltype(input_real)>(input_real), std::forward<decltype(input_imag)>(input_imag), std::forward<decltype(inverse)>(inverse), std::forward<decltype(local_bound)>(local_bound));
|
|
auto __res__ = ::llvm::dyn_cast<FFT2dOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
FFT2dOp FFT2dOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output_real, ::mlir::Type output_imag, ::mlir::Value input_real, ::mlir::Value input_imag, ::mlir::BoolAttr inverse, /*optional*/::mlir::BoolAttr local_bound) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output_real)>(output_real), std::forward<decltype(output_imag)>(output_imag), std::forward<decltype(input_real)>(input_real), std::forward<decltype(input_imag)>(input_imag), std::forward<decltype(inverse)>(inverse), std::forward<decltype(local_bound)>(local_bound));
|
|
}
|
|
|
|
void FFT2dOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input_real, ::mlir::Value input_imag, ::mlir::BoolAttr inverse, /*optional*/::mlir::BoolAttr local_bound) {
|
|
odsState.addOperands(input_real);
|
|
odsState.addOperands(input_imag);
|
|
odsState.getOrAddProperties<Properties>().inverse = inverse;
|
|
if (local_bound) {
|
|
odsState.getOrAddProperties<Properties>().local_bound = local_bound;
|
|
}
|
|
assert(resultTypes.size() == 2u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
FFT2dOp FFT2dOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input_real, ::mlir::Value input_imag, ::mlir::BoolAttr inverse, /*optional*/::mlir::BoolAttr local_bound) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input_real)>(input_real), std::forward<decltype(input_imag)>(input_imag), std::forward<decltype(inverse)>(inverse), std::forward<decltype(local_bound)>(local_bound));
|
|
auto __res__ = ::llvm::dyn_cast<FFT2dOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
FFT2dOp FFT2dOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input_real, ::mlir::Value input_imag, ::mlir::BoolAttr inverse, /*optional*/::mlir::BoolAttr local_bound) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input_real)>(input_real), std::forward<decltype(input_imag)>(input_imag), std::forward<decltype(inverse)>(inverse), std::forward<decltype(local_bound)>(local_bound));
|
|
}
|
|
|
|
void FFT2dOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output_real, ::mlir::Type output_imag, ::mlir::Value input_real, ::mlir::Value input_imag, bool inverse, /*optional*/bool local_bound) {
|
|
odsState.addOperands(input_real);
|
|
odsState.addOperands(input_imag);
|
|
odsState.getOrAddProperties<Properties>().inverse = odsBuilder.getBoolAttr(inverse);
|
|
odsState.getOrAddProperties<Properties>().local_bound = odsBuilder.getBoolAttr(local_bound);
|
|
odsState.addTypes(output_real);
|
|
odsState.addTypes(output_imag);
|
|
}
|
|
|
|
FFT2dOp FFT2dOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output_real, ::mlir::Type output_imag, ::mlir::Value input_real, ::mlir::Value input_imag, bool inverse, /*optional*/bool local_bound) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output_real)>(output_real), std::forward<decltype(output_imag)>(output_imag), std::forward<decltype(input_real)>(input_real), std::forward<decltype(input_imag)>(input_imag), std::forward<decltype(inverse)>(inverse), std::forward<decltype(local_bound)>(local_bound));
|
|
auto __res__ = ::llvm::dyn_cast<FFT2dOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
FFT2dOp FFT2dOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output_real, ::mlir::Type output_imag, ::mlir::Value input_real, ::mlir::Value input_imag, bool inverse, /*optional*/bool local_bound) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output_real)>(output_real), std::forward<decltype(output_imag)>(output_imag), std::forward<decltype(input_real)>(input_real), std::forward<decltype(input_imag)>(input_imag), std::forward<decltype(inverse)>(inverse), std::forward<decltype(local_bound)>(local_bound));
|
|
}
|
|
|
|
void FFT2dOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input_real, ::mlir::Value input_imag, bool inverse, /*optional*/bool local_bound) {
|
|
odsState.addOperands(input_real);
|
|
odsState.addOperands(input_imag);
|
|
odsState.getOrAddProperties<Properties>().inverse = odsBuilder.getBoolAttr(inverse);
|
|
odsState.getOrAddProperties<Properties>().local_bound = odsBuilder.getBoolAttr(local_bound);
|
|
assert(resultTypes.size() == 2u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
FFT2dOp FFT2dOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input_real, ::mlir::Value input_imag, bool inverse, /*optional*/bool local_bound) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input_real)>(input_real), std::forward<decltype(input_imag)>(input_imag), std::forward<decltype(inverse)>(inverse), std::forward<decltype(local_bound)>(local_bound));
|
|
auto __res__ = ::llvm::dyn_cast<FFT2dOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
FFT2dOp FFT2dOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input_real, ::mlir::Value input_imag, bool inverse, /*optional*/bool local_bound) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input_real)>(input_real), std::forward<decltype(input_imag)>(input_imag), std::forward<decltype(inverse)>(inverse), std::forward<decltype(local_bound)>(local_bound));
|
|
}
|
|
|
|
void FFT2dOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 2u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<FFT2dOp::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.");
|
|
}
|
|
}
|
|
|
|
FFT2dOp FFT2dOp::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<FFT2dOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
FFT2dOp FFT2dOp::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 FFT2dOp::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);
|
|
assert(resultTypes.size() == 2u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
FFT2dOp FFT2dOp::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<FFT2dOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
FFT2dOp FFT2dOp::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 FFT2dOp::verifyInvariantsImpl() {
|
|
auto tblgen_inverse = getProperties().inverse; (void)tblgen_inverse;
|
|
if (!tblgen_inverse) return emitOpError("requires attribute 'inverse'");
|
|
auto tblgen_local_bound = getProperties().local_bound; (void)tblgen_local_bound;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps4(*this, tblgen_inverse, "inverse")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps4(*this, tblgen_local_bound, "local_bound")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps21(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps21(*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_TosaOps21(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSResults(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps21(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult FFT2dOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult FFT2dOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void FFT2dOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getLocalBoundAttr();
|
|
if(attr && (attr == odsBuilder.getBoolAttr(false)))
|
|
elidedAttrs.push_back("local_bound");
|
|
}
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void FFT2dOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
FFT2dOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
FFT2dOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return FFT2dOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::FFT2dOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::FFT2dOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::FloorOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
FloorOpGenericAdaptorBase::FloorOpGenericAdaptorBase(FloorOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
FloorOpAdaptor::FloorOpAdaptor(FloorOp op) : FloorOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult FloorOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult FloorOp::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 FloorOp::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 FloorOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> FloorOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void FloorOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void FloorOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult FloorOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void FloorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1) {
|
|
odsState.addOperands(input1);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
FloorOp FloorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1));
|
|
auto __res__ = ::llvm::dyn_cast<FloorOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
FloorOp FloorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1));
|
|
}
|
|
|
|
void FloorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
odsState.addOperands(input1);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
FloorOp FloorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1));
|
|
auto __res__ = ::llvm::dyn_cast<FloorOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
FloorOp FloorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1));
|
|
}
|
|
|
|
void FloorOp::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);
|
|
}
|
|
|
|
FloorOp FloorOp::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<FloorOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
FloorOp FloorOp::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 FloorOp::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);
|
|
}
|
|
|
|
FloorOp FloorOp::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<FloorOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
FloorOp FloorOp::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 FloorOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*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_TosaOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult FloorOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult FloorOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void FloorOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void FloorOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::FloorOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::GatherOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
GatherOpGenericAdaptorBase::GatherOpGenericAdaptorBase(GatherOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
GatherOpAdaptor::GatherOpAdaptor(GatherOp op) : GatherOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult GatherOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult GatherOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
|
|
if (!dict) {
|
|
emitError() << "expected DictionaryAttr to set properties";
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute GatherOp::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 GatherOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> GatherOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void GatherOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void GatherOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult GatherOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void GatherOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value values, ::mlir::Value indices) {
|
|
odsState.addOperands(values);
|
|
odsState.addOperands(indices);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
GatherOp GatherOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value values, ::mlir::Value indices) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(values)>(values), std::forward<decltype(indices)>(indices));
|
|
auto __res__ = ::llvm::dyn_cast<GatherOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
GatherOp GatherOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value values, ::mlir::Value indices) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(values)>(values), std::forward<decltype(indices)>(indices));
|
|
}
|
|
|
|
void GatherOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value values, ::mlir::Value indices) {
|
|
odsState.addOperands(values);
|
|
odsState.addOperands(indices);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
GatherOp GatherOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value values, ::mlir::Value indices) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(values)>(values), std::forward<decltype(indices)>(indices));
|
|
auto __res__ = ::llvm::dyn_cast<GatherOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
GatherOp GatherOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value values, ::mlir::Value indices) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(values)>(values), std::forward<decltype(indices)>(indices));
|
|
}
|
|
|
|
void GatherOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
GatherOp GatherOp::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<GatherOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
GatherOp GatherOp::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 GatherOp::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);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
GatherOp GatherOp::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<GatherOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
GatherOp GatherOp::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 GatherOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps21(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps22(*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_TosaOps21(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult GatherOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult GatherOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void GatherOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void GatherOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
GatherOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
GatherOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return GatherOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::GatherOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::GreaterEqualOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
GreaterEqualOpGenericAdaptorBase::GreaterEqualOpGenericAdaptorBase(GreaterEqualOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
GreaterEqualOpAdaptor::GreaterEqualOpAdaptor(GreaterEqualOp op) : GreaterEqualOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult GreaterEqualOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult GreaterEqualOp::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 GreaterEqualOp::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 GreaterEqualOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> GreaterEqualOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void GreaterEqualOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void GreaterEqualOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult GreaterEqualOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void GreaterEqualOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
GreaterEqualOp GreaterEqualOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<GreaterEqualOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
GreaterEqualOp GreaterEqualOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void GreaterEqualOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
GreaterEqualOp GreaterEqualOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<GreaterEqualOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
GreaterEqualOp GreaterEqualOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void GreaterEqualOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
GreaterEqualOp GreaterEqualOp::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<GreaterEqualOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
GreaterEqualOp GreaterEqualOp::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 GreaterEqualOp::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);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
GreaterEqualOp GreaterEqualOp::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<GreaterEqualOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
GreaterEqualOp GreaterEqualOp::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 GreaterEqualOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*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_TosaOps20(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult GreaterEqualOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult GreaterEqualOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void GreaterEqualOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void GreaterEqualOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::GreaterEqualOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::GreaterOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
GreaterOpGenericAdaptorBase::GreaterOpGenericAdaptorBase(GreaterOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
GreaterOpAdaptor::GreaterOpAdaptor(GreaterOp op) : GreaterOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult GreaterOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult GreaterOp::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 GreaterOp::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 GreaterOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> GreaterOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void GreaterOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void GreaterOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult GreaterOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void GreaterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
GreaterOp GreaterOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<GreaterOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
GreaterOp GreaterOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void GreaterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
GreaterOp GreaterOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<GreaterOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
GreaterOp GreaterOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void GreaterOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
GreaterOp GreaterOp::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<GreaterOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
GreaterOp GreaterOp::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 GreaterOp::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);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
GreaterOp GreaterOp::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<GreaterOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
GreaterOp GreaterOp::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 GreaterOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*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_TosaOps20(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult GreaterOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult GreaterOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void GreaterOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void GreaterOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::GreaterOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::IdentityOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
IdentityOpGenericAdaptorBase::IdentityOpGenericAdaptorBase(IdentityOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
IdentityOpAdaptor::IdentityOpAdaptor(IdentityOp op) : IdentityOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult IdentityOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult IdentityOp::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 IdentityOp::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 IdentityOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> IdentityOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void IdentityOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void IdentityOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult IdentityOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void IdentityOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1) {
|
|
odsState.addOperands(input1);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
IdentityOp IdentityOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1));
|
|
auto __res__ = ::llvm::dyn_cast<IdentityOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
IdentityOp IdentityOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1));
|
|
}
|
|
|
|
void IdentityOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
odsState.addOperands(input1);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
IdentityOp IdentityOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1));
|
|
auto __res__ = ::llvm::dyn_cast<IdentityOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
IdentityOp IdentityOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1));
|
|
}
|
|
|
|
void IdentityOp::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);
|
|
}
|
|
|
|
IdentityOp IdentityOp::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<IdentityOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
IdentityOp IdentityOp::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 IdentityOp::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);
|
|
}
|
|
|
|
IdentityOp IdentityOp::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<IdentityOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
IdentityOp IdentityOp::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 IdentityOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*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_TosaOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult IdentityOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult IdentityOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void IdentityOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void IdentityOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::IdentityOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::IfOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
IfOpGenericAdaptorBase::IfOpGenericAdaptorBase(IfOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> IfOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
bool isVariadic[] = {false, true};
|
|
int prevVariadicCount = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
if (isVariadic[i]) ++prevVariadicCount;
|
|
|
|
// Calculate how many dynamic values a static variadic operand corresponds to.
|
|
// This assumes all static variadic operands have the same dynamic value count.
|
|
int variadicSize = (odsOperandsSize - 1) / 1;
|
|
// `index` passed in as the parameter is the static index which counts each
|
|
// operand (variadic or not) as size 1. So here for each previous static variadic
|
|
// operand, we need to offset by (variadicSize - 1) to get where the dynamic
|
|
// value pack for this static operand starts.
|
|
int start = index + (variadicSize - 1) * prevVariadicCount;
|
|
int size = isVariadic[index] ? variadicSize : 1;
|
|
return {start, size};
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
IfOpAdaptor::IfOpAdaptor(IfOp op) : IfOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult IfOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> IfOp::getODSOperandIndexAndLength(unsigned index) {
|
|
bool isVariadic[] = {false, true};
|
|
int prevVariadicCount = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
if (isVariadic[i]) ++prevVariadicCount;
|
|
|
|
// Calculate how many dynamic values a static variadic operand corresponds to.
|
|
// This assumes all static variadic operands have the same dynamic value count.
|
|
int variadicSize = (getOperation()->getNumOperands() - 1) / 1;
|
|
// `index` passed in as the parameter is the static index which counts each
|
|
// operand (variadic or not) as size 1. So here for each previous static variadic
|
|
// operand, we need to offset by (variadicSize - 1) to get where the dynamic
|
|
// value pack for this static operand starts.
|
|
int start = index + (variadicSize - 1) * prevVariadicCount;
|
|
int size = isVariadic[index] ? variadicSize : 1;
|
|
return {start, size};
|
|
}
|
|
|
|
::mlir::MutableOperandRange IfOp::getInputListMutable() {
|
|
auto range = getODSOperandIndexAndLength(1);
|
|
auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
|
|
return mutableRange;
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> IfOp::getODSResultIndexAndLength(unsigned index) {
|
|
bool isVariadic[] = {true};
|
|
int prevVariadicCount = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
if (isVariadic[i]) ++prevVariadicCount;
|
|
|
|
// Calculate how many dynamic values a static variadic operand corresponds to.
|
|
// This assumes all static variadic operands have the same dynamic value count.
|
|
int variadicSize = (getOperation()->getNumResults() - 0) / 1;
|
|
// `index` passed in as the parameter is the static index which counts each
|
|
// operand (variadic or not) as size 1. So here for each previous static variadic
|
|
// operand, we need to offset by (variadicSize - 1) to get where the dynamic
|
|
// value pack for this static operand starts.
|
|
int start = index + (variadicSize - 1) * prevVariadicCount;
|
|
int size = isVariadic[index] ? variadicSize : 1;
|
|
return {start, size};
|
|
}
|
|
|
|
::llvm::LogicalResult IfOp::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 IfOp::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 IfOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> IfOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void IfOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void IfOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult IfOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void IfOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange output_list, ::mlir::Value condition, ::mlir::ValueRange input_list) {
|
|
odsState.addOperands(condition);
|
|
odsState.addOperands(input_list);
|
|
(void)odsState.addRegion();
|
|
(void)odsState.addRegion();
|
|
odsState.addTypes(output_list);
|
|
}
|
|
|
|
IfOp IfOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange output_list, ::mlir::Value condition, ::mlir::ValueRange input_list) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output_list)>(output_list), std::forward<decltype(condition)>(condition), std::forward<decltype(input_list)>(input_list));
|
|
auto __res__ = ::llvm::dyn_cast<IfOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
IfOp IfOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange output_list, ::mlir::Value condition, ::mlir::ValueRange input_list) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output_list)>(output_list), std::forward<decltype(condition)>(condition), std::forward<decltype(input_list)>(input_list));
|
|
}
|
|
|
|
void IfOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() >= 1u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
for (unsigned i = 0; i != 2; ++i)
|
|
(void)odsState.addRegion();
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
IfOp IfOp::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<IfOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
IfOp IfOp::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 IfOp::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);
|
|
for (unsigned i = 0; i != 2; ++i)
|
|
(void)odsState.addRegion();
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
IfOp IfOp::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<IfOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
IfOp IfOp::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 IfOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps20(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps19(*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_TosaOps19(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
|
|
for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0)))
|
|
if (::mlir::failed(__mlir_ods_local_region_constraint_TosaOps1(*this, region, "then_graph", index++)))
|
|
return ::mlir::failure();
|
|
|
|
for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(1)))
|
|
if (::mlir::failed(__mlir_ods_local_region_constraint_TosaOps1(*this, region, "else_graph", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult IfOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::llvm::LogicalResult IfOp::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;
|
|
|
|
for (::mlir::NamedAttribute attr : dict) {
|
|
if (!usedKeys.contains(attr.getName()))
|
|
return emitError() << "unknown key '" << attr.getName() <<
|
|
"' when parsing properties dictionary";
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
IfOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
IfOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return IfOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::IfOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::IntDivOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
IntDivOpGenericAdaptorBase::IntDivOpGenericAdaptorBase(IntDivOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
IntDivOpAdaptor::IntDivOpAdaptor(IntDivOp op) : IntDivOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult IntDivOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult IntDivOp::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 IntDivOp::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 IntDivOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> IntDivOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void IntDivOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void IntDivOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult IntDivOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void IntDivOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
IntDivOp IntDivOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<IntDivOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
IntDivOp IntDivOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void IntDivOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
IntDivOp IntDivOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<IntDivOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
IntDivOp IntDivOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void IntDivOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
IntDivOp IntDivOp::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<IntDivOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
IntDivOp IntDivOp::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 IntDivOp::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);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
IntDivOp IntDivOp::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<IntDivOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
IntDivOp IntDivOp::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 IntDivOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps23(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps23(*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_TosaOps23(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult IntDivOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult IntDivOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void IntDivOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void IntDivOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::IntDivOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::Log2CeilShapeOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
Log2CeilShapeOpGenericAdaptorBase::Log2CeilShapeOpGenericAdaptorBase(Log2CeilShapeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
Log2CeilShapeOpAdaptor::Log2CeilShapeOpAdaptor(Log2CeilShapeOp op) : Log2CeilShapeOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult Log2CeilShapeOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult Log2CeilShapeOp::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 Log2CeilShapeOp::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 Log2CeilShapeOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> Log2CeilShapeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void Log2CeilShapeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void Log2CeilShapeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult Log2CeilShapeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void Log2CeilShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input) {
|
|
odsState.addOperands(input);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
Log2CeilShapeOp Log2CeilShapeOp::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<Log2CeilShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
Log2CeilShapeOp Log2CeilShapeOp::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 Log2CeilShapeOp::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);
|
|
}
|
|
|
|
Log2CeilShapeOp Log2CeilShapeOp::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<Log2CeilShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
Log2CeilShapeOp Log2CeilShapeOp::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 Log2CeilShapeOp::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);
|
|
}
|
|
|
|
Log2CeilShapeOp Log2CeilShapeOp::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<Log2CeilShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
Log2CeilShapeOp Log2CeilShapeOp::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 Log2CeilShapeOp::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);
|
|
}
|
|
|
|
Log2CeilShapeOp Log2CeilShapeOp::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<Log2CeilShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
Log2CeilShapeOp Log2CeilShapeOp::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 Log2CeilShapeOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps2(*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_TosaOps2(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult Log2CeilShapeOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult Log2CeilShapeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void Log2CeilShapeOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void Log2CeilShapeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::Log2CeilShapeOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::Log2FloorShapeOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
Log2FloorShapeOpGenericAdaptorBase::Log2FloorShapeOpGenericAdaptorBase(Log2FloorShapeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
Log2FloorShapeOpAdaptor::Log2FloorShapeOpAdaptor(Log2FloorShapeOp op) : Log2FloorShapeOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult Log2FloorShapeOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult Log2FloorShapeOp::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 Log2FloorShapeOp::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 Log2FloorShapeOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> Log2FloorShapeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void Log2FloorShapeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void Log2FloorShapeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult Log2FloorShapeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void Log2FloorShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input) {
|
|
odsState.addOperands(input);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
Log2FloorShapeOp Log2FloorShapeOp::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<Log2FloorShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
Log2FloorShapeOp Log2FloorShapeOp::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 Log2FloorShapeOp::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);
|
|
}
|
|
|
|
Log2FloorShapeOp Log2FloorShapeOp::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<Log2FloorShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
Log2FloorShapeOp Log2FloorShapeOp::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 Log2FloorShapeOp::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);
|
|
}
|
|
|
|
Log2FloorShapeOp Log2FloorShapeOp::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<Log2FloorShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
Log2FloorShapeOp Log2FloorShapeOp::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 Log2FloorShapeOp::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);
|
|
}
|
|
|
|
Log2FloorShapeOp Log2FloorShapeOp::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<Log2FloorShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
Log2FloorShapeOp Log2FloorShapeOp::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 Log2FloorShapeOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps2(*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_TosaOps2(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult Log2FloorShapeOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult Log2FloorShapeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void Log2FloorShapeOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void Log2FloorShapeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::Log2FloorShapeOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::LogOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
LogOpGenericAdaptorBase::LogOpGenericAdaptorBase(LogOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
LogOpAdaptor::LogOpAdaptor(LogOp op) : LogOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult LogOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult LogOp::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 LogOp::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 LogOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> LogOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void LogOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void LogOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult LogOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void LogOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1) {
|
|
odsState.addOperands(input1);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
LogOp LogOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1));
|
|
auto __res__ = ::llvm::dyn_cast<LogOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LogOp LogOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1));
|
|
}
|
|
|
|
void LogOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
odsState.addOperands(input1);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
LogOp LogOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1));
|
|
auto __res__ = ::llvm::dyn_cast<LogOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LogOp LogOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1));
|
|
}
|
|
|
|
void LogOp::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);
|
|
}
|
|
|
|
LogOp LogOp::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<LogOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LogOp LogOp::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 LogOp::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);
|
|
}
|
|
|
|
LogOp LogOp::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<LogOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LogOp LogOp::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 LogOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*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_TosaOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult LogOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult LogOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void LogOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void LogOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::LogOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::LogicalAndOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
LogicalAndOpGenericAdaptorBase::LogicalAndOpGenericAdaptorBase(LogicalAndOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
LogicalAndOpAdaptor::LogicalAndOpAdaptor(LogicalAndOp op) : LogicalAndOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult LogicalAndOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult LogicalAndOp::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 LogicalAndOp::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 LogicalAndOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> LogicalAndOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void LogicalAndOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void LogicalAndOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult LogicalAndOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void LogicalAndOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
LogicalAndOp LogicalAndOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<LogicalAndOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LogicalAndOp LogicalAndOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void LogicalAndOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
LogicalAndOp LogicalAndOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<LogicalAndOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LogicalAndOp LogicalAndOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void LogicalAndOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
LogicalAndOp LogicalAndOp::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<LogicalAndOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LogicalAndOp LogicalAndOp::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 LogicalAndOp::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);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
LogicalAndOp LogicalAndOp::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<LogicalAndOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LogicalAndOp LogicalAndOp::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 LogicalAndOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps20(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps20(*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_TosaOps20(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult LogicalAndOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult LogicalAndOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void LogicalAndOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void LogicalAndOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::LogicalAndOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::LogicalLeftShiftOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
LogicalLeftShiftOpGenericAdaptorBase::LogicalLeftShiftOpGenericAdaptorBase(LogicalLeftShiftOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
LogicalLeftShiftOpAdaptor::LogicalLeftShiftOpAdaptor(LogicalLeftShiftOp op) : LogicalLeftShiftOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult LogicalLeftShiftOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult LogicalLeftShiftOp::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 LogicalLeftShiftOp::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 LogicalLeftShiftOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> LogicalLeftShiftOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void LogicalLeftShiftOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void LogicalLeftShiftOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult LogicalLeftShiftOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void LogicalLeftShiftOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
LogicalLeftShiftOp LogicalLeftShiftOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<LogicalLeftShiftOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LogicalLeftShiftOp LogicalLeftShiftOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void LogicalLeftShiftOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
LogicalLeftShiftOp LogicalLeftShiftOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<LogicalLeftShiftOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LogicalLeftShiftOp LogicalLeftShiftOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void LogicalLeftShiftOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
LogicalLeftShiftOp LogicalLeftShiftOp::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<LogicalLeftShiftOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LogicalLeftShiftOp LogicalLeftShiftOp::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 LogicalLeftShiftOp::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);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
LogicalLeftShiftOp LogicalLeftShiftOp::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<LogicalLeftShiftOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LogicalLeftShiftOp LogicalLeftShiftOp::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 LogicalLeftShiftOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*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_TosaOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult LogicalLeftShiftOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult LogicalLeftShiftOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void LogicalLeftShiftOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void LogicalLeftShiftOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::LogicalLeftShiftOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::LogicalNotOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
LogicalNotOpGenericAdaptorBase::LogicalNotOpGenericAdaptorBase(LogicalNotOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
LogicalNotOpAdaptor::LogicalNotOpAdaptor(LogicalNotOp op) : LogicalNotOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult LogicalNotOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult LogicalNotOp::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 LogicalNotOp::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 LogicalNotOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> LogicalNotOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void LogicalNotOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void LogicalNotOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult LogicalNotOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void LogicalNotOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1) {
|
|
odsState.addOperands(input1);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
LogicalNotOp LogicalNotOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1));
|
|
auto __res__ = ::llvm::dyn_cast<LogicalNotOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LogicalNotOp LogicalNotOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1));
|
|
}
|
|
|
|
void LogicalNotOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
odsState.addOperands(input1);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
LogicalNotOp LogicalNotOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1));
|
|
auto __res__ = ::llvm::dyn_cast<LogicalNotOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LogicalNotOp LogicalNotOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1));
|
|
}
|
|
|
|
void LogicalNotOp::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);
|
|
}
|
|
|
|
LogicalNotOp LogicalNotOp::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<LogicalNotOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LogicalNotOp LogicalNotOp::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 LogicalNotOp::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);
|
|
}
|
|
|
|
LogicalNotOp LogicalNotOp::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<LogicalNotOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LogicalNotOp LogicalNotOp::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 LogicalNotOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps20(*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_TosaOps20(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult LogicalNotOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult LogicalNotOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void LogicalNotOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void LogicalNotOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::LogicalNotOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::LogicalOrOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
LogicalOrOpGenericAdaptorBase::LogicalOrOpGenericAdaptorBase(LogicalOrOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
LogicalOrOpAdaptor::LogicalOrOpAdaptor(LogicalOrOp op) : LogicalOrOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult LogicalOrOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult LogicalOrOp::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 LogicalOrOp::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 LogicalOrOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> LogicalOrOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void LogicalOrOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void LogicalOrOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult LogicalOrOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void LogicalOrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
LogicalOrOp LogicalOrOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<LogicalOrOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LogicalOrOp LogicalOrOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void LogicalOrOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
LogicalOrOp LogicalOrOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<LogicalOrOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LogicalOrOp LogicalOrOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void LogicalOrOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
LogicalOrOp LogicalOrOp::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<LogicalOrOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LogicalOrOp LogicalOrOp::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 LogicalOrOp::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);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
LogicalOrOp LogicalOrOp::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<LogicalOrOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LogicalOrOp LogicalOrOp::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 LogicalOrOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps20(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps20(*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_TosaOps20(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult LogicalOrOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult LogicalOrOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void LogicalOrOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void LogicalOrOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::LogicalOrOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::LogicalRightShiftOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
LogicalRightShiftOpGenericAdaptorBase::LogicalRightShiftOpGenericAdaptorBase(LogicalRightShiftOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
LogicalRightShiftOpAdaptor::LogicalRightShiftOpAdaptor(LogicalRightShiftOp op) : LogicalRightShiftOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult LogicalRightShiftOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult LogicalRightShiftOp::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 LogicalRightShiftOp::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 LogicalRightShiftOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> LogicalRightShiftOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void LogicalRightShiftOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void LogicalRightShiftOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult LogicalRightShiftOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void LogicalRightShiftOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
LogicalRightShiftOp LogicalRightShiftOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<LogicalRightShiftOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LogicalRightShiftOp LogicalRightShiftOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void LogicalRightShiftOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
LogicalRightShiftOp LogicalRightShiftOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<LogicalRightShiftOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LogicalRightShiftOp LogicalRightShiftOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void LogicalRightShiftOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
LogicalRightShiftOp LogicalRightShiftOp::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<LogicalRightShiftOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LogicalRightShiftOp LogicalRightShiftOp::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 LogicalRightShiftOp::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);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
LogicalRightShiftOp LogicalRightShiftOp::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<LogicalRightShiftOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LogicalRightShiftOp LogicalRightShiftOp::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 LogicalRightShiftOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*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_TosaOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult LogicalRightShiftOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult LogicalRightShiftOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void LogicalRightShiftOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void LogicalRightShiftOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::LogicalRightShiftOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::LogicalXorOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
LogicalXorOpGenericAdaptorBase::LogicalXorOpGenericAdaptorBase(LogicalXorOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
LogicalXorOpAdaptor::LogicalXorOpAdaptor(LogicalXorOp op) : LogicalXorOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult LogicalXorOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult LogicalXorOp::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 LogicalXorOp::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 LogicalXorOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> LogicalXorOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void LogicalXorOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void LogicalXorOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult LogicalXorOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void LogicalXorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
LogicalXorOp LogicalXorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<LogicalXorOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LogicalXorOp LogicalXorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void LogicalXorOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
LogicalXorOp LogicalXorOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<LogicalXorOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LogicalXorOp LogicalXorOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void LogicalXorOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
LogicalXorOp LogicalXorOp::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<LogicalXorOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LogicalXorOp LogicalXorOp::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 LogicalXorOp::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);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
LogicalXorOp LogicalXorOp::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<LogicalXorOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
LogicalXorOp LogicalXorOp::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 LogicalXorOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps20(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps20(*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_TosaOps20(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult LogicalXorOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult LogicalXorOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void LogicalXorOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void LogicalXorOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::LogicalXorOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::MatMulOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
MatMulOpGenericAdaptorBase::MatMulOpGenericAdaptorBase(MatMulOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
MatMulOpAdaptor::MatMulOpAdaptor(MatMulOp op) : MatMulOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult MatMulOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult MatMulOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
|
|
if (!dict) {
|
|
emitError() << "expected DictionaryAttr to set properties";
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute MatMulOp::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 MatMulOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> MatMulOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void MatMulOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void MatMulOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult MatMulOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void MatMulOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type outputType, Value a, Value b) {
|
|
buildMatMulOpWithQuantInfo(odsBuilder, odsState, outputType,
|
|
a, b);
|
|
|
|
}
|
|
|
|
MatMulOp MatMulOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type outputType, Value a, Value b) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(outputType)>(outputType), std::forward<decltype(a)>(a), std::forward<decltype(b)>(b));
|
|
auto __res__ = ::llvm::dyn_cast<MatMulOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MatMulOp MatMulOp::create(::mlir::ImplicitLocOpBuilder &builder, Type outputType, Value a, Value b) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(outputType)>(outputType), std::forward<decltype(a)>(a), std::forward<decltype(b)>(b));
|
|
}
|
|
|
|
void MatMulOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value a, ::mlir::Value b, ::mlir::Value a_zp, ::mlir::Value b_zp) {
|
|
odsState.addOperands(a);
|
|
odsState.addOperands(b);
|
|
odsState.addOperands(a_zp);
|
|
odsState.addOperands(b_zp);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
MatMulOp MatMulOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value a, ::mlir::Value b, ::mlir::Value a_zp, ::mlir::Value b_zp) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(a)>(a), std::forward<decltype(b)>(b), std::forward<decltype(a_zp)>(a_zp), std::forward<decltype(b_zp)>(b_zp));
|
|
auto __res__ = ::llvm::dyn_cast<MatMulOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MatMulOp MatMulOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value a, ::mlir::Value b, ::mlir::Value a_zp, ::mlir::Value b_zp) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(a)>(a), std::forward<decltype(b)>(b), std::forward<decltype(a_zp)>(a_zp), std::forward<decltype(b_zp)>(b_zp));
|
|
}
|
|
|
|
void MatMulOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, ::mlir::Value a_zp, ::mlir::Value b_zp) {
|
|
odsState.addOperands(a);
|
|
odsState.addOperands(b);
|
|
odsState.addOperands(a_zp);
|
|
odsState.addOperands(b_zp);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
MatMulOp MatMulOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, ::mlir::Value a_zp, ::mlir::Value b_zp) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(a)>(a), std::forward<decltype(b)>(b), std::forward<decltype(a_zp)>(a_zp), std::forward<decltype(b_zp)>(b_zp));
|
|
auto __res__ = ::llvm::dyn_cast<MatMulOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MatMulOp MatMulOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value a, ::mlir::Value b, ::mlir::Value a_zp, ::mlir::Value b_zp) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(a)>(a), std::forward<decltype(b)>(b), std::forward<decltype(a_zp)>(a_zp), std::forward<decltype(b_zp)>(b_zp));
|
|
}
|
|
|
|
void MatMulOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 4u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
MatMulOp MatMulOp::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<MatMulOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MatMulOp MatMulOp::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 MatMulOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
|
|
assert(operands.size() == 4u && "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);
|
|
}
|
|
|
|
MatMulOp MatMulOp::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<MatMulOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MatMulOp MatMulOp::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 MatMulOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps21(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps21(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps7(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup3 = getODSOperands(3);
|
|
|
|
for (auto v : valueGroup3) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps7(*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_TosaOps21(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult MatMulOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult MatMulOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void MatMulOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void MatMulOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
MatMulOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
MatMulOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return MatMulOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::MatMulOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::MatmulTBlockScaledOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
MatmulTBlockScaledOpGenericAdaptorBase::MatmulTBlockScaledOpGenericAdaptorBase(MatmulTBlockScaledOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::mlir::tosa::BlockSize MatmulTBlockScaledOpGenericAdaptorBase::getBlockSize() {
|
|
auto attr = getBlockSizeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
MatmulTBlockScaledOpAdaptor::MatmulTBlockScaledOpAdaptor(MatmulTBlockScaledOp op) : MatmulTBlockScaledOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult MatmulTBlockScaledOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_block_size = getProperties().block_size; (void)tblgen_block_size;
|
|
if (!tblgen_block_size) return emitError(loc, "'tosa.matmul_t_block_scaled' op requires attribute 'block_size'");
|
|
|
|
if (tblgen_block_size && !((::llvm::isa<mlir::tosa::BlockSizeAttr>(tblgen_block_size))))
|
|
return emitError(loc, "'tosa.matmul_t_block_scaled' op attribute 'block_size' failed to satisfy constraint: Block size for the block_scaled formats");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult MatmulTBlockScaledOp::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.block_size;
|
|
auto attr = dict.get("block_size");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `block_size` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute MatmulTBlockScaledOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.block_size;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("block_size",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code MatmulTBlockScaledOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.block_size.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> MatmulTBlockScaledOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "block_size")
|
|
return prop.block_size;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void MatmulTBlockScaledOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "block_size") {
|
|
prop.block_size = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.block_size)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void MatmulTBlockScaledOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.block_size) attrs.append("block_size", prop.block_size);
|
|
}
|
|
|
|
::llvm::LogicalResult MatmulTBlockScaledOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getBlockSizeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps8(attr, "block_size", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult MatmulTBlockScaledOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.block_size)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void MatmulTBlockScaledOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.block_size);
|
|
}
|
|
|
|
::mlir::tosa::BlockSize MatmulTBlockScaledOp::getBlockSize() {
|
|
auto attr = getBlockSizeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
void MatmulTBlockScaledOp::setBlockSize(::mlir::tosa::BlockSize attrValue) {
|
|
getProperties().block_size = ::mlir::tosa::BlockSizeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue);
|
|
}
|
|
|
|
void MatmulTBlockScaledOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output_data, ::mlir::Value a_data, ::mlir::Value a_scale, ::mlir::Value b_data, ::mlir::Value b_scale, mlir::tosa::BlockSizeAttr block_size) {
|
|
odsState.addOperands(a_data);
|
|
odsState.addOperands(a_scale);
|
|
odsState.addOperands(b_data);
|
|
odsState.addOperands(b_scale);
|
|
odsState.getOrAddProperties<Properties>().block_size = block_size;
|
|
odsState.addTypes(output_data);
|
|
}
|
|
|
|
MatmulTBlockScaledOp MatmulTBlockScaledOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output_data, ::mlir::Value a_data, ::mlir::Value a_scale, ::mlir::Value b_data, ::mlir::Value b_scale, mlir::tosa::BlockSizeAttr block_size) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output_data)>(output_data), std::forward<decltype(a_data)>(a_data), std::forward<decltype(a_scale)>(a_scale), std::forward<decltype(b_data)>(b_data), std::forward<decltype(b_scale)>(b_scale), std::forward<decltype(block_size)>(block_size));
|
|
auto __res__ = ::llvm::dyn_cast<MatmulTBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MatmulTBlockScaledOp MatmulTBlockScaledOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output_data, ::mlir::Value a_data, ::mlir::Value a_scale, ::mlir::Value b_data, ::mlir::Value b_scale, mlir::tosa::BlockSizeAttr block_size) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output_data)>(output_data), std::forward<decltype(a_data)>(a_data), std::forward<decltype(a_scale)>(a_scale), std::forward<decltype(b_data)>(b_data), std::forward<decltype(b_scale)>(b_scale), std::forward<decltype(block_size)>(block_size));
|
|
}
|
|
|
|
void MatmulTBlockScaledOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a_data, ::mlir::Value a_scale, ::mlir::Value b_data, ::mlir::Value b_scale, mlir::tosa::BlockSizeAttr block_size) {
|
|
odsState.addOperands(a_data);
|
|
odsState.addOperands(a_scale);
|
|
odsState.addOperands(b_data);
|
|
odsState.addOperands(b_scale);
|
|
odsState.getOrAddProperties<Properties>().block_size = block_size;
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
MatmulTBlockScaledOp MatmulTBlockScaledOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value a_data, ::mlir::Value a_scale, ::mlir::Value b_data, ::mlir::Value b_scale, mlir::tosa::BlockSizeAttr block_size) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(a_data)>(a_data), std::forward<decltype(a_scale)>(a_scale), std::forward<decltype(b_data)>(b_data), std::forward<decltype(b_scale)>(b_scale), std::forward<decltype(block_size)>(block_size));
|
|
auto __res__ = ::llvm::dyn_cast<MatmulTBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MatmulTBlockScaledOp MatmulTBlockScaledOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value a_data, ::mlir::Value a_scale, ::mlir::Value b_data, ::mlir::Value b_scale, mlir::tosa::BlockSizeAttr block_size) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(a_data)>(a_data), std::forward<decltype(a_scale)>(a_scale), std::forward<decltype(b_data)>(b_data), std::forward<decltype(b_scale)>(b_scale), std::forward<decltype(block_size)>(block_size));
|
|
}
|
|
|
|
void MatmulTBlockScaledOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output_data, ::mlir::Value a_data, ::mlir::Value a_scale, ::mlir::Value b_data, ::mlir::Value b_scale, ::mlir::tosa::BlockSize block_size) {
|
|
odsState.addOperands(a_data);
|
|
odsState.addOperands(a_scale);
|
|
odsState.addOperands(b_data);
|
|
odsState.addOperands(b_scale);
|
|
odsState.getOrAddProperties<Properties>().block_size = ::mlir::tosa::BlockSizeAttr::get(odsBuilder.getContext(), block_size);
|
|
odsState.addTypes(output_data);
|
|
}
|
|
|
|
MatmulTBlockScaledOp MatmulTBlockScaledOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output_data, ::mlir::Value a_data, ::mlir::Value a_scale, ::mlir::Value b_data, ::mlir::Value b_scale, ::mlir::tosa::BlockSize block_size) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output_data)>(output_data), std::forward<decltype(a_data)>(a_data), std::forward<decltype(a_scale)>(a_scale), std::forward<decltype(b_data)>(b_data), std::forward<decltype(b_scale)>(b_scale), std::forward<decltype(block_size)>(block_size));
|
|
auto __res__ = ::llvm::dyn_cast<MatmulTBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MatmulTBlockScaledOp MatmulTBlockScaledOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output_data, ::mlir::Value a_data, ::mlir::Value a_scale, ::mlir::Value b_data, ::mlir::Value b_scale, ::mlir::tosa::BlockSize block_size) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output_data)>(output_data), std::forward<decltype(a_data)>(a_data), std::forward<decltype(a_scale)>(a_scale), std::forward<decltype(b_data)>(b_data), std::forward<decltype(b_scale)>(b_scale), std::forward<decltype(block_size)>(block_size));
|
|
}
|
|
|
|
void MatmulTBlockScaledOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value a_data, ::mlir::Value a_scale, ::mlir::Value b_data, ::mlir::Value b_scale, ::mlir::tosa::BlockSize block_size) {
|
|
odsState.addOperands(a_data);
|
|
odsState.addOperands(a_scale);
|
|
odsState.addOperands(b_data);
|
|
odsState.addOperands(b_scale);
|
|
odsState.getOrAddProperties<Properties>().block_size = ::mlir::tosa::BlockSizeAttr::get(odsBuilder.getContext(), block_size);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
MatmulTBlockScaledOp MatmulTBlockScaledOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value a_data, ::mlir::Value a_scale, ::mlir::Value b_data, ::mlir::Value b_scale, ::mlir::tosa::BlockSize block_size) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(a_data)>(a_data), std::forward<decltype(a_scale)>(a_scale), std::forward<decltype(b_data)>(b_data), std::forward<decltype(b_scale)>(b_scale), std::forward<decltype(block_size)>(block_size));
|
|
auto __res__ = ::llvm::dyn_cast<MatmulTBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MatmulTBlockScaledOp MatmulTBlockScaledOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value a_data, ::mlir::Value a_scale, ::mlir::Value b_data, ::mlir::Value b_scale, ::mlir::tosa::BlockSize block_size) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(a_data)>(a_data), std::forward<decltype(a_scale)>(a_scale), std::forward<decltype(b_data)>(b_data), std::forward<decltype(b_scale)>(b_scale), std::forward<decltype(block_size)>(block_size));
|
|
}
|
|
|
|
void MatmulTBlockScaledOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 4u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<MatmulTBlockScaledOp::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.");
|
|
}
|
|
}
|
|
|
|
MatmulTBlockScaledOp MatmulTBlockScaledOp::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<MatmulTBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MatmulTBlockScaledOp MatmulTBlockScaledOp::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 MatmulTBlockScaledOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
|
|
assert(operands.size() == 4u && "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);
|
|
}
|
|
|
|
MatmulTBlockScaledOp MatmulTBlockScaledOp::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<MatmulTBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MatmulTBlockScaledOp MatmulTBlockScaledOp::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 MatmulTBlockScaledOp::verifyInvariantsImpl() {
|
|
auto tblgen_block_size = getProperties().block_size; (void)tblgen_block_size;
|
|
if (!tblgen_block_size) return emitOpError("requires attribute 'block_size'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps8(*this, tblgen_block_size, "block_size")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps24(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps25(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps24(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup3 = getODSOperands(3);
|
|
|
|
for (auto v : valueGroup3) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps25(*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_TosaOps21(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult MatmulTBlockScaledOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::llvm::LogicalResult MatmulTBlockScaledOp::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.block_size;
|
|
auto block_sizeAttrName = ::mlir::StringAttr::get(ctx, "block_size");
|
|
auto attr = dict.get(block_sizeAttrName);
|
|
usedKeys.insert(block_sizeAttrName);
|
|
if (attr || /*isRequired=*/true) {
|
|
if (!attr) {
|
|
emitError() << "expected key entry for block_size 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 `block_size` 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();
|
|
}
|
|
|
|
void MatmulTBlockScaledOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
MatmulTBlockScaledOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
MatmulTBlockScaledOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return MatmulTBlockScaledOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::MatmulTBlockScaledOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::MatmulTBlockScaledOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::MaxPool2dAdaptiveOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
MaxPool2dAdaptiveOpGenericAdaptorBase::MaxPool2dAdaptiveOpGenericAdaptorBase(MaxPool2dAdaptiveOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
mlir::tosa::NanPropagationModeAttr MaxPool2dAdaptiveOpGenericAdaptorBase::getNanModeAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<mlir::tosa::NanPropagationModeAttr>(getProperties().nan_mode);
|
|
return attr;
|
|
}
|
|
|
|
::mlir::tosa::NanPropagationMode MaxPool2dAdaptiveOpGenericAdaptorBase::getNanMode() {
|
|
auto attr = getNanModeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
MaxPool2dAdaptiveOpAdaptor::MaxPool2dAdaptiveOpAdaptor(MaxPool2dAdaptiveOp op) : MaxPool2dAdaptiveOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult MaxPool2dAdaptiveOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_nan_mode = getProperties().nan_mode; (void)tblgen_nan_mode;
|
|
|
|
if (tblgen_nan_mode && !((::llvm::isa<mlir::tosa::NanPropagationModeAttr>(tblgen_nan_mode))))
|
|
return emitError(loc, "'tosa.max_pool2d_adaptive' op attribute 'nan_mode' failed to satisfy constraint: Supported NaN propagation strategies");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult MaxPool2dAdaptiveOp::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.nan_mode;
|
|
auto attr = dict.get("nan_mode");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `nan_mode` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute MaxPool2dAdaptiveOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.nan_mode;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("nan_mode",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code MaxPool2dAdaptiveOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.nan_mode.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> MaxPool2dAdaptiveOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "nan_mode")
|
|
return prop.nan_mode;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void MaxPool2dAdaptiveOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "nan_mode") {
|
|
prop.nan_mode = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.nan_mode)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void MaxPool2dAdaptiveOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.nan_mode) attrs.append("nan_mode", prop.nan_mode);
|
|
}
|
|
|
|
::llvm::LogicalResult MaxPool2dAdaptiveOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getNanModeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps3(attr, "nan_mode", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult MaxPool2dAdaptiveOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.nan_mode)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void MaxPool2dAdaptiveOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.nan_mode);
|
|
}
|
|
|
|
::mlir::tosa::NanPropagationMode MaxPool2dAdaptiveOp::getNanMode() {
|
|
auto attr = getNanModeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
void MaxPool2dAdaptiveOp::setNanMode(::mlir::tosa::NanPropagationMode attrValue) {
|
|
getProperties().nan_mode = ::mlir::tosa::NanPropagationModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue);
|
|
}
|
|
|
|
void MaxPool2dAdaptiveOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, ::mlir::Value kernel, ::mlir::Value stride, ::mlir::Value pad, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(kernel);
|
|
odsState.addOperands(stride);
|
|
odsState.addOperands(pad);
|
|
if (nan_mode) {
|
|
odsState.getOrAddProperties<Properties>().nan_mode = nan_mode;
|
|
}
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
MaxPool2dAdaptiveOp MaxPool2dAdaptiveOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, ::mlir::Value kernel, ::mlir::Value stride, ::mlir::Value pad, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<MaxPool2dAdaptiveOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MaxPool2dAdaptiveOp MaxPool2dAdaptiveOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, ::mlir::Value kernel, ::mlir::Value stride, ::mlir::Value pad, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void MaxPool2dAdaptiveOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value kernel, ::mlir::Value stride, ::mlir::Value pad, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(kernel);
|
|
odsState.addOperands(stride);
|
|
odsState.addOperands(pad);
|
|
if (nan_mode) {
|
|
odsState.getOrAddProperties<Properties>().nan_mode = nan_mode;
|
|
}
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
MaxPool2dAdaptiveOp MaxPool2dAdaptiveOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value kernel, ::mlir::Value stride, ::mlir::Value pad, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<MaxPool2dAdaptiveOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MaxPool2dAdaptiveOp MaxPool2dAdaptiveOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value kernel, ::mlir::Value stride, ::mlir::Value pad, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void MaxPool2dAdaptiveOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, ::mlir::Value kernel, ::mlir::Value stride, ::mlir::Value pad, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(kernel);
|
|
odsState.addOperands(stride);
|
|
odsState.addOperands(pad);
|
|
odsState.getOrAddProperties<Properties>().nan_mode = ::mlir::tosa::NanPropagationModeAttr::get(odsBuilder.getContext(), nan_mode);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
MaxPool2dAdaptiveOp MaxPool2dAdaptiveOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, ::mlir::Value kernel, ::mlir::Value stride, ::mlir::Value pad, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<MaxPool2dAdaptiveOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MaxPool2dAdaptiveOp MaxPool2dAdaptiveOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, ::mlir::Value kernel, ::mlir::Value stride, ::mlir::Value pad, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void MaxPool2dAdaptiveOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value kernel, ::mlir::Value stride, ::mlir::Value pad, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(kernel);
|
|
odsState.addOperands(stride);
|
|
odsState.addOperands(pad);
|
|
odsState.getOrAddProperties<Properties>().nan_mode = ::mlir::tosa::NanPropagationModeAttr::get(odsBuilder.getContext(), nan_mode);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
MaxPool2dAdaptiveOp MaxPool2dAdaptiveOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value kernel, ::mlir::Value stride, ::mlir::Value pad, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<MaxPool2dAdaptiveOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MaxPool2dAdaptiveOp MaxPool2dAdaptiveOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value kernel, ::mlir::Value stride, ::mlir::Value pad, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void MaxPool2dAdaptiveOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 4u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<MaxPool2dAdaptiveOp::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.");
|
|
}
|
|
}
|
|
|
|
MaxPool2dAdaptiveOp MaxPool2dAdaptiveOp::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<MaxPool2dAdaptiveOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MaxPool2dAdaptiveOp MaxPool2dAdaptiveOp::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 MaxPool2dAdaptiveOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
|
|
assert(operands.size() == 4u && "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);
|
|
}
|
|
|
|
MaxPool2dAdaptiveOp MaxPool2dAdaptiveOp::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<MaxPool2dAdaptiveOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MaxPool2dAdaptiveOp MaxPool2dAdaptiveOp::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 MaxPool2dAdaptiveOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) {
|
|
::mlir::Builder odsBuilder(opName.getContext());
|
|
if (!properties.nan_mode)
|
|
properties.nan_mode = ::mlir::tosa::NanPropagationModeAttr::get(odsBuilder.getContext(), ::mlir::tosa::NanPropagationMode::PROPAGATE);
|
|
}
|
|
|
|
::llvm::LogicalResult MaxPool2dAdaptiveOp::verifyInvariantsImpl() {
|
|
auto tblgen_nan_mode = getProperties().nan_mode; (void)tblgen_nan_mode;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps3(*this, tblgen_nan_mode, "nan_mode")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps6(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps8(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps8(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup3 = getODSOperands(3);
|
|
|
|
for (auto v : valueGroup3) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps9(*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_TosaOps6(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult MaxPool2dAdaptiveOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::llvm::LogicalResult MaxPool2dAdaptiveOp::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.nan_mode;
|
|
auto nan_modeAttrName = ::mlir::StringAttr::get(ctx, "nan_mode");
|
|
auto attr = dict.get(nan_modeAttrName);
|
|
usedKeys.insert(nan_modeAttrName);
|
|
if (attr || /*isRequired=*/false) {
|
|
if (!attr) {
|
|
emitError() << "expected key entry for nan_mode 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 `nan_mode` 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();
|
|
}
|
|
|
|
void MaxPool2dAdaptiveOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
MaxPool2dAdaptiveOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
MaxPool2dAdaptiveOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return MaxPool2dAdaptiveOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::MaxPool2dAdaptiveOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::MaxPool2dAdaptiveOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::MaxPool2dOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
MaxPool2dOpGenericAdaptorBase::MaxPool2dOpGenericAdaptorBase(MaxPool2dOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::llvm::ArrayRef<int64_t> MaxPool2dOpGenericAdaptorBase::getKernel() {
|
|
auto attr = getKernelAttr();
|
|
return attr;
|
|
}
|
|
|
|
::llvm::ArrayRef<int64_t> MaxPool2dOpGenericAdaptorBase::getStride() {
|
|
auto attr = getStrideAttr();
|
|
return attr;
|
|
}
|
|
|
|
::llvm::ArrayRef<int64_t> MaxPool2dOpGenericAdaptorBase::getPad() {
|
|
auto attr = getPadAttr();
|
|
return attr;
|
|
}
|
|
|
|
mlir::tosa::NanPropagationModeAttr MaxPool2dOpGenericAdaptorBase::getNanModeAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<mlir::tosa::NanPropagationModeAttr>(getProperties().nan_mode);
|
|
return attr;
|
|
}
|
|
|
|
::mlir::tosa::NanPropagationMode MaxPool2dOpGenericAdaptorBase::getNanMode() {
|
|
auto attr = getNanModeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
MaxPool2dOpAdaptor::MaxPool2dOpAdaptor(MaxPool2dOp op) : MaxPool2dOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult MaxPool2dOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_kernel = getProperties().kernel; (void)tblgen_kernel;
|
|
if (!tblgen_kernel) return emitError(loc, "'tosa.max_pool2d' op requires attribute 'kernel'");
|
|
auto tblgen_nan_mode = getProperties().nan_mode; (void)tblgen_nan_mode;
|
|
auto tblgen_pad = getProperties().pad; (void)tblgen_pad;
|
|
if (!tblgen_pad) return emitError(loc, "'tosa.max_pool2d' op requires attribute 'pad'");
|
|
auto tblgen_stride = getProperties().stride; (void)tblgen_stride;
|
|
if (!tblgen_stride) return emitError(loc, "'tosa.max_pool2d' op requires attribute 'stride'");
|
|
|
|
if (tblgen_kernel && !(((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_kernel))) && ((::llvm::cast<::mlir::DenseArrayAttr>(tblgen_kernel).size() == 2))))
|
|
return emitError(loc, "'tosa.max_pool2d' op attribute 'kernel' failed to satisfy constraint: i64 dense array attribute with exactly 2 elements");
|
|
|
|
if (tblgen_stride && !(((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_stride))) && ((::llvm::cast<::mlir::DenseArrayAttr>(tblgen_stride).size() == 2))))
|
|
return emitError(loc, "'tosa.max_pool2d' op attribute 'stride' failed to satisfy constraint: i64 dense array attribute with exactly 2 elements");
|
|
|
|
if (tblgen_pad && !(((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_pad))) && ((::llvm::cast<::mlir::DenseArrayAttr>(tblgen_pad).size() == 4))))
|
|
return emitError(loc, "'tosa.max_pool2d' op attribute 'pad' failed to satisfy constraint: i64 dense array attribute with exactly 4 elements");
|
|
|
|
if (tblgen_nan_mode && !((::llvm::isa<mlir::tosa::NanPropagationModeAttr>(tblgen_nan_mode))))
|
|
return emitError(loc, "'tosa.max_pool2d' op attribute 'nan_mode' failed to satisfy constraint: Supported NaN propagation strategies");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult MaxPool2dOp::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.kernel;
|
|
auto attr = dict.get("kernel");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `kernel` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.nan_mode;
|
|
auto attr = dict.get("nan_mode");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `nan_mode` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.pad;
|
|
auto attr = dict.get("pad");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `pad` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.stride;
|
|
auto attr = dict.get("stride");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `stride` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute MaxPool2dOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.kernel;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("kernel",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.nan_mode;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("nan_mode",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.pad;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("pad",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.stride;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("stride",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code MaxPool2dOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.kernel.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.nan_mode.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.pad.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.stride.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> MaxPool2dOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "kernel")
|
|
return prop.kernel;
|
|
|
|
if (name == "nan_mode")
|
|
return prop.nan_mode;
|
|
|
|
if (name == "pad")
|
|
return prop.pad;
|
|
|
|
if (name == "stride")
|
|
return prop.stride;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void MaxPool2dOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "kernel") {
|
|
prop.kernel = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.kernel)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "nan_mode") {
|
|
prop.nan_mode = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.nan_mode)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "pad") {
|
|
prop.pad = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.pad)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "stride") {
|
|
prop.stride = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.stride)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void MaxPool2dOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.kernel) attrs.append("kernel", prop.kernel);
|
|
|
|
if (prop.nan_mode) attrs.append("nan_mode", prop.nan_mode);
|
|
|
|
if (prop.pad) attrs.append("pad", prop.pad);
|
|
|
|
if (prop.stride) attrs.append("stride", prop.stride);
|
|
}
|
|
|
|
::llvm::LogicalResult MaxPool2dOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getKernelAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps6(attr, "kernel", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getNanModeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps3(attr, "nan_mode", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getPadAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps7(attr, "pad", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getStrideAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps6(attr, "stride", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult MaxPool2dOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.kernel)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.nan_mode)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readAttribute(prop.pad)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readAttribute(prop.stride)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void MaxPool2dOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.kernel);
|
|
|
|
writer.writeOptionalAttribute(prop.nan_mode);
|
|
writer.writeAttribute(prop.pad);
|
|
writer.writeAttribute(prop.stride);
|
|
}
|
|
|
|
::llvm::ArrayRef<int64_t> MaxPool2dOp::getKernel() {
|
|
auto attr = getKernelAttr();
|
|
return attr;
|
|
}
|
|
|
|
::llvm::ArrayRef<int64_t> MaxPool2dOp::getStride() {
|
|
auto attr = getStrideAttr();
|
|
return attr;
|
|
}
|
|
|
|
::llvm::ArrayRef<int64_t> MaxPool2dOp::getPad() {
|
|
auto attr = getPadAttr();
|
|
return attr;
|
|
}
|
|
|
|
::mlir::tosa::NanPropagationMode MaxPool2dOp::getNanMode() {
|
|
auto attr = getNanModeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
void MaxPool2dOp::setKernel(::llvm::ArrayRef<int64_t> attrValue) {
|
|
getProperties().kernel = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue);
|
|
}
|
|
|
|
void MaxPool2dOp::setStride(::llvm::ArrayRef<int64_t> attrValue) {
|
|
getProperties().stride = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue);
|
|
}
|
|
|
|
void MaxPool2dOp::setPad(::llvm::ArrayRef<int64_t> attrValue) {
|
|
getProperties().pad = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue);
|
|
}
|
|
|
|
void MaxPool2dOp::setNanMode(::mlir::tosa::NanPropagationMode attrValue) {
|
|
getProperties().nan_mode = ::mlir::tosa::NanPropagationModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue);
|
|
}
|
|
|
|
void MaxPool2dOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, ::mlir::DenseI64ArrayAttr kernel, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr pad, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().kernel = kernel;
|
|
odsState.getOrAddProperties<Properties>().stride = stride;
|
|
odsState.getOrAddProperties<Properties>().pad = pad;
|
|
if (nan_mode) {
|
|
odsState.getOrAddProperties<Properties>().nan_mode = nan_mode;
|
|
}
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
MaxPool2dOp MaxPool2dOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, ::mlir::DenseI64ArrayAttr kernel, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr pad, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<MaxPool2dOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MaxPool2dOp MaxPool2dOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, ::mlir::DenseI64ArrayAttr kernel, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr pad, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void MaxPool2dOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::DenseI64ArrayAttr kernel, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr pad, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().kernel = kernel;
|
|
odsState.getOrAddProperties<Properties>().stride = stride;
|
|
odsState.getOrAddProperties<Properties>().pad = pad;
|
|
if (nan_mode) {
|
|
odsState.getOrAddProperties<Properties>().nan_mode = nan_mode;
|
|
}
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
MaxPool2dOp MaxPool2dOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::DenseI64ArrayAttr kernel, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr pad, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<MaxPool2dOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MaxPool2dOp MaxPool2dOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::DenseI64ArrayAttr kernel, ::mlir::DenseI64ArrayAttr stride, ::mlir::DenseI64ArrayAttr pad, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void MaxPool2dOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, ::llvm::ArrayRef<int64_t> kernel, ::llvm::ArrayRef<int64_t> stride, ::llvm::ArrayRef<int64_t> pad, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().kernel = odsBuilder.getDenseI64ArrayAttr(kernel);
|
|
odsState.getOrAddProperties<Properties>().stride = odsBuilder.getDenseI64ArrayAttr(stride);
|
|
odsState.getOrAddProperties<Properties>().pad = odsBuilder.getDenseI64ArrayAttr(pad);
|
|
odsState.getOrAddProperties<Properties>().nan_mode = ::mlir::tosa::NanPropagationModeAttr::get(odsBuilder.getContext(), nan_mode);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
MaxPool2dOp MaxPool2dOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, ::llvm::ArrayRef<int64_t> kernel, ::llvm::ArrayRef<int64_t> stride, ::llvm::ArrayRef<int64_t> pad, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<MaxPool2dOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MaxPool2dOp MaxPool2dOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, ::llvm::ArrayRef<int64_t> kernel, ::llvm::ArrayRef<int64_t> stride, ::llvm::ArrayRef<int64_t> pad, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void MaxPool2dOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::llvm::ArrayRef<int64_t> kernel, ::llvm::ArrayRef<int64_t> stride, ::llvm::ArrayRef<int64_t> pad, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().kernel = odsBuilder.getDenseI64ArrayAttr(kernel);
|
|
odsState.getOrAddProperties<Properties>().stride = odsBuilder.getDenseI64ArrayAttr(stride);
|
|
odsState.getOrAddProperties<Properties>().pad = odsBuilder.getDenseI64ArrayAttr(pad);
|
|
odsState.getOrAddProperties<Properties>().nan_mode = ::mlir::tosa::NanPropagationModeAttr::get(odsBuilder.getContext(), nan_mode);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
MaxPool2dOp MaxPool2dOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::llvm::ArrayRef<int64_t> kernel, ::llvm::ArrayRef<int64_t> stride, ::llvm::ArrayRef<int64_t> pad, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<MaxPool2dOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MaxPool2dOp MaxPool2dOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::llvm::ArrayRef<int64_t> kernel, ::llvm::ArrayRef<int64_t> stride, ::llvm::ArrayRef<int64_t> pad, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(kernel)>(kernel), std::forward<decltype(stride)>(stride), std::forward<decltype(pad)>(pad), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void MaxPool2dOp::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<MaxPool2dOp::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.");
|
|
}
|
|
}
|
|
|
|
MaxPool2dOp MaxPool2dOp::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<MaxPool2dOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MaxPool2dOp MaxPool2dOp::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 MaxPool2dOp::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);
|
|
}
|
|
|
|
MaxPool2dOp MaxPool2dOp::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<MaxPool2dOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MaxPool2dOp MaxPool2dOp::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 MaxPool2dOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) {
|
|
::mlir::Builder odsBuilder(opName.getContext());
|
|
if (!properties.nan_mode)
|
|
properties.nan_mode = ::mlir::tosa::NanPropagationModeAttr::get(odsBuilder.getContext(), ::mlir::tosa::NanPropagationMode::PROPAGATE);
|
|
}
|
|
|
|
::llvm::LogicalResult MaxPool2dOp::verifyInvariantsImpl() {
|
|
auto tblgen_kernel = getProperties().kernel; (void)tblgen_kernel;
|
|
if (!tblgen_kernel) return emitOpError("requires attribute 'kernel'");
|
|
auto tblgen_nan_mode = getProperties().nan_mode; (void)tblgen_nan_mode;
|
|
auto tblgen_pad = getProperties().pad; (void)tblgen_pad;
|
|
if (!tblgen_pad) return emitOpError("requires attribute 'pad'");
|
|
auto tblgen_stride = getProperties().stride; (void)tblgen_stride;
|
|
if (!tblgen_stride) return emitOpError("requires attribute 'stride'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps6(*this, tblgen_kernel, "kernel")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps6(*this, tblgen_stride, "stride")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps7(*this, tblgen_pad, "pad")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps3(*this, tblgen_nan_mode, "nan_mode")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps6(*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_TosaOps6(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult MaxPool2dOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::llvm::LogicalResult MaxPool2dOp::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.kernel;
|
|
auto kernelAttrName = ::mlir::StringAttr::get(ctx, "kernel");
|
|
auto attr = dict.get(kernelAttrName);
|
|
usedKeys.insert(kernelAttrName);
|
|
if (attr || /*isRequired=*/true) {
|
|
if (!attr) {
|
|
emitError() << "expected key entry for kernel 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 `kernel` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
{
|
|
|
|
auto &propStorage = prop.stride;
|
|
auto strideAttrName = ::mlir::StringAttr::get(ctx, "stride");
|
|
auto attr = dict.get(strideAttrName);
|
|
usedKeys.insert(strideAttrName);
|
|
if (attr || /*isRequired=*/true) {
|
|
if (!attr) {
|
|
emitError() << "expected key entry for stride 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 `stride` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
{
|
|
|
|
auto &propStorage = prop.pad;
|
|
auto padAttrName = ::mlir::StringAttr::get(ctx, "pad");
|
|
auto attr = dict.get(padAttrName);
|
|
usedKeys.insert(padAttrName);
|
|
if (attr || /*isRequired=*/true) {
|
|
if (!attr) {
|
|
emitError() << "expected key entry for pad 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 `pad` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
{
|
|
|
|
auto &propStorage = prop.nan_mode;
|
|
auto nan_modeAttrName = ::mlir::StringAttr::get(ctx, "nan_mode");
|
|
auto attr = dict.get(nan_modeAttrName);
|
|
usedKeys.insert(nan_modeAttrName);
|
|
if (attr || /*isRequired=*/false) {
|
|
if (!attr) {
|
|
emitError() << "expected key entry for nan_mode 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 `nan_mode` 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();
|
|
}
|
|
|
|
void MaxPool2dOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
MaxPool2dOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
MaxPool2dOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return MaxPool2dOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::MaxPool2dOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::MaxPool2dOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::MaxShapeOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
MaxShapeOpGenericAdaptorBase::MaxShapeOpGenericAdaptorBase(MaxShapeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
MaxShapeOpAdaptor::MaxShapeOpAdaptor(MaxShapeOp op) : MaxShapeOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult MaxShapeOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult MaxShapeOp::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 MaxShapeOp::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 MaxShapeOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> MaxShapeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void MaxShapeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void MaxShapeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult MaxShapeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void MaxShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
MaxShapeOp MaxShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<MaxShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MaxShapeOp MaxShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void MaxShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
MaxShapeOp MaxShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<MaxShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MaxShapeOp MaxShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void MaxShapeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
MaxShapeOp MaxShapeOp::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<MaxShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MaxShapeOp MaxShapeOp::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 MaxShapeOp::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);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
MaxShapeOp MaxShapeOp::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<MaxShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MaxShapeOp MaxShapeOp::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 MaxShapeOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps2(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps2(*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_TosaOps2(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult MaxShapeOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult MaxShapeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void MaxShapeOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void MaxShapeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::MaxShapeOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::MaximumOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
MaximumOpGenericAdaptorBase::MaximumOpGenericAdaptorBase(MaximumOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
mlir::tosa::NanPropagationModeAttr MaximumOpGenericAdaptorBase::getNanModeAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<mlir::tosa::NanPropagationModeAttr>(getProperties().nan_mode);
|
|
return attr;
|
|
}
|
|
|
|
::mlir::tosa::NanPropagationMode MaximumOpGenericAdaptorBase::getNanMode() {
|
|
auto attr = getNanModeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
MaximumOpAdaptor::MaximumOpAdaptor(MaximumOp op) : MaximumOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult MaximumOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_nan_mode = getProperties().nan_mode; (void)tblgen_nan_mode;
|
|
|
|
if (tblgen_nan_mode && !((::llvm::isa<mlir::tosa::NanPropagationModeAttr>(tblgen_nan_mode))))
|
|
return emitError(loc, "'tosa.maximum' op attribute 'nan_mode' failed to satisfy constraint: Supported NaN propagation strategies");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult MaximumOp::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.nan_mode;
|
|
auto attr = dict.get("nan_mode");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `nan_mode` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute MaximumOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.nan_mode;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("nan_mode",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code MaximumOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.nan_mode.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> MaximumOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "nan_mode")
|
|
return prop.nan_mode;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void MaximumOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "nan_mode") {
|
|
prop.nan_mode = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.nan_mode)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void MaximumOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.nan_mode) attrs.append("nan_mode", prop.nan_mode);
|
|
}
|
|
|
|
::llvm::LogicalResult MaximumOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getNanModeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps3(attr, "nan_mode", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult MaximumOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.nan_mode)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void MaximumOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.nan_mode);
|
|
}
|
|
|
|
::mlir::tosa::NanPropagationMode MaximumOp::getNanMode() {
|
|
auto attr = getNanModeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
void MaximumOp::setNanMode(::mlir::tosa::NanPropagationMode attrValue) {
|
|
getProperties().nan_mode = ::mlir::tosa::NanPropagationModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue);
|
|
}
|
|
|
|
void MaximumOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
if (nan_mode) {
|
|
odsState.getOrAddProperties<Properties>().nan_mode = nan_mode;
|
|
}
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
MaximumOp MaximumOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<MaximumOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MaximumOp MaximumOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void MaximumOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
if (nan_mode) {
|
|
odsState.getOrAddProperties<Properties>().nan_mode = nan_mode;
|
|
}
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
MaximumOp MaximumOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<MaximumOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MaximumOp MaximumOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void MaximumOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.getOrAddProperties<Properties>().nan_mode = ::mlir::tosa::NanPropagationModeAttr::get(odsBuilder.getContext(), nan_mode);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
MaximumOp MaximumOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<MaximumOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MaximumOp MaximumOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void MaximumOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.getOrAddProperties<Properties>().nan_mode = ::mlir::tosa::NanPropagationModeAttr::get(odsBuilder.getContext(), nan_mode);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
MaximumOp MaximumOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<MaximumOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MaximumOp MaximumOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void MaximumOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<MaximumOp::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.");
|
|
}
|
|
}
|
|
|
|
MaximumOp MaximumOp::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<MaximumOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MaximumOp MaximumOp::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 MaximumOp::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);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
MaximumOp MaximumOp::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<MaximumOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MaximumOp MaximumOp::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 MaximumOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) {
|
|
::mlir::Builder odsBuilder(opName.getContext());
|
|
if (!properties.nan_mode)
|
|
properties.nan_mode = ::mlir::tosa::NanPropagationModeAttr::get(odsBuilder.getContext(), ::mlir::tosa::NanPropagationMode::PROPAGATE);
|
|
}
|
|
|
|
::llvm::LogicalResult MaximumOp::verifyInvariantsImpl() {
|
|
auto tblgen_nan_mode = getProperties().nan_mode; (void)tblgen_nan_mode;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps3(*this, tblgen_nan_mode, "nan_mode")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*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_TosaOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult MaximumOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::llvm::LogicalResult MaximumOp::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.nan_mode;
|
|
auto nan_modeAttrName = ::mlir::StringAttr::get(ctx, "nan_mode");
|
|
auto attr = dict.get(nan_modeAttrName);
|
|
usedKeys.insert(nan_modeAttrName);
|
|
if (attr || /*isRequired=*/false) {
|
|
if (!attr) {
|
|
emitError() << "expected key entry for nan_mode 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 `nan_mode` 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();
|
|
}
|
|
|
|
void MaximumOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::MaximumOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::MaximumOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::MinShapeOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
MinShapeOpGenericAdaptorBase::MinShapeOpGenericAdaptorBase(MinShapeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
MinShapeOpAdaptor::MinShapeOpAdaptor(MinShapeOp op) : MinShapeOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult MinShapeOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult MinShapeOp::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 MinShapeOp::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 MinShapeOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> MinShapeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void MinShapeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void MinShapeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult MinShapeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void MinShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
MinShapeOp MinShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<MinShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MinShapeOp MinShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void MinShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
MinShapeOp MinShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<MinShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MinShapeOp MinShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void MinShapeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
MinShapeOp MinShapeOp::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<MinShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MinShapeOp MinShapeOp::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 MinShapeOp::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);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
MinShapeOp MinShapeOp::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<MinShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MinShapeOp MinShapeOp::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 MinShapeOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps2(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps2(*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_TosaOps2(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult MinShapeOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult MinShapeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void MinShapeOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void MinShapeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::MinShapeOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::MinimumOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
MinimumOpGenericAdaptorBase::MinimumOpGenericAdaptorBase(MinimumOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
mlir::tosa::NanPropagationModeAttr MinimumOpGenericAdaptorBase::getNanModeAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<mlir::tosa::NanPropagationModeAttr>(getProperties().nan_mode);
|
|
return attr;
|
|
}
|
|
|
|
::mlir::tosa::NanPropagationMode MinimumOpGenericAdaptorBase::getNanMode() {
|
|
auto attr = getNanModeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
MinimumOpAdaptor::MinimumOpAdaptor(MinimumOp op) : MinimumOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult MinimumOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_nan_mode = getProperties().nan_mode; (void)tblgen_nan_mode;
|
|
|
|
if (tblgen_nan_mode && !((::llvm::isa<mlir::tosa::NanPropagationModeAttr>(tblgen_nan_mode))))
|
|
return emitError(loc, "'tosa.minimum' op attribute 'nan_mode' failed to satisfy constraint: Supported NaN propagation strategies");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult MinimumOp::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.nan_mode;
|
|
auto attr = dict.get("nan_mode");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `nan_mode` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute MinimumOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.nan_mode;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("nan_mode",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code MinimumOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.nan_mode.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> MinimumOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "nan_mode")
|
|
return prop.nan_mode;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void MinimumOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "nan_mode") {
|
|
prop.nan_mode = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.nan_mode)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void MinimumOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.nan_mode) attrs.append("nan_mode", prop.nan_mode);
|
|
}
|
|
|
|
::llvm::LogicalResult MinimumOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getNanModeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps3(attr, "nan_mode", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult MinimumOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.nan_mode)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void MinimumOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.nan_mode);
|
|
}
|
|
|
|
::mlir::tosa::NanPropagationMode MinimumOp::getNanMode() {
|
|
auto attr = getNanModeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
void MinimumOp::setNanMode(::mlir::tosa::NanPropagationMode attrValue) {
|
|
getProperties().nan_mode = ::mlir::tosa::NanPropagationModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue);
|
|
}
|
|
|
|
void MinimumOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
if (nan_mode) {
|
|
odsState.getOrAddProperties<Properties>().nan_mode = nan_mode;
|
|
}
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
MinimumOp MinimumOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<MinimumOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MinimumOp MinimumOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void MinimumOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
if (nan_mode) {
|
|
odsState.getOrAddProperties<Properties>().nan_mode = nan_mode;
|
|
}
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
MinimumOp MinimumOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<MinimumOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MinimumOp MinimumOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void MinimumOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.getOrAddProperties<Properties>().nan_mode = ::mlir::tosa::NanPropagationModeAttr::get(odsBuilder.getContext(), nan_mode);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
MinimumOp MinimumOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<MinimumOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MinimumOp MinimumOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void MinimumOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.getOrAddProperties<Properties>().nan_mode = ::mlir::tosa::NanPropagationModeAttr::get(odsBuilder.getContext(), nan_mode);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
MinimumOp MinimumOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<MinimumOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MinimumOp MinimumOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void MinimumOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<MinimumOp::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.");
|
|
}
|
|
}
|
|
|
|
MinimumOp MinimumOp::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<MinimumOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MinimumOp MinimumOp::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 MinimumOp::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);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
MinimumOp MinimumOp::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<MinimumOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MinimumOp MinimumOp::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 MinimumOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) {
|
|
::mlir::Builder odsBuilder(opName.getContext());
|
|
if (!properties.nan_mode)
|
|
properties.nan_mode = ::mlir::tosa::NanPropagationModeAttr::get(odsBuilder.getContext(), ::mlir::tosa::NanPropagationMode::PROPAGATE);
|
|
}
|
|
|
|
::llvm::LogicalResult MinimumOp::verifyInvariantsImpl() {
|
|
auto tblgen_nan_mode = getProperties().nan_mode; (void)tblgen_nan_mode;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps3(*this, tblgen_nan_mode, "nan_mode")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*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_TosaOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult MinimumOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::llvm::LogicalResult MinimumOp::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.nan_mode;
|
|
auto nan_modeAttrName = ::mlir::StringAttr::get(ctx, "nan_mode");
|
|
auto attr = dict.get(nan_modeAttrName);
|
|
usedKeys.insert(nan_modeAttrName);
|
|
if (attr || /*isRequired=*/false) {
|
|
if (!attr) {
|
|
emitError() << "expected key entry for nan_mode 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 `nan_mode` 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();
|
|
}
|
|
|
|
void MinimumOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::MinimumOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::MinimumOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::ModShapeOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
ModShapeOpGenericAdaptorBase::ModShapeOpGenericAdaptorBase(ModShapeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
ModShapeOpAdaptor::ModShapeOpAdaptor(ModShapeOp op) : ModShapeOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult ModShapeOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ModShapeOp::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 ModShapeOp::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 ModShapeOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> ModShapeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void ModShapeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void ModShapeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult ModShapeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ModShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ModShapeOp ModShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<ModShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ModShapeOp ModShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void ModShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ModShapeOp ModShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<ModShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ModShapeOp ModShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void ModShapeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ModShapeOp ModShapeOp::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<ModShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ModShapeOp ModShapeOp::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 ModShapeOp::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);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ModShapeOp ModShapeOp::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<ModShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ModShapeOp ModShapeOp::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 ModShapeOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps2(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps2(*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_TosaOps2(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ModShapeOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult ModShapeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ModShapeOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void ModShapeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::ModShapeOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::MulOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
MulOpGenericAdaptorBase::MulOpGenericAdaptorBase(MulOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
MulOpAdaptor::MulOpAdaptor(MulOp op) : MulOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult MulOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult MulOp::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 MulOp::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 MulOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> MulOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void MulOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void MulOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult MulOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void MulOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2, ::mlir::Value shift) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.addOperands(shift);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
MulOp MulOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2, ::mlir::Value shift) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(shift)>(shift));
|
|
auto __res__ = ::llvm::dyn_cast<MulOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MulOp MulOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2, ::mlir::Value shift) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(shift)>(shift));
|
|
}
|
|
|
|
void MulOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2, ::mlir::Value shift) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.addOperands(shift);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
MulOp MulOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2, ::mlir::Value shift) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(shift)>(shift));
|
|
auto __res__ = ::llvm::dyn_cast<MulOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MulOp MulOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2, ::mlir::Value shift) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(shift)>(shift));
|
|
}
|
|
|
|
void MulOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 3u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
MulOp MulOp::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<MulOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MulOp MulOp::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 MulOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
|
|
assert(operands.size() == 3u && "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);
|
|
}
|
|
|
|
MulOp MulOp::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<MulOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MulOp MulOp::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 MulOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps26(*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_TosaOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult MulOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult MulOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void MulOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void MulOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::MulOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::MulShapeOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
MulShapeOpGenericAdaptorBase::MulShapeOpGenericAdaptorBase(MulShapeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
MulShapeOpAdaptor::MulShapeOpAdaptor(MulShapeOp op) : MulShapeOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult MulShapeOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult MulShapeOp::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 MulShapeOp::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 MulShapeOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> MulShapeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void MulShapeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void MulShapeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult MulShapeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void MulShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
MulShapeOp MulShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<MulShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MulShapeOp MulShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void MulShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
MulShapeOp MulShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<MulShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MulShapeOp MulShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void MulShapeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
MulShapeOp MulShapeOp::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<MulShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MulShapeOp MulShapeOp::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 MulShapeOp::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);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
MulShapeOp MulShapeOp::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<MulShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
MulShapeOp MulShapeOp::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 MulShapeOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps2(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps2(*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_TosaOps2(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult MulShapeOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult MulShapeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void MulShapeOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void MulShapeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::MulShapeOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::NegateOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
NegateOpGenericAdaptorBase::NegateOpGenericAdaptorBase(NegateOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
NegateOpAdaptor::NegateOpAdaptor(NegateOp op) : NegateOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult NegateOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult NegateOp::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 NegateOp::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 NegateOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> NegateOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void NegateOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void NegateOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult NegateOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void NegateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type outputType, Value input) {
|
|
buildNegateOpWithQuantInfo(odsBuilder, odsState, outputType, input);
|
|
|
|
}
|
|
|
|
NegateOp NegateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type outputType, Value input) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(outputType)>(outputType), std::forward<decltype(input)>(input));
|
|
auto __res__ = ::llvm::dyn_cast<NegateOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
NegateOp NegateOp::create(::mlir::ImplicitLocOpBuilder &builder, Type outputType, Value input) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(outputType)>(outputType), std::forward<decltype(input)>(input));
|
|
}
|
|
|
|
void NegateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input1_zp, ::mlir::Value output_zp) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input1_zp);
|
|
odsState.addOperands(output_zp);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
NegateOp NegateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input1_zp, ::mlir::Value output_zp) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input1_zp)>(input1_zp), std::forward<decltype(output_zp)>(output_zp));
|
|
auto __res__ = ::llvm::dyn_cast<NegateOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
NegateOp NegateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input1_zp, ::mlir::Value output_zp) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input1_zp)>(input1_zp), std::forward<decltype(output_zp)>(output_zp));
|
|
}
|
|
|
|
void NegateOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input1_zp, ::mlir::Value output_zp) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input1_zp);
|
|
odsState.addOperands(output_zp);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
NegateOp NegateOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input1_zp, ::mlir::Value output_zp) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input1_zp)>(input1_zp), std::forward<decltype(output_zp)>(output_zp));
|
|
auto __res__ = ::llvm::dyn_cast<NegateOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
NegateOp NegateOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input1_zp, ::mlir::Value output_zp) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input1_zp)>(input1_zp), std::forward<decltype(output_zp)>(output_zp));
|
|
}
|
|
|
|
void NegateOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 3u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
NegateOp NegateOp::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<NegateOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
NegateOp NegateOp::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 NegateOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
|
|
assert(operands.size() == 3u && "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);
|
|
}
|
|
|
|
NegateOp NegateOp::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<NegateOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
NegateOp NegateOp::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 NegateOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps7(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps7(*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_TosaOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult NegateOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult NegateOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void NegateOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void NegateOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
NegateOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
NegateOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return NegateOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::NegateOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::PadOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
PadOpGenericAdaptorBase::PadOpGenericAdaptorBase(PadOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
PadOpAdaptor::PadOpAdaptor(PadOp op) : PadOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult PadOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult PadOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
|
|
if (!dict) {
|
|
emitError() << "expected DictionaryAttr to set properties";
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute PadOp::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 PadOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> PadOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void PadOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void PadOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult PadOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void PadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Type outputType, Value input, Value paddings) {
|
|
buildPadOpWithQuantInfo(odsBuilder, odsState, outputType,
|
|
input, paddings);
|
|
|
|
}
|
|
|
|
PadOp PadOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, Type outputType, Value input, Value paddings) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(outputType)>(outputType), std::forward<decltype(input)>(input), std::forward<decltype(paddings)>(paddings));
|
|
auto __res__ = ::llvm::dyn_cast<PadOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
PadOp PadOp::create(::mlir::ImplicitLocOpBuilder &builder, Type outputType, Value input, Value paddings) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(outputType)>(outputType), std::forward<decltype(input)>(input), std::forward<decltype(paddings)>(paddings));
|
|
}
|
|
|
|
void PadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value padding, ::mlir::Value pad_const) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(padding);
|
|
odsState.addOperands(pad_const);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
PadOp PadOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value padding, ::mlir::Value pad_const) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(padding)>(padding), std::forward<decltype(pad_const)>(pad_const));
|
|
auto __res__ = ::llvm::dyn_cast<PadOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
PadOp PadOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value padding, ::mlir::Value pad_const) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(padding)>(padding), std::forward<decltype(pad_const)>(pad_const));
|
|
}
|
|
|
|
void PadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value padding, ::mlir::Value pad_const) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(padding);
|
|
odsState.addOperands(pad_const);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
PadOp PadOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value padding, ::mlir::Value pad_const) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(padding)>(padding), std::forward<decltype(pad_const)>(pad_const));
|
|
auto __res__ = ::llvm::dyn_cast<PadOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
PadOp PadOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value padding, ::mlir::Value pad_const) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(padding)>(padding), std::forward<decltype(pad_const)>(pad_const));
|
|
}
|
|
|
|
void PadOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 3u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
PadOp PadOp::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<PadOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
PadOp PadOp::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 PadOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
|
|
assert(operands.size() == 3u && "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);
|
|
}
|
|
|
|
PadOp PadOp::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<PadOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
PadOp PadOp::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 PadOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps2(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps27(*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_TosaOps5(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult PadOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult PadOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void PadOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void PadOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
PadOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
PadOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return PadOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::PadOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::PowOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
PowOpGenericAdaptorBase::PowOpGenericAdaptorBase(PowOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
PowOpAdaptor::PowOpAdaptor(PowOp op) : PowOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult PowOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult PowOp::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 PowOp::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 PowOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> PowOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void PowOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void PowOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult PowOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void PowOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
PowOp PowOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<PowOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
PowOp PowOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void PowOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
PowOp PowOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<PowOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
PowOp PowOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void PowOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
PowOp PowOp::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<PowOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
PowOp PowOp::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 PowOp::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);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
PowOp PowOp::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<PowOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
PowOp PowOp::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 PowOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*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_TosaOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult PowOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult PowOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void PowOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void PowOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::PowOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::RFFT2dOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
RFFT2dOpGenericAdaptorBase::RFFT2dOpGenericAdaptorBase(RFFT2dOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::mlir::BoolAttr RFFT2dOpGenericAdaptorBase::getLocalBoundAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().local_bound);
|
|
if (!attr)
|
|
attr = ::mlir::Builder(odsAttrs.getContext()).getBoolAttr(false);
|
|
return attr;
|
|
}
|
|
|
|
bool RFFT2dOpGenericAdaptorBase::getLocalBound() {
|
|
auto attr = getLocalBoundAttr();
|
|
if (!attr)
|
|
return ::mlir::Builder(odsAttrs.getContext()).getBoolAttr(false).getValue();
|
|
return attr.getValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
RFFT2dOpAdaptor::RFFT2dOpAdaptor(RFFT2dOp op) : RFFT2dOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult RFFT2dOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_local_bound = getProperties().local_bound; (void)tblgen_local_bound;
|
|
|
|
if (tblgen_local_bound && !((::llvm::isa<::mlir::BoolAttr>(tblgen_local_bound))))
|
|
return emitError(loc, "'tosa.rfft2d' op attribute 'local_bound' failed to satisfy constraint: bool attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void RFFT2dOp::getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn) {
|
|
auto resultGroup0 = getODSResults(0);
|
|
if (!resultGroup0.empty())
|
|
setNameFn(*resultGroup0.begin(), "output_real");
|
|
auto resultGroup1 = getODSResults(1);
|
|
if (!resultGroup1.empty())
|
|
setNameFn(*resultGroup1.begin(), "output_imag");
|
|
}
|
|
|
|
::llvm::LogicalResult RFFT2dOp::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.local_bound;
|
|
auto attr = dict.get("local_bound");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `local_bound` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute RFFT2dOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.local_bound;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("local_bound",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code RFFT2dOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.local_bound.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> RFFT2dOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "local_bound")
|
|
return prop.local_bound;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void RFFT2dOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "local_bound") {
|
|
prop.local_bound = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.local_bound)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void RFFT2dOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.local_bound) attrs.append("local_bound", prop.local_bound);
|
|
}
|
|
|
|
::llvm::LogicalResult RFFT2dOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getLocalBoundAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps4(attr, "local_bound", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult RFFT2dOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.local_bound)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void RFFT2dOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.local_bound);
|
|
}
|
|
|
|
bool RFFT2dOp::getLocalBound() {
|
|
auto attr = getLocalBoundAttr();
|
|
if (!attr)
|
|
return ::mlir::Builder((*this)->getContext()).getBoolAttr(false).getValue();
|
|
return attr.getValue();
|
|
}
|
|
|
|
void RFFT2dOp::setLocalBound(::std::optional<bool> attrValue) {
|
|
auto &odsProp = getProperties().local_bound;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getBoolAttr(*attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void RFFT2dOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output_real, ::mlir::Type output_imag, ::mlir::Value input_real, /*optional*/::mlir::BoolAttr local_bound) {
|
|
odsState.addOperands(input_real);
|
|
if (local_bound) {
|
|
odsState.getOrAddProperties<Properties>().local_bound = local_bound;
|
|
}
|
|
odsState.addTypes(output_real);
|
|
odsState.addTypes(output_imag);
|
|
}
|
|
|
|
RFFT2dOp RFFT2dOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output_real, ::mlir::Type output_imag, ::mlir::Value input_real, /*optional*/::mlir::BoolAttr local_bound) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output_real)>(output_real), std::forward<decltype(output_imag)>(output_imag), std::forward<decltype(input_real)>(input_real), std::forward<decltype(local_bound)>(local_bound));
|
|
auto __res__ = ::llvm::dyn_cast<RFFT2dOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
RFFT2dOp RFFT2dOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output_real, ::mlir::Type output_imag, ::mlir::Value input_real, /*optional*/::mlir::BoolAttr local_bound) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output_real)>(output_real), std::forward<decltype(output_imag)>(output_imag), std::forward<decltype(input_real)>(input_real), std::forward<decltype(local_bound)>(local_bound));
|
|
}
|
|
|
|
void RFFT2dOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input_real, /*optional*/::mlir::BoolAttr local_bound) {
|
|
odsState.addOperands(input_real);
|
|
if (local_bound) {
|
|
odsState.getOrAddProperties<Properties>().local_bound = local_bound;
|
|
}
|
|
assert(resultTypes.size() == 2u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
RFFT2dOp RFFT2dOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input_real, /*optional*/::mlir::BoolAttr local_bound) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input_real)>(input_real), std::forward<decltype(local_bound)>(local_bound));
|
|
auto __res__ = ::llvm::dyn_cast<RFFT2dOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
RFFT2dOp RFFT2dOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input_real, /*optional*/::mlir::BoolAttr local_bound) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input_real)>(input_real), std::forward<decltype(local_bound)>(local_bound));
|
|
}
|
|
|
|
void RFFT2dOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output_real, ::mlir::Type output_imag, ::mlir::Value input_real, /*optional*/bool local_bound) {
|
|
odsState.addOperands(input_real);
|
|
odsState.getOrAddProperties<Properties>().local_bound = odsBuilder.getBoolAttr(local_bound);
|
|
odsState.addTypes(output_real);
|
|
odsState.addTypes(output_imag);
|
|
}
|
|
|
|
RFFT2dOp RFFT2dOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output_real, ::mlir::Type output_imag, ::mlir::Value input_real, /*optional*/bool local_bound) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output_real)>(output_real), std::forward<decltype(output_imag)>(output_imag), std::forward<decltype(input_real)>(input_real), std::forward<decltype(local_bound)>(local_bound));
|
|
auto __res__ = ::llvm::dyn_cast<RFFT2dOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
RFFT2dOp RFFT2dOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output_real, ::mlir::Type output_imag, ::mlir::Value input_real, /*optional*/bool local_bound) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output_real)>(output_real), std::forward<decltype(output_imag)>(output_imag), std::forward<decltype(input_real)>(input_real), std::forward<decltype(local_bound)>(local_bound));
|
|
}
|
|
|
|
void RFFT2dOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input_real, /*optional*/bool local_bound) {
|
|
odsState.addOperands(input_real);
|
|
odsState.getOrAddProperties<Properties>().local_bound = odsBuilder.getBoolAttr(local_bound);
|
|
assert(resultTypes.size() == 2u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
RFFT2dOp RFFT2dOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input_real, /*optional*/bool local_bound) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input_real)>(input_real), std::forward<decltype(local_bound)>(local_bound));
|
|
auto __res__ = ::llvm::dyn_cast<RFFT2dOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
RFFT2dOp RFFT2dOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input_real, /*optional*/bool local_bound) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input_real)>(input_real), std::forward<decltype(local_bound)>(local_bound));
|
|
}
|
|
|
|
void RFFT2dOp::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() == 2u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<RFFT2dOp::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.");
|
|
}
|
|
}
|
|
|
|
RFFT2dOp RFFT2dOp::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<RFFT2dOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
RFFT2dOp RFFT2dOp::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 RFFT2dOp::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() == 2u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
RFFT2dOp RFFT2dOp::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<RFFT2dOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
RFFT2dOp RFFT2dOp::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 RFFT2dOp::verifyInvariantsImpl() {
|
|
auto tblgen_local_bound = getProperties().local_bound; (void)tblgen_local_bound;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps4(*this, tblgen_local_bound, "local_bound")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps21(*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_TosaOps21(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSResults(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps21(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult RFFT2dOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult RFFT2dOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void RFFT2dOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getLocalBoundAttr();
|
|
if(attr && (attr == odsBuilder.getBoolAttr(false)))
|
|
elidedAttrs.push_back("local_bound");
|
|
}
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void RFFT2dOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
RFFT2dOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
RFFT2dOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return RFFT2dOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::RFFT2dOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::RFFT2dOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::ReciprocalOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
ReciprocalOpGenericAdaptorBase::ReciprocalOpGenericAdaptorBase(ReciprocalOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
ReciprocalOpAdaptor::ReciprocalOpAdaptor(ReciprocalOp op) : ReciprocalOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult ReciprocalOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ReciprocalOp::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 ReciprocalOp::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 ReciprocalOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> ReciprocalOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void ReciprocalOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void ReciprocalOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult ReciprocalOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ReciprocalOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1) {
|
|
odsState.addOperands(input1);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ReciprocalOp ReciprocalOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1));
|
|
auto __res__ = ::llvm::dyn_cast<ReciprocalOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReciprocalOp ReciprocalOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1));
|
|
}
|
|
|
|
void ReciprocalOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
odsState.addOperands(input1);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ReciprocalOp ReciprocalOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1));
|
|
auto __res__ = ::llvm::dyn_cast<ReciprocalOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReciprocalOp ReciprocalOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1));
|
|
}
|
|
|
|
void ReciprocalOp::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);
|
|
}
|
|
|
|
ReciprocalOp ReciprocalOp::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<ReciprocalOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReciprocalOp ReciprocalOp::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 ReciprocalOp::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);
|
|
}
|
|
|
|
ReciprocalOp ReciprocalOp::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<ReciprocalOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReciprocalOp ReciprocalOp::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 ReciprocalOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*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_TosaOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ReciprocalOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult ReciprocalOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ReciprocalOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void ReciprocalOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::ReciprocalOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::ReduceAllOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
ReduceAllOpGenericAdaptorBase::ReduceAllOpGenericAdaptorBase(ReduceAllOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
uint32_t ReduceAllOpGenericAdaptorBase::getAxis() {
|
|
auto attr = getAxisAttr();
|
|
return attr.getValue().getZExtValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
ReduceAllOpAdaptor::ReduceAllOpAdaptor(ReduceAllOp op) : ReduceAllOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult ReduceAllOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_axis = getProperties().axis; (void)tblgen_axis;
|
|
if (!tblgen_axis) return emitError(loc, "'tosa.reduce_all' op requires attribute 'axis'");
|
|
|
|
if (tblgen_axis && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_axis))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_axis).getType().isSignlessInteger(32)))))
|
|
return emitError(loc, "'tosa.reduce_all' op attribute 'axis' failed to satisfy constraint: 32-bit signless integer attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ReduceAllOp::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.axis;
|
|
auto attr = dict.get("axis");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `axis` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute ReduceAllOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.axis;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("axis",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code ReduceAllOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.axis.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> ReduceAllOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "axis")
|
|
return prop.axis;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void ReduceAllOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "axis") {
|
|
prop.axis = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.axis)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void ReduceAllOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.axis) attrs.append("axis", prop.axis);
|
|
}
|
|
|
|
::llvm::LogicalResult ReduceAllOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getAxisAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps2(attr, "axis", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ReduceAllOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.axis)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ReduceAllOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.axis);
|
|
}
|
|
|
|
uint32_t ReduceAllOp::getAxis() {
|
|
auto attr = getAxisAttr();
|
|
return attr.getValue().getZExtValue();
|
|
}
|
|
|
|
void ReduceAllOp::setAxis(uint32_t attrValue) {
|
|
getProperties().axis = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), attrValue);
|
|
}
|
|
|
|
void ReduceAllOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = axis;
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ReduceAllOp ReduceAllOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceAllOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceAllOp ReduceAllOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void ReduceAllOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = axis;
|
|
|
|
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
|
|
if (::mlir::succeeded(ReduceAllOp::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);
|
|
|
|
}
|
|
|
|
ReduceAllOp ReduceAllOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceAllOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceAllOp ReduceAllOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void ReduceAllOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = axis;
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ReduceAllOp ReduceAllOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceAllOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceAllOp ReduceAllOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void ReduceAllOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, uint32_t axis) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), axis);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ReduceAllOp ReduceAllOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, uint32_t axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceAllOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceAllOp ReduceAllOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, uint32_t axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void ReduceAllOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value input, uint32_t axis) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), axis);
|
|
|
|
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
|
|
if (::mlir::succeeded(ReduceAllOp::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);
|
|
|
|
}
|
|
|
|
ReduceAllOp ReduceAllOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value input, uint32_t axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceAllOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceAllOp ReduceAllOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value input, uint32_t axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void ReduceAllOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, uint32_t axis) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), axis);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ReduceAllOp ReduceAllOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, uint32_t axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceAllOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceAllOp ReduceAllOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, uint32_t axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void ReduceAllOp::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<ReduceAllOp::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.");
|
|
}
|
|
}
|
|
|
|
ReduceAllOp ReduceAllOp::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<ReduceAllOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceAllOp ReduceAllOp::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 ReduceAllOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 1u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<ReduceAllOp::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(ReduceAllOp::inferReturnTypes(odsBuilder.getContext(),
|
|
odsState.location, operands,
|
|
odsState.attributes.getDictionary(odsState.getContext()),
|
|
odsState.getRawProperties(),
|
|
odsState.regions, inferredReturnTypes))) {
|
|
assert(inferredReturnTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(inferredReturnTypes);
|
|
} else {
|
|
::llvm::report_fatal_error("Failed to infer result type(s).");
|
|
}
|
|
}
|
|
|
|
ReduceAllOp ReduceAllOp::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<ReduceAllOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceAllOp ReduceAllOp::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 ReduceAllOp::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);
|
|
}
|
|
|
|
ReduceAllOp ReduceAllOp::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<ReduceAllOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceAllOp ReduceAllOp::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 ReduceAllOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::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);
|
|
|
|
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
|
|
if (::mlir::succeeded(ReduceAllOp::inferReturnTypes(odsBuilder.getContext(),
|
|
odsState.location, operands,
|
|
odsState.attributes.getDictionary(odsState.getContext()),
|
|
odsState.getRawProperties(),
|
|
odsState.regions, inferredReturnTypes))) {
|
|
assert(inferredReturnTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(inferredReturnTypes);
|
|
} else {
|
|
::llvm::report_fatal_error("Failed to infer result type(s).");
|
|
}
|
|
}
|
|
|
|
ReduceAllOp ReduceAllOp::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<ReduceAllOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceAllOp ReduceAllOp::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 ReduceAllOp::verifyInvariantsImpl() {
|
|
auto tblgen_axis = getProperties().axis; (void)tblgen_axis;
|
|
if (!tblgen_axis) return emitOpError("requires attribute 'axis'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps2(*this, tblgen_axis, "axis")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps5(*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_TosaOps5(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ReduceAllOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult ReduceAllOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ReduceAllOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void ReduceAllOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
ReduceAllOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
ReduceAllOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return ReduceAllOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
LogicalResult
|
|
ReduceAllOp::inferReturnTypes(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) {
|
|
SmallVector<ShapedTypeComponents, 2> retComponents;
|
|
if (failed(ReduceAllOp::inferReturnTypeComponents(context, location,
|
|
operands, attributes, properties, regions,
|
|
retComponents)))
|
|
return failure();
|
|
return ::mlir::detail::inferReturnTensorTypes(retComponents,
|
|
inferredReturnTypes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::ReduceAllOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::ReduceAllOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::ReduceAnyOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
ReduceAnyOpGenericAdaptorBase::ReduceAnyOpGenericAdaptorBase(ReduceAnyOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
uint32_t ReduceAnyOpGenericAdaptorBase::getAxis() {
|
|
auto attr = getAxisAttr();
|
|
return attr.getValue().getZExtValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
ReduceAnyOpAdaptor::ReduceAnyOpAdaptor(ReduceAnyOp op) : ReduceAnyOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult ReduceAnyOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_axis = getProperties().axis; (void)tblgen_axis;
|
|
if (!tblgen_axis) return emitError(loc, "'tosa.reduce_any' op requires attribute 'axis'");
|
|
|
|
if (tblgen_axis && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_axis))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_axis).getType().isSignlessInteger(32)))))
|
|
return emitError(loc, "'tosa.reduce_any' op attribute 'axis' failed to satisfy constraint: 32-bit signless integer attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ReduceAnyOp::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.axis;
|
|
auto attr = dict.get("axis");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `axis` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute ReduceAnyOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.axis;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("axis",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code ReduceAnyOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.axis.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> ReduceAnyOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "axis")
|
|
return prop.axis;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void ReduceAnyOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "axis") {
|
|
prop.axis = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.axis)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void ReduceAnyOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.axis) attrs.append("axis", prop.axis);
|
|
}
|
|
|
|
::llvm::LogicalResult ReduceAnyOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getAxisAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps2(attr, "axis", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ReduceAnyOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.axis)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ReduceAnyOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.axis);
|
|
}
|
|
|
|
uint32_t ReduceAnyOp::getAxis() {
|
|
auto attr = getAxisAttr();
|
|
return attr.getValue().getZExtValue();
|
|
}
|
|
|
|
void ReduceAnyOp::setAxis(uint32_t attrValue) {
|
|
getProperties().axis = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), attrValue);
|
|
}
|
|
|
|
void ReduceAnyOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = axis;
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ReduceAnyOp ReduceAnyOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceAnyOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceAnyOp ReduceAnyOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void ReduceAnyOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = axis;
|
|
|
|
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
|
|
if (::mlir::succeeded(ReduceAnyOp::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);
|
|
|
|
}
|
|
|
|
ReduceAnyOp ReduceAnyOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceAnyOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceAnyOp ReduceAnyOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void ReduceAnyOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = axis;
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ReduceAnyOp ReduceAnyOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceAnyOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceAnyOp ReduceAnyOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void ReduceAnyOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, uint32_t axis) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), axis);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ReduceAnyOp ReduceAnyOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, uint32_t axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceAnyOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceAnyOp ReduceAnyOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, uint32_t axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void ReduceAnyOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value input, uint32_t axis) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), axis);
|
|
|
|
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
|
|
if (::mlir::succeeded(ReduceAnyOp::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);
|
|
|
|
}
|
|
|
|
ReduceAnyOp ReduceAnyOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value input, uint32_t axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceAnyOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceAnyOp ReduceAnyOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value input, uint32_t axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void ReduceAnyOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, uint32_t axis) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), axis);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ReduceAnyOp ReduceAnyOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, uint32_t axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceAnyOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceAnyOp ReduceAnyOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, uint32_t axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void ReduceAnyOp::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<ReduceAnyOp::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.");
|
|
}
|
|
}
|
|
|
|
ReduceAnyOp ReduceAnyOp::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<ReduceAnyOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceAnyOp ReduceAnyOp::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 ReduceAnyOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 1u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<ReduceAnyOp::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(ReduceAnyOp::inferReturnTypes(odsBuilder.getContext(),
|
|
odsState.location, operands,
|
|
odsState.attributes.getDictionary(odsState.getContext()),
|
|
odsState.getRawProperties(),
|
|
odsState.regions, inferredReturnTypes))) {
|
|
assert(inferredReturnTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(inferredReturnTypes);
|
|
} else {
|
|
::llvm::report_fatal_error("Failed to infer result type(s).");
|
|
}
|
|
}
|
|
|
|
ReduceAnyOp ReduceAnyOp::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<ReduceAnyOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceAnyOp ReduceAnyOp::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 ReduceAnyOp::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);
|
|
}
|
|
|
|
ReduceAnyOp ReduceAnyOp::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<ReduceAnyOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceAnyOp ReduceAnyOp::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 ReduceAnyOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::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);
|
|
|
|
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
|
|
if (::mlir::succeeded(ReduceAnyOp::inferReturnTypes(odsBuilder.getContext(),
|
|
odsState.location, operands,
|
|
odsState.attributes.getDictionary(odsState.getContext()),
|
|
odsState.getRawProperties(),
|
|
odsState.regions, inferredReturnTypes))) {
|
|
assert(inferredReturnTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(inferredReturnTypes);
|
|
} else {
|
|
::llvm::report_fatal_error("Failed to infer result type(s).");
|
|
}
|
|
}
|
|
|
|
ReduceAnyOp ReduceAnyOp::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<ReduceAnyOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceAnyOp ReduceAnyOp::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 ReduceAnyOp::verifyInvariantsImpl() {
|
|
auto tblgen_axis = getProperties().axis; (void)tblgen_axis;
|
|
if (!tblgen_axis) return emitOpError("requires attribute 'axis'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps2(*this, tblgen_axis, "axis")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps5(*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_TosaOps5(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ReduceAnyOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult ReduceAnyOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ReduceAnyOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void ReduceAnyOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
ReduceAnyOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
ReduceAnyOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return ReduceAnyOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
LogicalResult
|
|
ReduceAnyOp::inferReturnTypes(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) {
|
|
SmallVector<ShapedTypeComponents, 2> retComponents;
|
|
if (failed(ReduceAnyOp::inferReturnTypeComponents(context, location,
|
|
operands, attributes, properties, regions,
|
|
retComponents)))
|
|
return failure();
|
|
return ::mlir::detail::inferReturnTensorTypes(retComponents,
|
|
inferredReturnTypes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::ReduceAnyOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::ReduceAnyOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::ReduceMaxOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
ReduceMaxOpGenericAdaptorBase::ReduceMaxOpGenericAdaptorBase(ReduceMaxOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
uint32_t ReduceMaxOpGenericAdaptorBase::getAxis() {
|
|
auto attr = getAxisAttr();
|
|
return attr.getValue().getZExtValue();
|
|
}
|
|
|
|
mlir::tosa::NanPropagationModeAttr ReduceMaxOpGenericAdaptorBase::getNanModeAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<mlir::tosa::NanPropagationModeAttr>(getProperties().nan_mode);
|
|
return attr;
|
|
}
|
|
|
|
::mlir::tosa::NanPropagationMode ReduceMaxOpGenericAdaptorBase::getNanMode() {
|
|
auto attr = getNanModeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
ReduceMaxOpAdaptor::ReduceMaxOpAdaptor(ReduceMaxOp op) : ReduceMaxOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult ReduceMaxOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_axis = getProperties().axis; (void)tblgen_axis;
|
|
if (!tblgen_axis) return emitError(loc, "'tosa.reduce_max' op requires attribute 'axis'");
|
|
auto tblgen_nan_mode = getProperties().nan_mode; (void)tblgen_nan_mode;
|
|
|
|
if (tblgen_axis && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_axis))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_axis).getType().isSignlessInteger(32)))))
|
|
return emitError(loc, "'tosa.reduce_max' op attribute 'axis' failed to satisfy constraint: 32-bit signless integer attribute");
|
|
|
|
if (tblgen_nan_mode && !((::llvm::isa<mlir::tosa::NanPropagationModeAttr>(tblgen_nan_mode))))
|
|
return emitError(loc, "'tosa.reduce_max' op attribute 'nan_mode' failed to satisfy constraint: Supported NaN propagation strategies");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ReduceMaxOp::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.axis;
|
|
auto attr = dict.get("axis");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `axis` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.nan_mode;
|
|
auto attr = dict.get("nan_mode");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `nan_mode` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute ReduceMaxOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.axis;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("axis",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.nan_mode;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("nan_mode",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code ReduceMaxOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.axis.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.nan_mode.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> ReduceMaxOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "axis")
|
|
return prop.axis;
|
|
|
|
if (name == "nan_mode")
|
|
return prop.nan_mode;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void ReduceMaxOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "axis") {
|
|
prop.axis = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.axis)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "nan_mode") {
|
|
prop.nan_mode = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.nan_mode)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void ReduceMaxOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.axis) attrs.append("axis", prop.axis);
|
|
|
|
if (prop.nan_mode) attrs.append("nan_mode", prop.nan_mode);
|
|
}
|
|
|
|
::llvm::LogicalResult ReduceMaxOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getAxisAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps2(attr, "axis", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getNanModeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps3(attr, "nan_mode", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ReduceMaxOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.axis)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.nan_mode)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ReduceMaxOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.axis);
|
|
|
|
writer.writeOptionalAttribute(prop.nan_mode);
|
|
}
|
|
|
|
uint32_t ReduceMaxOp::getAxis() {
|
|
auto attr = getAxisAttr();
|
|
return attr.getValue().getZExtValue();
|
|
}
|
|
|
|
::mlir::tosa::NanPropagationMode ReduceMaxOp::getNanMode() {
|
|
auto attr = getNanModeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
void ReduceMaxOp::setAxis(uint32_t attrValue) {
|
|
getProperties().axis = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), attrValue);
|
|
}
|
|
|
|
void ReduceMaxOp::setNanMode(::mlir::tosa::NanPropagationMode attrValue) {
|
|
getProperties().nan_mode = ::mlir::tosa::NanPropagationModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue);
|
|
}
|
|
|
|
void ReduceMaxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, ::mlir::IntegerAttr axis, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = axis;
|
|
if (nan_mode) {
|
|
odsState.getOrAddProperties<Properties>().nan_mode = nan_mode;
|
|
}
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ReduceMaxOp ReduceMaxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, ::mlir::IntegerAttr axis, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceMaxOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceMaxOp ReduceMaxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, ::mlir::IntegerAttr axis, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void ReduceMaxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value input, ::mlir::IntegerAttr axis, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = axis;
|
|
if (nan_mode) {
|
|
odsState.getOrAddProperties<Properties>().nan_mode = nan_mode;
|
|
}
|
|
|
|
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
|
|
if (::mlir::succeeded(ReduceMaxOp::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);
|
|
|
|
}
|
|
|
|
ReduceMaxOp ReduceMaxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value input, ::mlir::IntegerAttr axis, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceMaxOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceMaxOp ReduceMaxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value input, ::mlir::IntegerAttr axis, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void ReduceMaxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::IntegerAttr axis, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = axis;
|
|
if (nan_mode) {
|
|
odsState.getOrAddProperties<Properties>().nan_mode = nan_mode;
|
|
}
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ReduceMaxOp ReduceMaxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::IntegerAttr axis, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceMaxOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceMaxOp ReduceMaxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::IntegerAttr axis, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void ReduceMaxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, uint32_t axis, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), axis);
|
|
odsState.getOrAddProperties<Properties>().nan_mode = ::mlir::tosa::NanPropagationModeAttr::get(odsBuilder.getContext(), nan_mode);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ReduceMaxOp ReduceMaxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, uint32_t axis, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceMaxOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceMaxOp ReduceMaxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, uint32_t axis, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void ReduceMaxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value input, uint32_t axis, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), axis);
|
|
odsState.getOrAddProperties<Properties>().nan_mode = ::mlir::tosa::NanPropagationModeAttr::get(odsBuilder.getContext(), nan_mode);
|
|
|
|
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
|
|
if (::mlir::succeeded(ReduceMaxOp::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);
|
|
|
|
}
|
|
|
|
ReduceMaxOp ReduceMaxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value input, uint32_t axis, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceMaxOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceMaxOp ReduceMaxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value input, uint32_t axis, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void ReduceMaxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, uint32_t axis, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), axis);
|
|
odsState.getOrAddProperties<Properties>().nan_mode = ::mlir::tosa::NanPropagationModeAttr::get(odsBuilder.getContext(), nan_mode);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ReduceMaxOp ReduceMaxOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, uint32_t axis, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceMaxOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceMaxOp ReduceMaxOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, uint32_t axis, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void ReduceMaxOp::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<ReduceMaxOp::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.");
|
|
}
|
|
}
|
|
|
|
ReduceMaxOp ReduceMaxOp::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<ReduceMaxOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceMaxOp ReduceMaxOp::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 ReduceMaxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 1u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<ReduceMaxOp::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(ReduceMaxOp::inferReturnTypes(odsBuilder.getContext(),
|
|
odsState.location, operands,
|
|
odsState.attributes.getDictionary(odsState.getContext()),
|
|
odsState.getRawProperties(),
|
|
odsState.regions, inferredReturnTypes))) {
|
|
assert(inferredReturnTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(inferredReturnTypes);
|
|
} else {
|
|
::llvm::report_fatal_error("Failed to infer result type(s).");
|
|
}
|
|
}
|
|
|
|
ReduceMaxOp ReduceMaxOp::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<ReduceMaxOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceMaxOp ReduceMaxOp::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 ReduceMaxOp::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);
|
|
}
|
|
|
|
ReduceMaxOp ReduceMaxOp::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<ReduceMaxOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceMaxOp ReduceMaxOp::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 ReduceMaxOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::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);
|
|
|
|
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
|
|
if (::mlir::succeeded(ReduceMaxOp::inferReturnTypes(odsBuilder.getContext(),
|
|
odsState.location, operands,
|
|
odsState.attributes.getDictionary(odsState.getContext()),
|
|
odsState.getRawProperties(),
|
|
odsState.regions, inferredReturnTypes))) {
|
|
assert(inferredReturnTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(inferredReturnTypes);
|
|
} else {
|
|
::llvm::report_fatal_error("Failed to infer result type(s).");
|
|
}
|
|
}
|
|
|
|
ReduceMaxOp ReduceMaxOp::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<ReduceMaxOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceMaxOp ReduceMaxOp::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));
|
|
}
|
|
|
|
void ReduceMaxOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) {
|
|
::mlir::Builder odsBuilder(opName.getContext());
|
|
if (!properties.nan_mode)
|
|
properties.nan_mode = ::mlir::tosa::NanPropagationModeAttr::get(odsBuilder.getContext(), ::mlir::tosa::NanPropagationMode::PROPAGATE);
|
|
}
|
|
|
|
::llvm::LogicalResult ReduceMaxOp::verifyInvariantsImpl() {
|
|
auto tblgen_axis = getProperties().axis; (void)tblgen_axis;
|
|
if (!tblgen_axis) return emitOpError("requires attribute 'axis'");
|
|
auto tblgen_nan_mode = getProperties().nan_mode; (void)tblgen_nan_mode;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps2(*this, tblgen_axis, "axis")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps3(*this, tblgen_nan_mode, "nan_mode")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps5(*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_TosaOps5(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ReduceMaxOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::llvm::LogicalResult ReduceMaxOp::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.axis;
|
|
auto axisAttrName = ::mlir::StringAttr::get(ctx, "axis");
|
|
auto attr = dict.get(axisAttrName);
|
|
usedKeys.insert(axisAttrName);
|
|
if (attr || /*isRequired=*/true) {
|
|
if (!attr) {
|
|
emitError() << "expected key entry for axis 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 `axis` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
{
|
|
|
|
auto &propStorage = prop.nan_mode;
|
|
auto nan_modeAttrName = ::mlir::StringAttr::get(ctx, "nan_mode");
|
|
auto attr = dict.get(nan_modeAttrName);
|
|
usedKeys.insert(nan_modeAttrName);
|
|
if (attr || /*isRequired=*/false) {
|
|
if (!attr) {
|
|
emitError() << "expected key entry for nan_mode 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 `nan_mode` 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();
|
|
}
|
|
|
|
void ReduceMaxOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
ReduceMaxOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
ReduceMaxOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return ReduceMaxOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
LogicalResult
|
|
ReduceMaxOp::inferReturnTypes(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) {
|
|
SmallVector<ShapedTypeComponents, 2> retComponents;
|
|
if (failed(ReduceMaxOp::inferReturnTypeComponents(context, location,
|
|
operands, attributes, properties, regions,
|
|
retComponents)))
|
|
return failure();
|
|
return ::mlir::detail::inferReturnTensorTypes(retComponents,
|
|
inferredReturnTypes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::ReduceMaxOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::ReduceMaxOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::ReduceMinOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
ReduceMinOpGenericAdaptorBase::ReduceMinOpGenericAdaptorBase(ReduceMinOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
uint32_t ReduceMinOpGenericAdaptorBase::getAxis() {
|
|
auto attr = getAxisAttr();
|
|
return attr.getValue().getZExtValue();
|
|
}
|
|
|
|
mlir::tosa::NanPropagationModeAttr ReduceMinOpGenericAdaptorBase::getNanModeAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<mlir::tosa::NanPropagationModeAttr>(getProperties().nan_mode);
|
|
return attr;
|
|
}
|
|
|
|
::mlir::tosa::NanPropagationMode ReduceMinOpGenericAdaptorBase::getNanMode() {
|
|
auto attr = getNanModeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
ReduceMinOpAdaptor::ReduceMinOpAdaptor(ReduceMinOp op) : ReduceMinOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult ReduceMinOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_axis = getProperties().axis; (void)tblgen_axis;
|
|
if (!tblgen_axis) return emitError(loc, "'tosa.reduce_min' op requires attribute 'axis'");
|
|
auto tblgen_nan_mode = getProperties().nan_mode; (void)tblgen_nan_mode;
|
|
|
|
if (tblgen_axis && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_axis))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_axis).getType().isSignlessInteger(32)))))
|
|
return emitError(loc, "'tosa.reduce_min' op attribute 'axis' failed to satisfy constraint: 32-bit signless integer attribute");
|
|
|
|
if (tblgen_nan_mode && !((::llvm::isa<mlir::tosa::NanPropagationModeAttr>(tblgen_nan_mode))))
|
|
return emitError(loc, "'tosa.reduce_min' op attribute 'nan_mode' failed to satisfy constraint: Supported NaN propagation strategies");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ReduceMinOp::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.axis;
|
|
auto attr = dict.get("axis");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `axis` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.nan_mode;
|
|
auto attr = dict.get("nan_mode");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `nan_mode` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute ReduceMinOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.axis;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("axis",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.nan_mode;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("nan_mode",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code ReduceMinOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.axis.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.nan_mode.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> ReduceMinOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "axis")
|
|
return prop.axis;
|
|
|
|
if (name == "nan_mode")
|
|
return prop.nan_mode;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void ReduceMinOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "axis") {
|
|
prop.axis = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.axis)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "nan_mode") {
|
|
prop.nan_mode = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.nan_mode)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void ReduceMinOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.axis) attrs.append("axis", prop.axis);
|
|
|
|
if (prop.nan_mode) attrs.append("nan_mode", prop.nan_mode);
|
|
}
|
|
|
|
::llvm::LogicalResult ReduceMinOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getAxisAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps2(attr, "axis", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getNanModeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps3(attr, "nan_mode", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ReduceMinOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.axis)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.nan_mode)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ReduceMinOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.axis);
|
|
|
|
writer.writeOptionalAttribute(prop.nan_mode);
|
|
}
|
|
|
|
uint32_t ReduceMinOp::getAxis() {
|
|
auto attr = getAxisAttr();
|
|
return attr.getValue().getZExtValue();
|
|
}
|
|
|
|
::mlir::tosa::NanPropagationMode ReduceMinOp::getNanMode() {
|
|
auto attr = getNanModeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
void ReduceMinOp::setAxis(uint32_t attrValue) {
|
|
getProperties().axis = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), attrValue);
|
|
}
|
|
|
|
void ReduceMinOp::setNanMode(::mlir::tosa::NanPropagationMode attrValue) {
|
|
getProperties().nan_mode = ::mlir::tosa::NanPropagationModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue);
|
|
}
|
|
|
|
void ReduceMinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, ::mlir::IntegerAttr axis, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = axis;
|
|
if (nan_mode) {
|
|
odsState.getOrAddProperties<Properties>().nan_mode = nan_mode;
|
|
}
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ReduceMinOp ReduceMinOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, ::mlir::IntegerAttr axis, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceMinOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceMinOp ReduceMinOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, ::mlir::IntegerAttr axis, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void ReduceMinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value input, ::mlir::IntegerAttr axis, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = axis;
|
|
if (nan_mode) {
|
|
odsState.getOrAddProperties<Properties>().nan_mode = nan_mode;
|
|
}
|
|
|
|
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
|
|
if (::mlir::succeeded(ReduceMinOp::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);
|
|
|
|
}
|
|
|
|
ReduceMinOp ReduceMinOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value input, ::mlir::IntegerAttr axis, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceMinOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceMinOp ReduceMinOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value input, ::mlir::IntegerAttr axis, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void ReduceMinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::IntegerAttr axis, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = axis;
|
|
if (nan_mode) {
|
|
odsState.getOrAddProperties<Properties>().nan_mode = nan_mode;
|
|
}
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ReduceMinOp ReduceMinOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::IntegerAttr axis, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceMinOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceMinOp ReduceMinOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::IntegerAttr axis, mlir::tosa::NanPropagationModeAttr nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void ReduceMinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, uint32_t axis, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), axis);
|
|
odsState.getOrAddProperties<Properties>().nan_mode = ::mlir::tosa::NanPropagationModeAttr::get(odsBuilder.getContext(), nan_mode);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ReduceMinOp ReduceMinOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, uint32_t axis, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceMinOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceMinOp ReduceMinOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, uint32_t axis, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void ReduceMinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value input, uint32_t axis, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), axis);
|
|
odsState.getOrAddProperties<Properties>().nan_mode = ::mlir::tosa::NanPropagationModeAttr::get(odsBuilder.getContext(), nan_mode);
|
|
|
|
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
|
|
if (::mlir::succeeded(ReduceMinOp::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);
|
|
|
|
}
|
|
|
|
ReduceMinOp ReduceMinOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value input, uint32_t axis, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceMinOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceMinOp ReduceMinOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value input, uint32_t axis, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void ReduceMinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, uint32_t axis, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), axis);
|
|
odsState.getOrAddProperties<Properties>().nan_mode = ::mlir::tosa::NanPropagationModeAttr::get(odsBuilder.getContext(), nan_mode);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ReduceMinOp ReduceMinOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, uint32_t axis, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis), std::forward<decltype(nan_mode)>(nan_mode));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceMinOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceMinOp ReduceMinOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, uint32_t axis, ::mlir::tosa::NanPropagationMode nan_mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis), std::forward<decltype(nan_mode)>(nan_mode));
|
|
}
|
|
|
|
void ReduceMinOp::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<ReduceMinOp::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.");
|
|
}
|
|
}
|
|
|
|
ReduceMinOp ReduceMinOp::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<ReduceMinOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceMinOp ReduceMinOp::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 ReduceMinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 1u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<ReduceMinOp::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(ReduceMinOp::inferReturnTypes(odsBuilder.getContext(),
|
|
odsState.location, operands,
|
|
odsState.attributes.getDictionary(odsState.getContext()),
|
|
odsState.getRawProperties(),
|
|
odsState.regions, inferredReturnTypes))) {
|
|
assert(inferredReturnTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(inferredReturnTypes);
|
|
} else {
|
|
::llvm::report_fatal_error("Failed to infer result type(s).");
|
|
}
|
|
}
|
|
|
|
ReduceMinOp ReduceMinOp::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<ReduceMinOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceMinOp ReduceMinOp::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 ReduceMinOp::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);
|
|
}
|
|
|
|
ReduceMinOp ReduceMinOp::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<ReduceMinOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceMinOp ReduceMinOp::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 ReduceMinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::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);
|
|
|
|
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
|
|
if (::mlir::succeeded(ReduceMinOp::inferReturnTypes(odsBuilder.getContext(),
|
|
odsState.location, operands,
|
|
odsState.attributes.getDictionary(odsState.getContext()),
|
|
odsState.getRawProperties(),
|
|
odsState.regions, inferredReturnTypes))) {
|
|
assert(inferredReturnTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(inferredReturnTypes);
|
|
} else {
|
|
::llvm::report_fatal_error("Failed to infer result type(s).");
|
|
}
|
|
}
|
|
|
|
ReduceMinOp ReduceMinOp::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<ReduceMinOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceMinOp ReduceMinOp::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));
|
|
}
|
|
|
|
void ReduceMinOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) {
|
|
::mlir::Builder odsBuilder(opName.getContext());
|
|
if (!properties.nan_mode)
|
|
properties.nan_mode = ::mlir::tosa::NanPropagationModeAttr::get(odsBuilder.getContext(), ::mlir::tosa::NanPropagationMode::PROPAGATE);
|
|
}
|
|
|
|
::llvm::LogicalResult ReduceMinOp::verifyInvariantsImpl() {
|
|
auto tblgen_axis = getProperties().axis; (void)tblgen_axis;
|
|
if (!tblgen_axis) return emitOpError("requires attribute 'axis'");
|
|
auto tblgen_nan_mode = getProperties().nan_mode; (void)tblgen_nan_mode;
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps2(*this, tblgen_axis, "axis")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps3(*this, tblgen_nan_mode, "nan_mode")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps5(*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_TosaOps5(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ReduceMinOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::llvm::LogicalResult ReduceMinOp::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.axis;
|
|
auto axisAttrName = ::mlir::StringAttr::get(ctx, "axis");
|
|
auto attr = dict.get(axisAttrName);
|
|
usedKeys.insert(axisAttrName);
|
|
if (attr || /*isRequired=*/true) {
|
|
if (!attr) {
|
|
emitError() << "expected key entry for axis 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 `axis` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
{
|
|
|
|
auto &propStorage = prop.nan_mode;
|
|
auto nan_modeAttrName = ::mlir::StringAttr::get(ctx, "nan_mode");
|
|
auto attr = dict.get(nan_modeAttrName);
|
|
usedKeys.insert(nan_modeAttrName);
|
|
if (attr || /*isRequired=*/false) {
|
|
if (!attr) {
|
|
emitError() << "expected key entry for nan_mode 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 `nan_mode` 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();
|
|
}
|
|
|
|
void ReduceMinOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
ReduceMinOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
ReduceMinOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return ReduceMinOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
LogicalResult
|
|
ReduceMinOp::inferReturnTypes(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) {
|
|
SmallVector<ShapedTypeComponents, 2> retComponents;
|
|
if (failed(ReduceMinOp::inferReturnTypeComponents(context, location,
|
|
operands, attributes, properties, regions,
|
|
retComponents)))
|
|
return failure();
|
|
return ::mlir::detail::inferReturnTensorTypes(retComponents,
|
|
inferredReturnTypes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::ReduceMinOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::ReduceMinOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::ReduceProductOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
ReduceProductOpGenericAdaptorBase::ReduceProductOpGenericAdaptorBase(ReduceProductOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
uint32_t ReduceProductOpGenericAdaptorBase::getAxis() {
|
|
auto attr = getAxisAttr();
|
|
return attr.getValue().getZExtValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
ReduceProductOpAdaptor::ReduceProductOpAdaptor(ReduceProductOp op) : ReduceProductOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult ReduceProductOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_axis = getProperties().axis; (void)tblgen_axis;
|
|
if (!tblgen_axis) return emitError(loc, "'tosa.reduce_product' op requires attribute 'axis'");
|
|
|
|
if (tblgen_axis && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_axis))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_axis).getType().isSignlessInteger(32)))))
|
|
return emitError(loc, "'tosa.reduce_product' op attribute 'axis' failed to satisfy constraint: 32-bit signless integer attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ReduceProductOp::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.axis;
|
|
auto attr = dict.get("axis");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `axis` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute ReduceProductOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.axis;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("axis",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code ReduceProductOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.axis.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> ReduceProductOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "axis")
|
|
return prop.axis;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void ReduceProductOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "axis") {
|
|
prop.axis = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.axis)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void ReduceProductOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.axis) attrs.append("axis", prop.axis);
|
|
}
|
|
|
|
::llvm::LogicalResult ReduceProductOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getAxisAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps2(attr, "axis", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ReduceProductOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.axis)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ReduceProductOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.axis);
|
|
}
|
|
|
|
uint32_t ReduceProductOp::getAxis() {
|
|
auto attr = getAxisAttr();
|
|
return attr.getValue().getZExtValue();
|
|
}
|
|
|
|
void ReduceProductOp::setAxis(uint32_t attrValue) {
|
|
getProperties().axis = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), attrValue);
|
|
}
|
|
|
|
void ReduceProductOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = axis;
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ReduceProductOp ReduceProductOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceProductOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceProductOp ReduceProductOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void ReduceProductOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = axis;
|
|
|
|
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
|
|
if (::mlir::succeeded(ReduceProductOp::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);
|
|
|
|
}
|
|
|
|
ReduceProductOp ReduceProductOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceProductOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceProductOp ReduceProductOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void ReduceProductOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = axis;
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ReduceProductOp ReduceProductOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceProductOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceProductOp ReduceProductOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void ReduceProductOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, uint32_t axis) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), axis);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ReduceProductOp ReduceProductOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, uint32_t axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceProductOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceProductOp ReduceProductOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, uint32_t axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void ReduceProductOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value input, uint32_t axis) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), axis);
|
|
|
|
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
|
|
if (::mlir::succeeded(ReduceProductOp::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);
|
|
|
|
}
|
|
|
|
ReduceProductOp ReduceProductOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value input, uint32_t axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceProductOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceProductOp ReduceProductOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value input, uint32_t axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void ReduceProductOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, uint32_t axis) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), axis);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ReduceProductOp ReduceProductOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, uint32_t axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceProductOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceProductOp ReduceProductOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, uint32_t axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void ReduceProductOp::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<ReduceProductOp::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.");
|
|
}
|
|
}
|
|
|
|
ReduceProductOp ReduceProductOp::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<ReduceProductOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceProductOp ReduceProductOp::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 ReduceProductOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 1u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<ReduceProductOp::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(ReduceProductOp::inferReturnTypes(odsBuilder.getContext(),
|
|
odsState.location, operands,
|
|
odsState.attributes.getDictionary(odsState.getContext()),
|
|
odsState.getRawProperties(),
|
|
odsState.regions, inferredReturnTypes))) {
|
|
assert(inferredReturnTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(inferredReturnTypes);
|
|
} else {
|
|
::llvm::report_fatal_error("Failed to infer result type(s).");
|
|
}
|
|
}
|
|
|
|
ReduceProductOp ReduceProductOp::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<ReduceProductOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceProductOp ReduceProductOp::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 ReduceProductOp::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);
|
|
}
|
|
|
|
ReduceProductOp ReduceProductOp::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<ReduceProductOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceProductOp ReduceProductOp::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 ReduceProductOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::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);
|
|
|
|
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
|
|
if (::mlir::succeeded(ReduceProductOp::inferReturnTypes(odsBuilder.getContext(),
|
|
odsState.location, operands,
|
|
odsState.attributes.getDictionary(odsState.getContext()),
|
|
odsState.getRawProperties(),
|
|
odsState.regions, inferredReturnTypes))) {
|
|
assert(inferredReturnTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(inferredReturnTypes);
|
|
} else {
|
|
::llvm::report_fatal_error("Failed to infer result type(s).");
|
|
}
|
|
}
|
|
|
|
ReduceProductOp ReduceProductOp::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<ReduceProductOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceProductOp ReduceProductOp::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 ReduceProductOp::verifyInvariantsImpl() {
|
|
auto tblgen_axis = getProperties().axis; (void)tblgen_axis;
|
|
if (!tblgen_axis) return emitOpError("requires attribute 'axis'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps2(*this, tblgen_axis, "axis")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps5(*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_TosaOps5(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ReduceProductOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult ReduceProductOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ReduceProductOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void ReduceProductOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
ReduceProductOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
ReduceProductOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return ReduceProductOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
LogicalResult
|
|
ReduceProductOp::inferReturnTypes(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) {
|
|
SmallVector<ShapedTypeComponents, 2> retComponents;
|
|
if (failed(ReduceProductOp::inferReturnTypeComponents(context, location,
|
|
operands, attributes, properties, regions,
|
|
retComponents)))
|
|
return failure();
|
|
return ::mlir::detail::inferReturnTensorTypes(retComponents,
|
|
inferredReturnTypes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::ReduceProductOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::ReduceProductOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::ReduceSumOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
ReduceSumOpGenericAdaptorBase::ReduceSumOpGenericAdaptorBase(ReduceSumOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
uint32_t ReduceSumOpGenericAdaptorBase::getAxis() {
|
|
auto attr = getAxisAttr();
|
|
return attr.getValue().getZExtValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
ReduceSumOpAdaptor::ReduceSumOpAdaptor(ReduceSumOp op) : ReduceSumOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult ReduceSumOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_axis = getProperties().axis; (void)tblgen_axis;
|
|
if (!tblgen_axis) return emitError(loc, "'tosa.reduce_sum' op requires attribute 'axis'");
|
|
|
|
if (tblgen_axis && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_axis))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_axis).getType().isSignlessInteger(32)))))
|
|
return emitError(loc, "'tosa.reduce_sum' op attribute 'axis' failed to satisfy constraint: 32-bit signless integer attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ReduceSumOp::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.axis;
|
|
auto attr = dict.get("axis");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `axis` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute ReduceSumOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.axis;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("axis",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code ReduceSumOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.axis.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> ReduceSumOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "axis")
|
|
return prop.axis;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void ReduceSumOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "axis") {
|
|
prop.axis = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.axis)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void ReduceSumOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.axis) attrs.append("axis", prop.axis);
|
|
}
|
|
|
|
::llvm::LogicalResult ReduceSumOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getAxisAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps2(attr, "axis", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ReduceSumOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.axis)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ReduceSumOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.axis);
|
|
}
|
|
|
|
uint32_t ReduceSumOp::getAxis() {
|
|
auto attr = getAxisAttr();
|
|
return attr.getValue().getZExtValue();
|
|
}
|
|
|
|
void ReduceSumOp::setAxis(uint32_t attrValue) {
|
|
getProperties().axis = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), attrValue);
|
|
}
|
|
|
|
void ReduceSumOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = axis;
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ReduceSumOp ReduceSumOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceSumOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceSumOp ReduceSumOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void ReduceSumOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = axis;
|
|
|
|
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
|
|
if (::mlir::succeeded(ReduceSumOp::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);
|
|
|
|
}
|
|
|
|
ReduceSumOp ReduceSumOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceSumOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceSumOp ReduceSumOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void ReduceSumOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = axis;
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ReduceSumOp ReduceSumOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceSumOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceSumOp ReduceSumOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::IntegerAttr axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void ReduceSumOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, uint32_t axis) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), axis);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ReduceSumOp ReduceSumOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, uint32_t axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceSumOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceSumOp ReduceSumOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, uint32_t axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void ReduceSumOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value input, uint32_t axis) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), axis);
|
|
|
|
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
|
|
if (::mlir::succeeded(ReduceSumOp::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);
|
|
|
|
}
|
|
|
|
ReduceSumOp ReduceSumOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value input, uint32_t axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceSumOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceSumOp ReduceSumOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value input, uint32_t axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void ReduceSumOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, uint32_t axis) {
|
|
odsState.addOperands(input);
|
|
odsState.getOrAddProperties<Properties>().axis = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), axis);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ReduceSumOp ReduceSumOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, uint32_t axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<ReduceSumOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceSumOp ReduceSumOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, uint32_t axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void ReduceSumOp::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<ReduceSumOp::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.");
|
|
}
|
|
}
|
|
|
|
ReduceSumOp ReduceSumOp::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<ReduceSumOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceSumOp ReduceSumOp::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 ReduceSumOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 1u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<ReduceSumOp::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(ReduceSumOp::inferReturnTypes(odsBuilder.getContext(),
|
|
odsState.location, operands,
|
|
odsState.attributes.getDictionary(odsState.getContext()),
|
|
odsState.getRawProperties(),
|
|
odsState.regions, inferredReturnTypes))) {
|
|
assert(inferredReturnTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(inferredReturnTypes);
|
|
} else {
|
|
::llvm::report_fatal_error("Failed to infer result type(s).");
|
|
}
|
|
}
|
|
|
|
ReduceSumOp ReduceSumOp::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<ReduceSumOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceSumOp ReduceSumOp::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 ReduceSumOp::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);
|
|
}
|
|
|
|
ReduceSumOp ReduceSumOp::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<ReduceSumOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceSumOp ReduceSumOp::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 ReduceSumOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::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);
|
|
|
|
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
|
|
if (::mlir::succeeded(ReduceSumOp::inferReturnTypes(odsBuilder.getContext(),
|
|
odsState.location, operands,
|
|
odsState.attributes.getDictionary(odsState.getContext()),
|
|
odsState.getRawProperties(),
|
|
odsState.regions, inferredReturnTypes))) {
|
|
assert(inferredReturnTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(inferredReturnTypes);
|
|
} else {
|
|
::llvm::report_fatal_error("Failed to infer result type(s).");
|
|
}
|
|
}
|
|
|
|
ReduceSumOp ReduceSumOp::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<ReduceSumOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReduceSumOp ReduceSumOp::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 ReduceSumOp::verifyInvariantsImpl() {
|
|
auto tblgen_axis = getProperties().axis; (void)tblgen_axis;
|
|
if (!tblgen_axis) return emitOpError("requires attribute 'axis'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps2(*this, tblgen_axis, "axis")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps5(*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_TosaOps5(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ReduceSumOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult ReduceSumOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ReduceSumOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void ReduceSumOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
ReduceSumOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
ReduceSumOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return ReduceSumOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
LogicalResult
|
|
ReduceSumOp::inferReturnTypes(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) {
|
|
SmallVector<ShapedTypeComponents, 2> retComponents;
|
|
if (failed(ReduceSumOp::inferReturnTypeComponents(context, location,
|
|
operands, attributes, properties, regions,
|
|
retComponents)))
|
|
return failure();
|
|
return ::mlir::detail::inferReturnTensorTypes(retComponents,
|
|
inferredReturnTypes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::ReduceSumOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::ReduceSumOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::RescaleOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
RescaleOpGenericAdaptorBase::RescaleOpGenericAdaptorBase(RescaleOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
bool RescaleOpGenericAdaptorBase::getScale32() {
|
|
auto attr = getScale32Attr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
::mlir::tosa::RoundingMode RescaleOpGenericAdaptorBase::getRoundingMode() {
|
|
auto attr = getRoundingModeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
bool RescaleOpGenericAdaptorBase::getPerChannel() {
|
|
auto attr = getPerChannelAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
bool RescaleOpGenericAdaptorBase::getInputUnsigned() {
|
|
auto attr = getInputUnsignedAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
bool RescaleOpGenericAdaptorBase::getOutputUnsigned() {
|
|
auto attr = getOutputUnsignedAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
RescaleOpAdaptor::RescaleOpAdaptor(RescaleOp op) : RescaleOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult RescaleOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_input_unsigned = getProperties().input_unsigned; (void)tblgen_input_unsigned;
|
|
if (!tblgen_input_unsigned) return emitError(loc, "'tosa.rescale' op requires attribute 'input_unsigned'");
|
|
auto tblgen_output_unsigned = getProperties().output_unsigned; (void)tblgen_output_unsigned;
|
|
if (!tblgen_output_unsigned) return emitError(loc, "'tosa.rescale' op requires attribute 'output_unsigned'");
|
|
auto tblgen_per_channel = getProperties().per_channel; (void)tblgen_per_channel;
|
|
if (!tblgen_per_channel) return emitError(loc, "'tosa.rescale' op requires attribute 'per_channel'");
|
|
auto tblgen_rounding_mode = getProperties().rounding_mode; (void)tblgen_rounding_mode;
|
|
if (!tblgen_rounding_mode) return emitError(loc, "'tosa.rescale' op requires attribute 'rounding_mode'");
|
|
auto tblgen_scale32 = getProperties().scale32; (void)tblgen_scale32;
|
|
if (!tblgen_scale32) return emitError(loc, "'tosa.rescale' op requires attribute 'scale32'");
|
|
|
|
if (tblgen_scale32 && !((::llvm::isa<::mlir::BoolAttr>(tblgen_scale32))))
|
|
return emitError(loc, "'tosa.rescale' op attribute 'scale32' failed to satisfy constraint: bool attribute");
|
|
|
|
if (tblgen_rounding_mode && !((::llvm::isa<mlir::tosa::RoundingModeAttr>(tblgen_rounding_mode))))
|
|
return emitError(loc, "'tosa.rescale' op attribute 'rounding_mode' failed to satisfy constraint: Supported rounding modes");
|
|
|
|
if (tblgen_per_channel && !((::llvm::isa<::mlir::BoolAttr>(tblgen_per_channel))))
|
|
return emitError(loc, "'tosa.rescale' op attribute 'per_channel' failed to satisfy constraint: bool attribute");
|
|
|
|
if (tblgen_input_unsigned && !((::llvm::isa<::mlir::BoolAttr>(tblgen_input_unsigned))))
|
|
return emitError(loc, "'tosa.rescale' op attribute 'input_unsigned' failed to satisfy constraint: bool attribute");
|
|
|
|
if (tblgen_output_unsigned && !((::llvm::isa<::mlir::BoolAttr>(tblgen_output_unsigned))))
|
|
return emitError(loc, "'tosa.rescale' op attribute 'output_unsigned' failed to satisfy constraint: bool attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult RescaleOp::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.input_unsigned;
|
|
auto attr = dict.get("input_unsigned");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `input_unsigned` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.output_unsigned;
|
|
auto attr = dict.get("output_unsigned");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `output_unsigned` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.per_channel;
|
|
auto attr = dict.get("per_channel");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `per_channel` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.rounding_mode;
|
|
auto attr = dict.get("rounding_mode");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `rounding_mode` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.scale32;
|
|
auto attr = dict.get("scale32");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `scale32` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute RescaleOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.input_unsigned;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("input_unsigned",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.output_unsigned;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("output_unsigned",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.per_channel;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("per_channel",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.rounding_mode;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("rounding_mode",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.scale32;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("scale32",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code RescaleOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.input_unsigned.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.output_unsigned.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.per_channel.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.rounding_mode.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.scale32.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> RescaleOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "input_unsigned")
|
|
return prop.input_unsigned;
|
|
|
|
if (name == "output_unsigned")
|
|
return prop.output_unsigned;
|
|
|
|
if (name == "per_channel")
|
|
return prop.per_channel;
|
|
|
|
if (name == "rounding_mode")
|
|
return prop.rounding_mode;
|
|
|
|
if (name == "scale32")
|
|
return prop.scale32;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void RescaleOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "input_unsigned") {
|
|
prop.input_unsigned = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.input_unsigned)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "output_unsigned") {
|
|
prop.output_unsigned = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.output_unsigned)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "per_channel") {
|
|
prop.per_channel = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.per_channel)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "rounding_mode") {
|
|
prop.rounding_mode = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.rounding_mode)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "scale32") {
|
|
prop.scale32 = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.scale32)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void RescaleOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.input_unsigned) attrs.append("input_unsigned", prop.input_unsigned);
|
|
|
|
if (prop.output_unsigned) attrs.append("output_unsigned", prop.output_unsigned);
|
|
|
|
if (prop.per_channel) attrs.append("per_channel", prop.per_channel);
|
|
|
|
if (prop.rounding_mode) attrs.append("rounding_mode", prop.rounding_mode);
|
|
|
|
if (prop.scale32) attrs.append("scale32", prop.scale32);
|
|
}
|
|
|
|
::llvm::LogicalResult RescaleOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getInputUnsignedAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps4(attr, "input_unsigned", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getOutputUnsignedAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps4(attr, "output_unsigned", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getPerChannelAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps4(attr, "per_channel", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getRoundingModeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps1(attr, "rounding_mode", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getScale32AttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps4(attr, "scale32", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult RescaleOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.input_unsigned)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readAttribute(prop.output_unsigned)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readAttribute(prop.per_channel)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readAttribute(prop.rounding_mode)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readAttribute(prop.scale32)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void RescaleOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.input_unsigned);
|
|
writer.writeAttribute(prop.output_unsigned);
|
|
writer.writeAttribute(prop.per_channel);
|
|
writer.writeAttribute(prop.rounding_mode);
|
|
writer.writeAttribute(prop.scale32);
|
|
}
|
|
|
|
bool RescaleOp::getScale32() {
|
|
auto attr = getScale32Attr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
::mlir::tosa::RoundingMode RescaleOp::getRoundingMode() {
|
|
auto attr = getRoundingModeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
bool RescaleOp::getPerChannel() {
|
|
auto attr = getPerChannelAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
bool RescaleOp::getInputUnsigned() {
|
|
auto attr = getInputUnsignedAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
bool RescaleOp::getOutputUnsigned() {
|
|
auto attr = getOutputUnsignedAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
void RescaleOp::setScale32(bool attrValue) {
|
|
getProperties().scale32 = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue);
|
|
}
|
|
|
|
void RescaleOp::setRoundingMode(::mlir::tosa::RoundingMode attrValue) {
|
|
getProperties().rounding_mode = ::mlir::tosa::RoundingModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue);
|
|
}
|
|
|
|
void RescaleOp::setPerChannel(bool attrValue) {
|
|
getProperties().per_channel = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue);
|
|
}
|
|
|
|
void RescaleOp::setInputUnsigned(bool attrValue) {
|
|
getProperties().input_unsigned = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue);
|
|
}
|
|
|
|
void RescaleOp::setOutputUnsigned(bool attrValue) {
|
|
getProperties().output_unsigned = ::mlir::Builder((*this)->getContext()).getBoolAttr(attrValue);
|
|
}
|
|
|
|
void RescaleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, ::mlir::Value multiplier, ::mlir::Value shift, ::mlir::Value input_zp, ::mlir::Value output_zp, ::mlir::BoolAttr scale32, mlir::tosa::RoundingModeAttr rounding_mode, ::mlir::BoolAttr per_channel, ::mlir::BoolAttr input_unsigned, ::mlir::BoolAttr output_unsigned) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(multiplier);
|
|
odsState.addOperands(shift);
|
|
odsState.addOperands(input_zp);
|
|
odsState.addOperands(output_zp);
|
|
odsState.getOrAddProperties<Properties>().scale32 = scale32;
|
|
odsState.getOrAddProperties<Properties>().rounding_mode = rounding_mode;
|
|
odsState.getOrAddProperties<Properties>().per_channel = per_channel;
|
|
odsState.getOrAddProperties<Properties>().input_unsigned = input_unsigned;
|
|
odsState.getOrAddProperties<Properties>().output_unsigned = output_unsigned;
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
RescaleOp RescaleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, ::mlir::Value multiplier, ::mlir::Value shift, ::mlir::Value input_zp, ::mlir::Value output_zp, ::mlir::BoolAttr scale32, mlir::tosa::RoundingModeAttr rounding_mode, ::mlir::BoolAttr per_channel, ::mlir::BoolAttr input_unsigned, ::mlir::BoolAttr output_unsigned) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(multiplier)>(multiplier), std::forward<decltype(shift)>(shift), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(output_zp)>(output_zp), std::forward<decltype(scale32)>(scale32), std::forward<decltype(rounding_mode)>(rounding_mode), std::forward<decltype(per_channel)>(per_channel), std::forward<decltype(input_unsigned)>(input_unsigned), std::forward<decltype(output_unsigned)>(output_unsigned));
|
|
auto __res__ = ::llvm::dyn_cast<RescaleOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
RescaleOp RescaleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, ::mlir::Value multiplier, ::mlir::Value shift, ::mlir::Value input_zp, ::mlir::Value output_zp, ::mlir::BoolAttr scale32, mlir::tosa::RoundingModeAttr rounding_mode, ::mlir::BoolAttr per_channel, ::mlir::BoolAttr input_unsigned, ::mlir::BoolAttr output_unsigned) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(multiplier)>(multiplier), std::forward<decltype(shift)>(shift), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(output_zp)>(output_zp), std::forward<decltype(scale32)>(scale32), std::forward<decltype(rounding_mode)>(rounding_mode), std::forward<decltype(per_channel)>(per_channel), std::forward<decltype(input_unsigned)>(input_unsigned), std::forward<decltype(output_unsigned)>(output_unsigned));
|
|
}
|
|
|
|
void RescaleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value multiplier, ::mlir::Value shift, ::mlir::Value input_zp, ::mlir::Value output_zp, ::mlir::BoolAttr scale32, mlir::tosa::RoundingModeAttr rounding_mode, ::mlir::BoolAttr per_channel, ::mlir::BoolAttr input_unsigned, ::mlir::BoolAttr output_unsigned) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(multiplier);
|
|
odsState.addOperands(shift);
|
|
odsState.addOperands(input_zp);
|
|
odsState.addOperands(output_zp);
|
|
odsState.getOrAddProperties<Properties>().scale32 = scale32;
|
|
odsState.getOrAddProperties<Properties>().rounding_mode = rounding_mode;
|
|
odsState.getOrAddProperties<Properties>().per_channel = per_channel;
|
|
odsState.getOrAddProperties<Properties>().input_unsigned = input_unsigned;
|
|
odsState.getOrAddProperties<Properties>().output_unsigned = output_unsigned;
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
RescaleOp RescaleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value multiplier, ::mlir::Value shift, ::mlir::Value input_zp, ::mlir::Value output_zp, ::mlir::BoolAttr scale32, mlir::tosa::RoundingModeAttr rounding_mode, ::mlir::BoolAttr per_channel, ::mlir::BoolAttr input_unsigned, ::mlir::BoolAttr output_unsigned) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(multiplier)>(multiplier), std::forward<decltype(shift)>(shift), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(output_zp)>(output_zp), std::forward<decltype(scale32)>(scale32), std::forward<decltype(rounding_mode)>(rounding_mode), std::forward<decltype(per_channel)>(per_channel), std::forward<decltype(input_unsigned)>(input_unsigned), std::forward<decltype(output_unsigned)>(output_unsigned));
|
|
auto __res__ = ::llvm::dyn_cast<RescaleOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
RescaleOp RescaleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value multiplier, ::mlir::Value shift, ::mlir::Value input_zp, ::mlir::Value output_zp, ::mlir::BoolAttr scale32, mlir::tosa::RoundingModeAttr rounding_mode, ::mlir::BoolAttr per_channel, ::mlir::BoolAttr input_unsigned, ::mlir::BoolAttr output_unsigned) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(multiplier)>(multiplier), std::forward<decltype(shift)>(shift), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(output_zp)>(output_zp), std::forward<decltype(scale32)>(scale32), std::forward<decltype(rounding_mode)>(rounding_mode), std::forward<decltype(per_channel)>(per_channel), std::forward<decltype(input_unsigned)>(input_unsigned), std::forward<decltype(output_unsigned)>(output_unsigned));
|
|
}
|
|
|
|
void RescaleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, ::mlir::Value multiplier, ::mlir::Value shift, ::mlir::Value input_zp, ::mlir::Value output_zp, bool scale32, ::mlir::tosa::RoundingMode rounding_mode, bool per_channel, bool input_unsigned, bool output_unsigned) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(multiplier);
|
|
odsState.addOperands(shift);
|
|
odsState.addOperands(input_zp);
|
|
odsState.addOperands(output_zp);
|
|
odsState.getOrAddProperties<Properties>().scale32 = odsBuilder.getBoolAttr(scale32);
|
|
odsState.getOrAddProperties<Properties>().rounding_mode = ::mlir::tosa::RoundingModeAttr::get(odsBuilder.getContext(), rounding_mode);
|
|
odsState.getOrAddProperties<Properties>().per_channel = odsBuilder.getBoolAttr(per_channel);
|
|
odsState.getOrAddProperties<Properties>().input_unsigned = odsBuilder.getBoolAttr(input_unsigned);
|
|
odsState.getOrAddProperties<Properties>().output_unsigned = odsBuilder.getBoolAttr(output_unsigned);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
RescaleOp RescaleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, ::mlir::Value multiplier, ::mlir::Value shift, ::mlir::Value input_zp, ::mlir::Value output_zp, bool scale32, ::mlir::tosa::RoundingMode rounding_mode, bool per_channel, bool input_unsigned, bool output_unsigned) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(multiplier)>(multiplier), std::forward<decltype(shift)>(shift), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(output_zp)>(output_zp), std::forward<decltype(scale32)>(scale32), std::forward<decltype(rounding_mode)>(rounding_mode), std::forward<decltype(per_channel)>(per_channel), std::forward<decltype(input_unsigned)>(input_unsigned), std::forward<decltype(output_unsigned)>(output_unsigned));
|
|
auto __res__ = ::llvm::dyn_cast<RescaleOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
RescaleOp RescaleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, ::mlir::Value multiplier, ::mlir::Value shift, ::mlir::Value input_zp, ::mlir::Value output_zp, bool scale32, ::mlir::tosa::RoundingMode rounding_mode, bool per_channel, bool input_unsigned, bool output_unsigned) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(multiplier)>(multiplier), std::forward<decltype(shift)>(shift), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(output_zp)>(output_zp), std::forward<decltype(scale32)>(scale32), std::forward<decltype(rounding_mode)>(rounding_mode), std::forward<decltype(per_channel)>(per_channel), std::forward<decltype(input_unsigned)>(input_unsigned), std::forward<decltype(output_unsigned)>(output_unsigned));
|
|
}
|
|
|
|
void RescaleOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value multiplier, ::mlir::Value shift, ::mlir::Value input_zp, ::mlir::Value output_zp, bool scale32, ::mlir::tosa::RoundingMode rounding_mode, bool per_channel, bool input_unsigned, bool output_unsigned) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(multiplier);
|
|
odsState.addOperands(shift);
|
|
odsState.addOperands(input_zp);
|
|
odsState.addOperands(output_zp);
|
|
odsState.getOrAddProperties<Properties>().scale32 = odsBuilder.getBoolAttr(scale32);
|
|
odsState.getOrAddProperties<Properties>().rounding_mode = ::mlir::tosa::RoundingModeAttr::get(odsBuilder.getContext(), rounding_mode);
|
|
odsState.getOrAddProperties<Properties>().per_channel = odsBuilder.getBoolAttr(per_channel);
|
|
odsState.getOrAddProperties<Properties>().input_unsigned = odsBuilder.getBoolAttr(input_unsigned);
|
|
odsState.getOrAddProperties<Properties>().output_unsigned = odsBuilder.getBoolAttr(output_unsigned);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
RescaleOp RescaleOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value multiplier, ::mlir::Value shift, ::mlir::Value input_zp, ::mlir::Value output_zp, bool scale32, ::mlir::tosa::RoundingMode rounding_mode, bool per_channel, bool input_unsigned, bool output_unsigned) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(multiplier)>(multiplier), std::forward<decltype(shift)>(shift), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(output_zp)>(output_zp), std::forward<decltype(scale32)>(scale32), std::forward<decltype(rounding_mode)>(rounding_mode), std::forward<decltype(per_channel)>(per_channel), std::forward<decltype(input_unsigned)>(input_unsigned), std::forward<decltype(output_unsigned)>(output_unsigned));
|
|
auto __res__ = ::llvm::dyn_cast<RescaleOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
RescaleOp RescaleOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value multiplier, ::mlir::Value shift, ::mlir::Value input_zp, ::mlir::Value output_zp, bool scale32, ::mlir::tosa::RoundingMode rounding_mode, bool per_channel, bool input_unsigned, bool output_unsigned) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(multiplier)>(multiplier), std::forward<decltype(shift)>(shift), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(output_zp)>(output_zp), std::forward<decltype(scale32)>(scale32), std::forward<decltype(rounding_mode)>(rounding_mode), std::forward<decltype(per_channel)>(per_channel), std::forward<decltype(input_unsigned)>(input_unsigned), std::forward<decltype(output_unsigned)>(output_unsigned));
|
|
}
|
|
|
|
void RescaleOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 5u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<RescaleOp::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.");
|
|
}
|
|
}
|
|
|
|
RescaleOp RescaleOp::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<RescaleOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
RescaleOp RescaleOp::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 RescaleOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
|
|
assert(operands.size() == 5u && "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);
|
|
}
|
|
|
|
RescaleOp RescaleOp::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<RescaleOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
RescaleOp RescaleOp::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 RescaleOp::verifyInvariantsImpl() {
|
|
auto tblgen_input_unsigned = getProperties().input_unsigned; (void)tblgen_input_unsigned;
|
|
if (!tblgen_input_unsigned) return emitOpError("requires attribute 'input_unsigned'");
|
|
auto tblgen_output_unsigned = getProperties().output_unsigned; (void)tblgen_output_unsigned;
|
|
if (!tblgen_output_unsigned) return emitOpError("requires attribute 'output_unsigned'");
|
|
auto tblgen_per_channel = getProperties().per_channel; (void)tblgen_per_channel;
|
|
if (!tblgen_per_channel) return emitOpError("requires attribute 'per_channel'");
|
|
auto tblgen_rounding_mode = getProperties().rounding_mode; (void)tblgen_rounding_mode;
|
|
if (!tblgen_rounding_mode) return emitOpError("requires attribute 'rounding_mode'");
|
|
auto tblgen_scale32 = getProperties().scale32; (void)tblgen_scale32;
|
|
if (!tblgen_scale32) return emitOpError("requires attribute 'scale32'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps4(*this, tblgen_scale32, "scale32")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps1(*this, tblgen_rounding_mode, "rounding_mode")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps4(*this, tblgen_per_channel, "per_channel")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps4(*this, tblgen_input_unsigned, "input_unsigned")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps4(*this, tblgen_output_unsigned, "output_unsigned")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps28(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps29(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup3 = getODSOperands(3);
|
|
|
|
for (auto v : valueGroup3) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps7(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup4 = getODSOperands(4);
|
|
|
|
for (auto v : valueGroup4) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps7(*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_TosaOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult RescaleOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::llvm::LogicalResult RescaleOp::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.scale32;
|
|
auto scale32AttrName = ::mlir::StringAttr::get(ctx, "scale32");
|
|
auto attr = dict.get(scale32AttrName);
|
|
usedKeys.insert(scale32AttrName);
|
|
if (attr || /*isRequired=*/true) {
|
|
if (!attr) {
|
|
emitError() << "expected key entry for scale32 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 `scale32` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
{
|
|
|
|
auto &propStorage = prop.rounding_mode;
|
|
auto rounding_modeAttrName = ::mlir::StringAttr::get(ctx, "rounding_mode");
|
|
auto attr = dict.get(rounding_modeAttrName);
|
|
usedKeys.insert(rounding_modeAttrName);
|
|
if (attr || /*isRequired=*/true) {
|
|
if (!attr) {
|
|
emitError() << "expected key entry for rounding_mode 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 `rounding_mode` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
{
|
|
|
|
auto &propStorage = prop.per_channel;
|
|
auto per_channelAttrName = ::mlir::StringAttr::get(ctx, "per_channel");
|
|
auto attr = dict.get(per_channelAttrName);
|
|
usedKeys.insert(per_channelAttrName);
|
|
if (attr || /*isRequired=*/true) {
|
|
if (!attr) {
|
|
emitError() << "expected key entry for per_channel 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 `per_channel` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
{
|
|
|
|
auto &propStorage = prop.input_unsigned;
|
|
auto input_unsignedAttrName = ::mlir::StringAttr::get(ctx, "input_unsigned");
|
|
auto attr = dict.get(input_unsignedAttrName);
|
|
usedKeys.insert(input_unsignedAttrName);
|
|
if (attr || /*isRequired=*/true) {
|
|
if (!attr) {
|
|
emitError() << "expected key entry for input_unsigned 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 `input_unsigned` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
{
|
|
|
|
auto &propStorage = prop.output_unsigned;
|
|
auto output_unsignedAttrName = ::mlir::StringAttr::get(ctx, "output_unsigned");
|
|
auto attr = dict.get(output_unsignedAttrName);
|
|
usedKeys.insert(output_unsignedAttrName);
|
|
if (attr || /*isRequired=*/true) {
|
|
if (!attr) {
|
|
emitError() << "expected key entry for output_unsigned 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 `output_unsigned` 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();
|
|
}
|
|
|
|
void RescaleOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
RescaleOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
RescaleOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return RescaleOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::RescaleOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::RescaleOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::ReshapeBlockScaledOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
ReshapeBlockScaledOpGenericAdaptorBase::ReshapeBlockScaledOpGenericAdaptorBase(ReshapeBlockScaledOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> ReshapeBlockScaledOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
bool isVariadic[] = {true, false};
|
|
int prevVariadicCount = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
if (isVariadic[i]) ++prevVariadicCount;
|
|
|
|
// Calculate how many dynamic values a static variadic operand corresponds to.
|
|
// This assumes all static variadic operands have the same dynamic value count.
|
|
int variadicSize = (odsOperandsSize - 1) / 1;
|
|
// `index` passed in as the parameter is the static index which counts each
|
|
// operand (variadic or not) as size 1. So here for each previous static variadic
|
|
// operand, we need to offset by (variadicSize - 1) to get where the dynamic
|
|
// value pack for this static operand starts.
|
|
int start = index + (variadicSize - 1) * prevVariadicCount;
|
|
int size = isVariadic[index] ? variadicSize : 1;
|
|
return {start, size};
|
|
}
|
|
|
|
::mlir::tosa::BlockSize ReshapeBlockScaledOpGenericAdaptorBase::getBlockSize() {
|
|
auto attr = getBlockSizeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
ReshapeBlockScaledOpAdaptor::ReshapeBlockScaledOpAdaptor(ReshapeBlockScaledOp op) : ReshapeBlockScaledOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult ReshapeBlockScaledOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_block_size = getProperties().block_size; (void)tblgen_block_size;
|
|
if (!tblgen_block_size) return emitError(loc, "'tosa.reshape_block_scaled' op requires attribute 'block_size'");
|
|
|
|
if (tblgen_block_size && !((::llvm::isa<mlir::tosa::BlockSizeAttr>(tblgen_block_size))))
|
|
return emitError(loc, "'tosa.reshape_block_scaled' op attribute 'block_size' failed to satisfy constraint: Block size for the block_scaled formats");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> ReshapeBlockScaledOp::getODSOperandIndexAndLength(unsigned index) {
|
|
bool isVariadic[] = {true, false};
|
|
int prevVariadicCount = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
if (isVariadic[i]) ++prevVariadicCount;
|
|
|
|
// Calculate how many dynamic values a static variadic operand corresponds to.
|
|
// This assumes all static variadic operands have the same dynamic value count.
|
|
int variadicSize = (getOperation()->getNumOperands() - 1) / 1;
|
|
// `index` passed in as the parameter is the static index which counts each
|
|
// operand (variadic or not) as size 1. So here for each previous static variadic
|
|
// operand, we need to offset by (variadicSize - 1) to get where the dynamic
|
|
// value pack for this static operand starts.
|
|
int start = index + (variadicSize - 1) * prevVariadicCount;
|
|
int size = isVariadic[index] ? variadicSize : 1;
|
|
return {start, size};
|
|
}
|
|
|
|
::mlir::MutableOperandRange ReshapeBlockScaledOp::getInputMutable() {
|
|
auto range = getODSOperandIndexAndLength(0);
|
|
auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
|
|
return mutableRange;
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> ReshapeBlockScaledOp::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 ReshapeBlockScaledOp::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.block_size;
|
|
auto attr = dict.get("block_size");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `block_size` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute ReshapeBlockScaledOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.block_size;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("block_size",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code ReshapeBlockScaledOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.block_size.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> ReshapeBlockScaledOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "block_size")
|
|
return prop.block_size;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void ReshapeBlockScaledOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "block_size") {
|
|
prop.block_size = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.block_size)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void ReshapeBlockScaledOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.block_size) attrs.append("block_size", prop.block_size);
|
|
}
|
|
|
|
::llvm::LogicalResult ReshapeBlockScaledOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getBlockSizeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps8(attr, "block_size", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ReshapeBlockScaledOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.block_size)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ReshapeBlockScaledOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.block_size);
|
|
}
|
|
|
|
::mlir::tosa::BlockSize ReshapeBlockScaledOp::getBlockSize() {
|
|
auto attr = getBlockSizeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
void ReshapeBlockScaledOp::setBlockSize(::mlir::tosa::BlockSize attrValue) {
|
|
getProperties().block_size = ::mlir::tosa::BlockSizeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue);
|
|
}
|
|
|
|
void ReshapeBlockScaledOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange output, ::mlir::ValueRange input, ::mlir::Value new_value_shape, mlir::tosa::BlockSizeAttr block_size) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(new_value_shape);
|
|
odsState.getOrAddProperties<Properties>().block_size = block_size;
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ReshapeBlockScaledOp ReshapeBlockScaledOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange output, ::mlir::ValueRange input, ::mlir::Value new_value_shape, mlir::tosa::BlockSizeAttr block_size) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(new_value_shape)>(new_value_shape), std::forward<decltype(block_size)>(block_size));
|
|
auto __res__ = ::llvm::dyn_cast<ReshapeBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReshapeBlockScaledOp ReshapeBlockScaledOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange output, ::mlir::ValueRange input, ::mlir::Value new_value_shape, mlir::tosa::BlockSizeAttr block_size) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(new_value_shape)>(new_value_shape), std::forward<decltype(block_size)>(block_size));
|
|
}
|
|
|
|
void ReshapeBlockScaledOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange input, ::mlir::Value new_value_shape, mlir::tosa::BlockSizeAttr block_size) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(new_value_shape);
|
|
odsState.getOrAddProperties<Properties>().block_size = block_size;
|
|
|
|
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
|
|
if (::mlir::succeeded(ReshapeBlockScaledOp::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);
|
|
|
|
}
|
|
|
|
ReshapeBlockScaledOp ReshapeBlockScaledOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange input, ::mlir::Value new_value_shape, mlir::tosa::BlockSizeAttr block_size) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(input)>(input), std::forward<decltype(new_value_shape)>(new_value_shape), std::forward<decltype(block_size)>(block_size));
|
|
auto __res__ = ::llvm::dyn_cast<ReshapeBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReshapeBlockScaledOp ReshapeBlockScaledOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange input, ::mlir::Value new_value_shape, mlir::tosa::BlockSizeAttr block_size) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(input)>(input), std::forward<decltype(new_value_shape)>(new_value_shape), std::forward<decltype(block_size)>(block_size));
|
|
}
|
|
|
|
void ReshapeBlockScaledOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange output, ::mlir::ValueRange input, ::mlir::Value new_value_shape, ::mlir::tosa::BlockSize block_size) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(new_value_shape);
|
|
odsState.getOrAddProperties<Properties>().block_size = ::mlir::tosa::BlockSizeAttr::get(odsBuilder.getContext(), block_size);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ReshapeBlockScaledOp ReshapeBlockScaledOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange output, ::mlir::ValueRange input, ::mlir::Value new_value_shape, ::mlir::tosa::BlockSize block_size) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(new_value_shape)>(new_value_shape), std::forward<decltype(block_size)>(block_size));
|
|
auto __res__ = ::llvm::dyn_cast<ReshapeBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReshapeBlockScaledOp ReshapeBlockScaledOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange output, ::mlir::ValueRange input, ::mlir::Value new_value_shape, ::mlir::tosa::BlockSize block_size) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(new_value_shape)>(new_value_shape), std::forward<decltype(block_size)>(block_size));
|
|
}
|
|
|
|
void ReshapeBlockScaledOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange input, ::mlir::Value new_value_shape, ::mlir::tosa::BlockSize block_size) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(new_value_shape);
|
|
odsState.getOrAddProperties<Properties>().block_size = ::mlir::tosa::BlockSizeAttr::get(odsBuilder.getContext(), block_size);
|
|
|
|
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
|
|
if (::mlir::succeeded(ReshapeBlockScaledOp::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);
|
|
|
|
}
|
|
|
|
ReshapeBlockScaledOp ReshapeBlockScaledOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange input, ::mlir::Value new_value_shape, ::mlir::tosa::BlockSize block_size) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(input)>(input), std::forward<decltype(new_value_shape)>(new_value_shape), std::forward<decltype(block_size)>(block_size));
|
|
auto __res__ = ::llvm::dyn_cast<ReshapeBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReshapeBlockScaledOp ReshapeBlockScaledOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange input, ::mlir::Value new_value_shape, ::mlir::tosa::BlockSize block_size) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(input)>(input), std::forward<decltype(new_value_shape)>(new_value_shape), std::forward<decltype(block_size)>(block_size));
|
|
}
|
|
|
|
void ReshapeBlockScaledOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() >= 1u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
odsState.addTypes(resultTypes);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<ReshapeBlockScaledOp::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.");
|
|
}
|
|
}
|
|
|
|
ReshapeBlockScaledOp ReshapeBlockScaledOp::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<ReshapeBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReshapeBlockScaledOp ReshapeBlockScaledOp::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 ReshapeBlockScaledOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() >= 1u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<ReshapeBlockScaledOp::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(ReshapeBlockScaledOp::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).");
|
|
}
|
|
}
|
|
|
|
ReshapeBlockScaledOp ReshapeBlockScaledOp::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<ReshapeBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReshapeBlockScaledOp ReshapeBlockScaledOp::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 ReshapeBlockScaledOp::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);
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ReshapeBlockScaledOp ReshapeBlockScaledOp::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<ReshapeBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReshapeBlockScaledOp ReshapeBlockScaledOp::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 ReshapeBlockScaledOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::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);
|
|
|
|
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
|
|
if (::mlir::succeeded(ReshapeBlockScaledOp::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).");
|
|
}
|
|
}
|
|
|
|
ReshapeBlockScaledOp ReshapeBlockScaledOp::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<ReshapeBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReshapeBlockScaledOp ReshapeBlockScaledOp::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 ReshapeBlockScaledOp::verifyInvariantsImpl() {
|
|
auto tblgen_block_size = getProperties().block_size; (void)tblgen_block_size;
|
|
if (!tblgen_block_size) return emitOpError("requires attribute 'block_size'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps8(*this, tblgen_block_size, "block_size")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps19(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps2(*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_TosaOps19(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ReshapeBlockScaledOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult ReshapeBlockScaledOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ReshapeBlockScaledOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void ReshapeBlockScaledOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
ReshapeBlockScaledOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
ReshapeBlockScaledOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return ReshapeBlockScaledOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
LogicalResult
|
|
ReshapeBlockScaledOp::inferReturnTypes(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) {
|
|
SmallVector<ShapedTypeComponents, 2> retComponents;
|
|
if (failed(ReshapeBlockScaledOp::inferReturnTypeComponents(context, location,
|
|
operands, attributes, properties, regions,
|
|
retComponents)))
|
|
return failure();
|
|
return ::mlir::detail::inferReturnTensorTypes(retComponents,
|
|
inferredReturnTypes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::ReshapeBlockScaledOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::ReshapeBlockScaledOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::ReshapeOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
ReshapeOpGenericAdaptorBase::ReshapeOpGenericAdaptorBase(ReshapeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
ReshapeOpAdaptor::ReshapeOpAdaptor(ReshapeOp op) : ReshapeOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult ReshapeOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ReshapeOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
|
|
if (!dict) {
|
|
emitError() << "expected DictionaryAttr to set properties";
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute ReshapeOp::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 ReshapeOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> ReshapeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void ReshapeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void ReshapeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult ReshapeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ReshapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value shape) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(shape);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ReshapeOp ReshapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value shape) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(shape)>(shape));
|
|
auto __res__ = ::llvm::dyn_cast<ReshapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReshapeOp ReshapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value shape) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(shape)>(shape));
|
|
}
|
|
|
|
void ReshapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value input1, ::mlir::Value shape) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(shape);
|
|
|
|
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
|
|
if (::mlir::succeeded(ReshapeOp::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);
|
|
|
|
}
|
|
|
|
ReshapeOp ReshapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Value input1, ::mlir::Value shape) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(input1)>(input1), std::forward<decltype(shape)>(shape));
|
|
auto __res__ = ::llvm::dyn_cast<ReshapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReshapeOp ReshapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Value input1, ::mlir::Value shape) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(input1)>(input1), std::forward<decltype(shape)>(shape));
|
|
}
|
|
|
|
void ReshapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value shape) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(shape);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ReshapeOp ReshapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value shape) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(shape)>(shape));
|
|
auto __res__ = ::llvm::dyn_cast<ReshapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReshapeOp ReshapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value shape) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(shape)>(shape));
|
|
}
|
|
|
|
void ReshapeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ReshapeOp ReshapeOp::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<ReshapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReshapeOp ReshapeOp::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 ReshapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
|
|
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
|
|
if (::mlir::succeeded(ReshapeOp::inferReturnTypes(odsBuilder.getContext(),
|
|
odsState.location, operands,
|
|
odsState.attributes.getDictionary(odsState.getContext()),
|
|
odsState.getRawProperties(),
|
|
odsState.regions, inferredReturnTypes))) {
|
|
assert(inferredReturnTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(inferredReturnTypes);
|
|
} else {
|
|
::llvm::report_fatal_error("Failed to infer result type(s).");
|
|
}
|
|
}
|
|
|
|
ReshapeOp ReshapeOp::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<ReshapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReshapeOp ReshapeOp::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 ReshapeOp::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);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ReshapeOp ReshapeOp::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<ReshapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReshapeOp ReshapeOp::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 ReshapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::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);
|
|
|
|
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
|
|
if (::mlir::succeeded(ReshapeOp::inferReturnTypes(odsBuilder.getContext(),
|
|
odsState.location, operands,
|
|
odsState.attributes.getDictionary(odsState.getContext()),
|
|
odsState.getRawProperties(),
|
|
odsState.regions, inferredReturnTypes))) {
|
|
assert(inferredReturnTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(inferredReturnTypes);
|
|
} else {
|
|
::llvm::report_fatal_error("Failed to infer result type(s).");
|
|
}
|
|
}
|
|
|
|
ReshapeOp ReshapeOp::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<ReshapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReshapeOp ReshapeOp::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 ReshapeOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps2(*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_TosaOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ReshapeOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult ReshapeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ReshapeOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void ReshapeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
ReshapeOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
ReshapeOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return ReshapeOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
LogicalResult
|
|
ReshapeOp::inferReturnTypes(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes) {
|
|
SmallVector<ShapedTypeComponents, 2> retComponents;
|
|
if (failed(ReshapeOp::inferReturnTypeComponents(context, location,
|
|
operands, attributes, properties, regions,
|
|
retComponents)))
|
|
return failure();
|
|
return ::mlir::detail::inferReturnTensorTypes(retComponents,
|
|
inferredReturnTypes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::ReshapeOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::ResizeOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
ResizeOpGenericAdaptorBase::ResizeOpGenericAdaptorBase(ResizeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::mlir::tosa::ResizeMode ResizeOpGenericAdaptorBase::getMode() {
|
|
auto attr = getModeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
ResizeOpAdaptor::ResizeOpAdaptor(ResizeOp op) : ResizeOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult ResizeOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_mode = getProperties().mode; (void)tblgen_mode;
|
|
if (!tblgen_mode) return emitError(loc, "'tosa.resize' op requires attribute 'mode'");
|
|
|
|
if (tblgen_mode && !((::llvm::isa<mlir::tosa::ResizeModeAttr>(tblgen_mode))))
|
|
return emitError(loc, "'tosa.resize' op attribute 'mode' failed to satisfy constraint: Supported resize/upsampling strategies");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ResizeOp::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.mode;
|
|
auto attr = dict.get("mode");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `mode` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute ResizeOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.mode;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("mode",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code ResizeOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.mode.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> ResizeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "mode")
|
|
return prop.mode;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void ResizeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "mode") {
|
|
prop.mode = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.mode)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void ResizeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.mode) attrs.append("mode", prop.mode);
|
|
}
|
|
|
|
::llvm::LogicalResult ResizeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getModeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps15(attr, "mode", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ResizeOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.mode)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ResizeOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.mode);
|
|
}
|
|
|
|
::mlir::tosa::ResizeMode ResizeOp::getMode() {
|
|
auto attr = getModeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
void ResizeOp::setMode(::mlir::tosa::ResizeMode attrValue) {
|
|
getProperties().mode = ::mlir::tosa::ResizeModeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue);
|
|
}
|
|
|
|
void ResizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, ::mlir::Value scale, ::mlir::Value offset, ::mlir::Value border, mlir::tosa::ResizeModeAttr mode) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(scale);
|
|
odsState.addOperands(offset);
|
|
odsState.addOperands(border);
|
|
odsState.getOrAddProperties<Properties>().mode = mode;
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ResizeOp ResizeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, ::mlir::Value scale, ::mlir::Value offset, ::mlir::Value border, mlir::tosa::ResizeModeAttr mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(scale)>(scale), std::forward<decltype(offset)>(offset), std::forward<decltype(border)>(border), std::forward<decltype(mode)>(mode));
|
|
auto __res__ = ::llvm::dyn_cast<ResizeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ResizeOp ResizeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, ::mlir::Value scale, ::mlir::Value offset, ::mlir::Value border, mlir::tosa::ResizeModeAttr mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(scale)>(scale), std::forward<decltype(offset)>(offset), std::forward<decltype(border)>(border), std::forward<decltype(mode)>(mode));
|
|
}
|
|
|
|
void ResizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value scale, ::mlir::Value offset, ::mlir::Value border, mlir::tosa::ResizeModeAttr mode) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(scale);
|
|
odsState.addOperands(offset);
|
|
odsState.addOperands(border);
|
|
odsState.getOrAddProperties<Properties>().mode = mode;
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ResizeOp ResizeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value scale, ::mlir::Value offset, ::mlir::Value border, mlir::tosa::ResizeModeAttr mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(scale)>(scale), std::forward<decltype(offset)>(offset), std::forward<decltype(border)>(border), std::forward<decltype(mode)>(mode));
|
|
auto __res__ = ::llvm::dyn_cast<ResizeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ResizeOp ResizeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value scale, ::mlir::Value offset, ::mlir::Value border, mlir::tosa::ResizeModeAttr mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(scale)>(scale), std::forward<decltype(offset)>(offset), std::forward<decltype(border)>(border), std::forward<decltype(mode)>(mode));
|
|
}
|
|
|
|
void ResizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, ::mlir::Value scale, ::mlir::Value offset, ::mlir::Value border, ::mlir::tosa::ResizeMode mode) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(scale);
|
|
odsState.addOperands(offset);
|
|
odsState.addOperands(border);
|
|
odsState.getOrAddProperties<Properties>().mode = ::mlir::tosa::ResizeModeAttr::get(odsBuilder.getContext(), mode);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ResizeOp ResizeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, ::mlir::Value scale, ::mlir::Value offset, ::mlir::Value border, ::mlir::tosa::ResizeMode mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(scale)>(scale), std::forward<decltype(offset)>(offset), std::forward<decltype(border)>(border), std::forward<decltype(mode)>(mode));
|
|
auto __res__ = ::llvm::dyn_cast<ResizeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ResizeOp ResizeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, ::mlir::Value scale, ::mlir::Value offset, ::mlir::Value border, ::mlir::tosa::ResizeMode mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(scale)>(scale), std::forward<decltype(offset)>(offset), std::forward<decltype(border)>(border), std::forward<decltype(mode)>(mode));
|
|
}
|
|
|
|
void ResizeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value scale, ::mlir::Value offset, ::mlir::Value border, ::mlir::tosa::ResizeMode mode) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(scale);
|
|
odsState.addOperands(offset);
|
|
odsState.addOperands(border);
|
|
odsState.getOrAddProperties<Properties>().mode = ::mlir::tosa::ResizeModeAttr::get(odsBuilder.getContext(), mode);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ResizeOp ResizeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value scale, ::mlir::Value offset, ::mlir::Value border, ::mlir::tosa::ResizeMode mode) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(scale)>(scale), std::forward<decltype(offset)>(offset), std::forward<decltype(border)>(border), std::forward<decltype(mode)>(mode));
|
|
auto __res__ = ::llvm::dyn_cast<ResizeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ResizeOp ResizeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value scale, ::mlir::Value offset, ::mlir::Value border, ::mlir::tosa::ResizeMode mode) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(scale)>(scale), std::forward<decltype(offset)>(offset), std::forward<decltype(border)>(border), std::forward<decltype(mode)>(mode));
|
|
}
|
|
|
|
void ResizeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 4u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<ResizeOp::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.");
|
|
}
|
|
}
|
|
|
|
ResizeOp ResizeOp::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<ResizeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ResizeOp ResizeOp::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 ResizeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
|
|
assert(operands.size() == 4u && "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);
|
|
}
|
|
|
|
ResizeOp ResizeOp::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<ResizeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ResizeOp ResizeOp::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 ResizeOp::verifyInvariantsImpl() {
|
|
auto tblgen_mode = getProperties().mode; (void)tblgen_mode;
|
|
if (!tblgen_mode) return emitOpError("requires attribute 'mode'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps15(*this, tblgen_mode, "mode")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps6(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps9(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps8(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup3 = getODSOperands(3);
|
|
|
|
for (auto v : valueGroup3) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps8(*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_TosaOps6(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ResizeOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::llvm::LogicalResult ResizeOp::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.mode;
|
|
auto modeAttrName = ::mlir::StringAttr::get(ctx, "mode");
|
|
auto attr = dict.get(modeAttrName);
|
|
usedKeys.insert(modeAttrName);
|
|
if (attr || /*isRequired=*/true) {
|
|
if (!attr) {
|
|
emitError() << "expected key entry for mode 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 `mode` 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();
|
|
}
|
|
|
|
void ResizeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
ResizeOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
ResizeOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return ResizeOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::ResizeOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::ResizeOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::ReverseOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
ReverseOpGenericAdaptorBase::ReverseOpGenericAdaptorBase(ReverseOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
uint32_t ReverseOpGenericAdaptorBase::getAxis() {
|
|
auto attr = getAxisAttr();
|
|
return attr.getValue().getZExtValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
ReverseOpAdaptor::ReverseOpAdaptor(ReverseOp op) : ReverseOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult ReverseOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_axis = getProperties().axis; (void)tblgen_axis;
|
|
if (!tblgen_axis) return emitError(loc, "'tosa.reverse' op requires attribute 'axis'");
|
|
|
|
if (tblgen_axis && !(((::llvm::isa<::mlir::IntegerAttr>(tblgen_axis))) && ((::llvm::cast<::mlir::IntegerAttr>(tblgen_axis).getType().isSignlessInteger(32)))))
|
|
return emitError(loc, "'tosa.reverse' op attribute 'axis' failed to satisfy constraint: 32-bit signless integer attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ReverseOp::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.axis;
|
|
auto attr = dict.get("axis");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `axis` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute ReverseOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.axis;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("axis",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code ReverseOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.axis.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> ReverseOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "axis")
|
|
return prop.axis;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void ReverseOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "axis") {
|
|
prop.axis = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.axis)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void ReverseOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.axis) attrs.append("axis", prop.axis);
|
|
}
|
|
|
|
::llvm::LogicalResult ReverseOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getAxisAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps2(attr, "axis", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ReverseOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.axis)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ReverseOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.axis);
|
|
}
|
|
|
|
uint32_t ReverseOp::getAxis() {
|
|
auto attr = getAxisAttr();
|
|
return attr.getValue().getZExtValue();
|
|
}
|
|
|
|
void ReverseOp::setAxis(uint32_t attrValue) {
|
|
getProperties().axis = ::mlir::Builder((*this)->getContext()).getIntegerAttr(::mlir::Builder((*this)->getContext()).getIntegerType(32), attrValue);
|
|
}
|
|
|
|
void ReverseOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::IntegerAttr axis) {
|
|
odsState.addOperands(input1);
|
|
odsState.getOrAddProperties<Properties>().axis = axis;
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ReverseOp ReverseOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::IntegerAttr axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<ReverseOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReverseOp ReverseOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::IntegerAttr axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void ReverseOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::IntegerAttr axis) {
|
|
odsState.addOperands(input1);
|
|
odsState.getOrAddProperties<Properties>().axis = axis;
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ReverseOp ReverseOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::IntegerAttr axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<ReverseOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReverseOp ReverseOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::IntegerAttr axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void ReverseOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, uint32_t axis) {
|
|
odsState.addOperands(input1);
|
|
odsState.getOrAddProperties<Properties>().axis = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), axis);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
ReverseOp ReverseOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, uint32_t axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<ReverseOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReverseOp ReverseOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, uint32_t axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void ReverseOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, uint32_t axis) {
|
|
odsState.addOperands(input1);
|
|
odsState.getOrAddProperties<Properties>().axis = odsBuilder.getIntegerAttr(odsBuilder.getIntegerType(32), axis);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ReverseOp ReverseOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, uint32_t axis) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(axis)>(axis));
|
|
auto __res__ = ::llvm::dyn_cast<ReverseOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReverseOp ReverseOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, uint32_t axis) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(axis)>(axis));
|
|
}
|
|
|
|
void ReverseOp::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<ReverseOp::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.");
|
|
}
|
|
}
|
|
|
|
ReverseOp ReverseOp::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<ReverseOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReverseOp ReverseOp::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 ReverseOp::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);
|
|
}
|
|
|
|
ReverseOp ReverseOp::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<ReverseOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ReverseOp ReverseOp::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 ReverseOp::verifyInvariantsImpl() {
|
|
auto tblgen_axis = getProperties().axis; (void)tblgen_axis;
|
|
if (!tblgen_axis) return emitOpError("requires attribute 'axis'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps2(*this, tblgen_axis, "axis")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps5(*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_TosaOps5(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ReverseOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult ReverseOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ReverseOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void ReverseOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::ReverseOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::ReverseOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::RowGatherBlockScaledOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
RowGatherBlockScaledOpGenericAdaptorBase::RowGatherBlockScaledOpGenericAdaptorBase(RowGatherBlockScaledOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> RowGatherBlockScaledOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
bool isVariadic[] = {true, false, false};
|
|
int prevVariadicCount = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
if (isVariadic[i]) ++prevVariadicCount;
|
|
|
|
// Calculate how many dynamic values a static variadic operand corresponds to.
|
|
// This assumes all static variadic operands have the same dynamic value count.
|
|
int variadicSize = (odsOperandsSize - 2) / 1;
|
|
// `index` passed in as the parameter is the static index which counts each
|
|
// operand (variadic or not) as size 1. So here for each previous static variadic
|
|
// operand, we need to offset by (variadicSize - 1) to get where the dynamic
|
|
// value pack for this static operand starts.
|
|
int start = index + (variadicSize - 1) * prevVariadicCount;
|
|
int size = isVariadic[index] ? variadicSize : 1;
|
|
return {start, size};
|
|
}
|
|
|
|
::mlir::tosa::BlockSize RowGatherBlockScaledOpGenericAdaptorBase::getBlockSize() {
|
|
auto attr = getBlockSizeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
RowGatherBlockScaledOpAdaptor::RowGatherBlockScaledOpAdaptor(RowGatherBlockScaledOp op) : RowGatherBlockScaledOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult RowGatherBlockScaledOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_block_size = getProperties().block_size; (void)tblgen_block_size;
|
|
if (!tblgen_block_size) return emitError(loc, "'tosa.row_gather_block_scaled' op requires attribute 'block_size'");
|
|
|
|
if (tblgen_block_size && !((::llvm::isa<mlir::tosa::BlockSizeAttr>(tblgen_block_size))))
|
|
return emitError(loc, "'tosa.row_gather_block_scaled' op attribute 'block_size' failed to satisfy constraint: Block size for the block_scaled formats");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> RowGatherBlockScaledOp::getODSOperandIndexAndLength(unsigned index) {
|
|
bool isVariadic[] = {true, false, false};
|
|
int prevVariadicCount = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
if (isVariadic[i]) ++prevVariadicCount;
|
|
|
|
// Calculate how many dynamic values a static variadic operand corresponds to.
|
|
// This assumes all static variadic operands have the same dynamic value count.
|
|
int variadicSize = (getOperation()->getNumOperands() - 2) / 1;
|
|
// `index` passed in as the parameter is the static index which counts each
|
|
// operand (variadic or not) as size 1. So here for each previous static variadic
|
|
// operand, we need to offset by (variadicSize - 1) to get where the dynamic
|
|
// value pack for this static operand starts.
|
|
int start = index + (variadicSize - 1) * prevVariadicCount;
|
|
int size = isVariadic[index] ? variadicSize : 1;
|
|
return {start, size};
|
|
}
|
|
|
|
::mlir::MutableOperandRange RowGatherBlockScaledOp::getValuesMutable() {
|
|
auto range = getODSOperandIndexAndLength(0);
|
|
auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
|
|
return mutableRange;
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> RowGatherBlockScaledOp::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 RowGatherBlockScaledOp::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.block_size;
|
|
auto attr = dict.get("block_size");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `block_size` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute RowGatherBlockScaledOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.block_size;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("block_size",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code RowGatherBlockScaledOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.block_size.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> RowGatherBlockScaledOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "block_size")
|
|
return prop.block_size;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void RowGatherBlockScaledOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "block_size") {
|
|
prop.block_size = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.block_size)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void RowGatherBlockScaledOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.block_size) attrs.append("block_size", prop.block_size);
|
|
}
|
|
|
|
::llvm::LogicalResult RowGatherBlockScaledOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getBlockSizeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps8(attr, "block_size", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult RowGatherBlockScaledOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.block_size)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void RowGatherBlockScaledOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.block_size);
|
|
}
|
|
|
|
::mlir::tosa::BlockSize RowGatherBlockScaledOp::getBlockSize() {
|
|
auto attr = getBlockSizeAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
void RowGatherBlockScaledOp::setBlockSize(::mlir::tosa::BlockSize attrValue) {
|
|
getProperties().block_size = ::mlir::tosa::BlockSizeAttr::get(::mlir::Builder((*this)->getContext()).getContext(), attrValue);
|
|
}
|
|
|
|
void RowGatherBlockScaledOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange output, ::mlir::ValueRange values, ::mlir::Value indices, ::mlir::Value row_count, mlir::tosa::BlockSizeAttr block_size) {
|
|
odsState.addOperands(values);
|
|
odsState.addOperands(indices);
|
|
odsState.addOperands(row_count);
|
|
odsState.getOrAddProperties<Properties>().block_size = block_size;
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
RowGatherBlockScaledOp RowGatherBlockScaledOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange output, ::mlir::ValueRange values, ::mlir::Value indices, ::mlir::Value row_count, mlir::tosa::BlockSizeAttr block_size) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(values)>(values), std::forward<decltype(indices)>(indices), std::forward<decltype(row_count)>(row_count), std::forward<decltype(block_size)>(block_size));
|
|
auto __res__ = ::llvm::dyn_cast<RowGatherBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
RowGatherBlockScaledOp RowGatherBlockScaledOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange output, ::mlir::ValueRange values, ::mlir::Value indices, ::mlir::Value row_count, mlir::tosa::BlockSizeAttr block_size) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(values)>(values), std::forward<decltype(indices)>(indices), std::forward<decltype(row_count)>(row_count), std::forward<decltype(block_size)>(block_size));
|
|
}
|
|
|
|
void RowGatherBlockScaledOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange output, ::mlir::ValueRange values, ::mlir::Value indices, ::mlir::Value row_count, ::mlir::tosa::BlockSize block_size) {
|
|
odsState.addOperands(values);
|
|
odsState.addOperands(indices);
|
|
odsState.addOperands(row_count);
|
|
odsState.getOrAddProperties<Properties>().block_size = ::mlir::tosa::BlockSizeAttr::get(odsBuilder.getContext(), block_size);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
RowGatherBlockScaledOp RowGatherBlockScaledOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange output, ::mlir::ValueRange values, ::mlir::Value indices, ::mlir::Value row_count, ::mlir::tosa::BlockSize block_size) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(values)>(values), std::forward<decltype(indices)>(indices), std::forward<decltype(row_count)>(row_count), std::forward<decltype(block_size)>(block_size));
|
|
auto __res__ = ::llvm::dyn_cast<RowGatherBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
RowGatherBlockScaledOp RowGatherBlockScaledOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange output, ::mlir::ValueRange values, ::mlir::Value indices, ::mlir::Value row_count, ::mlir::tosa::BlockSize block_size) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(values)>(values), std::forward<decltype(indices)>(indices), std::forward<decltype(row_count)>(row_count), std::forward<decltype(block_size)>(block_size));
|
|
}
|
|
|
|
void RowGatherBlockScaledOp::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<RowGatherBlockScaledOp::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.");
|
|
}
|
|
}
|
|
|
|
RowGatherBlockScaledOp RowGatherBlockScaledOp::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<RowGatherBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
RowGatherBlockScaledOp RowGatherBlockScaledOp::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 RowGatherBlockScaledOp::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);
|
|
}
|
|
|
|
RowGatherBlockScaledOp RowGatherBlockScaledOp::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<RowGatherBlockScaledOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
RowGatherBlockScaledOp RowGatherBlockScaledOp::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 RowGatherBlockScaledOp::verifyInvariantsImpl() {
|
|
auto tblgen_block_size = getProperties().block_size; (void)tblgen_block_size;
|
|
if (!tblgen_block_size) return emitOpError("requires attribute 'block_size'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps8(*this, tblgen_block_size, "block_size")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps30(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps22(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps31(*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_TosaOps30(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult RowGatherBlockScaledOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult RowGatherBlockScaledOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void RowGatherBlockScaledOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void RowGatherBlockScaledOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
RowGatherBlockScaledOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
RowGatherBlockScaledOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return RowGatherBlockScaledOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::RowGatherBlockScaledOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::RowGatherBlockScaledOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::RowGatherOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
RowGatherOpGenericAdaptorBase::RowGatherOpGenericAdaptorBase(RowGatherOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
RowGatherOpAdaptor::RowGatherOpAdaptor(RowGatherOp op) : RowGatherOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult RowGatherOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult RowGatherOp::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 RowGatherOp::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 RowGatherOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> RowGatherOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void RowGatherOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void RowGatherOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult RowGatherOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void RowGatherOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value values, ::mlir::Value indices, ::mlir::Value row_count) {
|
|
odsState.addOperands(values);
|
|
odsState.addOperands(indices);
|
|
odsState.addOperands(row_count);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
RowGatherOp RowGatherOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value values, ::mlir::Value indices, ::mlir::Value row_count) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(values)>(values), std::forward<decltype(indices)>(indices), std::forward<decltype(row_count)>(row_count));
|
|
auto __res__ = ::llvm::dyn_cast<RowGatherOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
RowGatherOp RowGatherOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value values, ::mlir::Value indices, ::mlir::Value row_count) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(values)>(values), std::forward<decltype(indices)>(indices), std::forward<decltype(row_count)>(row_count));
|
|
}
|
|
|
|
void RowGatherOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value values, ::mlir::Value indices, ::mlir::Value row_count) {
|
|
odsState.addOperands(values);
|
|
odsState.addOperands(indices);
|
|
odsState.addOperands(row_count);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
RowGatherOp RowGatherOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value values, ::mlir::Value indices, ::mlir::Value row_count) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(values)>(values), std::forward<decltype(indices)>(indices), std::forward<decltype(row_count)>(row_count));
|
|
auto __res__ = ::llvm::dyn_cast<RowGatherOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
RowGatherOp RowGatherOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value values, ::mlir::Value indices, ::mlir::Value row_count) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(values)>(values), std::forward<decltype(indices)>(indices), std::forward<decltype(row_count)>(row_count));
|
|
}
|
|
|
|
void RowGatherOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 3u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
RowGatherOp RowGatherOp::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<RowGatherOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
RowGatherOp RowGatherOp::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 RowGatherOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
|
|
assert(operands.size() == 3u && "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);
|
|
}
|
|
|
|
RowGatherOp RowGatherOp::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<RowGatherOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
RowGatherOp RowGatherOp::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 RowGatherOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps21(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps22(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps31(*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_TosaOps21(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult RowGatherOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult RowGatherOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void RowGatherOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void RowGatherOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
RowGatherOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
RowGatherOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return RowGatherOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::RowGatherOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::RsqrtOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
RsqrtOpGenericAdaptorBase::RsqrtOpGenericAdaptorBase(RsqrtOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
RsqrtOpAdaptor::RsqrtOpAdaptor(RsqrtOp op) : RsqrtOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult RsqrtOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult RsqrtOp::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 RsqrtOp::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 RsqrtOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> RsqrtOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void RsqrtOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void RsqrtOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult RsqrtOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void RsqrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1) {
|
|
odsState.addOperands(input1);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
RsqrtOp RsqrtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1));
|
|
auto __res__ = ::llvm::dyn_cast<RsqrtOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
RsqrtOp RsqrtOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1));
|
|
}
|
|
|
|
void RsqrtOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
odsState.addOperands(input1);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
RsqrtOp RsqrtOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1));
|
|
auto __res__ = ::llvm::dyn_cast<RsqrtOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
RsqrtOp RsqrtOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1));
|
|
}
|
|
|
|
void RsqrtOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 1u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
RsqrtOp RsqrtOp::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<RsqrtOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
RsqrtOp RsqrtOp::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 RsqrtOp::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);
|
|
}
|
|
|
|
RsqrtOp RsqrtOp::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<RsqrtOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
RsqrtOp RsqrtOp::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 RsqrtOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*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_TosaOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult RsqrtOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult RsqrtOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void RsqrtOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void RsqrtOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::RsqrtOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::ScatterOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
ScatterOpGenericAdaptorBase::ScatterOpGenericAdaptorBase(ScatterOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
ScatterOpAdaptor::ScatterOpAdaptor(ScatterOp op) : ScatterOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult ScatterOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ScatterOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
|
|
if (!dict) {
|
|
emitError() << "expected DictionaryAttr to set properties";
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute ScatterOp::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 ScatterOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> ScatterOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void ScatterOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void ScatterOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult ScatterOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ScatterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type values_out, ::mlir::Value values_in, ::mlir::Value indices, ::mlir::Value input) {
|
|
odsState.addOperands(values_in);
|
|
odsState.addOperands(indices);
|
|
odsState.addOperands(input);
|
|
odsState.addTypes(values_out);
|
|
}
|
|
|
|
ScatterOp ScatterOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type values_out, ::mlir::Value values_in, ::mlir::Value indices, ::mlir::Value input) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(values_out)>(values_out), std::forward<decltype(values_in)>(values_in), std::forward<decltype(indices)>(indices), std::forward<decltype(input)>(input));
|
|
auto __res__ = ::llvm::dyn_cast<ScatterOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ScatterOp ScatterOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type values_out, ::mlir::Value values_in, ::mlir::Value indices, ::mlir::Value input) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(values_out)>(values_out), std::forward<decltype(values_in)>(values_in), std::forward<decltype(indices)>(indices), std::forward<decltype(input)>(input));
|
|
}
|
|
|
|
void ScatterOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value values_in, ::mlir::Value indices, ::mlir::Value input) {
|
|
odsState.addOperands(values_in);
|
|
odsState.addOperands(indices);
|
|
odsState.addOperands(input);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ScatterOp ScatterOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value values_in, ::mlir::Value indices, ::mlir::Value input) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(values_in)>(values_in), std::forward<decltype(indices)>(indices), std::forward<decltype(input)>(input));
|
|
auto __res__ = ::llvm::dyn_cast<ScatterOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ScatterOp ScatterOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value values_in, ::mlir::Value indices, ::mlir::Value input) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(values_in)>(values_in), std::forward<decltype(indices)>(indices), std::forward<decltype(input)>(input));
|
|
}
|
|
|
|
void ScatterOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 3u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
ScatterOp ScatterOp::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<ScatterOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ScatterOp ScatterOp::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 ScatterOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
|
|
assert(operands.size() == 3u && "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);
|
|
}
|
|
|
|
ScatterOp ScatterOp::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<ScatterOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
ScatterOp ScatterOp::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 ScatterOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps21(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps22(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps21(*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_TosaOps21(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult ScatterOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult ScatterOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void ScatterOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void ScatterOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
ScatterOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
ScatterOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return ScatterOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::ScatterOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::SelectOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
SelectOpGenericAdaptorBase::SelectOpGenericAdaptorBase(SelectOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
SelectOpAdaptor::SelectOpAdaptor(SelectOp op) : SelectOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult SelectOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult SelectOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
|
|
if (!dict) {
|
|
emitError() << "expected DictionaryAttr to set properties";
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute SelectOp::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 SelectOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> SelectOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void SelectOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void SelectOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult SelectOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void SelectOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2, ::mlir::Value input3) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.addOperands(input3);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
SelectOp SelectOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2, ::mlir::Value input3) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(input3)>(input3));
|
|
auto __res__ = ::llvm::dyn_cast<SelectOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SelectOp SelectOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2, ::mlir::Value input3) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(input3)>(input3));
|
|
}
|
|
|
|
void SelectOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2, ::mlir::Value input3) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.addOperands(input3);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
SelectOp SelectOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2, ::mlir::Value input3) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(input3)>(input3));
|
|
auto __res__ = ::llvm::dyn_cast<SelectOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SelectOp SelectOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2, ::mlir::Value input3) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2), std::forward<decltype(input3)>(input3));
|
|
}
|
|
|
|
void SelectOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 3u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
SelectOp SelectOp::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<SelectOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SelectOp SelectOp::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 SelectOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
|
|
assert(operands.size() == 3u && "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);
|
|
}
|
|
|
|
SelectOp SelectOp::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<SelectOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SelectOp SelectOp::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 SelectOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps20(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*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_TosaOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult SelectOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
void SelectOp::getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context) {
|
|
results.add(canonicalize);
|
|
}
|
|
|
|
::mlir::ParseResult SelectOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void SelectOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void SelectOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::SelectOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::SigmoidOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
SigmoidOpGenericAdaptorBase::SigmoidOpGenericAdaptorBase(SigmoidOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
SigmoidOpAdaptor::SigmoidOpAdaptor(SigmoidOp op) : SigmoidOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult SigmoidOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult SigmoidOp::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 SigmoidOp::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 SigmoidOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> SigmoidOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void SigmoidOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void SigmoidOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult SigmoidOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void SigmoidOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input) {
|
|
odsState.addOperands(input);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
SigmoidOp SigmoidOp::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<SigmoidOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SigmoidOp SigmoidOp::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 SigmoidOp::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);
|
|
}
|
|
|
|
SigmoidOp SigmoidOp::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<SigmoidOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SigmoidOp SigmoidOp::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 SigmoidOp::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);
|
|
}
|
|
|
|
SigmoidOp SigmoidOp::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<SigmoidOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SigmoidOp SigmoidOp::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 SigmoidOp::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);
|
|
}
|
|
|
|
SigmoidOp SigmoidOp::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<SigmoidOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SigmoidOp SigmoidOp::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 SigmoidOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*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_TosaOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult SigmoidOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult SigmoidOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void SigmoidOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void SigmoidOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::SigmoidOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::SinOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
SinOpGenericAdaptorBase::SinOpGenericAdaptorBase(SinOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
SinOpAdaptor::SinOpAdaptor(SinOp op) : SinOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult SinOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult SinOp::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 SinOp::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 SinOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> SinOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void SinOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void SinOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult SinOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void SinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1) {
|
|
odsState.addOperands(input1);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
SinOp SinOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1));
|
|
auto __res__ = ::llvm::dyn_cast<SinOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SinOp SinOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1));
|
|
}
|
|
|
|
void SinOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
odsState.addOperands(input1);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
SinOp SinOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1));
|
|
auto __res__ = ::llvm::dyn_cast<SinOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SinOp SinOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1));
|
|
}
|
|
|
|
void SinOp::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);
|
|
}
|
|
|
|
SinOp SinOp::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<SinOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SinOp SinOp::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 SinOp::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);
|
|
}
|
|
|
|
SinOp SinOp::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<SinOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SinOp SinOp::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 SinOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps18(*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_TosaOps18(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult SinOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult SinOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void SinOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void SinOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::SinOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::SliceOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
SliceOpGenericAdaptorBase::SliceOpGenericAdaptorBase(SliceOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
SliceOpAdaptor::SliceOpAdaptor(SliceOp op) : SliceOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult SliceOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult SliceOp::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 SliceOp::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 SliceOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> SliceOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void SliceOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void SliceOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult SliceOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void SliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value start, ::mlir::Value size) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(start);
|
|
odsState.addOperands(size);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
SliceOp SliceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value start, ::mlir::Value size) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(start)>(start), std::forward<decltype(size)>(size));
|
|
auto __res__ = ::llvm::dyn_cast<SliceOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SliceOp SliceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value start, ::mlir::Value size) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(start)>(start), std::forward<decltype(size)>(size));
|
|
}
|
|
|
|
void SliceOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value start, ::mlir::Value size) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(start);
|
|
odsState.addOperands(size);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
SliceOp SliceOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value start, ::mlir::Value size) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(start)>(start), std::forward<decltype(size)>(size));
|
|
auto __res__ = ::llvm::dyn_cast<SliceOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SliceOp SliceOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value start, ::mlir::Value size) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(start)>(start), std::forward<decltype(size)>(size));
|
|
}
|
|
|
|
void SliceOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 3u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
SliceOp SliceOp::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<SliceOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SliceOp SliceOp::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 SliceOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
|
|
assert(operands.size() == 3u && "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);
|
|
}
|
|
|
|
SliceOp SliceOp::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<SliceOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SliceOp SliceOp::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 SliceOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps2(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps2(*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_TosaOps5(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult SliceOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult SliceOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void SliceOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void SliceOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
SliceOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
SliceOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return SliceOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::SliceOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::SliceShapeOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
SliceShapeOpGenericAdaptorBase::SliceShapeOpGenericAdaptorBase(SliceShapeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
SliceShapeOpAdaptor::SliceShapeOpAdaptor(SliceShapeOp op) : SliceShapeOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult SliceShapeOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult SliceShapeOp::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 SliceShapeOp::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 SliceShapeOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> SliceShapeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void SliceShapeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void SliceShapeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult SliceShapeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void SliceShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, ::mlir::Value start, ::mlir::Value size) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(start);
|
|
odsState.addOperands(size);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
SliceShapeOp SliceShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, ::mlir::Value start, ::mlir::Value size) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(start)>(start), std::forward<decltype(size)>(size));
|
|
auto __res__ = ::llvm::dyn_cast<SliceShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SliceShapeOp SliceShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, ::mlir::Value start, ::mlir::Value size) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(start)>(start), std::forward<decltype(size)>(size));
|
|
}
|
|
|
|
void SliceShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value start, ::mlir::Value size) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(start);
|
|
odsState.addOperands(size);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
SliceShapeOp SliceShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value start, ::mlir::Value size) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(start)>(start), std::forward<decltype(size)>(size));
|
|
auto __res__ = ::llvm::dyn_cast<SliceShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SliceShapeOp SliceShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value start, ::mlir::Value size) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(start)>(start), std::forward<decltype(size)>(size));
|
|
}
|
|
|
|
void SliceShapeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 3u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
SliceShapeOp SliceShapeOp::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<SliceShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SliceShapeOp SliceShapeOp::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 SliceShapeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
|
|
assert(operands.size() == 3u && "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);
|
|
}
|
|
|
|
SliceShapeOp SliceShapeOp::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<SliceShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SliceShapeOp SliceShapeOp::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 SliceShapeOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps2(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps31(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps31(*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_TosaOps2(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult SliceShapeOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult SliceShapeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void SliceShapeOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void SliceShapeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::SliceShapeOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::SubOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
SubOpGenericAdaptorBase::SubOpGenericAdaptorBase(SubOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
SubOpAdaptor::SubOpAdaptor(SubOp op) : SubOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult SubOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult SubOp::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 SubOp::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 SubOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> SubOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void SubOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void SubOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult SubOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void SubOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
SubOp SubOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<SubOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SubOp SubOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void SubOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
SubOp SubOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<SubOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SubOp SubOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void SubOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
SubOp SubOp::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<SubOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SubOp SubOp::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 SubOp::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);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
SubOp SubOp::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<SubOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SubOp SubOp::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 SubOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*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_TosaOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult SubOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult SubOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void SubOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void SubOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::SubOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::SubShapeOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
SubShapeOpGenericAdaptorBase::SubShapeOpGenericAdaptorBase(SubShapeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
SubShapeOpAdaptor::SubShapeOpAdaptor(SubShapeOp op) : SubShapeOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult SubShapeOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult SubShapeOp::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 SubShapeOp::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 SubShapeOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> SubShapeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void SubShapeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void SubShapeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult SubShapeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void SubShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
SubShapeOp SubShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<SubShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SubShapeOp SubShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void SubShapeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(input2);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
SubShapeOp SubShapeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
auto __res__ = ::llvm::dyn_cast<SubShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SubShapeOp SubShapeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value input2) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(input2)>(input2));
|
|
}
|
|
|
|
void SubShapeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
SubShapeOp SubShapeOp::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<SubShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SubShapeOp SubShapeOp::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 SubShapeOp::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);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
SubShapeOp SubShapeOp::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<SubShapeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
SubShapeOp SubShapeOp::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 SubShapeOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps2(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps2(*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_TosaOps2(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult SubShapeOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult SubShapeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void SubShapeOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void SubShapeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::SubShapeOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::TableOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
TableOpGenericAdaptorBase::TableOpGenericAdaptorBase(TableOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
TableOpAdaptor::TableOpAdaptor(TableOp op) : TableOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult TableOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TableOp::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 TableOp::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 TableOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> TableOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void TableOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void TableOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult TableOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void TableOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value table) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(table);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
TableOp TableOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value table) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(table)>(table));
|
|
auto __res__ = ::llvm::dyn_cast<TableOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TableOp TableOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value table) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(table)>(table));
|
|
}
|
|
|
|
void TableOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value table) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(table);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TableOp TableOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value table) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(table)>(table));
|
|
auto __res__ = ::llvm::dyn_cast<TableOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TableOp TableOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value table) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(table)>(table));
|
|
}
|
|
|
|
void TableOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TableOp TableOp::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<TableOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TableOp TableOp::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 TableOp::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);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TableOp TableOp::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<TableOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TableOp TableOp::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 TableOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps16(*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_TosaOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TableOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult TableOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void TableOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void TableOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
TableOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
TableOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return TableOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::TableOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::TanhOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
TanhOpGenericAdaptorBase::TanhOpGenericAdaptorBase(TanhOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
TanhOpAdaptor::TanhOpAdaptor(TanhOp op) : TanhOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult TanhOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TanhOp::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 TanhOp::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 TanhOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> TanhOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void TanhOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void TanhOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult TanhOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void TanhOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input) {
|
|
odsState.addOperands(input);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
TanhOp TanhOp::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<TanhOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TanhOp TanhOp::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 TanhOp::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);
|
|
}
|
|
|
|
TanhOp TanhOp::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<TanhOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TanhOp TanhOp::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 TanhOp::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);
|
|
}
|
|
|
|
TanhOp TanhOp::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<TanhOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TanhOp TanhOp::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 TanhOp::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);
|
|
}
|
|
|
|
TanhOp TanhOp::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<TanhOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TanhOp TanhOp::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 TanhOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*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_TosaOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TanhOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult TanhOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void TanhOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void TanhOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::TanhOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::TileOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
TileOpGenericAdaptorBase::TileOpGenericAdaptorBase(TileOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
|
|
} // namespace detail
|
|
TileOpAdaptor::TileOpAdaptor(TileOp op) : TileOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult TileOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TileOp::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 TileOp::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 TileOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> TileOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void TileOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void TileOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult TileOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void TileOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value multiples) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(multiples);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
TileOp TileOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value multiples) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(multiples)>(multiples));
|
|
auto __res__ = ::llvm::dyn_cast<TileOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TileOp TileOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::Value multiples) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(multiples)>(multiples));
|
|
}
|
|
|
|
void TileOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value multiples) {
|
|
odsState.addOperands(input1);
|
|
odsState.addOperands(multiples);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TileOp TileOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value multiples) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(multiples)>(multiples));
|
|
auto __res__ = ::llvm::dyn_cast<TileOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TileOp TileOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::Value multiples) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(multiples)>(multiples));
|
|
}
|
|
|
|
void TileOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 2u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TileOp TileOp::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<TileOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TileOp TileOp::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 TileOp::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);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TileOp TileOp::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<TileOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TileOp TileOp::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 TileOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps5(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps2(*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_TosaOps5(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TileOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult TileOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void TileOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void TileOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
TileOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
TileOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return TileOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::TileOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::TransposeConv2DOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
TransposeConv2DOpGenericAdaptorBase::TransposeConv2DOpGenericAdaptorBase(TransposeConv2DOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::llvm::ArrayRef<int64_t> TransposeConv2DOpGenericAdaptorBase::getOutPad() {
|
|
auto attr = getOutPadAttr();
|
|
return attr;
|
|
}
|
|
|
|
::llvm::ArrayRef<int64_t> TransposeConv2DOpGenericAdaptorBase::getStride() {
|
|
auto attr = getStrideAttr();
|
|
return attr;
|
|
}
|
|
|
|
::mlir::Type TransposeConv2DOpGenericAdaptorBase::getAccType() {
|
|
auto attr = getAccTypeAttr();
|
|
return ::llvm::cast<::mlir::Type>(attr.getValue());
|
|
}
|
|
|
|
::mlir::BoolAttr TransposeConv2DOpGenericAdaptorBase::getLocalBoundAttr() {
|
|
auto attr = ::llvm::dyn_cast_or_null<::mlir::BoolAttr>(getProperties().local_bound);
|
|
if (!attr)
|
|
attr = ::mlir::Builder(odsAttrs.getContext()).getBoolAttr(false);
|
|
return attr;
|
|
}
|
|
|
|
bool TransposeConv2DOpGenericAdaptorBase::getLocalBound() {
|
|
auto attr = getLocalBoundAttr();
|
|
if (!attr)
|
|
return ::mlir::Builder(odsAttrs.getContext()).getBoolAttr(false).getValue();
|
|
return attr.getValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
TransposeConv2DOpAdaptor::TransposeConv2DOpAdaptor(TransposeConv2DOp op) : TransposeConv2DOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult TransposeConv2DOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_acc_type = getProperties().acc_type; (void)tblgen_acc_type;
|
|
if (!tblgen_acc_type) return emitError(loc, "'tosa.transpose_conv2d' op requires attribute 'acc_type'");
|
|
auto tblgen_local_bound = getProperties().local_bound; (void)tblgen_local_bound;
|
|
auto tblgen_out_pad = getProperties().out_pad; (void)tblgen_out_pad;
|
|
if (!tblgen_out_pad) return emitError(loc, "'tosa.transpose_conv2d' op requires attribute 'out_pad'");
|
|
auto tblgen_stride = getProperties().stride; (void)tblgen_stride;
|
|
if (!tblgen_stride) return emitError(loc, "'tosa.transpose_conv2d' op requires attribute 'stride'");
|
|
|
|
if (tblgen_out_pad && !(((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_out_pad))) && ((::llvm::cast<::mlir::DenseArrayAttr>(tblgen_out_pad).size() == 4))))
|
|
return emitError(loc, "'tosa.transpose_conv2d' op attribute 'out_pad' failed to satisfy constraint: i64 dense array attribute with exactly 4 elements");
|
|
|
|
if (tblgen_stride && !(((::llvm::isa<::mlir::DenseI64ArrayAttr>(tblgen_stride))) && ((::llvm::cast<::mlir::DenseArrayAttr>(tblgen_stride).size() == 2))))
|
|
return emitError(loc, "'tosa.transpose_conv2d' op attribute 'stride' failed to satisfy constraint: i64 dense array attribute with exactly 2 elements");
|
|
|
|
if (tblgen_acc_type && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_acc_type))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_acc_type).getValue()))) && (((::llvm::cast<::mlir::TypeAttr>(tblgen_acc_type).getValue().isSignlessInteger(32))) || ((::llvm::cast<::mlir::TypeAttr>(tblgen_acc_type).getValue().isSignlessInteger(48))) || ((::llvm::cast<::mlir::TypeAttr>(tblgen_acc_type).getValue().isF16())) || ((::llvm::cast<::mlir::TypeAttr>(tblgen_acc_type).getValue().isF32())))))
|
|
return emitError(loc, "'tosa.transpose_conv2d' op attribute 'acc_type' failed to satisfy constraint: type attribute of 32-bit signless integer or 48-bit signless integer or 16-bit float or 32-bit float");
|
|
|
|
if (tblgen_local_bound && !((::llvm::isa<::mlir::BoolAttr>(tblgen_local_bound))))
|
|
return emitError(loc, "'tosa.transpose_conv2d' op attribute 'local_bound' failed to satisfy constraint: bool attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TransposeConv2DOp::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.acc_type;
|
|
auto attr = dict.get("acc_type");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `acc_type` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.local_bound;
|
|
auto attr = dict.get("local_bound");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `local_bound` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.out_pad;
|
|
auto attr = dict.get("out_pad");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `out_pad` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.stride;
|
|
auto attr = dict.get("stride");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `stride` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute TransposeConv2DOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.acc_type;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("acc_type",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.local_bound;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("local_bound",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.out_pad;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("out_pad",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.stride;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("stride",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code TransposeConv2DOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.acc_type.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.local_bound.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.out_pad.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.stride.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> TransposeConv2DOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "acc_type")
|
|
return prop.acc_type;
|
|
|
|
if (name == "local_bound")
|
|
return prop.local_bound;
|
|
|
|
if (name == "out_pad")
|
|
return prop.out_pad;
|
|
|
|
if (name == "stride")
|
|
return prop.stride;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void TransposeConv2DOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "acc_type") {
|
|
prop.acc_type = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.acc_type)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "local_bound") {
|
|
prop.local_bound = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.local_bound)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "out_pad") {
|
|
prop.out_pad = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.out_pad)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "stride") {
|
|
prop.stride = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.stride)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void TransposeConv2DOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.acc_type) attrs.append("acc_type", prop.acc_type);
|
|
|
|
if (prop.local_bound) attrs.append("local_bound", prop.local_bound);
|
|
|
|
if (prop.out_pad) attrs.append("out_pad", prop.out_pad);
|
|
|
|
if (prop.stride) attrs.append("stride", prop.stride);
|
|
}
|
|
|
|
::llvm::LogicalResult TransposeConv2DOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getAccTypeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps5(attr, "acc_type", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getLocalBoundAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps4(attr, "local_bound", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getOutPadAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps7(attr, "out_pad", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getStrideAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps6(attr, "stride", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TransposeConv2DOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.acc_type)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.local_bound)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readAttribute(prop.out_pad)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readAttribute(prop.stride)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void TransposeConv2DOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.acc_type);
|
|
|
|
writer.writeOptionalAttribute(prop.local_bound);
|
|
writer.writeAttribute(prop.out_pad);
|
|
writer.writeAttribute(prop.stride);
|
|
}
|
|
|
|
::llvm::ArrayRef<int64_t> TransposeConv2DOp::getOutPad() {
|
|
auto attr = getOutPadAttr();
|
|
return attr;
|
|
}
|
|
|
|
::llvm::ArrayRef<int64_t> TransposeConv2DOp::getStride() {
|
|
auto attr = getStrideAttr();
|
|
return attr;
|
|
}
|
|
|
|
::mlir::Type TransposeConv2DOp::getAccType() {
|
|
auto attr = getAccTypeAttr();
|
|
return ::llvm::cast<::mlir::Type>(attr.getValue());
|
|
}
|
|
|
|
bool TransposeConv2DOp::getLocalBound() {
|
|
auto attr = getLocalBoundAttr();
|
|
if (!attr)
|
|
return ::mlir::Builder((*this)->getContext()).getBoolAttr(false).getValue();
|
|
return attr.getValue();
|
|
}
|
|
|
|
void TransposeConv2DOp::setOutPad(::llvm::ArrayRef<int64_t> attrValue) {
|
|
getProperties().out_pad = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue);
|
|
}
|
|
|
|
void TransposeConv2DOp::setStride(::llvm::ArrayRef<int64_t> attrValue) {
|
|
getProperties().stride = ::mlir::Builder((*this)->getContext()).getDenseI64ArrayAttr(attrValue);
|
|
}
|
|
|
|
void TransposeConv2DOp::setAccType(::mlir::Type attrValue) {
|
|
getProperties().acc_type = ::mlir::TypeAttr::get(attrValue);
|
|
}
|
|
|
|
void TransposeConv2DOp::setLocalBound(::std::optional<bool> attrValue) {
|
|
auto &odsProp = getProperties().local_bound;
|
|
if (attrValue)
|
|
odsProp = ::mlir::Builder((*this)->getContext()).getBoolAttr(*attrValue);
|
|
else
|
|
odsProp = nullptr;
|
|
}
|
|
|
|
void TransposeConv2DOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type outputType, ::mlir::Value input, ::mlir::Value weight, mlir::Value bias, ::mlir::DenseI64ArrayAttr outpad, ::mlir::DenseI64ArrayAttr stride, ::mlir::TypeAttr acc_type) {
|
|
buildTransConvOpWithQuantInfo(odsBuilder, odsState, outputType,
|
|
input, weight, bias,
|
|
outpad, stride, acc_type);
|
|
|
|
}
|
|
|
|
TransposeConv2DOp TransposeConv2DOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type outputType, ::mlir::Value input, ::mlir::Value weight, mlir::Value bias, ::mlir::DenseI64ArrayAttr outpad, ::mlir::DenseI64ArrayAttr stride, ::mlir::TypeAttr acc_type) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(outputType)>(outputType), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(outpad)>(outpad), std::forward<decltype(stride)>(stride), std::forward<decltype(acc_type)>(acc_type));
|
|
auto __res__ = ::llvm::dyn_cast<TransposeConv2DOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TransposeConv2DOp TransposeConv2DOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type outputType, ::mlir::Value input, ::mlir::Value weight, mlir::Value bias, ::mlir::DenseI64ArrayAttr outpad, ::mlir::DenseI64ArrayAttr stride, ::mlir::TypeAttr acc_type) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(outputType)>(outputType), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(outpad)>(outpad), std::forward<decltype(stride)>(stride), std::forward<decltype(acc_type)>(acc_type));
|
|
}
|
|
|
|
void TransposeConv2DOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::mlir::DenseI64ArrayAttr out_pad, ::mlir::DenseI64ArrayAttr stride, ::mlir::TypeAttr acc_type, /*optional*/::mlir::BoolAttr local_bound) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(weight);
|
|
odsState.addOperands(bias);
|
|
odsState.addOperands(input_zp);
|
|
odsState.addOperands(weight_zp);
|
|
odsState.getOrAddProperties<Properties>().out_pad = out_pad;
|
|
odsState.getOrAddProperties<Properties>().stride = stride;
|
|
odsState.getOrAddProperties<Properties>().acc_type = acc_type;
|
|
if (local_bound) {
|
|
odsState.getOrAddProperties<Properties>().local_bound = local_bound;
|
|
}
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
TransposeConv2DOp TransposeConv2DOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::mlir::DenseI64ArrayAttr out_pad, ::mlir::DenseI64ArrayAttr stride, ::mlir::TypeAttr acc_type, /*optional*/::mlir::BoolAttr local_bound) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(weight_zp)>(weight_zp), std::forward<decltype(out_pad)>(out_pad), std::forward<decltype(stride)>(stride), std::forward<decltype(acc_type)>(acc_type), std::forward<decltype(local_bound)>(local_bound));
|
|
auto __res__ = ::llvm::dyn_cast<TransposeConv2DOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TransposeConv2DOp TransposeConv2DOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::mlir::DenseI64ArrayAttr out_pad, ::mlir::DenseI64ArrayAttr stride, ::mlir::TypeAttr acc_type, /*optional*/::mlir::BoolAttr local_bound) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(weight_zp)>(weight_zp), std::forward<decltype(out_pad)>(out_pad), std::forward<decltype(stride)>(stride), std::forward<decltype(acc_type)>(acc_type), std::forward<decltype(local_bound)>(local_bound));
|
|
}
|
|
|
|
void TransposeConv2DOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::mlir::DenseI64ArrayAttr out_pad, ::mlir::DenseI64ArrayAttr stride, ::mlir::TypeAttr acc_type, /*optional*/::mlir::BoolAttr local_bound) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(weight);
|
|
odsState.addOperands(bias);
|
|
odsState.addOperands(input_zp);
|
|
odsState.addOperands(weight_zp);
|
|
odsState.getOrAddProperties<Properties>().out_pad = out_pad;
|
|
odsState.getOrAddProperties<Properties>().stride = stride;
|
|
odsState.getOrAddProperties<Properties>().acc_type = acc_type;
|
|
if (local_bound) {
|
|
odsState.getOrAddProperties<Properties>().local_bound = local_bound;
|
|
}
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TransposeConv2DOp TransposeConv2DOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::mlir::DenseI64ArrayAttr out_pad, ::mlir::DenseI64ArrayAttr stride, ::mlir::TypeAttr acc_type, /*optional*/::mlir::BoolAttr local_bound) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(weight_zp)>(weight_zp), std::forward<decltype(out_pad)>(out_pad), std::forward<decltype(stride)>(stride), std::forward<decltype(acc_type)>(acc_type), std::forward<decltype(local_bound)>(local_bound));
|
|
auto __res__ = ::llvm::dyn_cast<TransposeConv2DOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TransposeConv2DOp TransposeConv2DOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::mlir::DenseI64ArrayAttr out_pad, ::mlir::DenseI64ArrayAttr stride, ::mlir::TypeAttr acc_type, /*optional*/::mlir::BoolAttr local_bound) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(weight_zp)>(weight_zp), std::forward<decltype(out_pad)>(out_pad), std::forward<decltype(stride)>(stride), std::forward<decltype(acc_type)>(acc_type), std::forward<decltype(local_bound)>(local_bound));
|
|
}
|
|
|
|
void TransposeConv2DOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::llvm::ArrayRef<int64_t> out_pad, ::llvm::ArrayRef<int64_t> stride, ::mlir::Type acc_type, /*optional*/bool local_bound) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(weight);
|
|
odsState.addOperands(bias);
|
|
odsState.addOperands(input_zp);
|
|
odsState.addOperands(weight_zp);
|
|
odsState.getOrAddProperties<Properties>().out_pad = odsBuilder.getDenseI64ArrayAttr(out_pad);
|
|
odsState.getOrAddProperties<Properties>().stride = odsBuilder.getDenseI64ArrayAttr(stride);
|
|
odsState.getOrAddProperties<Properties>().acc_type = ::mlir::TypeAttr::get(acc_type);
|
|
odsState.getOrAddProperties<Properties>().local_bound = odsBuilder.getBoolAttr(local_bound);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
TransposeConv2DOp TransposeConv2DOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::llvm::ArrayRef<int64_t> out_pad, ::llvm::ArrayRef<int64_t> stride, ::mlir::Type acc_type, /*optional*/bool local_bound) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(weight_zp)>(weight_zp), std::forward<decltype(out_pad)>(out_pad), std::forward<decltype(stride)>(stride), std::forward<decltype(acc_type)>(acc_type), std::forward<decltype(local_bound)>(local_bound));
|
|
auto __res__ = ::llvm::dyn_cast<TransposeConv2DOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TransposeConv2DOp TransposeConv2DOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::llvm::ArrayRef<int64_t> out_pad, ::llvm::ArrayRef<int64_t> stride, ::mlir::Type acc_type, /*optional*/bool local_bound) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(weight_zp)>(weight_zp), std::forward<decltype(out_pad)>(out_pad), std::forward<decltype(stride)>(stride), std::forward<decltype(acc_type)>(acc_type), std::forward<decltype(local_bound)>(local_bound));
|
|
}
|
|
|
|
void TransposeConv2DOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::llvm::ArrayRef<int64_t> out_pad, ::llvm::ArrayRef<int64_t> stride, ::mlir::Type acc_type, /*optional*/bool local_bound) {
|
|
odsState.addOperands(input);
|
|
odsState.addOperands(weight);
|
|
odsState.addOperands(bias);
|
|
odsState.addOperands(input_zp);
|
|
odsState.addOperands(weight_zp);
|
|
odsState.getOrAddProperties<Properties>().out_pad = odsBuilder.getDenseI64ArrayAttr(out_pad);
|
|
odsState.getOrAddProperties<Properties>().stride = odsBuilder.getDenseI64ArrayAttr(stride);
|
|
odsState.getOrAddProperties<Properties>().acc_type = ::mlir::TypeAttr::get(acc_type);
|
|
odsState.getOrAddProperties<Properties>().local_bound = odsBuilder.getBoolAttr(local_bound);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TransposeConv2DOp TransposeConv2DOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::llvm::ArrayRef<int64_t> out_pad, ::llvm::ArrayRef<int64_t> stride, ::mlir::Type acc_type, /*optional*/bool local_bound) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(weight_zp)>(weight_zp), std::forward<decltype(out_pad)>(out_pad), std::forward<decltype(stride)>(stride), std::forward<decltype(acc_type)>(acc_type), std::forward<decltype(local_bound)>(local_bound));
|
|
auto __res__ = ::llvm::dyn_cast<TransposeConv2DOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TransposeConv2DOp TransposeConv2DOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input, ::mlir::Value weight, ::mlir::Value bias, ::mlir::Value input_zp, ::mlir::Value weight_zp, ::llvm::ArrayRef<int64_t> out_pad, ::llvm::ArrayRef<int64_t> stride, ::mlir::Type acc_type, /*optional*/bool local_bound) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input)>(input), std::forward<decltype(weight)>(weight), std::forward<decltype(bias)>(bias), std::forward<decltype(input_zp)>(input_zp), std::forward<decltype(weight_zp)>(weight_zp), std::forward<decltype(out_pad)>(out_pad), std::forward<decltype(stride)>(stride), std::forward<decltype(acc_type)>(acc_type), std::forward<decltype(local_bound)>(local_bound));
|
|
}
|
|
|
|
void TransposeConv2DOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 5u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<TransposeConv2DOp::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.");
|
|
}
|
|
}
|
|
|
|
TransposeConv2DOp TransposeConv2DOp::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<TransposeConv2DOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TransposeConv2DOp TransposeConv2DOp::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 TransposeConv2DOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
|
|
assert(operands.size() == 5u && "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);
|
|
}
|
|
|
|
TransposeConv2DOp TransposeConv2DOp::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<TransposeConv2DOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TransposeConv2DOp TransposeConv2DOp::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 TransposeConv2DOp::verifyInvariantsImpl() {
|
|
auto tblgen_acc_type = getProperties().acc_type; (void)tblgen_acc_type;
|
|
if (!tblgen_acc_type) return emitOpError("requires attribute 'acc_type'");
|
|
auto tblgen_local_bound = getProperties().local_bound; (void)tblgen_local_bound;
|
|
auto tblgen_out_pad = getProperties().out_pad; (void)tblgen_out_pad;
|
|
if (!tblgen_out_pad) return emitOpError("requires attribute 'out_pad'");
|
|
auto tblgen_stride = getProperties().stride; (void)tblgen_stride;
|
|
if (!tblgen_stride) return emitOpError("requires attribute 'stride'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps7(*this, tblgen_out_pad, "out_pad")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps6(*this, tblgen_stride, "stride")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps5(*this, tblgen_acc_type, "acc_type")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps4(*this, tblgen_local_bound, "local_bound")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps6(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup1 = getODSOperands(1);
|
|
|
|
for (auto v : valueGroup1) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps6(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup2 = getODSOperands(2);
|
|
|
|
for (auto v : valueGroup2) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps16(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup3 = getODSOperands(3);
|
|
|
|
for (auto v : valueGroup3) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps7(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
auto valueGroup4 = getODSOperands(4);
|
|
|
|
for (auto v : valueGroup4) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps7(*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_TosaOps6(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TransposeConv2DOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult TransposeConv2DOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void TransposeConv2DOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
{
|
|
::mlir::Builder odsBuilder(getContext());
|
|
::mlir::Attribute attr = getLocalBoundAttr();
|
|
if(attr && (attr == odsBuilder.getBoolAttr(false)))
|
|
elidedAttrs.push_back("local_bound");
|
|
}
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void TransposeConv2DOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
TransposeConv2DOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
TransposeConv2DOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return TransposeConv2DOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::TransposeConv2DOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::TransposeConv2DOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::TransposeOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
TransposeOpGenericAdaptorBase::TransposeOpGenericAdaptorBase(TransposeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::llvm::ArrayRef<int32_t> TransposeOpGenericAdaptorBase::getPerms() {
|
|
auto attr = getPermsAttr();
|
|
return attr;
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
TransposeOpAdaptor::TransposeOpAdaptor(TransposeOp op) : TransposeOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult TransposeOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_perms = getProperties().perms; (void)tblgen_perms;
|
|
if (!tblgen_perms) return emitError(loc, "'tosa.transpose' op requires attribute 'perms'");
|
|
|
|
if (tblgen_perms && !((::llvm::isa<::mlir::DenseI32ArrayAttr>(tblgen_perms))))
|
|
return emitError(loc, "'tosa.transpose' op attribute 'perms' failed to satisfy constraint: i32 dense array attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TransposeOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
|
|
if (!dict) {
|
|
emitError() << "expected DictionaryAttr to set properties";
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.perms;
|
|
auto attr = dict.get("perms");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `perms` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute TransposeOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.perms;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("perms",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code TransposeOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.perms.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> TransposeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "perms")
|
|
return prop.perms;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void TransposeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "perms") {
|
|
prop.perms = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.perms)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void TransposeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.perms) attrs.append("perms", prop.perms);
|
|
}
|
|
|
|
::llvm::LogicalResult TransposeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getPermsAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps16(attr, "perms", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TransposeOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.perms)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void TransposeOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.perms);
|
|
}
|
|
|
|
::llvm::ArrayRef<int32_t> TransposeOp::getPerms() {
|
|
auto attr = getPermsAttr();
|
|
return attr;
|
|
}
|
|
|
|
void TransposeOp::setPerms(::llvm::ArrayRef<int32_t> attrValue) {
|
|
getProperties().perms = ::mlir::Builder((*this)->getContext()).getDenseI32ArrayAttr(attrValue);
|
|
}
|
|
|
|
void TransposeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::mlir::DenseI32ArrayAttr perms) {
|
|
odsState.addOperands(input1);
|
|
odsState.getOrAddProperties<Properties>().perms = perms;
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
TransposeOp TransposeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::mlir::DenseI32ArrayAttr perms) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(perms)>(perms));
|
|
auto __res__ = ::llvm::dyn_cast<TransposeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TransposeOp TransposeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::mlir::DenseI32ArrayAttr perms) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(perms)>(perms));
|
|
}
|
|
|
|
void TransposeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::DenseI32ArrayAttr perms) {
|
|
odsState.addOperands(input1);
|
|
odsState.getOrAddProperties<Properties>().perms = perms;
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TransposeOp TransposeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::DenseI32ArrayAttr perms) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(perms)>(perms));
|
|
auto __res__ = ::llvm::dyn_cast<TransposeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TransposeOp TransposeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::mlir::DenseI32ArrayAttr perms) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(perms)>(perms));
|
|
}
|
|
|
|
void TransposeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output, ::mlir::Value input1, ::llvm::ArrayRef<int32_t> perms) {
|
|
odsState.addOperands(input1);
|
|
odsState.getOrAddProperties<Properties>().perms = odsBuilder.getDenseI32ArrayAttr(perms);
|
|
odsState.addTypes(output);
|
|
}
|
|
|
|
TransposeOp TransposeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output, ::mlir::Value input1, ::llvm::ArrayRef<int32_t> perms) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(perms)>(perms));
|
|
auto __res__ = ::llvm::dyn_cast<TransposeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TransposeOp TransposeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output, ::mlir::Value input1, ::llvm::ArrayRef<int32_t> perms) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output)>(output), std::forward<decltype(input1)>(input1), std::forward<decltype(perms)>(perms));
|
|
}
|
|
|
|
void TransposeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::llvm::ArrayRef<int32_t> perms) {
|
|
odsState.addOperands(input1);
|
|
odsState.getOrAddProperties<Properties>().perms = odsBuilder.getDenseI32ArrayAttr(perms);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
TransposeOp TransposeOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::llvm::ArrayRef<int32_t> perms) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(perms)>(perms));
|
|
auto __res__ = ::llvm::dyn_cast<TransposeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TransposeOp TransposeOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::Value input1, ::llvm::ArrayRef<int32_t> perms) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(input1)>(input1), std::forward<decltype(perms)>(perms));
|
|
}
|
|
|
|
void TransposeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 1u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<TransposeOp::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.");
|
|
}
|
|
}
|
|
|
|
TransposeOp TransposeOp::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<TransposeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TransposeOp TransposeOp::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 TransposeOp::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);
|
|
}
|
|
|
|
TransposeOp TransposeOp::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<TransposeOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
TransposeOp TransposeOp::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 TransposeOp::verifyInvariantsImpl() {
|
|
auto tblgen_perms = getProperties().perms; (void)tblgen_perms;
|
|
if (!tblgen_perms) return emitOpError("requires attribute 'perms'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps16(*this, tblgen_perms, "perms")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps5(*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_TosaOps5(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
if (!(((getElementTypeOrSelf((*this->getODSOperands(0).begin()))) == (getElementTypeOrSelf((*this->getODSResults(0).begin()))) && (getElementTypeOrSelf((*this->getODSResults(0).begin()))) == (getElementTypeOrSelf((*this->getODSOperands(0).begin()))))))
|
|
return emitOpError("failed to verify that all of {input1, output} have same element type");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult TransposeOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult TransposeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> allOperands;
|
|
::llvm::ArrayRef<::mlir::Type> allOperandTypes;
|
|
::llvm::ArrayRef<::mlir::Type> allResultTypes;
|
|
[[maybe_unused]] ::llvm::SMLoc allOperandLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(allOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (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(allOperands, allOperandTypes, allOperandLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void TransposeOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getOperation()->getOperands();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printFunctionalType(getOperation()->getOperandTypes(), getOperation()->getResultTypes());
|
|
}
|
|
|
|
void TransposeOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
TransposeOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
TransposeOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return TransposeOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::TransposeOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::TransposeOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::VariableOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
VariableOpGenericAdaptorBase::VariableOpGenericAdaptorBase(VariableOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::llvm::StringRef VariableOpGenericAdaptorBase::getSymName() {
|
|
auto attr = getSymNameAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
::mlir::DenseIntElementsAttr VariableOpGenericAdaptorBase::getVarShape() {
|
|
auto attr = getVarShapeAttr();
|
|
return attr;
|
|
}
|
|
|
|
::mlir::Type VariableOpGenericAdaptorBase::getType() {
|
|
auto attr = getTypeAttr();
|
|
return ::llvm::cast<::mlir::Type>(attr.getValue());
|
|
}
|
|
|
|
::std::optional<::mlir::Attribute> VariableOpGenericAdaptorBase::getInitialValue() {
|
|
auto attr = getInitialValueAttr();
|
|
return attr ? ::std::optional<::mlir::Attribute>(attr) : (::std::nullopt);
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
VariableOpAdaptor::VariableOpAdaptor(VariableOp op) : VariableOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult VariableOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_initial_value = getProperties().initial_value; (void)tblgen_initial_value;
|
|
auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name;
|
|
if (!tblgen_sym_name) return emitError(loc, "'tosa.variable' op requires attribute 'sym_name'");
|
|
auto tblgen_type = getProperties().type; (void)tblgen_type;
|
|
if (!tblgen_type) return emitError(loc, "'tosa.variable' op requires attribute 'type'");
|
|
auto tblgen_var_shape = getProperties().var_shape; (void)tblgen_var_shape;
|
|
if (!tblgen_var_shape) return emitError(loc, "'tosa.variable' op requires attribute 'var_shape'");
|
|
|
|
if (tblgen_sym_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_sym_name))))
|
|
return emitError(loc, "'tosa.variable' op attribute 'sym_name' failed to satisfy constraint: string attribute");
|
|
|
|
if (tblgen_var_shape && !(((::llvm::isa<::mlir::DenseIntElementsAttr>(tblgen_var_shape))) && ((::llvm::cast<::mlir::DenseIntElementsAttr>(tblgen_var_shape)
|
|
.getType()
|
|
.getElementType()
|
|
.isIndex()))))
|
|
return emitError(loc, "'tosa.variable' op attribute 'var_shape' failed to satisfy constraint: index elements attribute");
|
|
|
|
if (tblgen_type && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_type))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_type).getValue()))) && ((true))))
|
|
return emitError(loc, "'tosa.variable' op attribute 'type' failed to satisfy constraint: any type attribute");
|
|
|
|
if (tblgen_initial_value && !((true)))
|
|
return emitError(loc, "'tosa.variable' op attribute 'initial_value' failed to satisfy constraint: any attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult VariableOp::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.initial_value;
|
|
auto attr = dict.get("initial_value");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `initial_value` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.sym_name;
|
|
auto attr = dict.get("sym_name");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `sym_name` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.type;
|
|
auto attr = dict.get("type");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `type` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.var_shape;
|
|
auto attr = dict.get("var_shape");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `var_shape` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute VariableOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.initial_value;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("initial_value",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.sym_name;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("sym_name",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.type;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("type",
|
|
propStorage));
|
|
}
|
|
|
|
{
|
|
const auto &propStorage = prop.var_shape;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("var_shape",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code VariableOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.initial_value.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.sym_name.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.type.getAsOpaquePointer()),
|
|
llvm::hash_value(prop.var_shape.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> VariableOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "initial_value")
|
|
return prop.initial_value;
|
|
|
|
if (name == "sym_name")
|
|
return prop.sym_name;
|
|
|
|
if (name == "type")
|
|
return prop.type;
|
|
|
|
if (name == "var_shape")
|
|
return prop.var_shape;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void VariableOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "initial_value") {
|
|
prop.initial_value = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.initial_value)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "sym_name") {
|
|
prop.sym_name = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.sym_name)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "type") {
|
|
prop.type = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.type)>>(value);
|
|
return;
|
|
}
|
|
|
|
if (name == "var_shape") {
|
|
prop.var_shape = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.var_shape)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void VariableOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.initial_value) attrs.append("initial_value", prop.initial_value);
|
|
|
|
if (prop.sym_name) attrs.append("sym_name", prop.sym_name);
|
|
|
|
if (prop.type) attrs.append("type", prop.type);
|
|
|
|
if (prop.var_shape) attrs.append("var_shape", prop.var_shape);
|
|
}
|
|
|
|
::llvm::LogicalResult VariableOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getInitialValueAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps18(attr, "initial_value", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getSymNameAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps14(attr, "sym_name", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getTypeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps17(attr, "type", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getVarShapeAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps11(attr, "var_shape", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult VariableOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readOptionalAttribute(prop.initial_value)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readAttribute(prop.sym_name)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readAttribute(prop.type)))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(reader.readAttribute(prop.var_shape)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void VariableOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
|
|
writer.writeOptionalAttribute(prop.initial_value);
|
|
writer.writeAttribute(prop.sym_name);
|
|
writer.writeAttribute(prop.type);
|
|
writer.writeAttribute(prop.var_shape);
|
|
}
|
|
|
|
::llvm::StringRef VariableOp::getSymName() {
|
|
auto attr = getSymNameAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
::mlir::DenseIntElementsAttr VariableOp::getVarShape() {
|
|
auto attr = getVarShapeAttr();
|
|
return attr;
|
|
}
|
|
|
|
::mlir::Type VariableOp::getType() {
|
|
auto attr = getTypeAttr();
|
|
return ::llvm::cast<::mlir::Type>(attr.getValue());
|
|
}
|
|
|
|
::std::optional<::mlir::Attribute> VariableOp::getInitialValue() {
|
|
auto attr = getInitialValueAttr();
|
|
return attr ? ::std::optional<::mlir::Attribute>(attr) : (::std::nullopt);
|
|
}
|
|
|
|
void VariableOp::setSymName(::llvm::StringRef attrValue) {
|
|
getProperties().sym_name = ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue);
|
|
}
|
|
|
|
void VariableOp::setType(::mlir::Type attrValue) {
|
|
getProperties().type = ::mlir::TypeAttr::get(attrValue);
|
|
}
|
|
|
|
void VariableOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, StringRef sym_name, Type variable_type, Attribute initial_value) {
|
|
buildVariableOp(odsBuilder, odsState, sym_name, variable_type, initial_value);
|
|
|
|
}
|
|
|
|
VariableOp VariableOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, StringRef sym_name, Type variable_type, Attribute initial_value) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(variable_type)>(variable_type), std::forward<decltype(initial_value)>(initial_value));
|
|
auto __res__ = ::llvm::dyn_cast<VariableOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
VariableOp VariableOp::create(::mlir::ImplicitLocOpBuilder &builder, StringRef sym_name, Type variable_type, Attribute initial_value) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(variable_type)>(variable_type), std::forward<decltype(initial_value)>(initial_value));
|
|
}
|
|
|
|
void VariableOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::StringAttr sym_name, ::mlir::DenseIntElementsAttr var_shape, ::mlir::TypeAttr type, /*optional*/::mlir::Attribute initial_value) {
|
|
odsState.getOrAddProperties<Properties>().sym_name = sym_name;
|
|
odsState.getOrAddProperties<Properties>().var_shape = var_shape;
|
|
odsState.getOrAddProperties<Properties>().type = type;
|
|
if (initial_value) {
|
|
odsState.getOrAddProperties<Properties>().initial_value = initial_value;
|
|
}
|
|
}
|
|
|
|
VariableOp VariableOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::StringAttr sym_name, ::mlir::DenseIntElementsAttr var_shape, ::mlir::TypeAttr type, /*optional*/::mlir::Attribute initial_value) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(var_shape)>(var_shape), std::forward<decltype(type)>(type), std::forward<decltype(initial_value)>(initial_value));
|
|
auto __res__ = ::llvm::dyn_cast<VariableOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
VariableOp VariableOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::StringAttr sym_name, ::mlir::DenseIntElementsAttr var_shape, ::mlir::TypeAttr type, /*optional*/::mlir::Attribute initial_value) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(var_shape)>(var_shape), std::forward<decltype(type)>(type), std::forward<decltype(initial_value)>(initial_value));
|
|
}
|
|
|
|
void VariableOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, ::mlir::DenseIntElementsAttr var_shape, ::mlir::TypeAttr type, /*optional*/::mlir::Attribute initial_value) {
|
|
odsState.getOrAddProperties<Properties>().sym_name = sym_name;
|
|
odsState.getOrAddProperties<Properties>().var_shape = var_shape;
|
|
odsState.getOrAddProperties<Properties>().type = type;
|
|
if (initial_value) {
|
|
odsState.getOrAddProperties<Properties>().initial_value = initial_value;
|
|
}
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
VariableOp VariableOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, ::mlir::DenseIntElementsAttr var_shape, ::mlir::TypeAttr type, /*optional*/::mlir::Attribute initial_value) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(var_shape)>(var_shape), std::forward<decltype(type)>(type), std::forward<decltype(initial_value)>(initial_value));
|
|
auto __res__ = ::llvm::dyn_cast<VariableOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
VariableOp VariableOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, ::mlir::DenseIntElementsAttr var_shape, ::mlir::TypeAttr type, /*optional*/::mlir::Attribute initial_value) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(var_shape)>(var_shape), std::forward<decltype(type)>(type), std::forward<decltype(initial_value)>(initial_value));
|
|
}
|
|
|
|
void VariableOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llvm::StringRef sym_name, ::mlir::DenseIntElementsAttr var_shape, ::mlir::Type type, /*optional*/::mlir::Attribute initial_value) {
|
|
odsState.getOrAddProperties<Properties>().sym_name = odsBuilder.getStringAttr(sym_name);
|
|
odsState.getOrAddProperties<Properties>().var_shape = var_shape;
|
|
odsState.getOrAddProperties<Properties>().type = ::mlir::TypeAttr::get(type);
|
|
if (initial_value) {
|
|
odsState.getOrAddProperties<Properties>().initial_value = initial_value;
|
|
}
|
|
}
|
|
|
|
VariableOp VariableOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::llvm::StringRef sym_name, ::mlir::DenseIntElementsAttr var_shape, ::mlir::Type type, /*optional*/::mlir::Attribute initial_value) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(var_shape)>(var_shape), std::forward<decltype(type)>(type), std::forward<decltype(initial_value)>(initial_value));
|
|
auto __res__ = ::llvm::dyn_cast<VariableOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
VariableOp VariableOp::create(::mlir::ImplicitLocOpBuilder &builder, ::llvm::StringRef sym_name, ::mlir::DenseIntElementsAttr var_shape, ::mlir::Type type, /*optional*/::mlir::Attribute initial_value) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(var_shape)>(var_shape), std::forward<decltype(type)>(type), std::forward<decltype(initial_value)>(initial_value));
|
|
}
|
|
|
|
void VariableOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, ::mlir::DenseIntElementsAttr var_shape, ::mlir::Type type, /*optional*/::mlir::Attribute initial_value) {
|
|
odsState.getOrAddProperties<Properties>().sym_name = odsBuilder.getStringAttr(sym_name);
|
|
odsState.getOrAddProperties<Properties>().var_shape = var_shape;
|
|
odsState.getOrAddProperties<Properties>().type = ::mlir::TypeAttr::get(type);
|
|
if (initial_value) {
|
|
odsState.getOrAddProperties<Properties>().initial_value = initial_value;
|
|
}
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
VariableOp VariableOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, ::mlir::DenseIntElementsAttr var_shape, ::mlir::Type type, /*optional*/::mlir::Attribute initial_value) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(var_shape)>(var_shape), std::forward<decltype(type)>(type), std::forward<decltype(initial_value)>(initial_value));
|
|
auto __res__ = ::llvm::dyn_cast<VariableOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
VariableOp VariableOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, ::mlir::DenseIntElementsAttr var_shape, ::mlir::Type type, /*optional*/::mlir::Attribute initial_value) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(sym_name)>(sym_name), std::forward<decltype(var_shape)>(var_shape), std::forward<decltype(type)>(type), std::forward<decltype(initial_value)>(initial_value));
|
|
}
|
|
|
|
void VariableOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 0u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 0u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<VariableOp::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.");
|
|
}
|
|
}
|
|
|
|
VariableOp VariableOp::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<VariableOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
VariableOp VariableOp::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 VariableOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
|
|
assert(operands.size() == 0u && "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);
|
|
}
|
|
|
|
VariableOp VariableOp::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<VariableOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
VariableOp VariableOp::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 VariableOp::verifyInvariantsImpl() {
|
|
auto tblgen_initial_value = getProperties().initial_value; (void)tblgen_initial_value;
|
|
auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name;
|
|
if (!tblgen_sym_name) return emitOpError("requires attribute 'sym_name'");
|
|
auto tblgen_type = getProperties().type; (void)tblgen_type;
|
|
if (!tblgen_type) return emitOpError("requires attribute 'type'");
|
|
auto tblgen_var_shape = getProperties().var_shape; (void)tblgen_var_shape;
|
|
if (!tblgen_var_shape) return emitOpError("requires attribute 'var_shape'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps14(*this, tblgen_sym_name, "sym_name")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps11(*this, tblgen_var_shape, "var_shape")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps17(*this, tblgen_type, "type")))
|
|
return ::mlir::failure();
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps18(*this, tblgen_initial_value, "initial_value")))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult VariableOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult VariableOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::mlir::StringAttr sym_nameAttr;
|
|
::mlir::DenseIntElementsAttr var_shapeAttr;
|
|
::mlir::TypeAttr typeAttr;
|
|
::mlir::Attribute initial_valueAttr;
|
|
|
|
if (parser.parseSymbolName(sym_nameAttr))
|
|
return ::mlir::failure();
|
|
if (sym_nameAttr) result.getOrAddProperties<VariableOp::Properties>().sym_name = sym_nameAttr;
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() {
|
|
return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op ";
|
|
})))
|
|
return ::mlir::failure();
|
|
}
|
|
{
|
|
auto odsResult = parseVariableOpTypeOrInitialValue(parser, var_shapeAttr, typeAttr, initial_valueAttr);
|
|
if (odsResult) return ::mlir::failure();
|
|
result.getOrAddProperties<VariableOp::Properties>().var_shape = var_shapeAttr;
|
|
result.getOrAddProperties<VariableOp::Properties>().type = typeAttr;
|
|
if (initial_valueAttr)
|
|
result.getOrAddProperties<VariableOp::Properties>().initial_value = initial_valueAttr;
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void VariableOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printSymbolName(getSymNameAttr().getValue());
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("sym_name");
|
|
elidedAttrs.push_back("var_shape");
|
|
elidedAttrs.push_back("type");
|
|
elidedAttrs.push_back("initial_value");
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ';
|
|
printVariableOpTypeOrInitialValue(_odsPrinter, *this, getVarShapeAttr(), getTypeAttr(), getInitialValueAttr());
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::VariableOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::VariableOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::VariableReadOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
VariableReadOpGenericAdaptorBase::VariableReadOpGenericAdaptorBase(VariableReadOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::llvm::StringRef VariableReadOpGenericAdaptorBase::getName() {
|
|
auto attr = getNameAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
VariableReadOpAdaptor::VariableReadOpAdaptor(VariableReadOp op) : VariableReadOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult VariableReadOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_name = getProperties().name; (void)tblgen_name;
|
|
if (!tblgen_name) return emitError(loc, "'tosa.variable_read' op requires attribute 'name'");
|
|
|
|
if (tblgen_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_name))))
|
|
return emitError(loc, "'tosa.variable_read' op attribute 'name' failed to satisfy constraint: string attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult VariableReadOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
|
|
if (!dict) {
|
|
emitError() << "expected DictionaryAttr to set properties";
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.name;
|
|
auto attr = dict.get("name");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `name` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute VariableReadOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.name;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("name",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code VariableReadOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.name.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> VariableReadOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "name")
|
|
return prop.name;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void VariableReadOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "name") {
|
|
prop.name = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.name)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void VariableReadOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.name) attrs.append("name", prop.name);
|
|
}
|
|
|
|
::llvm::LogicalResult VariableReadOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getNameAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps14(attr, "name", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult VariableReadOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.name)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void VariableReadOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.name);
|
|
}
|
|
|
|
::llvm::StringRef VariableReadOp::getName() {
|
|
auto attr = getNameAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
void VariableReadOp::setName(::llvm::StringRef attrValue) {
|
|
getProperties().name = ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue);
|
|
}
|
|
|
|
void VariableReadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output1, ::mlir::StringAttr name) {
|
|
odsState.getOrAddProperties<Properties>().name = name;
|
|
odsState.addTypes(output1);
|
|
}
|
|
|
|
VariableReadOp VariableReadOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output1, ::mlir::StringAttr name) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output1)>(output1), std::forward<decltype(name)>(name));
|
|
auto __res__ = ::llvm::dyn_cast<VariableReadOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
VariableReadOp VariableReadOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output1, ::mlir::StringAttr name) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output1)>(output1), std::forward<decltype(name)>(name));
|
|
}
|
|
|
|
void VariableReadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::StringAttr name) {
|
|
odsState.getOrAddProperties<Properties>().name = name;
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
VariableReadOp VariableReadOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::StringAttr name) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(name)>(name));
|
|
auto __res__ = ::llvm::dyn_cast<VariableReadOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
VariableReadOp VariableReadOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::StringAttr name) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(name)>(name));
|
|
}
|
|
|
|
void VariableReadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type output1, ::llvm::StringRef name) {
|
|
odsState.getOrAddProperties<Properties>().name = odsBuilder.getStringAttr(name);
|
|
odsState.addTypes(output1);
|
|
}
|
|
|
|
VariableReadOp VariableReadOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type output1, ::llvm::StringRef name) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(output1)>(output1), std::forward<decltype(name)>(name));
|
|
auto __res__ = ::llvm::dyn_cast<VariableReadOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
VariableReadOp VariableReadOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type output1, ::llvm::StringRef name) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(output1)>(output1), std::forward<decltype(name)>(name));
|
|
}
|
|
|
|
void VariableReadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::llvm::StringRef name) {
|
|
odsState.getOrAddProperties<Properties>().name = odsBuilder.getStringAttr(name);
|
|
assert(resultTypes.size() == 1u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
VariableReadOp VariableReadOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::llvm::StringRef name) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(name)>(name));
|
|
auto __res__ = ::llvm::dyn_cast<VariableReadOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
VariableReadOp VariableReadOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::llvm::StringRef name) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(name)>(name));
|
|
}
|
|
|
|
void VariableReadOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
assert(operands.size() == 0u && "mismatched number of parameters");
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 1u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<VariableReadOp::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.");
|
|
}
|
|
}
|
|
|
|
VariableReadOp VariableReadOp::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<VariableReadOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
VariableReadOp VariableReadOp::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 VariableReadOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
|
|
assert(operands.size() == 0u && "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);
|
|
}
|
|
|
|
VariableReadOp VariableReadOp::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<VariableReadOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
VariableReadOp VariableReadOp::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 VariableReadOp::verifyInvariantsImpl() {
|
|
auto tblgen_name = getProperties().name; (void)tblgen_name;
|
|
if (!tblgen_name) return emitOpError("requires attribute 'name'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps14(*this, tblgen_name, "name")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSResults(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult VariableReadOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult VariableReadOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::mlir::StringAttr nameAttr;
|
|
::mlir::Type output1RawType{};
|
|
::llvm::ArrayRef<::mlir::Type> output1Types(&output1RawType, 1);
|
|
|
|
if (parser.parseSymbolName(nameAttr))
|
|
return ::mlir::failure();
|
|
if (nameAttr) result.getOrAddProperties<VariableReadOp::Properties>().name = nameAttr;
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() {
|
|
return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op ";
|
|
})))
|
|
return ::mlir::failure();
|
|
}
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
{
|
|
::mlir::TensorType type;
|
|
if (parser.parseCustomTypeWithFallback(type))
|
|
return ::mlir::failure();
|
|
output1RawType = type;
|
|
}
|
|
result.addTypes(output1Types);
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void VariableReadOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printSymbolName(getNameAttr().getValue());
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("name");
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
{
|
|
auto type = getOutput1().getType();
|
|
if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type))
|
|
_odsPrinter.printStrippedAttrOrType(validType);
|
|
else
|
|
_odsPrinter << type;
|
|
}
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::VariableReadOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::VariableReadOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::VariableWriteOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
VariableWriteOpGenericAdaptorBase::VariableWriteOpGenericAdaptorBase(VariableWriteOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
::llvm::StringRef VariableWriteOpGenericAdaptorBase::getName() {
|
|
auto attr = getNameAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
VariableWriteOpAdaptor::VariableWriteOpAdaptor(VariableWriteOp op) : VariableWriteOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult VariableWriteOpAdaptor::verify(::mlir::Location loc) {
|
|
auto tblgen_name = getProperties().name; (void)tblgen_name;
|
|
if (!tblgen_name) return emitError(loc, "'tosa.variable_write' op requires attribute 'name'");
|
|
|
|
if (tblgen_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_name))))
|
|
return emitError(loc, "'tosa.variable_write' op attribute 'name' failed to satisfy constraint: string attribute");
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult VariableWriteOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
|
|
if (!dict) {
|
|
emitError() << "expected DictionaryAttr to set properties";
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
{
|
|
auto &propStorage = prop.name;
|
|
auto attr = dict.get("name");
|
|
if (attr) {
|
|
auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
|
|
if (convertedAttr) {
|
|
propStorage = convertedAttr;
|
|
} else {
|
|
emitError() << "Invalid attribute `name` in property conversion: " << attr;
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::mlir::Attribute VariableWriteOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
|
|
::mlir::SmallVector<::mlir::NamedAttribute> attrs;
|
|
::mlir::Builder odsBuilder{ctx};
|
|
|
|
{
|
|
const auto &propStorage = prop.name;
|
|
if (propStorage)
|
|
attrs.push_back(odsBuilder.getNamedAttr("name",
|
|
propStorage));
|
|
}
|
|
|
|
if (!attrs.empty())
|
|
return odsBuilder.getDictionaryAttr(attrs);
|
|
return {};
|
|
}
|
|
|
|
llvm::hash_code VariableWriteOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine(
|
|
llvm::hash_value(prop.name.getAsOpaquePointer()));
|
|
}
|
|
|
|
std::optional<mlir::Attribute> VariableWriteOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
if (name == "name")
|
|
return prop.name;
|
|
return std::nullopt;
|
|
}
|
|
|
|
void VariableWriteOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
if (name == "name") {
|
|
prop.name = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.name)>>(value);
|
|
return;
|
|
}
|
|
}
|
|
|
|
void VariableWriteOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
if (prop.name) attrs.append("name", prop.name);
|
|
}
|
|
|
|
::llvm::LogicalResult VariableWriteOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
{
|
|
::mlir::Attribute attr = attrs.get(getNameAttrName(opName));
|
|
if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps14(attr, "name", emitError)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult VariableWriteOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
|
|
auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
|
|
if (::mlir::failed(reader.readAttribute(prop.name)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void VariableWriteOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
|
|
auto &prop = getProperties(); (void)prop;
|
|
writer.writeAttribute(prop.name);
|
|
}
|
|
|
|
::llvm::StringRef VariableWriteOp::getName() {
|
|
auto attr = getNameAttr();
|
|
return attr.getValue();
|
|
}
|
|
|
|
void VariableWriteOp::setName(::llvm::StringRef attrValue) {
|
|
getProperties().name = ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue);
|
|
}
|
|
|
|
void VariableWriteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::StringAttr name, ::mlir::Value input1) {
|
|
odsState.addOperands(input1);
|
|
odsState.getOrAddProperties<Properties>().name = name;
|
|
}
|
|
|
|
VariableWriteOp VariableWriteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::StringAttr name, ::mlir::Value input1) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(name)>(name), std::forward<decltype(input1)>(input1));
|
|
auto __res__ = ::llvm::dyn_cast<VariableWriteOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
VariableWriteOp VariableWriteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::StringAttr name, ::mlir::Value input1) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(name)>(name), std::forward<decltype(input1)>(input1));
|
|
}
|
|
|
|
void VariableWriteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::StringAttr name, ::mlir::Value input1) {
|
|
odsState.addOperands(input1);
|
|
odsState.getOrAddProperties<Properties>().name = name;
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
VariableWriteOp VariableWriteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::StringAttr name, ::mlir::Value input1) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(name)>(name), std::forward<decltype(input1)>(input1));
|
|
auto __res__ = ::llvm::dyn_cast<VariableWriteOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
VariableWriteOp VariableWriteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::StringAttr name, ::mlir::Value input1) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(name)>(name), std::forward<decltype(input1)>(input1));
|
|
}
|
|
|
|
void VariableWriteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llvm::StringRef name, ::mlir::Value input1) {
|
|
odsState.addOperands(input1);
|
|
odsState.getOrAddProperties<Properties>().name = odsBuilder.getStringAttr(name);
|
|
}
|
|
|
|
VariableWriteOp VariableWriteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::llvm::StringRef name, ::mlir::Value input1) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(name)>(name), std::forward<decltype(input1)>(input1));
|
|
auto __res__ = ::llvm::dyn_cast<VariableWriteOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
VariableWriteOp VariableWriteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::llvm::StringRef name, ::mlir::Value input1) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(name)>(name), std::forward<decltype(input1)>(input1));
|
|
}
|
|
|
|
void VariableWriteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::llvm::StringRef name, ::mlir::Value input1) {
|
|
odsState.addOperands(input1);
|
|
odsState.getOrAddProperties<Properties>().name = odsBuilder.getStringAttr(name);
|
|
assert(resultTypes.size() == 0u && "mismatched number of results");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
VariableWriteOp VariableWriteOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::llvm::StringRef name, ::mlir::Value input1) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(name)>(name), std::forward<decltype(input1)>(input1));
|
|
auto __res__ = ::llvm::dyn_cast<VariableWriteOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
VariableWriteOp VariableWriteOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::llvm::StringRef name, ::mlir::Value input1) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(name)>(name), std::forward<decltype(input1)>(input1));
|
|
}
|
|
|
|
void VariableWriteOp::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);
|
|
|
|
if (!attributes.empty()) {
|
|
(void)odsState.getOrAddProperties<VariableWriteOp::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.");
|
|
}
|
|
}
|
|
|
|
VariableWriteOp VariableWriteOp::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<VariableWriteOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
VariableWriteOp VariableWriteOp::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 VariableWriteOp::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);
|
|
}
|
|
|
|
VariableWriteOp VariableWriteOp::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<VariableWriteOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
VariableWriteOp VariableWriteOp::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 VariableWriteOp::verifyInvariantsImpl() {
|
|
auto tblgen_name = getProperties().name; (void)tblgen_name;
|
|
if (!tblgen_name) return emitOpError("requires attribute 'name'");
|
|
|
|
if (::mlir::failed(__mlir_ods_local_attr_constraint_TosaOps14(*this, tblgen_name, "name")))
|
|
return ::mlir::failure();
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps1(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult VariableWriteOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::mlir::ParseResult VariableWriteOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::mlir::StringAttr nameAttr;
|
|
::mlir::OpAsmParser::UnresolvedOperand input1RawOperand{};
|
|
::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> input1Operands(&input1RawOperand, 1); ::llvm::SMLoc input1OperandsLoc;
|
|
(void)input1OperandsLoc;
|
|
::mlir::Type input1RawType{};
|
|
::llvm::ArrayRef<::mlir::Type> input1Types(&input1RawType, 1);
|
|
|
|
if (parser.parseSymbolName(nameAttr))
|
|
return ::mlir::failure();
|
|
if (nameAttr) result.getOrAddProperties<VariableWriteOp::Properties>().name = nameAttr;
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() {
|
|
return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op ";
|
|
})))
|
|
return ::mlir::failure();
|
|
}
|
|
if (parser.parseComma())
|
|
return ::mlir::failure();
|
|
|
|
input1OperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperand(input1RawOperand))
|
|
return ::mlir::failure();
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
{
|
|
::mlir::TensorType type;
|
|
if (parser.parseCustomTypeWithFallback(type))
|
|
return ::mlir::failure();
|
|
input1RawType = type;
|
|
}
|
|
if (parser.resolveOperands(input1Operands, input1Types, input1OperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void VariableWriteOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter.printSymbolName(getNameAttr().getValue());
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
elidedAttrs.push_back("name");
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ",";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getInput1();
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
{
|
|
auto type = getInput1().getType();
|
|
if (auto validType = ::llvm::dyn_cast<::mlir::TensorType>(type))
|
|
_odsPrinter.printStrippedAttrOrType(validType);
|
|
else
|
|
_odsPrinter << type;
|
|
}
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::VariableWriteOp)
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::detail::VariableWriteOpGenericAdaptorBase::Properties)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::WhileOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
WhileOpGenericAdaptorBase::WhileOpGenericAdaptorBase(WhileOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> WhileOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
bool isVariadic[] = {true};
|
|
int prevVariadicCount = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
if (isVariadic[i]) ++prevVariadicCount;
|
|
|
|
// Calculate how many dynamic values a static variadic operand corresponds to.
|
|
// This assumes all static variadic operands have the same dynamic value count.
|
|
int variadicSize = (odsOperandsSize - 0) / 1;
|
|
// `index` passed in as the parameter is the static index which counts each
|
|
// operand (variadic or not) as size 1. So here for each previous static variadic
|
|
// operand, we need to offset by (variadicSize - 1) to get where the dynamic
|
|
// value pack for this static operand starts.
|
|
int start = index + (variadicSize - 1) * prevVariadicCount;
|
|
int size = isVariadic[index] ? variadicSize : 1;
|
|
return {start, size};
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
WhileOpAdaptor::WhileOpAdaptor(WhileOp op) : WhileOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult WhileOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> WhileOp::getODSOperandIndexAndLength(unsigned index) {
|
|
bool isVariadic[] = {true};
|
|
int prevVariadicCount = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
if (isVariadic[i]) ++prevVariadicCount;
|
|
|
|
// Calculate how many dynamic values a static variadic operand corresponds to.
|
|
// This assumes all static variadic operands have the same dynamic value count.
|
|
int variadicSize = (getOperation()->getNumOperands() - 0) / 1;
|
|
// `index` passed in as the parameter is the static index which counts each
|
|
// operand (variadic or not) as size 1. So here for each previous static variadic
|
|
// operand, we need to offset by (variadicSize - 1) to get where the dynamic
|
|
// value pack for this static operand starts.
|
|
int start = index + (variadicSize - 1) * prevVariadicCount;
|
|
int size = isVariadic[index] ? variadicSize : 1;
|
|
return {start, size};
|
|
}
|
|
|
|
::mlir::MutableOperandRange WhileOp::getInputListMutable() {
|
|
auto range = getODSOperandIndexAndLength(0);
|
|
auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
|
|
return mutableRange;
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> WhileOp::getODSResultIndexAndLength(unsigned index) {
|
|
bool isVariadic[] = {true};
|
|
int prevVariadicCount = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
if (isVariadic[i]) ++prevVariadicCount;
|
|
|
|
// Calculate how many dynamic values a static variadic operand corresponds to.
|
|
// This assumes all static variadic operands have the same dynamic value count.
|
|
int variadicSize = (getOperation()->getNumResults() - 0) / 1;
|
|
// `index` passed in as the parameter is the static index which counts each
|
|
// operand (variadic or not) as size 1. So here for each previous static variadic
|
|
// operand, we need to offset by (variadicSize - 1) to get where the dynamic
|
|
// value pack for this static operand starts.
|
|
int start = index + (variadicSize - 1) * prevVariadicCount;
|
|
int size = isVariadic[index] ? variadicSize : 1;
|
|
return {start, size};
|
|
}
|
|
|
|
::llvm::LogicalResult WhileOp::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 WhileOp::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 WhileOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> WhileOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void WhileOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void WhileOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult WhileOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void WhileOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
for (unsigned i = 0; i != 2; ++i)
|
|
(void)odsState.addRegion();
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
WhileOp WhileOp::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<WhileOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
WhileOp WhileOp::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 WhileOp::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);
|
|
for (unsigned i = 0; i != 2; ++i)
|
|
(void)odsState.addRegion();
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
WhileOp WhileOp::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<WhileOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
WhileOp WhileOp::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 WhileOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps19(*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_TosaOps19(*this, v.getType(), "result", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
|
|
for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(0)))
|
|
if (::mlir::failed(__mlir_ods_local_region_constraint_TosaOps1(*this, region, "cond_graph", index++)))
|
|
return ::mlir::failure();
|
|
|
|
for (auto ®ion : ::llvm::MutableArrayRef((*this)->getRegion(1)))
|
|
if (::mlir::failed(__mlir_ods_local_region_constraint_TosaOps1(*this, region, "body_graph", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult WhileOp::verifyInvariants() {
|
|
if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
|
|
return ::mlir::success();
|
|
return ::mlir::failure();
|
|
}
|
|
|
|
::llvm::LogicalResult WhileOp::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;
|
|
|
|
for (::mlir::NamedAttribute attr : dict) {
|
|
if (!usedKeys.contains(attr.getName()))
|
|
return emitError() << "unknown key '" << attr.getName() <<
|
|
"' when parsing properties dictionary";
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult
|
|
WhileOp::inferReturnTypeComponents(::mlir::MLIRContext *context,
|
|
std::optional<::mlir::Location> location,
|
|
::mlir::ValueShapeRange operands, ::mlir::DictionaryAttr attributes,
|
|
::mlir::PropertyRef properties, ::mlir::RegionRange regions,
|
|
::llvm::SmallVectorImpl<::mlir::ShapedTypeComponents> &inferredReturnShapes) {
|
|
WhileOp::Adaptor adaptor(operands, attributes, properties, regions);
|
|
return WhileOp::inferReturnTypeComponents(context,
|
|
location, adaptor, inferredReturnShapes);
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::WhileOp)
|
|
|
|
namespace mlir::tosa {
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// mlir::tosa::YieldOp definitions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
namespace detail {
|
|
|
|
YieldOpGenericAdaptorBase::YieldOpGenericAdaptorBase(YieldOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
|
|
|
|
std::pair<unsigned, unsigned> YieldOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
|
|
bool isVariadic[] = {true};
|
|
int prevVariadicCount = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
if (isVariadic[i]) ++prevVariadicCount;
|
|
|
|
// Calculate how many dynamic values a static variadic operand corresponds to.
|
|
// This assumes all static variadic operands have the same dynamic value count.
|
|
int variadicSize = (odsOperandsSize - 0) / 1;
|
|
// `index` passed in as the parameter is the static index which counts each
|
|
// operand (variadic or not) as size 1. So here for each previous static variadic
|
|
// operand, we need to offset by (variadicSize - 1) to get where the dynamic
|
|
// value pack for this static operand starts.
|
|
int start = index + (variadicSize - 1) * prevVariadicCount;
|
|
int size = isVariadic[index] ? variadicSize : 1;
|
|
return {start, size};
|
|
}
|
|
|
|
|
|
} // namespace detail
|
|
YieldOpAdaptor::YieldOpAdaptor(YieldOp op) : YieldOpGenericAdaptor(op->getOperands(), op) {}
|
|
|
|
::llvm::LogicalResult YieldOpAdaptor::verify(::mlir::Location loc) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
std::pair<unsigned, unsigned> YieldOp::getODSOperandIndexAndLength(unsigned index) {
|
|
bool isVariadic[] = {true};
|
|
int prevVariadicCount = 0;
|
|
for (unsigned i = 0; i < index; ++i)
|
|
if (isVariadic[i]) ++prevVariadicCount;
|
|
|
|
// Calculate how many dynamic values a static variadic operand corresponds to.
|
|
// This assumes all static variadic operands have the same dynamic value count.
|
|
int variadicSize = (getOperation()->getNumOperands() - 0) / 1;
|
|
// `index` passed in as the parameter is the static index which counts each
|
|
// operand (variadic or not) as size 1. So here for each previous static variadic
|
|
// operand, we need to offset by (variadicSize - 1) to get where the dynamic
|
|
// value pack for this static operand starts.
|
|
int start = index + (variadicSize - 1) * prevVariadicCount;
|
|
int size = isVariadic[index] ? variadicSize : 1;
|
|
return {start, size};
|
|
}
|
|
|
|
::mlir::MutableOperandRange YieldOp::getInputsMutable() {
|
|
auto range = getODSOperandIndexAndLength(0);
|
|
auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
|
|
return mutableRange;
|
|
}
|
|
|
|
::llvm::LogicalResult YieldOp::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 YieldOp::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 YieldOp::computePropertiesHash(const Properties &prop) {
|
|
using llvm::hash_value;
|
|
return llvm::hash_combine();
|
|
}
|
|
|
|
std::optional<mlir::Attribute> YieldOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
|
|
return std::nullopt;
|
|
}
|
|
|
|
void YieldOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
|
|
}
|
|
|
|
void YieldOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
|
|
}
|
|
|
|
::llvm::LogicalResult YieldOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void YieldOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange inputs) {
|
|
odsState.addOperands(inputs);
|
|
}
|
|
|
|
YieldOp YieldOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::ValueRange inputs) {
|
|
::mlir::OperationState __state__(location, getOperationName());
|
|
build(builder, __state__, std::forward<decltype(inputs)>(inputs));
|
|
auto __res__ = ::llvm::dyn_cast<YieldOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
YieldOp YieldOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::ValueRange inputs) {
|
|
return create(builder, builder.getLoc(), std::forward<decltype(inputs)>(inputs));
|
|
}
|
|
|
|
void YieldOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
|
|
odsState.addOperands(operands);
|
|
odsState.addAttributes(attributes);
|
|
assert(resultTypes.size() == 0u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
YieldOp YieldOp::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<YieldOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
YieldOp YieldOp::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 YieldOp::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() == 0u && "mismatched number of return types");
|
|
odsState.addTypes(resultTypes);
|
|
}
|
|
|
|
YieldOp YieldOp::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<YieldOp>(builder.create(__state__));
|
|
assert(__res__ && "builder didn't return the right type");
|
|
return __res__;
|
|
}
|
|
|
|
YieldOp YieldOp::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 YieldOp::verifyInvariantsImpl() {
|
|
{
|
|
unsigned index = 0; (void)index;
|
|
auto valueGroup0 = getODSOperands(0);
|
|
|
|
for (auto v : valueGroup0) {
|
|
if (::mlir::failed(__mlir_ods_local_type_constraint_TosaOps19(*this, v.getType(), "operand", index++)))
|
|
return ::mlir::failure();
|
|
}
|
|
}
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::LogicalResult YieldOp::verifyInvariants() {
|
|
return verifyInvariantsImpl();
|
|
}
|
|
|
|
::mlir::ParseResult YieldOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
|
|
::llvm::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> inputsOperands;
|
|
::llvm::SMLoc inputsOperandsLoc;
|
|
(void)inputsOperandsLoc;
|
|
::llvm::SmallVector<::mlir::Type, 1> inputsTypes;
|
|
|
|
inputsOperandsLoc = parser.getCurrentLocation();
|
|
if (parser.parseOperandList(inputsOperands))
|
|
return ::mlir::failure();
|
|
{
|
|
auto loc = parser.getCurrentLocation();(void)loc;
|
|
if (parser.parseOptionalAttrDict(result.attributes))
|
|
return ::mlir::failure();
|
|
if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() {
|
|
return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op ";
|
|
})))
|
|
return ::mlir::failure();
|
|
}
|
|
if (parser.parseColon())
|
|
return ::mlir::failure();
|
|
|
|
if (parser.parseTypeList(inputsTypes))
|
|
return ::mlir::failure();
|
|
if (parser.resolveOperands(inputsOperands, inputsTypes, inputsOperandsLoc, result.operands))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
void YieldOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getInputs();
|
|
::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
|
|
_odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
|
|
_odsPrinter << ' ' << ":";
|
|
_odsPrinter << ' ';
|
|
_odsPrinter << getInputs().getTypes();
|
|
}
|
|
|
|
void YieldOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
|
|
}
|
|
|
|
|
|
} // namespace mlir::tosa
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::YieldOp)
|
|
|
|
|
|
#endif // GET_OP_CLASSES
|
|
|