>,
InterfaceMethod<
/*desc=*/[{
+ Return the input block arguments of the region.
+ }],
+ /*retTy=*/"Block::BlockArgListType",
+ /*methodName=*/"getRegionInputArgs",
+ /*args=*/(ins),
+ /*methodBody=*/"",
+ /*defaultImplementation=*/[{
+ // MLIR currently does not support dependent interfaces or interface
+ // inheritance. By construction all ops with StructuredOpInterface must
+ // implement DestinationStyleOpInterface.
+ // TODO: reevalute the need for a cast when a better mechanism exists.
+ return getBlock()->getArguments().take_front(
+ cast<DestinationStyleOpInterface>(*this->getOperation())
+ .getNumInputs());
+ }]
+ >,
+ InterfaceMethod<
+ /*desc=*/[{
Return the output block arguments of the region.
}],
/*retTy=*/"Block::BlockArgListType",
include "mlir/Interfaces/ControlFlowInterfaces.td"
include "mlir/Interfaces/InferTypeOpInterface.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
+include "mlir/IR/OpAsmInterface.td"
// Base Tablegen class for Linalg ops.
// Linalg ops that correspond to library calls operate on ShapedType as their
AnyTypeOf<[AnyMemRef, AnyRankedTensor], "", "::mlir::ShapedType">;
def ReduceOp : LinalgStructuredBase_Op<"reduce", [
- SameVariadicOperandSize, SingleBlockImplicitTerminator<"YieldOp">
- ]> {
+ DeclareOpInterfaceMethods<OpAsmOpInterface, ["getAsmResultNames"]>,
+ DeclareOpInterfaceMethods<OpAsmOpInterface, ["getAsmBlockArgumentNames"]>,
+ SameVariadicOperandSize,
+ SingleBlockImplicitTerminator<"YieldOp">]> {
let summary = "Reduce operator";
let description = [{
Executes `combiner` on the `dimensions` of `inputs` and returns the
// ReduceOp
//===----------------------------------------------------------------------===//
+void ReduceOp::getAsmBlockArgumentNames(Region ®ion,
+ OpAsmSetValueNameFn setNameFn) {
+ for (Value v : getRegionInputArgs())
+ setNameFn(v, "in");
+ for (Value v : getRegionOutputArgs())
+ setNameFn(v, "init");
+}
+
+void ReduceOp::getAsmResultNames(
+ function_ref<void(Value, StringRef)> setNameFn) {
+ setNameFn(getResults().front(), "reduced");
+}
+
ArrayAttr ReduceOp::getIteratorTypes() {
int64_t inputRank = getInputs()[0].getType().cast<ShapedType>().getRank();
SmallVector<StringRef> iteratorTypes(inputRank,