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

[RELAY][FRONTEND][TENSORFLOW] Fix FuseBatchNorm output cast error if need_cast is True #4894

Merged
merged 1 commit into from Feb 19, 2020

Conversation

yhcvb
Copy link
Contributor

@yhcvb yhcvb commented Feb 16, 2020

No description provided.

@yhcvb
Copy link
Contributor Author

yhcvb commented Feb 16, 2020

@kevinthesun @FrozenGene can you please review this patch

@@ -897,6 +897,7 @@ def _impl(inputs, attr, params):
disables=['momentum'])(inputs, attr)

if need_cast:
out = _expr.TupleGetItem(out.astuple(), 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this related to float16?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I converted a float16 tf model containing the FusedBatchNorm operator.
For the float16 model, the output of the FusedBatchNorm layer is converted back to float16(there may be other quantization types).
But the FusedBatchNorm layer has 3 outputs, if passed directly to the Cast layer will cause an exception error.
So this modification only takes its first calculation output and passes it to the Cast

Copy link
Contributor

Choose a reason for hiding this comment

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

It's true. I too see this recently and above change should fix it.

@yhcvb yhcvb force-pushed the batchnorm_float16_cast_error branch from 9d1bb50 to 79204cb Compare February 19, 2020 01:58
@yhcvb yhcvb changed the title [RELAY][FRONTEND][TENSORFLOW] Fix FuseBatchNorm output cast float16 error [RELAY][FRONTEND][TENSORFLOW] Fix FuseBatchNorm output cast error if need_cast is True Feb 19, 2020
Copy link
Contributor

@kevinthesun kevinthesun left a comment

Choose a reason for hiding this comment

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

LGTM

@kevinthesun kevinthesun merged commit fccf226 into apache:master Feb 19, 2020
@kevinthesun
Copy link
Contributor

Thanks @yhcvb @srkreddy1238

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

3 participants