提交 1eefcd6a 编写于 作者: W wangguibao

Add BCLOUD for paddle-serving

Change-Id: I27a9772fde2405b70dd1114da951040b4e564266
上级 5b73d0cd
#edit-mode: -*- python -*-
#coding:utf-8
WORKROOT('../../../')
#gcc version, default 'gcc'
COMPILER('gcc482')
CONFIGS('third-64/protobuf@protobuf_3-2-0-6274_PD_BL')
CONFIGS('baidu/third-party/mklml@v20180406@git_branch')
NEED_OUTPUT('baidu/third-party/mklml')
#sub directory
Directory('pdcodegen')
Directory('configure')
Directory('predictor')
Directory('inferencer-fluid-cpu')
Directory('serving')
Directory('sdk-cpp')
#edit-mode: -*- python -*-
#coding:utf-8
WORKROOT('../../../')
#gcc version, default 'gcc'
COMPILER('gcc482')
CONFIGS('third-64/protobuf@protobuf_3-2-0-6274_PD_BL')
CONFIGS('baidu/base/baidu-rpc@ci-base')
CONFIGS('baidu/third-party/gflags@v2.0.0@git_branch')
CONFIGS('baidu/third-party/glog@v0.3.x@git_branch')
CONFIGS('baidu/third-party/opencv@master@git_branch')
#sub directory
Directory('pdcodegen')
Directory('configure')
Directory('sdk-cpp')
#edit-mode: -*- python -*-
#coding:utf-8
WORKROOT('../../../../')
ImportConfigsFrom('..')
INCPATHS('$INC')
INCPATHS('$OUT_ROOT/third-64/protobuf/output/include')
HEADERS('include/configure_parser.h', '$INC/configure/include')
HEADERS(GLOB_GEN_SRCS('proto/*.pb.h'), '$INC/configure/')
configure_sources = GLOB('proto/*.proto src/*.cpp')
#.a
StaticLibrary('pdconfigure', Sources(configure_sources))
......@@ -17,7 +17,12 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <fstream>
#ifdef BCLOUD
#include "base/logging.h"
#else
#include "butil/logging.h"
#endif
#include "google/protobuf/io/zero_copy_stream_impl.h"
#include "google/protobuf/text_format.h"
......
#edit-mode: -*- python -*-
#coding:utf-8
WORKROOT('../../../../')
#Preprocessor flags.
CPPFLAGS(r'-D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__const__= -Dtypeof=__typeof__ -DUSE_PTHREAD -DPYBIND_AVX_MKLML')
#CPPFLAGS(r'-DVERSION=\"%s\"' % SVN_LAST_CHANGED_REV())
#C++ flags.
CXXFLAGS('-g -O2 -pipe -W -Wall -fPIC -fno-omit-frame-pointer -Wno-deprecated -Wno-unused-parameter -Wno-unused-variable -Wno-unused-local-typedefs -Wno-sign-compare -std=c++11')
ImportConfigsFrom('..')
INCPATHS('$INC')
INCPATHS('../')
INCPATHS('$OUT_ROOT/third-64/protobuf/output/include')
PROTOC('third-64/protobuf/output/bin/protoc')
CONFIGS('baidu/paddlepaddle/paddle@v1.3.0_pb32@git_branch')
HEADERS('include/fluid_cpu_engine.h', '$INC/inferencer-fluid-cpu/include')
inferencer_fluid_cpu_sources = 'src/fluid_cpu_engine.cpp'
#.a
StaticLibrary('inferencer-fluid-cpu',
Sources(inferencer_fluid_cpu_sources))
......@@ -21,7 +21,11 @@
#include <vector>
#include "configure/include/configure_parser.h"
#include "configure/inferencer_configure.pb.h"
#ifdef BCLOUD
#include "paddle/fluid/inference/api/paddle_inference_api.h"
#else
#include "paddle/fluid/inference/paddle_inference_api.h"
#endif
#include "predictor/framework/infer.h"
namespace baidu {
......
#edit-mode: -*- python -*-
#coding:utf-8
WORKROOT('../../../../')
COMPILER('gcc482')
#Preprocessor flags.
CPPFLAGS(r'-D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__const__= -Dtypeof=__typeof__ -DUSE_PTHREAD')
#CPPFLAGS(r'-DVERSION=\"%s\"' % SVN_LAST_CHANGED_REV())
#C flags.
#CFLAGS('-g -pipe -W -Wall -fPIC')
#C++ flags.
CXXFLAGS('-g -O2 -pipe -W -Wall -fPIC -fno-omit-frame-pointer -Wno-deprecated -Wno-unused-parameter -Wno-unused-variable -Wno-unused-local-typedefs -Wno-sign-compare -std=c++11')
#link flags
LDFLAGS('-lpthread -lcrypto -lrt -lssl -ldl -lz')
ImportConfigsFrom('..')
INCPATHS('$INC')
INCPATHS('../')
INCPATHS('$OUT_ROOT/third-64/protobuf/output/include')
HEADERS(GLOB_GEN_SRCS('../predictor/proto/pds_option.pb.h'), '$INC/pdcodegen')
pdcodegen_sources = GLOB('plugin/*.cc')
pdcodegen_sources += ' ../predictor/proto/pds_option.proto'
pdcodegen_sources += ' src/pdcodegen.cpp'
DELETE_AUTO_LIBS('$OUT_ROOT/baidu/third-party/protobuf/output/lib/libprotobuf.a')
DELETE_AUTO_LIBS('$OUT_ROOT/baidu/third-party/protobuf/output/lib/libprotobuf-lite.a')
Application('pdcodegen', Sources(pdcodegen_sources))
......@@ -116,7 +116,7 @@ class PdsCodeGenerator : public CodeGenerator {
printer.Print("#include \"predictor/framework/service_manager.h\"\n");
}
if (generate_stub) {
printer.Print("#include <brpc/parallel_channel.h>\n");
printer.Print("#include <baidu::rpc/parallel_channel.h>\n");
printer.Print("#include \"sdk-cpp/include/factory.h\"\n");
printer.Print("#include \"sdk-cpp/include/stub.h\"\n");
printer.Print("#include \"sdk-cpp/include/stub_impl.h\"\n");
......@@ -274,9 +274,9 @@ class PdsCodeGenerator : public CodeGenerator {
google::protobuf::dots_to_colons(m->output_type()->full_name()));
if (m->name() == "inference") {
printer->Print(
" brpc::ClosureGuard done_guard(done);\n"
" brpc::Controller* cntl = \n"
" static_cast<brpc::Controller*>(cntl_base);\n"
" baidu::rpc::ClosureGuard done_guard(done);\n"
" baidu::rpc::Controller* cntl = \n"
" static_cast<baidu::rpc::Controller*>(cntl_base);\n"
" ::baidu::paddle_serving::predictor::InferService* svr = \n"
" "
"::baidu::paddle_serving::predictor::InferServiceManager::instance("
......@@ -311,9 +311,9 @@ class PdsCodeGenerator : public CodeGenerator {
}
if (m->name() == "debug") {
printer->Print(
" brpc::ClosureGuard done_guard(done);\n"
" brpc::Controller* cntl = \n"
" static_cast<brpc::Controller*>(cntl_base);\n"
" baidu::rpc::ClosureGuard done_guard(done);\n"
" baidu::rpc::Controller* cntl = \n"
" static_cast<baidu::rpc::Controller*>(cntl_base);\n"
" ::baidu::paddle_serving::predictor::InferService* svr = \n"
" "
"::baidu::paddle_serving::predictor::InferServiceManager::instance("
......@@ -329,7 +329,7 @@ class PdsCodeGenerator : public CodeGenerator {
"\"\]\";\n"
" LOG(INFO) << \" service_name=\[\" << \"$name$\" << \"\]\";\n" // NOLINT
" LOG(INFO) << \" log_id=\[\" << cntl->log_id() << \"\]\";\n" // NOLINT
" butil::IOBufBuilder debug_os;\n"
" base::IOBufBuilder debug_os;\n"
" int err_code = svr->inference(request, response, &debug_os);\n"
" if (err_code != 0) {\n"
" LOG(WARNING)\n"
......@@ -371,7 +371,7 @@ class PdsCodeGenerator : public CodeGenerator {
const std::string& service_name,
const std::string& class_name) const {
printer->Print(
"class $name$_StubCallMapper : public brpc::CallMapper {\n"
"class $name$_StubCallMapper : public baidu::rpc::CallMapper {\n"
"private:\n"
" uint32_t _package_size;\n"
" baidu::paddle_serving::sdk_cpp::Stub* _stub_handler;\n"
......@@ -389,7 +389,7 @@ class PdsCodeGenerator : public CodeGenerator {
class_name);
printer->Print(
"brpc::SubCall default_map(\n"
"baidu::rpc::SubCall default_map(\n"
" int channel_index,\n"
" const google::protobuf::MethodDescriptor* method,\n"
" const google::protobuf::Message* request,\n"
......@@ -409,7 +409,7 @@ class PdsCodeGenerator : public CodeGenerator {
printer->Print("}\n");
printer->Print(
"brpc::SubCall sub_package_map(\n"
"baidu::rpc::SubCall sub_package_map(\n"
" int channel_index,\n"
" const google::protobuf::MethodDescriptor* method,\n"
" const google::protobuf::Message* request,\n"
......@@ -458,7 +458,7 @@ class PdsCodeGenerator : public CodeGenerator {
printer->Print("}\n");
printer->Print(
"brpc::SubCall Map(\n"
"baidu::rpc::SubCall Map(\n"
" int channel_index,\n"
" const google::protobuf::MethodDescriptor* method,\n"
" const google::protobuf::Message* request,\n"
......@@ -473,8 +473,8 @@ class PdsCodeGenerator : public CodeGenerator {
"return default_map(channel_index, method, request, response);\n");
} else {
printer->Print(
"butil::Timer tt(butil::Timer::STARTED);\n"
"brpc::SubCall ret;\n"
"base::Timer tt(base::Timer::STARTED);\n"
"baidu::rpc::SubCall ret;\n"
"if (_package_size == 0) {\n"
" ret = default_map(channel_index, method, request, response);\n"
"} else {\n"
......@@ -482,7 +482,7 @@ class PdsCodeGenerator : public CodeGenerator {
"response);\n"
"}\n"
"tt.stop();\n"
"if (ret.flags != brpc::SKIP_SUB_CHANNEL && ret.method != NULL) {\n"
"if (ret.flags != baidu::rpc::SKIP_SUB_CHANNEL && ret.method != NULL) {\n"
" _stub_handler->update_latency(tt.u_elapsed(), \"pack_map\");\n"
"}\n"
"return ret;\n");
......@@ -496,7 +496,7 @@ class PdsCodeGenerator : public CodeGenerator {
////////////////////////////////////////////////////////////////
printer->Print(
"class $name$_StubResponseMerger : public brpc::ResponseMerger {\n"
"class $name$_StubResponseMerger : public baidu::rpc::ResponseMerger {\n"
"private:\n"
" uint32_t _package_size;\n"
" baidu::paddle_serving::sdk_cpp::Stub* _stub_handler;\n"
......@@ -514,7 +514,7 @@ class PdsCodeGenerator : public CodeGenerator {
class_name);
printer->Print(
"brpc::ResponseMerger::Result default_merge(\n"
"baidu::rpc::ResponseMerger::Result default_merge(\n"
" google::protobuf::Message* response,\n"
" const google::protobuf::Message* sub_response) {\n"
" baidu::paddle_serving::sdk_cpp::TracePackScope "
......@@ -530,7 +530,7 @@ class PdsCodeGenerator : public CodeGenerator {
printer->Print("}\n");
printer->Print(
"brpc::ResponseMerger::Result sub_package_merge(\n"
"baidu::rpc::ResponseMerger::Result sub_package_merge(\n"
" google::protobuf::Message* response,\n"
" const google::protobuf::Message* sub_response) {\n"
" baidu::paddle_serving::sdk_cpp::TracePackScope "
......@@ -546,22 +546,22 @@ class PdsCodeGenerator : public CodeGenerator {
printer->Print("}\n");
printer->Print(
"brpc::ResponseMerger::Result Merge(\n"
"baidu::rpc::ResponseMerger::Result Merge(\n"
" google::protobuf::Message* response,\n"
" const google::protobuf::Message* sub_response) {\n",
"name",
class_name);
printer->Indent();
printer->Print(
"butil::Timer tt(butil::Timer::STARTED);\n"
"brpc::ResponseMerger::Result ret;"
"base::Timer tt(base::Timer::STARTED);\n"
"baidu::rpc::ResponseMerger::Result ret;"
"if (_package_size <= 0) {\n"
" ret = default_merge(response, sub_response);\n"
"} else {\n"
" ret = sub_package_merge(response, sub_response);\n"
"}\n"
"tt.stop();\n"
"if (ret != brpc::ResponseMerger::FAIL) {\n"
"if (ret != baidu::rpc::ResponseMerger::FAIL) {\n"
" _stub_handler->update_latency(tt.u_elapsed(), \"pack_merge\");\n"
"}\n"
"return ret;\n");
......@@ -580,7 +580,7 @@ class PdsCodeGenerator : public CodeGenerator {
const std::string& class_name) const {
printer->Print(
"if (channel_index > 0) { \n"
" return brpc::SubCall::Skip();\n"
" return baidu::rpc::SubCall::Skip();\n"
"}\n");
printer->Print(
"google::protobuf::Message* cur_res = "
......@@ -591,14 +591,14 @@ class PdsCodeGenerator : public CodeGenerator {
" if (cur_res == NULL) {\n"
" LOG(ERROR) << \"Failed new response item!\";\n"
" _stub_handler->update_average(1, \"pack_fail\");\n"
" return brpc::SubCall::Bad();\n"
" return baidu::rpc::SubCall::Bad();\n"
" }\n"
" return brpc::SubCall(method, request, cur_res, "
"brpc::DELETE_RESPONSE);\n"
" return baidu::rpc::SubCall(method, request, cur_res, "
"baidu::rpc::DELETE_RESPONSE);\n"
"}\n");
"LOG(INFO) \n"
" << \"[default] Succ map, channel_index: \" << channel_index;\n";
printer->Print("return brpc::SubCall(method, request, cur_res, 0);\n");
printer->Print("return baidu::rpc::SubCall(method, request, cur_res, 0);\n");
return true;
}
bool generate_paddle_serving_stub_default_merger(
......@@ -610,11 +610,11 @@ class PdsCodeGenerator : public CodeGenerator {
printer->Print(
"try {\n"
" response->MergeFrom(*sub_response);\n"
" return brpc::ResponseMerger::MERGED;\n"
" return baidu::rpc::ResponseMerger::MERGED;\n"
"} catch (const std::exception& e) {\n"
" LOG(ERROR) << \"Merge failed.\";\n"
" _stub_handler->update_average(1, \"pack_fail\");\n"
" return brpc::ResponseMerger::FAIL;\n"
" return baidu::rpc::ResponseMerger::FAIL;\n"
"}\n");
return true;
}
......@@ -657,7 +657,7 @@ class PdsCodeGenerator : public CodeGenerator {
printer->Print(
"int start = _package_size * channel_index;\n"
"if (start >= total_size) {\n"
" return brpc::SubCall::Skip();\n"
" return baidu::rpc::SubCall::Skip();\n"
"}\n"
"int end = _package_size * (channel_index + 1);\n"
"if (end > total_size) {\n"
......@@ -670,7 +670,7 @@ class PdsCodeGenerator : public CodeGenerator {
"if (sub_req == NULL) {\n"
" LOG(ERROR) << \"failed fetch sub_req from stub.\";\n"
" _stub_handler->update_average(1, \"pack_fail\");\n"
" return brpc::SubCall::Bad();\n"
" return baidu::rpc::SubCall::Bad();\n"
"}\n",
"name",
class_name,
......@@ -685,7 +685,7 @@ class PdsCodeGenerator : public CodeGenerator {
"req->$field_name$_size()\n"
" << \", field: $field_name$.\";\n"
" _stub_handler->update_average(1, \"pack_fail\");\n"
" return brpc::SubCall::Bad();\n"
" return baidu::rpc::SubCall::Bad();\n"
"}\n",
"field_name",
field_name);
......@@ -718,7 +718,7 @@ class PdsCodeGenerator : public CodeGenerator {
" if (!sub_req) {\n"
" LOG(ERROR) << \"failed fetch sub_req from stub handler.\";\n"
" _stub_handler->update_average(1, \"pack_fail\");\n"
" return brpc::SubCall::Bad();\n"
" return baidu::rpc::SubCall::Bad();\n"
" }\n"
"}\n",
"req_type",
......@@ -761,9 +761,9 @@ class PdsCodeGenerator : public CodeGenerator {
"if (sub_res == NULL) {\n"
" LOG(ERROR) << \"failed create sub_res from res.\";\n"
" _stub_handler->update_average(1, \"pack_fail\");\n"
" return brpc::SubCall::Bad();\n"
" return baidu::rpc::SubCall::Bad();\n"
"}\n"
"return brpc::SubCall(method, sub_req, sub_res, 0);\n");
"return baidu::rpc::SubCall(method, sub_req, sub_res, 0);\n");
return true;
}
bool generate_paddle_serving_stub_package_merger(
......
#edit-mode: -*- python -*-
#coding:utf-8
WORKROOT('../../../../')
#Preprocessor flags.
CPPFLAGS(r'-D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__const__= -Dtypeof=__typeof__ -DUSE_PTHREAD')
#CPPFLAGS(r'-DVERSION=\"%s\"' % SVN_LAST_CHANGED_REV())
#C++ flags.
CXXFLAGS('-g -O2 -pipe -W -Wall -fPIC -fno-omit-frame-pointer -Wno-deprecated -Wno-unused-parameter -Wno-unused-variable -Wno-unused-local-typedefs -Wno-sign-compare -std=c++11')
ImportConfigsFrom('..')
INCPATHS('$INC')
INCPATHS('../')
INCPATHS('$OUT_ROOT/third-64/protobuf/output/include')
CONFIGS('baidu/base/baidu-rpc@ci-base')
cpp_source_dirs = []
cpp_source_dirs.append('common/*.cpp')
cpp_source_dirs.append('op/*.cpp')
cpp_source_dirs.append('framework/*.cpp')
cpp_source_dirs.append('mempool/*.cpp')
cpp_source_dirs.append('proto/*.proto')
HEADERS(GLOB_GEN_SRCS('proto/*.pb.h'), '$INC/predictor/')
HEADERS('common/*.h', '$INC/predictor/common')
HEADERS('framework/*.h', '$INC/predictor/framework')
HEADERS('mempool/*.h', '$INC/predictor/mempool')
#.a
StaticLibrary('pdserving', Sources(GLOB(' '.join(cpp_source_dirs)), 'src/pdserving.cpp'))
......@@ -31,13 +31,25 @@
#include "gflags/gflags.h"
#ifdef BCLOUD
#include "bthread.h"
#include "baidu/rpc/channel.h"
#include "baidu/rpc/policy/giano_authenticator.h"
#include "baidu/rpc/server.h"
#include "base/logging.h"
#include "base/comlog_sink.h"
#include "base/object_pool.h"
#include "base/time.h"
#else
#include "bthread/bthread.h"
#include "brpc/channel.h"
#include "brpc/policy/giano_authenticator.h"
#include "brpc/server.h"
#include "bthread/bthread.h"
#include "butil/logging.h"
#include "butil/object_pool.h"
#include "butil/time.h"
#endif
#include "configure/include/configure_parser.h"
#include "configure/server_configure.pb.h"
......@@ -45,3 +57,8 @@
#include "predictor/common/constant.h"
#include "predictor/common/types.h"
#include "predictor/common/utils.h"
#ifdef BCLOUD
namespace brpc = baidu::rpc;
namespace butil = base;
#endif
......@@ -21,6 +21,10 @@ namespace baidu {
namespace paddle_serving {
namespace predictor {
#ifdef BCLOUD
namespace butil = base;
#endif
class TimerFlow {
public:
static const int MAX_SIZE = 1024;
......
......@@ -14,7 +14,12 @@
#pragma once
#ifdef BCLOUD
#include <base/atomicops.h>
#else
#include <butil/atomicops.h>
#endif
#include <errno.h>
#include <algorithm>
#include <deque>
......
......@@ -14,7 +14,12 @@
#pragma once
#ifdef BCLOUD
#include <base/atomicops.h>
#else
#include <butil/atomicops.h>
#endif
#include <sys/syscall.h>
#include <boost/bind.hpp>
......
......@@ -18,7 +18,13 @@
#include <algorithm>
#include <deque>
#include <vector>
#ifdef BCLOUD
#include "base/atomicops.h"
#else
#include "butil/atomicops.h"
#endif
#include "predictor/common/inner_common.h"
#include "boost/function.hpp"
......
......@@ -13,7 +13,11 @@
// limitations under the License.
#include "predictor/framework/dag_view.h"
#ifdef BCLOUD
#include <baidu/rpc/traceprintf.h> // TRACEPRINTF
#else
#include <brpc/traceprintf.h> // TRACEPRINTF
#endif
#include <string>
#include "predictor/common/inner_common.h"
#include "predictor/framework/op_repository.h"
......
......@@ -13,7 +13,11 @@
// limitations under the License.
#include "predictor/framework/predictor_metric.h"
#ifdef BCLOUD
#include "base/memory/singleton.h"
#else
#include "butil/memory/singleton.h"
#endif
namespace baidu {
namespace paddle_serving {
......
......@@ -13,12 +13,24 @@
// limitations under the License.
#pragma once
#ifdef BCLOUD
#include <base/containers/flat_map.h> // FlatMap
#include <base/memory/singleton.h> // DefaultSingletonTraits
#include <base/scoped_lock.h> // BAIDU_SCOPED_LOCK
#else
#include <butil/containers/flat_map.h> // FlatMap
#include <butil/memory/singleton.h> // DefaultSingletonTraits
#include <butil/scoped_lock.h> // BAIDU_SCOPED_LOCK
#endif
#include <bvar/bvar.h> // bvar
#include <string>
#ifdef BCLOUD
namespace butil = base;
#endif
namespace baidu {
namespace paddle_serving {
namespace predictor {
......
......@@ -13,9 +13,15 @@
// limitations under the License.
#include "predictor/framework/server.h"
#ifdef BCLOUD
#include <baidu/rpc/policy/nova_pbrpc_protocol.h> // NovaServiceAdaptor
#include <baidu/rpc/policy/nshead_mcpack_protocol.h> // NsheadMcpackAdaptor
#include <baidu/rpc/policy/public_pbrpc_protocol.h> // PublicPbrpcServiceAdaptor
#else
#include <brpc/policy/nova_pbrpc_protocol.h> // NovaServiceAdaptor
#include <brpc/policy/nshead_mcpack_protocol.h> // NsheadMcpackAdaptor
#include <brpc/policy/public_pbrpc_protocol.h> // PublicPbrpcServiceAdaptor
#endif
#include <string>
#include <utility>
#include "predictor/common/inner_common.h"
......@@ -27,6 +33,10 @@ namespace baidu {
namespace paddle_serving {
namespace predictor {
#ifdef BCLOUD
namespace brpc = baidu::rpc;
#endif
volatile bool ServerManager::_s_reload_starting = true;
bool ServerManager::_compare_string_piece_without_case(
......
......@@ -20,6 +20,10 @@ namespace baidu {
namespace paddle_serving {
namespace predictor {
#ifdef BCLOUD
namespace brpc = baidu::rpc;
#endif
class ServerManager {
public:
typedef google::protobuf::Service Service;
......
......@@ -13,7 +13,12 @@
// limitations under the License.
#include "predictor/framework/service.h"
#ifdef BCLOUD
#include <base/time.h> // butil::Timer
#else
#include <butil/time.h> // butil::Timer
#endif
#include <list>
#include <string>
#include <vector>
......
......@@ -13,8 +13,15 @@
// limitations under the License.
#pragma once
#ifdef BCLOUD
#include <base/atomicops.h>
#include <base/logging.h>
#else
#include <butil/atomicops.h>
#include <butil/logging.h>
#endif
#include <execinfo.h>
#include <pthread.h>
#include <iostream>
......@@ -25,6 +32,10 @@
namespace im {
namespace fugue {
#ifdef BCLOUD
namespace butil = base;
#endif
namespace lockfree {
template <class T>
......
......@@ -13,7 +13,12 @@
// limitations under the License.
#include "predictor/op/op.h"
#include <butil/time.h> // butil::Timer
#ifdef BCLOUD
#else
#include <base/time.h> // base::Timer
#endif
#include <string>
#include "predictor/common/constant.h"
#include "predictor/common/utils.h"
......
......@@ -16,10 +16,15 @@
#include <sys/types.h>
#include <unistd.h>
#ifdef BCLOUD
#include <bthread_unstable.h> // bthread_set_worker_startfn
#else
#include <bthread/unstable.h> // bthread_set_worker_startfn
#endif
#include <fstream>
#include <iostream>
#include "butil/logging.h"
#include "predictor/common/constant.h"
#include "predictor/common/inner_common.h"
#include "predictor/framework/manager.h"
......@@ -107,6 +112,21 @@ int main(int argc, char** argv) {
g_change_server_port();
// initialize logger instance
#ifdef BCLOUD
logging::LoggingSettings settings;
settings.logging_dest = logging::LOG_TO_FILE;
std::string filename(argv[0]);
filename = filename.substr(filename.find_last_of('/') + 1);
settings.log_file = (std::string("./log/") + filename + ".log").c_str();
settings.delete_old = logging::DELETE_OLD_LOG_FILE;
logging::InitLogging(settings);
logging::ComlogSinkOptions cso;
cso.process_name = filename;
cso.enable_wf_device = true;
logging::ComlogSink::GetInstance()->Setup(&cso);
#else
if (FLAGS_log_dir == "") {
FLAGS_log_dir = "./log";
}
......@@ -125,7 +145,7 @@ int main(int argc, char** argv) {
google::InitGoogleLogging(strdup(argv[0]));
FLAGS_logbufsecs = 0;
FLAGS_logbuflevel = -1;
#endif
LOG(INFO) << "Succ initialize logger";
// initialize resource manager
......@@ -181,7 +201,10 @@ int main(int argc, char** argv) {
LOG(ERROR) << "Failed finalize resource manager";
}
#ifdef BCLOUD
#else
google::ShutdownGoogleLogging();
#endif
LOG(INFO) << "Paddle Inference Server exit successfully!";
return 0;
}
mkdir -p demo/serving/bin
mv bin/serving demo/serving/bin
mkdir -p demo/client/bin
mv bin/dense_format demo/client/bin/
mv bin/echo demo/client/bin
mv bin/int64tensor_format demo/client/bin
mv bin/sparse_format demo/client/bin
mv bin/text_classification demo/client/bin
mv bin/text_classification_press demo/client/bin
mv bin/ximage demo/client/bin
cp baidu_third-party_mklml/so/* demo/serving/bin/
rm -rf baidu_third-party_mklml
# Download test model and test dataset
pushd .
cd demo/client/data
mkdir -p text_classification
cd text_classification
wget --no-check-certificate https://paddle-serving.bj.bcebos.com/data/text_classification/test_set.tar.gz
tar zxvf test_set.tar.gz
popd
pushd .
cd demo/serving/
mkdir -p data/model/paddle/fluid/
cd data/model/paddle/fluid/
wget --no-check-certificate https://paddle-serving.bj.bcebos.com/data/text_classification/text_classification_lstm.tar.gz
tar zxvf text_classification_lstm.tar.gz
#edit-mode: -*- python -*-
#coding:utf-8
WORKROOT('../../../../')
#Preprocessor flags.
CPPFLAGS(r'-D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__const__= -Dtypeof=__typeof__ -DUSE_PTHREAD')
#CPPFLAGS(r'-DVERSION=\"%s\"' % SVN_LAST_CHANGED_REV())
#C++ flags.
CXXFLAGS('-g -O2 -pipe -W -Wall -fPIC -fno-omit-frame-pointer -Wno-deprecated -Wno-unused-parameter -Wno-unused-variable -Wno-unused-local-typedefs -Wno-sign-compare -std=c++11')
#link flags
LDFLAGS('-lpthread -lcrypto -lrt -lssl -ldl -lz -std=c++11')
ImportConfigsFrom('..')
INCPATHS('$INC')
INCPATHS('$INC/sdk-cpp')
INCPATHS('$INC/sdk-cpp/include')
INCPATHS('$OUT_ROOT/third-64/protobuf/output/include')
LIBS('$OUT/lib/libpdconfigure.a')
CONFIGS('baidu/base/baidu-rpc@ci-base')
CONFIGS('baidu/third-party/gflags@v2.0.0@git_branch')
CONFIGS('baidu/third-party/glog@v0.3.x@git_branch')
CONFIGS('baidu/third-party/opencv@master@git_branch')
DELETE_AUTO_LIBS('$OUT_ROOT/baidu/third-party/protobuf/output/lib/libprotobuf.a')
DELETE_AUTO_LIBS('$OUT_ROOT/baidu/third-party/protobuf/output/lib/libprotobuf-lite.a')
# DELETE_AUTO_LIBS('$OUT_ROOT/third-64/glog/output/lib/libglog.a')
DELETE_AUTO_LIBS('$OUT_ROOT/third-64/gflags/output/lib/libgflags.a')
DELETE_AUTO_LIBS('$OUT_ROOT/third-64/gflags/output/lib/libgflags_nothreads.a')
PROTOFLAGS(
'--plugin=protoc-gen-pdcodegen=../pdcodegen/plugin/pdcodegen',
'--pdcodegen_out proto --proto_path=.',
'--proto_path=../predictor/proto')
HEADERS(GLOB_GEN_SRCS('../configure/proto/sdk_configure.pb.h'), '$INC/sdk-cpp')
HEADERS(GLOB_GEN_SRCS('../predictor/proto/builtin_format.pb.h'), '$INC/sdk-cpp')
HEADERS(GLOB_GEN_SRCS('../predictor/proto/pds_option.pb.h'), '$INC/sdk-cpp')
HEADERS(GLOB_GEN_SRCS('proto/*.pb.h'), '$INC/sdk-cpp')
HEADERS('include/*.h', '$INC/sdk-cpp/include')
HEADERS('include/*.hpp', '$INC/sdk-cpp/include')
user_sources=GLOB("src/*.cpp proto/*.proto")
user_sources += ' ../predictor/proto/builtin_format.proto ../predictor/proto/pds_option.proto'
# .a
StaticLibrary('pdsdk-cpp', Sources(user_sources))
# Application
#bin
Application('ximage', Sources('demo/ximage.cpp'), WholeArchives('$OUT/lib/libpdsdk-cpp.a'))
Application('echo', Sources('demo/echo.cpp'), WholeArchives('$OUT/lib/libpdsdk-cpp.a'))
Application('dense_format', Sources('demo/dense_format.cpp'), WholeArchives('$OUT/lib/libpdsdk-cpp.a'))
Application('sparse_format', Sources('demo/sparse_format.cpp'), WholeArchives('$OUT/lib/libpdsdk-cpp.a'))
Application('int64tensor_format', Sources('demo/int64tensor_format.cpp'), WholeArchives('$OUT/lib/libpdsdk-cpp.a'))
Application('text_classification', Sources('demo/text_classification.cpp'), WholeArchives('$OUT/lib/libpdsdk-cpp.a'))
Application('text_classification_press', Sources('demo/text_classification_press.cpp'), WholeArchives('$OUT/lib/libpdsdk-cpp.a'))
OUTPUT('conf', '$OUT/demo/client')
OUTPUT('data', '$OUT/demo/client')
......@@ -63,6 +63,21 @@ int main(int argc, char** argv) {
PredictorApi api;
// initialize logger instance
#ifdef BCLOUD
logging::LoggingSettings settings;
settings.logging_dest = logging::LOG_TO_FILE;
std::string filename(argv[0]);
filename = filename.substr(filename.find_last_of('/') + 1);
settings.log_file = (std::string("./log/") + filename + ".log").c_str();
settings.delete_old = logging::DELETE_OLD_LOG_FILE;
logging::InitLogging(settings);
logging::ComlogSinkOptions cso;
cso.process_name = filename;
cso.enable_wf_device = true;
logging::ComlogSink::GetInstance()->Setup(&cso);
#else
struct stat st_buf;
int ret = 0;
if ((ret = stat("./log", &st_buf)) != 0) {
......@@ -75,6 +90,7 @@ int main(int argc, char** argv) {
}
FLAGS_log_dir = "./log";
google::InitGoogleLogging(strdup(argv[0]));
#endif
if (api.create("./conf", "predictors.prototxt") != 0) {
LOG(ERROR) << "Failed create predictors api!";
......@@ -94,7 +110,7 @@ int main(int argc, char** argv) {
Predictor* predictor = api.fetch_predictor("dense_service");
if (!predictor) {
LOG(ERROR) << "Failed fetch predictor: echo_service";
LOG(ERROR) << "Failed fetch predictor: dense_service";
return -1;
}
......@@ -130,8 +146,9 @@ int main(int argc, char** argv) {
api.thrd_finalize();
api.destroy();
#ifndef BCLOUD
google::ShutdownGoogleLogging();
#endif
return 0;
}
......
......@@ -46,6 +46,21 @@ int main(int argc, char** argv) {
PredictorApi api;
// initialize logger instance
#ifdef BCLOUD
logging::LoggingSettings settings;
settings.logging_dest = logging::LOG_TO_FILE;
std::string filename(argv[0]);
filename = filename.substr(filename.find_last_of('/') + 1);
settings.log_file = (std::string("./log/") + filename + ".log").c_str();
settings.delete_old = logging::DELETE_OLD_LOG_FILE;
logging::InitLogging(settings);
logging::ComlogSinkOptions cso;
cso.process_name = filename;
cso.enable_wf_device = true;
logging::ComlogSink::GetInstance()->Setup(&cso);
#else
struct stat st_buf;
int ret = 0;
if ((ret = stat("./log", &st_buf)) != 0) {
......@@ -58,6 +73,7 @@ int main(int argc, char** argv) {
}
FLAGS_log_dir = "./log";
google::InitGoogleLogging(strdup(argv[0]));
#endif
if (api.create("./conf", "predictors.prototxt") != 0) {
LOG(ERROR) << "Failed create predictors api!";
......@@ -113,7 +129,9 @@ int main(int argc, char** argv) {
api.thrd_finalize();
api.destroy();
#ifndef BCLOUD
google::ShutdownGoogleLogging();
#endif
return 0;
}
......
......@@ -75,6 +75,21 @@ int main(int argc, char** argv) {
PredictorApi api;
// initialize logger instance
#ifdef BCLOUD
logging::LoggingSettings settings;
settings.logging_dest = logging::LOG_TO_FILE;
std::string filename(argv[0]);
filename = filename.substr(filename.find_last_of('/') + 1);
settings.log_file = (std::string("./log/") + filename + ".log").c_str();
settings.delete_old = logging::DELETE_OLD_LOG_FILE;
logging::InitLogging(settings);
logging::ComlogSinkOptions cso;
cso.process_name = filename;
cso.enable_wf_device = true;
logging::ComlogSink::GetInstance()->Setup(&cso);
#else
struct stat st_buf;
int ret = 0;
if ((ret = stat("./log", &st_buf)) != 0) {
......@@ -87,6 +102,7 @@ int main(int argc, char** argv) {
}
FLAGS_log_dir = "./log";
google::InitGoogleLogging(strdup(argv[0]));
#endif
if (api.create("./conf", "predictors.prototxt") != 0) {
LOG(ERROR) << "Failed create predictors api!";
......@@ -142,7 +158,9 @@ int main(int argc, char** argv) {
api.thrd_finalize();
api.destroy();
#ifndef BCLOUD
google::ShutdownGoogleLogging();
#endif
return 0;
}
......
......@@ -73,6 +73,21 @@ int main(int argc, char** argv) {
PredictorApi api;
// initialize logger instance
#ifdef BCLOUD
logging::LoggingSettings settings;
settings.logging_dest = logging::LOG_TO_FILE;
std::string filename(argv[0]);
filename = filename.substr(filename.find_last_of('/') + 1);
settings.log_file = (std::string("./log/") + filename + ".log").c_str();
settings.delete_old = logging::DELETE_OLD_LOG_FILE;
logging::InitLogging(settings);
logging::ComlogSinkOptions cso;
cso.process_name = filename;
cso.enable_wf_device = true;
logging::ComlogSink::GetInstance()->Setup(&cso);
#else
struct stat st_buf;
int ret = 0;
if ((ret = stat("./log", &st_buf)) != 0) {
......@@ -85,6 +100,7 @@ int main(int argc, char** argv) {
}
FLAGS_log_dir = "./log";
google::InitGoogleLogging(strdup(argv[0]));
#endif
if (api.create("./conf", "predictors.prototxt") != 0) {
LOG(ERROR) << "Failed create predictors api!";
......@@ -140,7 +156,9 @@ int main(int argc, char** argv) {
api.thrd_finalize();
api.destroy();
#ifndef BCLOUD
google::ShutdownGoogleLogging();
#endif
return 0;
}
......
......@@ -171,6 +171,21 @@ int main(int argc, char **argv) {
PredictorApi api;
// initialize logger instance
#ifdef BCLOUD
logging::LoggingSettings settings;
settings.logging_dest = logging::LOG_TO_FILE;
std::string filename(argv[0]);
filename = filename.substr(filename.find_last_of('/') + 1);
settings.log_file = (std::string("./log/") + filename + ".log").c_str();
settings.delete_old = logging::DELETE_OLD_LOG_FILE;
logging::InitLogging(settings);
logging::ComlogSinkOptions cso;
cso.process_name = filename;
cso.enable_wf_device = true;
logging::ComlogSink::GetInstance()->Setup(&cso);
#else
struct stat st_buf;
int ret = 0;
if ((ret = stat("./log", &st_buf)) != 0) {
......@@ -185,6 +200,7 @@ int main(int argc, char **argv) {
google::InitGoogleLogging(strdup(argv[0]));
FLAGS_logbufsecs = 0;
FLAGS_logbuflevel = -1;
#endif
g_pred_labels.clear();
......@@ -261,6 +277,8 @@ int main(int argc, char **argv) {
LOG(INFO) << "Accuracy "
<< static_cast<double>(correct) / g_pred_labels.size();
LOG(INFO) << "correct " << correct;
LOG(INFO) << "g_pred_labels " << g_pred_labels.size();
api.thrd_finalize();
api.destroy();
......
......@@ -249,6 +249,21 @@ int main(int argc, char **argv) {
PredictorApi api;
// initialize logger instance
#ifdef BCLOUD
logging::LoggingSettings settings;
settings.logging_dest = logging::LOG_TO_FILE;
std::string filename(argv[0]);
filename = filename.substr(filename.find_last_of('/') + 1);
settings.log_file = (std::string("./log/") + filename + ".log").c_str();
settings.delete_old = logging::DELETE_OLD_LOG_FILE;
logging::InitLogging(settings);
logging::ComlogSinkOptions cso;
cso.process_name = filename;
cso.enable_wf_device = true;
logging::ComlogSink::GetInstance()->Setup(&cso);
#else
struct stat st_buf;
int ret = 0;
if ((ret = stat("./log", &st_buf)) != 0) {
......@@ -264,6 +279,7 @@ int main(int argc, char **argv) {
google::InitGoogleLogging(strdup(argv[0]));
FLAGS_logbufsecs = 0;
FLAGS_logbuflevel = -1;
#endif
g_pred_labels.resize(FLAGS_concurrency);
g_correct.resize(FLAGS_concurrency);
......
......@@ -22,6 +22,10 @@
#include "sdk-cpp/include/common.h"
#include "sdk-cpp/include/predictor_sdk.h"
#ifndef BCLOUD
using json2pb::JsonToProtoMessage;
#endif
using baidu::paddle_serving::sdk_cpp::Predictor;
using baidu::paddle_serving::sdk_cpp::PredictorApi;
using baidu::paddle_serving::predictor::format::XImageReqInstance;
......@@ -87,7 +91,7 @@ void print_res(const Request& req,
butil::IOBuf buf;
buf.append(json);
butil::IOBufAsZeroCopyInputStream wrapper(buf);
if (!json2pb::JsonToProtoMessage(&wrapper, &json_msg, &err_string)) {
if (!JsonToProtoMessage(&wrapper, &json_msg, &err_string)) {
LOG(ERROR) << "Failed parse json from str:" << json;
return;
}
......@@ -119,6 +123,21 @@ int main(int argc, char** argv) {
PredictorApi api;
// initialize logger instance
#ifdef BCLOUD
logging::LoggingSettings settings;
settings.logging_dest = logging::LOG_TO_FILE;
std::string filename(argv[0]);
filename = filename.substr(filename.find_last_of('/') + 1);
settings.log_file = (std::string("./log/") + filename + ".log").c_str();
settings.delete_old = logging::DELETE_OLD_LOG_FILE;
logging::InitLogging(settings);
logging::ComlogSinkOptions cso;
cso.process_name = filename;
cso.enable_wf_device = true;
logging::ComlogSink::GetInstance()->Setup(&cso);
#else
struct stat st_buf;
int ret = 0;
if ((ret = stat("./log", &st_buf)) != 0) {
......@@ -131,6 +150,7 @@ int main(int argc, char** argv) {
}
FLAGS_log_dir = "./log";
google::InitGoogleLogging(strdup(argv[0]));
#endif
if (api.create("./conf", "predictors.prototxt") != 0) {
LOG(ERROR) << "Failed create predictors api!";
......
......@@ -27,6 +27,16 @@
#include "gflags/gflags.h"
#include "google/protobuf/message.h"
#ifdef BCLOUD
#include "baidu/rpc/channel.h"
#include "baidu/rpc/parallel_channel.h"
#include "baidu/rpc/traceprintf.h"
#include "bthread.h"
#include "base/logging.h"
#include "base/comlog_sink.h"
#include "base/object_pool.h"
#include "base/time.h"
#else
#include "brpc/channel.h"
#include "brpc/parallel_channel.h"
#include "brpc/traceprintf.h"
......@@ -34,10 +44,22 @@
#include "butil/logging.h"
#include "butil/object_pool.h"
#include "butil/time.h"
#endif
#include "bvar/bvar.h"
#ifdef BCLOUD
#include "json_to_pb.h"
#else
#include "json2pb/json_to_pb.h"
#endif
#include "configure/include/configure_parser.h"
#include "configure/sdk_configure.pb.h"
#include "sdk-cpp/include/utils.h"
#ifdef BCLOUD
namespace brpc = baidu::rpc;
namespace butil = base;
#endif
......@@ -24,6 +24,10 @@ namespace baidu {
namespace paddle_serving {
namespace sdk_cpp {
#ifdef BCLOUD
namespace brpc = baidu::rpc;
#endif
#define INLINE_REGIST_OBJECT(D, B, E) \
do { \
Factory<D, B>* factory = new (std::nothrow) Factory<D, B>(); \
......
......@@ -18,6 +18,10 @@ namespace baidu {
namespace paddle_serving {
namespace sdk_cpp {
#ifdef BCLOUD
namespace butil = base;
#endif
class MetricScope;
class Stub;
template <typename T, typename C, typename R, typename I, typename O>
......
......@@ -17,6 +17,9 @@
namespace baidu {
namespace paddle_serving {
namespace sdk_cpp {
#ifdef BCLOUD
namespace butil = base;
#endif
template <typename T, typename C, typename R, typename I, typename O>
int StubImpl<T, C, R, I, O>::initialize(const VariantInfo& var,
......
......@@ -13,7 +13,11 @@
// limitations under the License.
#include "sdk-cpp/include/config_manager.h"
#ifdef BCLOUD
#include "baidu/rpc/server.h"
#else
#include "brpc/server.h"
#endif
#include "sdk-cpp/include/abtest.h"
namespace baidu {
......
#edit-mode: -*- python -*-
#coding:utf-8
WORKROOT('../../../../')
#Preprocessor flags.
CPPFLAGS(r'-D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__const__= -Dtypeof=__typeof__ -DUSE_PTHREAD')
#CPPFLAGS(r'-DVERSION=\"%s\"' % SVN_LAST_CHANGED_REV())
#C++ flags.
CXXFLAGS('-g -O2 -pipe -W -Wall -fPIC -fno-omit-frame-pointer -Wno-deprecated -Wno-unused-parameter -Wno-unused-variable -Wno-unused-local-typedefs -Wno-sign-compare -std=c++11')
#link flags
LDFLAGS('-lpthread -lcrypto -lrt -lssl -ldl -lz -std=c++11')
ImportConfigsFrom('..')
INCPATHS('$INC')
INCPATHS('$INC/predictor')
INCPATHS('../')
INCPATHS('../predictor/')
INCPATHS('$OUT_ROOT/third-64/protobuf/output/include')
INCPATHS('$OUT_ROOT/baidu/third-party/gflags/output/include')
INCPATHS('$OUT_ROOT/baidu/third-party/glog/output/include')
INCPATHS('$INC/predictor/proto')
LIBS('$OUT/lib/libpdserving.a')
LIBS('$OUT/lib/libpdconfigure.a')
LIBS('$OUT_ROOT/baidu/third-party/mklml/output/so/libmklml_intel.so')
LIBS('$OUT_ROOT/baidu/third-party/mklml/output/so/libmklml_gnu.so')
LIBS('$OUT_ROOT/baidu/third-party/mklml/output/so/libiomp5.so')
CONFIGS('baidu/base/baidu-rpc@ci-base')
CONFIGS('baidu/third-party/gflags@v2.0.0@git_branch')
CONFIGS('baidu/third-party/glog@v0.3.x@git_branch')
CONFIGS('baidu/third-party/opencv@master@git_branch')
cpp_source_dirs = []
cpp_source_dirs.append('op/*.cpp')
cpp_source_dirs.append('proto/*.proto')
DELETE_AUTO_LIBS('$OUT_ROOT/baidu/third-party/protobuf/output/lib/libprotobuf.a')
DELETE_AUTO_LIBS('$OUT_ROOT/baidu/third-party/protobuf/output/lib/libprotobuf-lite.a')
# DELETE_AUTO_LIBS('$OUT_ROOT/third-64/glog/output/lib/libglog.a')
DELETE_AUTO_LIBS('$OUT_ROOT/third-64/gflags/output/lib/libgflags.a')
DELETE_AUTO_LIBS('$OUT_ROOT/third-64/gflags/output/lib/libgflags_nothreads.a')
DELETE_AUTO_LIBS('$OUT_ROOT/baidu/paddlepaddle/paddle/output/lib/libpaddle_fluid_noavx_openblas.a')
PROTOFLAGS(
'--plugin=protoc-gen-pdcodegen=../pdcodegen/plugin/pdcodegen',
'--pdcodegen_out proto --proto_path=.',
'--proto_path=../predictor/proto')
HEADERS(GLOB_GEN_SRCS('../configure/proto/server_configure.pb.h'), '$INC/serving')
HEADERS(GLOB_GEN_SRCS('proto/*.pb.h'), '$INC/serving')
# Application
Application('serving', Sources(GLOB(' '.join(cpp_source_dirs))), WholeArchives('$OUT/lib/libinferencer-fluid-cpu.a'))
OUTPUT('conf', '$OUT/demo/serving/')
OUTPUT('data', '$OUT/demo/serving')
......@@ -14,7 +14,11 @@
#pragma once
#include <vector>
#ifdef BCLOUD
#include "paddle/fluid/inference/api/paddle_inference_api.h"
#else
#include "paddle/fluid/inference/paddle_inference_api.h"
#endif
#include "serving/image_class.pb.h"
namespace baidu {
......
......@@ -28,7 +28,11 @@
#include "opencv/cxcore.h"
#include "opencv/highgui.h"
#ifdef BCLOUD
#include "paddle/fluid/inference/api/paddle_inference_api.h"
#else
#include "paddle/fluid/inference/paddle_inference_api.h"
#endif
namespace baidu {
namespace paddle_serving {
......
......@@ -14,7 +14,11 @@
#pragma once
#include <vector>
#ifdef BCLOUD
#include "paddle/fluid/inference/api/paddle_inference_api.h"
#else
#include "paddle/fluid/inference/paddle_inference_api.h"
#endif
#include "serving/text_classification.pb.h"
namespace baidu {
......
......@@ -14,11 +14,20 @@
#include <google/protobuf/text_format.h>
#include <string>
#ifdef BCLOUD
#include "pb_to_json.h"
#else
#include "json2pb/pb_to_json.h"
#endif
#include "predictor/framework/memory.h"
#include "serving/op/write_json_op.h"
#ifndef BCLOUD
using json2pb::ProtoMessageToJson;
#endif
namespace baidu {
namespace paddle_serving {
namespace predictor {
......@@ -53,7 +62,7 @@ int WriteJsonOp::inference() {
return -1;
}
std::string* text = ins->mutable_response_json();
if (!json2pb::ProtoMessageToJson(
if (!ProtoMessageToJson(
classify_out->predictions(si), text, &err_string)) {
LOG(ERROR) << "Failed convert message["
<< classify_out->predictions(si).ShortDebugString()
......
......@@ -14,11 +14,20 @@
#include <google/protobuf/text_format.h>
#include <string>
#ifdef BCLOUD
#include "pb_to_json.h"
#else
#include "json2pb/pb_to_json.h"
#endif
#include "predictor/framework/memory.h"
#include "serving/op/write_op.h"
#ifndef BCLOUD
using json2pb::ProtoMessageToJson;
#endif
namespace baidu {
namespace paddle_serving {
namespace serving {
......@@ -53,7 +62,7 @@ int WriteOp::inference() {
return -1;
}
std::string* text = ins->mutable_response_json();
if (!json2pb::ProtoMessageToJson(
if (!ProtoMessageToJson(
classify_out->predictions(si), text, &err_string)) {
LOG(ERROR) << "Failed convert message["
<< classify_out->predictions(si).ShortDebugString()
......
// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto2";
import "pds_option.proto";
package baidu.paddle_serving.predictor.native_tensor;
option cc_generic_services = true;
enum TensorType {
FLOAT = 0;
DOUBLE = 1;
INT32 = 2;
INT64 = 3;
UINT32 = 4;
UINT64 = 5;
};
message DenseTensor {
optional string name = 1;
repeated uint32 shape = 2;
required TensorType type = 3;
repeated float float_data = 4;
repeated double double_data = 5;
repeated int32 int32_data = 6;
repeated int64 int64_data = 7;
repeated uint32 uint32_data = 8;
repeated uint64 uint64_data = 9;
};
message DenseRequest { repeated DenseTensor tensors = 1; };
message DenseResponse { repeated DenseTensor tensors = 1; };
service BuiltinDenseFormatService {
rpc inference(DenseRequest) returns (DenseResponse);
rpc debug(DenseRequest) returns (DenseResponse);
option (pds.options).generate_impl = true;
};
message SparseTensor {
required string name = 1;
repeated uint32 keys = 2;
repeated uint32 shape = 3;
required TensorType type = 4;
repeated float float_data = 5;
repeated double double_data = 6;
repeated int32 int32_data = 7;
repeated int64 int64_data = 8;
repeated uint32 uint32_data = 9;
repeated uint64 uint64_data = 10;
};
message SparseRequest { repeated SparseTensor tensors = 1; };
message SparseResponse { repeated SparseTensor tensors = 1; };
service BuiltinSparseFormatService {
rpc inference(SparseRequest) returns (SparseResponse);
rpc debug(SparseRequest) returns (SparseResponse);
option (pds.options).generate_impl = true;
};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册