[quant] handle empty input in fused_moving_avg_obs_fake_quant op (#64829)
authorSupriya Rao <supriyar@fb.com>
Tue, 14 Sep 2021 05:21:05 +0000 (22:21 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Tue, 14 Sep 2021 05:22:31 +0000 (22:22 -0700)
commitd4b4d835214683236253212dc5c901d3c69f5bc2
tree7fc45ca88ed03c916dd951891ed0feffdd85869c
parent0aef44cb3d8a346099ab8cec40258d263d3a262a
[quant] handle empty input in fused_moving_avg_obs_fake_quant op (#64829)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/64829

If an empty input is passed in, the aminmax operator fails with a runtime error like
```
RuntimeError: aminmax(): cannot compute aminmax over an empty dimension as the operation has no identity.
```

To avoid this during training we just return the input if we find it to be empty

Test Plan:
python test/test_quantization.py TestFusedObsFakeQuant

Imported from OSS

Reviewed By: jingsh

Differential Revision: D30870879

fbshipit-source-id: 0cb4b187449a45a37150a77510d2292f93a7d1cd
aten/src/ATen/native/quantized/cpu/fused_obs_fake_quant.cpp
test/quantization/core/test_workflow_ops.py