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

[microNPU][ETHOSU] Add fixed point for matmul #16401

Merged
merged 5 commits into from Feb 14, 2024

Conversation

Aleksei-grovety
Copy link
Contributor

@Aleksei-grovety Aleksei-grovety commented Jan 15, 2024

Added support for calculation matmul with 16 bits fixed point. Added legalization of non-quantized dense operation with quantization by fixed point multiplication.
cc @lhutton1, @ekalda, @leandron

Copy link
Contributor

@lhutton1 lhutton1 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @Aleksei-grovety, I had a couple of questions about the implementation

src/relay/backend/contrib/ethosu/compiler_attrs.cc Outdated Show resolved Hide resolved
python/tvm/relay/op/contrib/ethosu.py Outdated Show resolved Hide resolved
Copy link
Contributor

@lhutton1 lhutton1 left a comment

Choose a reason for hiding this comment

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

Thanks for the responses @Aleksei-grovety. My main concern is that we need to expose an option to the user, rather than encapsulating this information as part of a relay operator. Are you able to share any more context about where this type of operation comes from?

src/relay/backend/contrib/ethosu/compiler_attrs.cc Outdated Show resolved Hide resolved
@Aleksei-grovety
Copy link
Contributor Author

Are you able to share any more context about where this type of operation comes from?

One of the earliest uses of fixed-point arithmetic was in digital signal processing (DSP) applications, where it was used to perform high-speed and high-precision calculations on audio and video signals. Fixed-point arithmetic was well-suited for these applications because it could provide the necessary precision and speed while minimizing the resources required to perform the calculations.
Here is article Introduction to Fixed Point Number Representation.

Copy link
Contributor

@lhutton1 lhutton1 left a comment

Choose a reason for hiding this comment

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

Thanks for the cleanup @Aleksei-grovety. I think overall I'm still a bit unsure why fixed_point_fraction_size needs to be exposed from the microNPU compiler attrs, rather than the data being encoded in the Relay graph. For example, is it possible to insert relay.fixed_point_multiply operators on the inputs/outputs of the graph in between the matmul? Apologies if I'm still missing something here

@Aleksei-grovety
Copy link
Contributor Author

For example, is it possible to insert relay.fixed_point_multiply operators on the inputs/outputs of the graph in between the matmul

Yes, it's possible, I've updated the code.

Copy link
Contributor

@lhutton1 lhutton1 left a comment

Choose a reason for hiding this comment

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

Thanks @Aleksei-grovety, LGTM!

@lhutton1 lhutton1 merged commit 07ecb34 into apache:main Feb 14, 2024
19 checks passed
@lhutton1
Copy link
Contributor

Thanks @Aleksei-grovety!

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

2 participants