diff --git a/paddle/fluid/operators/dequantize_log_op.cc b/paddle/fluid/operators/dequantize_log_op.cc index bfd26061e329f0bd6bf52d5fec818ec168eaf1df..2ecd54f7edde63ab5f5256694117cfb15be69384 100644 --- a/paddle/fluid/operators/dequantize_log_op.cc +++ b/paddle/fluid/operators/dequantize_log_op.cc @@ -31,9 +31,9 @@ struct DequantizeFunctor { int ind = in->numel(); for (size_t i = 0; i < (unsigned)ind; i++) { if (input_data[i] < 0) { - output_data[i] = -std::pow(2.0, dict_data[input_data[i] + 128]); + output_data[i] = -dict_data[input_data[i] + 128]; } else { - output_data[i] = std::pow(2.0, dict_data[input_data[i]]); + output_data[i] = dict_data[input_data[i]]; } } } diff --git a/paddle/fluid/operators/dequantize_log_op.cu b/paddle/fluid/operators/dequantize_log_op.cu index 57bad318ab6b649b9ad9dd1a316f75ff7e8d86a5..9f63f8ed6f52019a8d15d2a4ecc3ec0ecc85e165 100644 --- a/paddle/fluid/operators/dequantize_log_op.cu +++ b/paddle/fluid/operators/dequantize_log_op.cu @@ -26,9 +26,9 @@ __global__ void KeDequantize(const T* in, const float* dict, int num, const int idx = threadIdx.x + blockIdx.x * blockDim.x; if (idx < num) { if (in[idx] < 0) { - out[idx] = -std::pow(static_cast(2.0), dict[in[idx] + 128]); + out[idx] = -dict[in[idx] + 128]; } else { - out[idx] = std::pow(static_cast(2.0), dict[in[idx]]); + out[idx] = dict[in[idx]]; } } } diff --git a/python/paddle/fluid/tests/unittests/test_dequantize_log_op.py b/python/paddle/fluid/tests/unittests/test_dequantize_log_op.py index 6c6f0811bbb8a1474a6c783feaf565a7877f9200..3ad1f05f92d58c9fa9e82611283a8bf0b7af237e 100644 --- a/python/paddle/fluid/tests/unittests/test_dequantize_log_op.py +++ b/python/paddle/fluid/tests/unittests/test_dequantize_log_op.py @@ -26,9 +26,9 @@ def dequantize_log(x, dict_data): output_data_f = output_data.flatten() for i in range(x_f.size): if x_f[i] < 0: - output_data_f[i] = -np.power(2, dict_data[x_f[i] + 128]) + output_data_f[i] = -dict_data[x_f[i] + 128] else: - output_data_f[i] = np.power(2, dict_data[x_f[i]]) + output_data_f[i] = dict_data[x_f[i]] return output_data_f.reshape(x.shape)