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

[Quantization] Fix annotation for multiply op #4458

Merged
merged 4 commits into from
Dec 12, 2019

Conversation

masahi
Copy link
Member

@masahi masahi commented Dec 3, 2019

When I tried to quantize a model with squeeze and excitation block, I hit the error at this line. The RHS of the multiply op should be checked for being constant, rather than hardcoded as weight.

@masahi
Copy link
Member Author

masahi commented Dec 3, 2019

@vinx13 I'm trying to get a simple quantization test case working. How can I get an int8 output from below? I'm getting FP32 result.

UPDATE: I need to add skip_conv_layers=[] to qconfig to force quantization on the first conv layer. But then I get an error at MulRealize. Working on it.

    data = relay.var("data", shape=(1, 16, 64, 64))
    conv = relay.nn.conv2d(data, relay.var("weight"),
                           kernel_size=(3, 3),
                           padding=(1, 1),
                           channels=16)
    act = relay.nn.relu(data=conv)
    pool = relay.nn.global_avg_pool2d(data=act)
    f = relay.Function(relay.analysis.free_vars(act), act * pool)
    mod, params = testing.create_workload(f)

    with relay.quantize.qconfig():
        print(relay.quantize.quantize(mod, params))

@vinx13 vinx13 self-assigned this Dec 8, 2019
}
if (rhs->dtype != dtype) {
rdata = Cast(rdata, dtype);
} else {
CHECK_EQ(rhs->dtype, dtype);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Is there a deep reason for having this check?

Copy link
Member

Choose a reason for hiding this comment

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

this check seems very trivial... @ZihengJiang ?

@masahi
Copy link
Member Author

masahi commented Dec 11, 2019

@vinx13 @ZihengJiang ready for review.

@masahi
Copy link
Member Author

masahi commented Dec 12, 2019

ping @vinx13 @ZihengJiang can we merge this?

@vinx13 vinx13 merged commit 48a5aa0 into apache:master Dec 12, 2019
zxy844288792 pushed a commit to zxy844288792/tvm that referenced this pull request Dec 13, 2019
* fix mul rewrite

* register Realize Rewrite for global avg pool and add test

* remove unnecessary check

* improve the test case
zxy844288792 pushed a commit to neo-ai/tvm that referenced this pull request Dec 13, 2019
* fix mul rewrite

* register Realize Rewrite for global avg pool and add test

* remove unnecessary check

* improve the test case
masahi added a commit to masahi/tvm that referenced this pull request Jun 19, 2020
)

* fix mul rewrite

* register Realize Rewrite for global avg pool and add test

* remove unnecessary check

* improve the test case
yzhliu pushed a commit that referenced this pull request Jun 19, 2020
…5850)

* fix mul rewrite

* register Realize Rewrite for global avg pool and add test

* remove unnecessary check

* improve the test case
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.

2 participants