fix simplify-affine-structures bug

Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>

Closes #157

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/157 from bondhugula:quickfix bd1fcd79825fc0bd5b4a3e688153fa0993ab703d
PiperOrigin-RevId: 273316498
This commit is contained in:
Uday Bondhugula 2019-10-07 10:03:38 -07:00 committed by TensorFlower Gardener
parent 9d862a484f
commit f23e6832c0

View File

@ -102,9 +102,16 @@ void SimplifyAffineStructures::runOnFunction() {
}
});
// Turn memrefs' non-identity layouts maps into ones with identity.
func.walk([](AllocOp op) { normalizeMemRef(op); });
// Turn memrefs' non-identity layouts maps into ones with identity. Collect
// alloc ops first and then process since normalizeMemRef replaces/erases ops
// during memref rewriting.
SmallVector<AllocOp, 4> allocOps;
func.walk([&](AllocOp op) { allocOps.push_back(op); });
for (auto allocOp : allocOps) {
normalizeMemRef(allocOp);
}
}
static PassRegistration<SimplifyAffineStructures>
pass("simplify-affine-structures", "Simplify affine expressions");
pass("simplify-affine-structures",
"Simplify affine expressions in maps/sets and normalize memrefs");