提交 b9590df6 编写于 作者: W wangjiawei04

add dist kv with quant infer op test=serving

上级 24c78e3b
...@@ -23,8 +23,8 @@ ...@@ -23,8 +23,8 @@
#include "core/predictor/framework/infer.h" #include "core/predictor/framework/infer.h"
#include "core/predictor/framework/memory.h" #include "core/predictor/framework/memory.h"
#include "core/predictor/framework/resource.h" #include "core/predictor/framework/resource.h"
#include "core/util/include/timer.h"
#include "core/predictor/tools/quant.h" #include "core/predictor/tools/quant.h"
#include "core/util/include/timer.h"
namespace baidu { namespace baidu {
namespace paddle_serving { namespace paddle_serving {
...@@ -145,13 +145,21 @@ int GeneralDistKVQuantInferOp::inference() { ...@@ -145,13 +145,21 @@ int GeneralDistKVQuantInferOp::inference() {
values[cube_val_idx].buff.size()); values[cube_val_idx].buff.size());
} else { } else {
// min (float), max (float), num, num, num... (Byte) // min (float), max (float), num, num, num... (Byte)
size_t num_of_float = values[cube_val_idx].buff.size() - 2 * sizeof(float); size_t num_of_float =
float* float_ptr = new float[num_of_float]; values[cube_val_idx].buff.size() - 2 * sizeof(float);
char* src_ptr = new char[values[cube_val_idx].buff.size()]; float *float_ptr = new float[num_of_float];
memcpy(src_ptr, values[cube_val_idx].buff.data(), values[cube_val_idx].buff.size()); char *src_ptr = new char[values[cube_val_idx].buff.size()];
float* minmax = reinterpret_cast<float*>(src_ptr); memcpy(src_ptr,
dequant(src_ptr + 2*sizeof(float), float_ptr, minmax[0], minmax[1], num_of_float, cube_quant_bits); values[cube_val_idx].buff.data(),
memcpy(data_ptr, float_ptr, sizeof(float)*num_of_float); values[cube_val_idx].buff.size());
float *minmax = reinterpret_cast<float *>(src_ptr);
dequant(src_ptr + 2 * sizeof(float),
float_ptr,
minmax[0],
minmax[1],
num_of_float,
cube_quant_bits);
memcpy(data_ptr, float_ptr, sizeof(float) * num_of_float);
delete float_ptr; delete float_ptr;
delete src_ptr; delete src_ptr;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册