diff --git a/demo-serving/op/ctr_prediction_op.cpp b/demo-serving/op/ctr_prediction_op.cpp index 8e0e6fc0ec1f82262a4dedc2dd0ccc3c2331b6d4..806dbc7c87b20271d68c7c0c590c889d4dff622e 100644 --- a/demo-serving/op/ctr_prediction_op.cpp +++ b/demo-serving/op/ctr_prediction_op.cpp @@ -15,6 +15,9 @@ #include "demo-serving/op/ctr_prediction_op.h" #include #include +#if 1 +#include +#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(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(value[j]) & 0xff); + } + + LOG(INFO) << oss.str().c_str(); + } +#endif } // Sparse embeddings diff --git a/predictor/framework/resource.cpp b/predictor/framework/resource.cpp index eadf123f38c215972edad85ee4da9be862f59fef..29c5b20765c99cd4d9223ea845326f032f726a06 100644 --- a/predictor/framework/resource.cpp +++ b/predictor/framework/resource.cpp @@ -15,7 +15,6 @@ #include "predictor/framework/resource.h" #include #include "predictor/common/inner_common.h" -#include "predictor/framework/infer.h" #include "predictor/framework/kv_manager.h" namespace baidu { namespace paddle_serving { diff --git a/predictor/framework/resource.h b/predictor/framework/resource.h index 9640888f91181826eb04faa03f5e73fdaecb346f..56e6bc2e8f748219409310e54744c755c81617a0 100644 --- a/predictor/framework/resource.h +++ b/predictor/framework/resource.h @@ -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(); }