Changeset View
Changeset View
Standalone View
Standalone View
mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td
Show First 20 Lines • Show All 188 Lines • ▼ Show 20 Lines | let extraClassDeclaration = [{ | ||||
static StringRef getStaticLowAttrName() { | static StringRef getStaticLowAttrName() { | ||||
return "static_low"; | return "static_low"; | ||||
} | } | ||||
static StringRef getStaticHighAttrName() { | static StringRef getStaticHighAttrName() { | ||||
return "static_high"; | return "static_high"; | ||||
} | } | ||||
RankedTensorType getSourceType() { | |||||
return source().getType().cast<RankedTensorType>(); | |||||
} | |||||
RankedTensorType getResultType() { | |||||
return getResult().getType().cast<RankedTensorType>(); | |||||
} | |||||
// Infer the shape of the result tensor given the static shapes | // Infer the shape of the result tensor given the static shapes | ||||
// and element type of the result tensor. | // and element type of the result tensor. | ||||
static RankedTensorType inferResultType(RankedTensorType sourceType, | static RankedTensorType inferResultType(RankedTensorType sourceType, | ||||
ArrayRef<int64_t> staticLow, | ArrayRef<int64_t> staticLow, | ||||
ArrayRef<int64_t> staticHigh); | ArrayRef<int64_t> staticHigh); | ||||
// Return a PadTensorOp that pads `source` to `type` size where the static | // Return a PadTensorOp that pads `source` to `type` size where the static | ||||
// sizes are assumed to be greater than the dynamic sizes. The op performs | // sizes are assumed to be greater than the dynamic sizes. The op performs | ||||
▲ Show 20 Lines • Show All 277 Lines • ▼ Show 20 Lines | SmallVector<Value, 8> getRanges() { | ||||
res.push_back(operand); | res.push_back(operand); | ||||
return res; | return res; | ||||
} | } | ||||
}]; | }]; | ||||
let hasFolder = 1; | let hasFolder = 1; | ||||
} | } | ||||
def Linalg_SimplePadOp : Linalg_Op<"simple_pad", [NoSideEffect]> { | |||||
let summary = "TODO: replace with pad_tensors when ready."; | |||||
let description = [{ | |||||
`linalg.simple_pad` is a tmp placeholder for padding and packing on tensors. | |||||
Its semantics are to pad a partially dynamic tensor to a fully static tensor | |||||
where the static sizes are assumed to be greater than the dynamic sizes. The | |||||
op perforrms "high" padding (i.e. it adds trailing padding values until the | |||||
desired size is met). | |||||
}]; | |||||
let arguments = (ins AnyRankedTensor:$tensor, AnyType:$padding); | |||||
let results = (outs AnyRankedTensor:$result); | |||||
// TODO: verify all static result, some dynamic input, static shapes match, | |||||
// element types match, ranks match etc. Use pad_tensors when ready but for | |||||
// now just let it ne fully specified by traits. | |||||
let verifier = ?; | |||||
let extraClassDeclaration = [{ | |||||
RankedTensorType getSourceType() { | |||||
return tensor().getType().cast<RankedTensorType>(); } | |||||
RankedTensorType getResultType() { | |||||
return getResult().getType().cast<RankedTensorType>(); } | |||||
}]; | |||||
let assemblyFormat = [{ | |||||
$tensor `pad` $padding attr-dict `:` | |||||
type($tensor) `to` type($result) `pad` type($padding) | |||||
}]; | |||||
} | |||||
def Linalg_YieldOp : Linalg_Op<"yield", [NoSideEffect, ReturnLike, Terminator]>, | def Linalg_YieldOp : Linalg_Op<"yield", [NoSideEffect, ReturnLike, Terminator]>, | ||||
Arguments<(ins Variadic<AnyType>:$values)> { | Arguments<(ins Variadic<AnyType>:$values)> { | ||||
let summary = "Linalg yield operation"; | let summary = "Linalg yield operation"; | ||||
let description = [{ | let description = [{ | ||||
`linalg.yield` is a special terminator operation for blocks inside regions | `linalg.yield` is a special terminator operation for blocks inside regions | ||||
in `linalg` generic ops. It returns values to the immediately enclosing | in `linalg` generic ops. It returns values to the immediately enclosing | ||||
`linalg` generic op. | `linalg` generic op. | ||||
Show All 9 Lines |