Restrict affine inlining to just Function operations.

The current restrictions on dim/symbols require a top-level symbol for the conservative case of a non-affine region. This should be relaxed in the future.

PiperOrigin-RevId: 267641838
This commit is contained in:
River Riddle 2019-09-06 11:43:35 -07:00 committed by A. Unique TensorFlower
parent 8154370b49
commit b78410fd81
1 changed files with 6 additions and 4 deletions

View File

@ -59,10 +59,12 @@ struct AffineInlinerInterface : public DialectInlinerInterface {
/// dialect, can be inlined into the given region, false otherwise.
bool isLegalToInline(Operation *op, Region *region,
BlockAndValueMapping &valueMapping) const final {
// Always allow inlining affine operations. There are some edge cases when
// inlining *into* affine structures, but that is handled in the other
// 'isLegalToInline' hook above.
return true;
// Always allow inlining affine operations into the top-level region of a
// function. There are some edge cases when inlining *into* affine
// structures, but that is handled in the other 'isLegalToInline' hook
// above.
// TODO: We should be able to inline into other regions than functions.
return isa<FuncOp>(region->getParentOp());
}
/// Affine regions should be analyzed recursively.