提交 c605a76a 编写于 作者: W wangguibao

CTR model serving

上级 6e036912
......@@ -15,6 +15,9 @@
#include "demo-serving/op/ctr_prediction_op.h"
#include <algorithm>
#include <string>
#if 1
#include <iomanip>
#endif
#include "cube/cube-api/include/cube_api.h"
#include "predictor/framework/infer.h"
#include "predictor/framework/kv_manager.h"
......@@ -56,13 +59,6 @@ void fill_response_with_message(Response *response,
return;
}
std::string str_tolower(std::string s) {
std::transform(s.begin(), s.end(), s.begin(), [](unsigned char c) {
return std::tolower(c);
});
return s;
}
int CTRPredictionOp::inference() {
const Request *req = dynamic_cast<const Request *>(get_request_message());
......@@ -123,6 +119,26 @@ int CTRPredictionOp::inference() {
return -1;
}
}
#if 1
for (int i = 0; i < keys.size(); ++i) {
std::ostringstream oss;
oss << keys[i] << ": ";
const char *value = (values[i].buff.data());
if (values[i].buff.size() !=
sizeof(float) * CTR_PREDICTION_EMBEDDING_SIZE) {
LOG(WARNING) << "Key " << keys[i] << " has values less than "
<< CTR_PREDICTION_EMBEDDING_SIZE;
}
for (int j = 0; j < values[i].buff.size(); ++j) {
oss << std::hex << std::uppercase << std::setw(2) << std::setfill('0')
<< (reinterpret_cast<int>(value[j]) & 0xff);
}
LOG(INFO) << oss.str().c_str();
}
#endif
}
// Sparse embeddings
......
......@@ -15,7 +15,6 @@
#include "predictor/framework/resource.h"
#include <string>
#include "predictor/common/inner_common.h"
#include "predictor/framework/infer.h"
#include "predictor/framework/kv_manager.h"
namespace baidu {
namespace paddle_serving {
......
......@@ -18,6 +18,7 @@
#include "cube/cube-api/include/cube_api.h"
#include "kvdb/paddle_rocksdb.h"
#include "predictor/common/inner_common.h"
#include "predictor/framework/infer.h"
#include "predictor/framework/memory.h"
namespace baidu {
......@@ -37,7 +38,13 @@ struct DynamicResource {
class Resource {
public:
Resource() {}
Resource() {
// Reference InferManager::instance() explicitly, to make sure static
// instance of InferManager is constructed before that of Resource, and
// destruct after that of Resource
// See https://stackoverflow.com/a/335746/1513460
InferManager::instance();
}
~Resource() { finalize(); }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册