From 30ab1773f9b0e32e3423c2f23b6561dac752252c Mon Sep 17 00:00:00 2001 From: Jongsoo Park Date: Wed, 6 Feb 2019 15:10:07 -0800 Subject: call istringstream clear after str (#16820) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/16820 Sometimes parsing histogram was not working correctly due to changes in D13633256 We need to call istringstream clear after str Reviewed By: csummersea Differential Revision: D13977509 fbshipit-source-id: ce3e8cb390641d8f0b5c9a7d6d6daadffeddbe11 --- caffe2/quantization/server/activation_distribution_observer.cc | 2 ++ caffe2/quantization/server/caffe2_dnnlowp_utils.cc | 2 ++ 2 files changed, 4 insertions(+) (limited to 'caffe2') diff --git a/caffe2/quantization/server/activation_distribution_observer.cc b/caffe2/quantization/server/activation_distribution_observer.cc index 85401d22e6..a341eb83c8 100644 --- a/caffe2/quantization/server/activation_distribution_observer.cc +++ b/caffe2/quantization/server/activation_distribution_observer.cc @@ -498,6 +498,7 @@ RegisterQuantizationParamsWithHistogramNetObserver:: } ist.str(first_line); + ist.clear(); bool new_format = true; int op_index, i, nbins; @@ -506,6 +507,7 @@ RegisterQuantizationParamsWithHistogramNetObserver:: ist >> op_index >> op_type >> i >> tensor_name >> min >> max >> nbins; if (nwords_first_line != nbins + 7) { ist.str(first_line); + ist.clear(); ist >> op_index >> i >> tensor_name >> min >> max >> nbins; if (nwords_first_line == nbins + 6) { new_format = false; diff --git a/caffe2/quantization/server/caffe2_dnnlowp_utils.cc b/caffe2/quantization/server/caffe2_dnnlowp_utils.cc index d4ca0baac7..9af991d3a9 100644 --- a/caffe2/quantization/server/caffe2_dnnlowp_utils.cc +++ b/caffe2/quantization/server/caffe2_dnnlowp_utils.cc @@ -438,6 +438,7 @@ NetDef AddScaleZeroOffsetArgumentsWithHistogram( } ist.str(first_line); + ist.clear(); bool new_format = true; int op_index, i, nbins; @@ -446,6 +447,7 @@ NetDef AddScaleZeroOffsetArgumentsWithHistogram( ist >> op_index >> op_type >> i >> tensor_name >> min >> max >> nbins; if (nwords_first_line != nbins + 7) { ist.str(first_line); + ist.clear(); ist >> op_index >> i >> tensor_name >> min >> max >> nbins; if (nwords_first_line == nbins + 6) { new_format = false; -- cgit v1.2.3