Changeset View
Changeset View
Standalone View
Standalone View
mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td
Show First 20 Lines • Show All 147 Lines • ▼ Show 20 Lines | let extraClassDeclaration = libraryCallName # [{ | ||||
} | } | ||||
Value getSource() { return input();} | Value getSource() { return input();} | ||||
Value getTarget() { return output(); } | Value getTarget() { return output(); } | ||||
}]; | }]; | ||||
let verifier = [{ return ::verify(*this); }]; | let verifier = [{ return ::verify(*this); }]; | ||||
let hasFolder = 1; | let hasFolder = 1; | ||||
let hasCanonicalizer = 1; | |||||
} | } | ||||
def FillOp : LinalgStructured_Op<"fill", [NInputs<0>, NOutputs<1>]> { | def FillOp : LinalgStructured_Op<"fill", [NInputs<0>, NOutputs<1>]> { | ||||
let arguments = (ins AnyStridedMemRef:$output, | let arguments = (ins AnyStridedMemRef:$output, | ||||
AnyTypeOf<[AnyFloat, AnySignlessInteger, AnyVector]>:$value); | AnyTypeOf<[AnyFloat, AnySignlessInteger, AnyVector]>:$value); | ||||
let extraClassDeclaration = libraryCallName # [{ | let extraClassDeclaration = libraryCallName # [{ | ||||
// Rank-polymorphic. | // Rank-polymorphic. | ||||
Show All 9 Lines | llvm::Optional<SmallVector<AffineMap, 8>> referenceIndexingMaps() { | ||||
return SmallVector<AffineMap, 8>{ | return SmallVector<AffineMap, 8>{ | ||||
extractOrIdentityMap(llvm::None, getNumParallelLoops(), context)}; | extractOrIdentityMap(llvm::None, getNumParallelLoops(), context)}; | ||||
} | } | ||||
}]; | }]; | ||||
let verifier = [{ return ::verify(*this); }]; | let verifier = [{ return ::verify(*this); }]; | ||||
let hasFolder = 1; | let hasFolder = 1; | ||||
let hasCanonicalizer = 1; | |||||
} | } | ||||
/// A base class for pooling operation such as conv. The arguments must contain | /// A base class for pooling operation such as conv. The arguments must contain | ||||
/// optional arguments `strides`, `dilations` and `padding` with following type: | /// optional arguments `strides`, `dilations` and `padding` with following type: | ||||
/// OptionalAttr<I64ArrayAttr>:$strides | /// OptionalAttr<I64ArrayAttr>:$strides | ||||
/// OptionalAttr<I64ArrayAttr>:$dilations | /// OptionalAttr<I64ArrayAttr>:$dilations | ||||
/// OptionalAttr<I64ElementsAttr>:$padding | /// OptionalAttr<I64ElementsAttr>:$padding | ||||
/// `strides` denotes the step of each window along the dimension. | /// `strides` denotes the step of each window along the dimension. | ||||
▲ Show 20 Lines • Show All 164 Lines • ▼ Show 20 Lines | llvm::Optional<SmallVector<AffineMap, 8>> referenceIndexingMaps() { | ||||
// output[b, x[0], ..., x[N-1], k] | // output[b, x[0], ..., x[N-1], k] | ||||
AffineMap::get(idx, 0, concat(concat(bs, xs), ks), context)}; | AffineMap::get(idx, 0, concat(concat(bs, xs), ks), context)}; | ||||
} | } | ||||
}]; | }]; | ||||
let verifier = [{ return ::verify(*this); }]; | let verifier = [{ return ::verify(*this); }]; | ||||
let hasFolder = 1; | let hasFolder = 1; | ||||
let hasCanonicalizer = 1; | |||||
} | } | ||||
class SingleInputPoolingBase_Op<string mnemonic> | class SingleInputPoolingBase_Op<string mnemonic> | ||||
: PoolingBase_Op<mnemonic, [NInputs<2>, NOutputs<1>]> { | : PoolingBase_Op<mnemonic, [NInputs<2>, NOutputs<1>]> { | ||||
let description = [{ | let description = [{ | ||||
A base class for single input pooling function. | A base class for single input pooling function. | ||||
TODO: Figure out a better way to handle window dimensions, i.e., eliminate | TODO: Figure out a better way to handle window dimensions, i.e., eliminate | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | llvm::Optional<SmallVector<AffineMap, 8>> referenceIndexingMaps() { | ||||
AffineMap::get(idx, 0, outputDims, context) | AffineMap::get(idx, 0, outputDims, context) | ||||
}; | }; | ||||
} | } | ||||
}]; | }]; | ||||
let verifier = [{ return ::verify(*this); }]; | let verifier = [{ return ::verify(*this); }]; | ||||
let hasFolder = 1; | let hasFolder = 1; | ||||
let hasCanonicalizer = 1; | |||||
} | } | ||||
def PoolingMaxOp: SingleInputPoolingBase_Op<"pooling_max"> { | def PoolingMaxOp: SingleInputPoolingBase_Op<"pooling_max"> { | ||||
let description = [{ | let description = [{ | ||||
Takes max op as pooling operation, i.e., it samples the maximum value in the | Takes max op as pooling operation, i.e., it samples the maximum value in the | ||||
window. | window. | ||||
}]; | }]; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 225 Lines • ▼ Show 20 Lines | OpBuilder< | ||||
"ValueRange args, int64_t argsIn, int64_t argsOut, " | "ValueRange args, int64_t argsIn, int64_t argsOut, " | ||||
"ArrayRef<AffineMap> indexingMaps, ArrayRef<StringRef> iteratorTypes, " | "ArrayRef<AffineMap> indexingMaps, ArrayRef<StringRef> iteratorTypes, " | ||||
"function_ref<void(OpBuilder &, Location, ValueRange)> = nullptr"> | "function_ref<void(OpBuilder &, Location, ValueRange)> = nullptr"> | ||||
]; | ]; | ||||
let verifier = [{ return ::verify(*this); }]; | let verifier = [{ return ::verify(*this); }]; | ||||
let hasFolder = 1; | let hasFolder = 1; | ||||
let hasCanonicalizer = 1; | |||||
} | } | ||||
/// GenericOp with Indexing (i.e. multi-for style in which the region is passed | /// GenericOp with Indexing (i.e. multi-for style in which the region is passed | ||||
/// the enclosing loop induction variables) | /// the enclosing loop induction variables) | ||||
def IndexedGenericOp : GenericOpBase<"indexed_generic"> { | def IndexedGenericOp : GenericOpBase<"indexed_generic"> { | ||||
let description = [{ | let description = [{ | ||||
Indexed Generic Linalg op form where the key properties of the computation | Indexed Generic Linalg op form where the key properties of the computation | ||||
are specified as attributes. In pretty form, a linalg.indexed_generic op is | are specified as attributes. In pretty form, a linalg.indexed_generic op is | ||||
▲ Show 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | OpBuilder< | ||||
"function_ref<void(OpBuilder &, Location, ValueRange, ValueRange)> " | "function_ref<void(OpBuilder &, Location, ValueRange, ValueRange)> " | ||||
"= nullptr"> | "= nullptr"> | ||||
]; | ]; | ||||
let verifier = [{ return ::verify(*this); }]; | let verifier = [{ return ::verify(*this); }]; | ||||
let hasFolder = 1; | let hasFolder = 1; | ||||
let hasCanonicalizer = 1; | |||||
} | } | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
// Named Linalg ops, implemented as a declarative configurations of generic ops. | // Named Linalg ops, implemented as a declarative configurations of generic ops. | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
def NamedStructuredOpTraits : NativeOpTrait<"linalg::NamedStructuredOpTraits">; | def NamedStructuredOpTraits : NativeOpTrait<"linalg::NamedStructuredOpTraits">; | ||||
class LinalgNamedStructured_Op<string mnemonic, list<OpTrait> props> | class LinalgNamedStructured_Op<string mnemonic, list<OpTrait> props> | ||||
: LinalgStructuredBase_Op<mnemonic, props> { | : LinalgStructuredBase_Op<mnemonic, props> { | ||||
string spec = ?; | string spec = ?; | ||||
// We cannot use an assemblyFormat atm because we need to hook in a custom- | // We cannot use an assemblyFormat atm because we need to hook in a custom- | ||||
// built implicit region from a static OpClass method. | // built implicit region from a static OpClass method. | ||||
// TODO: Revisit in the future if/when appropriate. | // TODO: Revisit in the future if/when appropriate. | ||||
// let assemblyFormat = "`(` operands `)` attr-dict `:` " | // let assemblyFormat = "`(` operands `)` attr-dict `:` " | ||||
// "functional-type(operands, results)"; | // "functional-type(operands, results)"; | ||||
// The parser needs to specialize on the OpType so it has to be auto-generated | // The parser needs to specialize on the OpType so it has to be auto-generated | ||||
// in the linalg-ods tool. | // in the linalg-ods tool. | ||||
let printer = [{ return ::printNamedStructuredOp(p, *this); }]; | let printer = [{ return ::printNamedStructuredOp(p, *this); }]; | ||||
let verifier = [{ return ::verifyNamedStructuredOp(*this); }]; | let verifier = [{ return ::verifyNamedStructuredOp(*this); }]; | ||||
let hasFolder = 1; | let hasFolder = 1; | ||||
let hasCanonicalizer = 1; | |||||
} | } | ||||
// This file is auto-generated from a tc specification. | // This file is auto-generated from a tc specification. | ||||
include "mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.td" | include "mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.td" | ||||
#endif // LINALG_STRUCTURED_OPS | #endif // LINALG_STRUCTURED_OPS |