[pytorch] Make qconv forward() thread safe (#63432)
authorJohn Shen <johnshen@fb.com>
Wed, 18 Aug 2021 17:35:55 +0000 (10:35 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Wed, 18 Aug 2021 17:37:13 +0000 (10:37 -0700)
commit7df2324120513c387524db604f8bcc7281aaf95f
tree78891f7716aa9ee46669982296fa133adffea667
parent565578cdab2cbf18fac0ea97c1a1f954492cc8b5
[pytorch] Make qconv forward() thread safe (#63432)

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

There's a race condition in quantized models when multiple threads call forward() due to qnnpack packing the weights the first time the operator is called. This locks the entire apply_impl function.

Test Plan:
https://github.com/pytorch/pytorch/issues/58055

Ran the script before and after, original crashes went away

Reviewed By: kimishpatel

Differential Revision: D30229520

fbshipit-source-id: d06cabe24199a80325cd57f24a7fd60624be2cf7
aten/src/ATen/native/quantized/cpu/qconv.cpp
aten/src/ATen/native/quantized/cpu/qconv_prepack.cpp
aten/src/ATen/native/quantized/cpu/qnnpack_utils.h