Skip to content

Commit

Permalink
[caffe2][dnnlowp] Remove openmp usage in quantize dnnlowp op
Browse files Browse the repository at this point in the history
Summary: It creates cpu overload issues when openmp gets enabled and OMP_NUM_THREADS=1 is not set.

Test Plan: buck test //caffe2/caffe2/quantization/server:quantize_dnnlowp_op_test

Reviewed By: jspark1105

Differential Revision: D24437305

fbshipit-source-id: 426209fc33ce0d4680c478f584716837ee62cb5e
  • Loading branch information
dskhudia authored and facebook-github-bot committed Oct 21, 2020
1 parent 6cd8b5e commit f47231b
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions caffe2/quantization/server/quantize_dnnlowp_op.cc
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#include "quantize_dnnlowp_op.h"
#include "dnnlowp_op.h"

#ifdef _OPENMP
#include <omp.h>
#endif

#include "caffe2/core/tensor_int8.h"
#include "caffe2/quantization/server/int8_gen_quant_params.h"
#include "caffe2_dnnlowp_utils.h"
Expand Down Expand Up @@ -67,16 +63,7 @@ bool QuantizeDNNLowPOp<T>::RunOnDevice() {
const float* in_data = Input(0).template data<float>();
T* out_data = output->t.template mutable_data<T>();

#ifdef _OPENMP
#pragma omp parallel
#endif
{
int i_begin, i_end;
tie(i_begin, i_end) = Get1DPartition(
Input(0).numel(), dnnlowp_get_num_threads(), dnnlowp_get_thread_num());
fbgemm::Quantize<T>(
in_data + i_begin, out_data + i_begin, i_end - i_begin, in_qparams);
}
fbgemm::Quantize<T>(in_data, out_data, Input(0).numel(), in_qparams);

PropagateOutputTensorQuantizationParams(this, 0, in_qparams);

Expand Down

0 comments on commit f47231b

Please sign in to comment.