Skip to content

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

Merged
lhutton1 merged 5 commits into
apache:mainfrom
Aleksei-grovety:ethosu-matmul-fixed-point
Feb 14, 2024
Merged

lhutton1 merged 5 commits into
apache:mainfrom
Aleksei-grovety:ethosu-matmul-fixed-point

Conversation

@Aleksei-grovety

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

Copy link
Copy Markdown
Contributor

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

@github-actions
github-actions Bot requested a review from lhutton1 January 15, 2024 10:42

@lhutton1 lhutton1 left a comment

Copy link
Copy Markdown
Contributor

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

Comment thread src/relay/backend/contrib/ethosu/compiler_attrs.cc Outdated
Comment thread python/tvm/relay/op/contrib/ethosu.py Outdated
@Aleksei-grovety
Aleksei-grovety force-pushed the ethosu-matmul-fixed-point branch from 2983626 to cb2faa8 Compare January 16, 2024 17:27

@lhutton1 lhutton1 left a comment

Copy link
Copy Markdown
Contributor

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?

Comment thread src/relay/backend/contrib/ethosu/compiler_attrs.cc Outdated
@Aleksei-grovety

Copy link
Copy Markdown
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.

@Aleksei-grovety
Aleksei-grovety force-pushed the ethosu-matmul-fixed-point branch from 69f3b37 to 53d7a2d Compare February 2, 2024 14:11

@lhutton1 lhutton1 left a comment

Copy link
Copy Markdown
Contributor

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
Aleksei-grovety force-pushed the ethosu-matmul-fixed-point branch from 53d7a2d to a23e8fc Compare February 9, 2024 15:59
@Aleksei-grovety

Copy link
Copy Markdown
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.

@lhutton1 lhutton1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @Aleksei-grovety, LGTM!

@Aleksei-grovety
Aleksei-grovety force-pushed the ethosu-matmul-fixed-point branch from a23e8fc to 5e9e432 Compare February 13, 2024 18:49
@lhutton1
lhutton1 merged commit 07ecb34 into apache:main Feb 14, 2024
@lhutton1

Copy link
Copy Markdown
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.

2 participants