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

[ONNX] Add MatMulInteger16 contrib op #9186

Merged
merged 12 commits into from
Nov 24, 2021

Conversation

abhikran-quic
Copy link
Contributor

@abhikran-quic abhikran-quic commented Oct 4, 2021

This PR adds support for contrib op: com.microsoft.MatMulInteger16.

Converge MatMul and MatmulInteger16 ops to use a single function with output dtype.

@tmoreau89
Copy link
Contributor

Thanks for helping with the review @cconvey ! CC-ing @mbrookhart @anwang2009 @AndrewZhaoLuo

python/tvm/relay/frontend/onnx.py Show resolved Hide resolved
python/tvm/relay/frontend/onnx.py Outdated Show resolved Hide resolved
python/tvm/relay/frontend/onnx.py Outdated Show resolved Hide resolved
@AndrewZhaoLuo
Copy link
Contributor

@abhikran-quic do you still plan on working on this?

@abhikran-quic
Copy link
Contributor Author

abhikran-quic commented Oct 21, 2021

@abhikran-quic do you still plan on working on this?

Hi @AndrewZhaoLuo : I've been out of office since last two weeks and hence I've not been able to reply here. Sorry about this!
I will fix the changes that you've suggested once I'm back.

@AndrewZhaoLuo
Copy link
Contributor

No problem, have a good vacation!

@tmoreau89
Copy link
Contributor

@abhikran-quic friendly ping to see if updating this PR is currently blocked, thanks!

@abhikran-quic
Copy link
Contributor Author

abhikran-quic commented Nov 21, 2021

@abhikran-quic https://github.com/apache/tvm/pull/9540/files should fix this. You can take these changes in this PR and I can close mine.

Thank you @AndrewZhaoLuo for your help on this. I've incorporated the changes mentioned by you in the latest patch.

However, there's one more pending issue. After removing test_matmulinteger from unsupported_onnx_tests, I saw an error from onnx.py . Here is the link to CI where failure is seen.

IMHO, when we remove test_matmulinteger the error is expected because there is no op named matmulinteger in onnx.py. Onnxruntime supports MatMulInteger16 and MatMulIntegerToFloat and hence we can add ops with the names mentioned in Onnx runtime documentation. Hence, removing test_matmulinteger is leading to the error.

In my latest patch, I've retained test_matmulinteger in unsupported_onnx_tests. Please share your thoughts on this.

@AndrewZhaoLuo
Copy link
Contributor

Ah yes, MatMulInteger is an onnx op but it is seperate from MatMulInteger16

Copy link
Contributor

@AndrewZhaoLuo AndrewZhaoLuo left a comment

Choose a reason for hiding this comment

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

LGTM

@abhikran-quic
Copy link
Contributor Author

LGTM

Thank you @AndrewZhaoLuo for your review.

I would request reviewers to please review this PR.

@abhikran-quic
Copy link
Contributor Author

Hello Reviewers,

Could you please review this PR for any more changes needed ?

Copy link
Contributor

@tmoreau89 tmoreau89 left a comment

Choose a reason for hiding this comment

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

LGTM

@tmoreau89 tmoreau89 merged commit 9c4e9ff into apache:main Nov 24, 2021
@tmoreau89
Copy link
Contributor

Thank you @abhikran-quic, @AndrewZhaoLuo, @cconvey the PR has been merged

@abhikran-quic abhikran-quic deleted the onnx-matmulinteger16 branch November 24, 2021 17:35
dchauhan-arm pushed a commit to dchauhan-arm/tvm that referenced this pull request Nov 29, 2021
* [ONNX] Add MatMulInteger16 contrib op

* Fix formatting errors

* Remove a code comment and do not set default value of nd

* Move flatten_to_nd function outside matmul to be used across multiple functions

* Add function docstring and describe the tests

* Use max/min value of int16 as high/low while generating input vectors

* Converge MatMul and MatMulInteger16 ops into a single op using output dtype

* Fix indentation issues

* Formatting changes

* Fix CUDA batchmatmul strategy to allow mixed precision

* Add test_matmulinteger to unsupported_onnx_tests
mehrdadh pushed a commit to mehrdadh/tvm that referenced this pull request Dec 1, 2021
* [ONNX] Add MatMulInteger16 contrib op

* Fix formatting errors

* Remove a code comment and do not set default value of nd

* Move flatten_to_nd function outside matmul to be used across multiple functions

* Add function docstring and describe the tests

* Use max/min value of int16 as high/low while generating input vectors

* Converge MatMul and MatMulInteger16 ops into a single op using output dtype

* Fix indentation issues

* Formatting changes

* Fix CUDA batchmatmul strategy to allow mixed precision

* Add test_matmulinteger to unsupported_onnx_tests
mehrdadh pushed a commit to mehrdadh/tvm that referenced this pull request Dec 1, 2021
* [ONNX] Add MatMulInteger16 contrib op

* Fix formatting errors

* Remove a code comment and do not set default value of nd

* Move flatten_to_nd function outside matmul to be used across multiple functions

* Add function docstring and describe the tests

* Use max/min value of int16 as high/low while generating input vectors

* Converge MatMul and MatMulInteger16 ops into a single op using output dtype

* Fix indentation issues

* Formatting changes

* Fix CUDA batchmatmul strategy to allow mixed precision

* Add test_matmulinteger to unsupported_onnx_tests
ylc pushed a commit to ylc/tvm that referenced this pull request Jan 7, 2022
* [ONNX] Add MatMulInteger16 contrib op

* Fix formatting errors

* Remove a code comment and do not set default value of nd

* Move flatten_to_nd function outside matmul to be used across multiple functions

* Add function docstring and describe the tests

* Use max/min value of int16 as high/low while generating input vectors

* Converge MatMul and MatMulInteger16 ops into a single op using output dtype

* Fix indentation issues

* Formatting changes

* Fix CUDA batchmatmul strategy to allow mixed precision

* Add test_matmulinteger to unsupported_onnx_tests
@Icemist
Copy link
Contributor

Icemist commented Jan 10, 2022

@abhikran-quic
Could I please ask why did you delete the code branch under the ONNX_DEFAULT_CONFIGS["use_nt_batch_matmul"] parameter?
I found that after this change, some of the code samples stopped working with an error like “Check failed: (reporter->AssertEQ(xk, yk)) is false: BatchDot: shapes of x and y is inconsistent, x shape=[16, 384, 384], y shape=[16, 384, 64]“
So now I see ONNX_DEFAULT_CONFIGS is not used by anyone. But The same logic with use_nt_batch_matmul is there for tensorflow.
Can we restore this logic? Will it affect the MatMulInteger16 operation you added?

yangulei pushed a commit to yangulei/tvm that referenced this pull request Jan 11, 2022
* [ONNX] Add MatMulInteger16 contrib op

* Fix formatting errors

* Remove a code comment and do not set default value of nd

* Move flatten_to_nd function outside matmul to be used across multiple functions

* Add function docstring and describe the tests

* Use max/min value of int16 as high/low while generating input vectors

* Converge MatMul and MatMulInteger16 ops into a single op using output dtype

* Fix indentation issues

* Formatting changes

* Fix CUDA batchmatmul strategy to allow mixed precision

* Add test_matmulinteger to unsupported_onnx_tests
@abhikran-quic
Copy link
Contributor Author

Hi @Icemist , This change was done to optimize the code path and since all the tests in automation passed, we went ahead and committed the change.
If this is affecting the logic you've mentioned above, we can restore it definitely.

yangulei pushed a commit to yangulei/tvm that referenced this pull request Jan 12, 2022
* [ONNX] Add MatMulInteger16 contrib op

* Fix formatting errors

* Remove a code comment and do not set default value of nd

* Move flatten_to_nd function outside matmul to be used across multiple functions

* Add function docstring and describe the tests

* Use max/min value of int16 as high/low while generating input vectors

* Converge MatMul and MatMulInteger16 ops into a single op using output dtype

* Fix indentation issues

* Formatting changes

* Fix CUDA batchmatmul strategy to allow mixed precision

* Add test_matmulinteger to unsupported_onnx_tests
ylc pushed a commit to ylc/tvm that referenced this pull request Jan 13, 2022
* [ONNX] Add MatMulInteger16 contrib op

* Fix formatting errors

* Remove a code comment and do not set default value of nd

* Move flatten_to_nd function outside matmul to be used across multiple functions

* Add function docstring and describe the tests

* Use max/min value of int16 as high/low while generating input vectors

* Converge MatMul and MatMulInteger16 ops into a single op using output dtype

* Fix indentation issues

* Formatting changes

* Fix CUDA batchmatmul strategy to allow mixed precision

* Add test_matmulinteger to unsupported_onnx_tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants