-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Adding support for TFLite QnnSubtract operator. #5230
Conversation
shoubhik
commented
Apr 3, 2020
- Adding TFLite quantized subtract operator with test case.
- Adding fix for depthwise conv2d if input channel is 1 with test case.
@anijain2305 and @zhiics can you take a look at this PR. |
@FrozenGene @yzhliu Can you take a look as well? Idea is that if input channel == 1, the depthwise conv becomes simple conv. |
The context for the change is this - tensorflow/tensorflow#23563 |
@FrozenGene @yzhliu Can you take a look at the fix for depthwise conv2d with 1 input channel. |
@FrozenGene If we have C = 1, then depth wise conv becomes normal conv. There is nothing to accumulate across input channels basically. And depth_multiplier becomes equal to the number of output channels. What do you think? Is the change good with you? |
I think it is ok. I met this thing ever. That is when input channel is 1 (for example, gray image), we will get depthwise convolution of multiplier greater than 1 rather than normal convolution. Would you mind doing one performance comparison? I expect we could get better performance when we use normal convolution. |
@FrozenGene It is not possible to use depthwise conv inside Relay here. The |
Yes. My meaning is before we decide to change or not, could we do one performance comparation so that we know depthwise with multiplier > 1 is good or becomes normal convolution is good. |
Thanks for the reply. Can you please share what two things we are comparing? I am still confused. Please let me know example of input shape, depth multiplier, groups etc. |
I leverage this issue tensorflow/tensorflow#23563 we talked about. For example we feed the input (1, 224, 224, 1),in our tensorflow we have convolution to handle it. i.e. |
Correct. So here, TFLite converts Conv to depthwise conv, where depthwise conv has input_channels = groups = 1 and depth multiplier > 1 This PR converts this type of depthwise conv back to normal conv. Exactly the same way that you are suggesting. (There is not even a way to run Relay depthwise conv with groups = 1) Let us know if that is ok. |
Yes. Convolution should be better I expect. However, I wish we could have one performance comparation result between these two ways. So that we decide whether we keep depthwise convolution with multiplier greater than 1 or like this pr converting back to normal convolution finally. |
@FrozenGene I think I have not clarified the issue why we are converting the kernel layout for HWOI to HWIO when number of input channels is 1. First, let us take the example of the current scenario
Assuming you have a network you mentioned before with depthwise convolution with input_channel = 1 and try to parse a Relay graph using the
The change
fixes this issue. This error happens because input_channel is 1 and in the Conv2dRel function fails as there are checks for In order to do the benchmarking, you are suggesting we need to change the underlying |
Oh...I understand it fully now. Thanks for clarifying. If we don't change the Conv2dRel, yes, we can not do benchmark comparison currently. I am fine with this change. |
Thanks @shoubhik @FrozenGene This is merged! |