Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MLIR] Binary backend - step 1 - nonxdlops fwd path #841

Merged
merged 16 commits into from
Apr 23, 2021
Merged

Conversation

jerryyin
Copy link
Member

@jerryyin jerryyin commented Apr 2, 2021

This PR enables the back-to-back execution of mlir binary backend fwd kernels.

I did the following in this PR:

  • Bumped the MLIR commit to latest
  • Implemented the MLIR binary backend invoker
  • Implemented the MLIR binary backend solver
    • Added .mlir extension for binary backend compilation
    • Amended the call chain such that both .mlir-cpp and .mlir extension are handled
  • Pulled in memref.hpp header from a subset of llvm source, refer to here
  • Added unit test for mlir binary backend

Please note: CI in full pass with initial commit 5ea65fb.

Also this is a follow-up from @atamazov 's review in this commit.


Update: MLIR repository has a breaking change in group convolution support. Because of that, I wouldn't be able to address any MLIR end concerns without adding the new feature. Therefore I will work in the following sequence:

  1. Get the first round of fwd/bwd/wrw solvers implemented and submitted to MIOpen
  2. Submit Adding StridedMemRefType from interface rocMLIR#136
  3. Bring MLIR to the latest, support group convolution, drop StridedMemRef

@codecov

This comment has been minimized.

src/mlir_build.cpp Outdated Show resolved Hide resolved
@jerryyin jerryyin force-pushed the igemm-bin2 branch 4 times, most recently from f0316ea to 153a8f4 Compare April 8, 2021 20:30
@atamazov
Copy link
Contributor

atamazov commented Apr 9, 2021

Reviewers, please review ;)

src/include/miopen/memref.hpp Show resolved Hide resolved
test/CMakeLists.txt Show resolved Hide resolved
test/CMakeLists.txt Show resolved Hide resolved
shurale-nkn
shurale-nkn previously approved these changes Apr 9, 2021
Copy link
Contributor

@shurale-nkn shurale-nkn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@atamazov
Copy link
Contributor

atamazov commented Apr 9, 2021

[Off-topic] @jerryyin Please try to not forget to terminate outdated CI job after pushing to the repo. Thanks!

@jerryyin
Copy link
Member Author

@atamazov Sounds good, will keep a closer eye on delinquent CI jobs.

@jerryyin jerryyin changed the title Implemented the fwd invoker and solver for mlir binary backend Implement mlir binary backend - step 1: fwd path Apr 12, 2021
Copy link
Contributor

@atamazov atamazov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like we should not borrow StridedMemRefType<> from MLIR. Conceptually, it represents the layout of MLIR kernel parameters. IIUC this layout may change in the future, so the relevant abstraction should be a part of the Miir API. Otherwise we will have a situation when some part of Miir implementation is penetrated into MIOpen.

Luckily we do not need much. The only thing we need is a struct type (POD type equivalent to the data members of StridedMemRefType<void, 4>). You can define it in the Miir.h, thus isolating MIOpen from the specific layout of MLIR kernel parameters.

When/if the implementation of StridedMemRefType<> in MLIR change, you would need to update that struct type in Miir.h.

Sounds reasonable?

src/conv/invokers/mlir_impl_gemm.cpp Outdated Show resolved Hide resolved
src/conv/invokers/mlir_impl_gemm.cpp Outdated Show resolved Hide resolved
Comment on lines 77 to 78
target.basePtr = const_cast<void*>(ptr); // NOLINT (cppcoreguidelines-pro-type-const-cast)
target.data = const_cast<void*>(ptr); // NOLINT (cppcoreguidelines-pro-type-const-cast)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Optimization] Only initialization of pointers (buffer addresses) should be left in the Invoker... (see next comment)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's postpone this. #862 created.

Comment on lines +80 to +81
std::copy(dims.cbegin(), dims.cend(), &target.sizes[0]);
std::copy(strides.cbegin(), strides.cend(), &target.strides[0]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...while strides and sizes and known in the Factory (outer lambda), and necessary initializations should be performed there. In this case the only thing that Invoker will need to do (before launching the kernel) is initialization of buffer addresses.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jerryyin Whatever design you are going to select, it should be able to satisfy this and this. This is the simplest test of design validity.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's postpone this. #862 created.

@atamazov
Copy link
Contributor

@JehandadKhan #795 merged in. Please make necessary changes right in this PR to resolve #795 (comment). If you do not have time, please ask me and I will do that.

@jerryyin Plase let us know if any objections.

@atamazov
Copy link
Contributor

@jerryyin Merge conflicts. Please let me know if you need help.

@JehandadKhan
Copy link
Collaborator

@JehandadKhan #795 merged in. Please make necessary changes right in this PR to resolve #795 (comment). If you do not have time, please ask me and I will do that.

@atamazov I have updated the branch.

* Fix find_permutation
* Misc fixes
@atamazov
Copy link
Contributor

One step to the approval left: #841 (comment)

atamazov
atamazov previously approved these changes Apr 19, 2021
Copy link
Contributor

@atamazov atamazov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@atamazov atamazov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@atamazov atamazov merged commit b9b5337 into develop Apr 23, 2021
@jerryyin jerryyin changed the title Implement mlir binary backend - step 1: fwd path [MLIR] Binary backend - step 1 - fwd path May 13, 2021
@jerryyin jerryyin changed the title [MLIR] Binary backend - step 1 - fwd path [MLIR] Binary backend - step 1 - nonxdlops fwd path May 13, 2021
@atamazov atamazov deleted the igemm-bin2 branch June 23, 2021 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants