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

[QNN] Channel wise quantization - Quantize & Requantize #4629

Merged
merged 1 commit into from
Jan 7, 2020

Conversation

anijain2305
Copy link
Contributor

@anijain2305 anijain2305 commented Jan 6, 2020

@anijain2305 anijain2305 force-pushed the channelwise_qnn branch 3 times, most recently from cf1fba5 to d692126 Compare January 6, 2020 16:45
@anijain2305
Copy link
Contributor Author

@anijain2305 anijain2305 changed the title WIP [QNN] Channel wise quantization - Quantize & Requantize [QNN] Channel wise quantization - Quantize & Requantize Jan 6, 2020
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.

Thanks @anijain2305 for the PR, I've added some comments.

python/tvm/relay/qnn/op/qnn.py Outdated Show resolved Hide resolved
include/tvm/relay/qnn/attrs.h Outdated Show resolved Hide resolved
python/tvm/relay/qnn/op/qnn.py Outdated Show resolved Hide resolved
include/tvm/relay/qnn/attrs.h Outdated Show resolved Hide resolved
src/relay/qnn/util.h Outdated Show resolved Hide resolved
Copy link
Contributor

@zhenhuaw-me zhenhuaw-me left a comment

Choose a reason for hiding this comment

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

LGTM. Several code style comments :)

src/relay/pass/pattern_util.h Outdated Show resolved Hide resolved
src/relay/pass/pattern_util.h Show resolved Hide resolved

auto expanded_output_scale = output_scale;
if (!IsConstScalar(output_scale)) {
expanded_output_scale = ExpandBiasToMatchAxis(output_scale, n_dim, {axis});
Copy link
Contributor

Choose a reason for hiding this comment

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

what about renaming ExpandBiasToMatchAxis to something more generic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This helper is used in many other passes. We can keep this name for now. And then send a separate PR for better naming across all those files.

src/relay/qnn/op/quantize.cc Outdated Show resolved Hide resolved
src/relay/qnn/util.h Outdated Show resolved Hide resolved
src/relay/qnn/util.h Outdated Show resolved Hide resolved
src/relay/qnn/util.h Show resolved Hide resolved
src/relay/qnn/op/requantize.cc Outdated Show resolved Hide resolved
@anijain2305
Copy link
Contributor Author

LGTM. Several code style comments :)

Thanks for the helpful comments @jackwish All the comments were very good and have been addressed :)

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.

Thanks @anijain2305 , LGTM

@zhiics
Copy link
Member

zhiics commented Jan 7, 2020

@tmoreau89 Could you please manage the PR?
@anijain2305 please retrigger CI

@tmoreau89
Copy link
Contributor

@zhiics on it, thanks

src/relay/pass/pattern_util.h Show resolved Hide resolved
src/relay/pass/pattern_util.h Show resolved Hide resolved
src/relay/qnn/op/quantize.cc Show resolved Hide resolved
@anijain2305
Copy link
Contributor Author

@shoubhik Thanks for the comments. Addressed.
@tmoreau89 CI passing now.

@tmoreau89 tmoreau89 merged commit 76efece into apache:master Jan 7, 2020
@tmoreau89
Copy link
Contributor

Thank you @anijain2305 , @shoubhik , @jackwish ; the PR has been merged

Comment on lines +42 to +43
.describe("The output channel axis for channel wise quantization. Default value is -1,"
"which corresponds to the last axis.")
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have an opinion on whether this is the right approach or not but the question that popped in my mind was :

Why not be more explicit and say that axis == -1 actually means per-tensor quantization ?

Thanks,
Ramana

Copy link
Contributor

Choose a reason for hiding this comment

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

Never mind , later in the thread things are a bit clearer. The axis of -1 is fine - it is part of the per-channel quantization scheme .

In some sense I would have preferred to see a IsPerChannelQuantized predicate, rather than reusing a IsConstScalar predicate further below but that's a code hygiene thing.

And , yes sorry about the slow response, I'm a bit snowed under.

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.

6 participants