This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Linalg] Add a linalg.reshape op
AbandonedPublic

Authored by nicolasvasilache on Dec 31 2019, 1:53 PM.

Details

Summary

This diff adds support for linalg.reshape which takes a view and collapses
its dimensions according to a reassociation list of maps to return a new view.

This is a pure metadata operation which does not allocate or copy.
In the general case, such a reshape may require allocating and moving data, these
cases are currently undefined behavior.

This is captured by the op documentation:

For now, it is assumed that all reassociation occur on contiguous
dimensions or that the reshape op will be folded into its consumers.
All other cases are undefined behavior and a reshape op may not lower to LLVM
if it cannot be proven statically that it does not require alloc+copy.

Relevant invalid and roundtrip test are added.

Diff Detail

Event Timeline

Unit tests: pass. 61162 tests passed, 0 failed and 728 were skipped.

clang-tidy: fail. Please fix clang-tidy findings.

clang-format: pass.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

rriddle requested changes to this revision.Dec 31 2019, 2:25 PM
rriddle added inline comments.
mlir/include/mlir/IR/Builders.h
380

I don't see why this should be here. This seems unrelated to Builders.

mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
351

Duplicated assert.

354

Cache the end iterator.

367

This should have a comment.

383

nit: use AffineMap instead of auto

406

Do not use -> or * on Value unless you really need to. They are going away and it just adds extra work for me. I see many other places in this revision that also use them.

This revision now requires changes to proceed.Dec 31 2019, 2:25 PM

fix unused symbol in dbg mode.

Unit tests: pass. 61162 tests passed, 0 failed and 728 were skipped.

clang-tidy: fail. Please fix clang-tidy findings.

clang-format: pass.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

nicolasvasilache abandoned this revision.Jan 1 2020, 3:35 PM

This needs more work, I have a better way.