Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
cafa0983
S
Serving
项目概览
PaddlePaddle
/
Serving
1 年多 前同步成功
通知
186
Star
833
Fork
253
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
105
列表
看板
标记
里程碑
合并请求
10
Wiki
2
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Serving
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
105
Issue
105
列表
看板
标记
里程碑
合并请求
10
合并请求
10
Pages
分析
分析
仓库分析
DevOps
Wiki
2
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
cafa0983
编写于
6月 24, 2019
作者:
W
wangjiawei04
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify variable name
Change-Id: Ic8bf6e4ebe23d23a5dfc670be2fe07a6f2352554
上级
52965dd8
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
40 addition
and
40 deletion
+40
-40
demo-serving/CMakeLists.txt
demo-serving/CMakeLists.txt
+1
-1
kvdb/CMakeLists.txt
kvdb/CMakeLists.txt
+2
-2
kvdb/include/kvdb/kvdb_impl.h
kvdb/include/kvdb/kvdb_impl.h
+1
-1
kvdb/include/kvdb/rocksdb_impl.h
kvdb/include/kvdb/rocksdb_impl.h
+5
-5
kvdb/src/gtest_db_func.cpp
kvdb/src/gtest_db_func.cpp
+1
-1
kvdb/src/gtest_db_thread.cpp
kvdb/src/gtest_db_thread.cpp
+1
-1
kvdb/src/gtest_kvdb.cpp
kvdb/src/gtest_kvdb.cpp
+4
-4
kvdb/src/mock_param_dict_impl.cpp
kvdb/src/mock_param_dict_impl.cpp
+23
-23
kvdb/src/rockskvdb_impl.cpp
kvdb/src/rockskvdb_impl.cpp
+1
-1
kvdb/src/test_rocksdb.cpp
kvdb/src/test_rocksdb.cpp
+1
-1
未找到文件。
demo-serving/CMakeLists.txt
浏览文件 @
cafa0983
...
...
@@ -32,7 +32,7 @@ if(WITH_GPU)
endif
()
target_link_libraries
(
serving opencv_imgcodecs
${
opencv_depend_libs
}
-Wl,--whole-archive fluid_cpu_engine
-Wl,--no-whole-archive pdserving paddle_fluid
${
paddle_depend_libs
}
rocksdb_impl
rocksdb
-Wl,--no-whole-archive pdserving paddle_fluid
${
paddle_depend_libs
}
kvdb
rocksdb
${
MKLML_LIB
}
${
MKLML_IOMP_LIB
}
-lpthread -lcrypto -lm -lrt -lssl -ldl -lz -lbz2
)
install
(
TARGETS serving
...
...
kvdb/CMakeLists.txt
浏览文件 @
cafa0983
...
...
@@ -8,8 +8,8 @@ set(SRC_LIST ${CMAKE_CURRENT_LIST_DIR}/src/test_rocksdb.cpp
${
CMAKE_CURRENT_LIST_DIR
}
/src/paddle_rocksdb.cpp
${
CMAKE_CURRENT_LIST_DIR
}
/src/gtest_kvdb.cpp
)
add_library
(
rocksdb_impl
${
SRC_LIST
}
)
install
(
TARGETS
rocksdb_impl
ARCHIVE DESTINATION
${
PADDLE_SERVING_INSTALL_DIR
}
/lib/
)
add_library
(
kvdb
${
SRC_LIST
}
)
install
(
TARGETS
kvdb
ARCHIVE DESTINATION
${
PADDLE_SERVING_INSTALL_DIR
}
/lib/
)
add_executable
(
kvdb_test
${
SRC_LIST
}
)
add_dependencies
(
kvdb_test rocksdb
)
...
...
kvdb/include/kvdb/kvdb_impl.h
浏览文件 @
cafa0983
...
...
@@ -45,7 +45,7 @@ public:
virtual
std
::
string
GetMD5
()
=
0
;
virtual
bool
CheckDiff
()
=
0
;
virtual
std
::
chrono
::
system_clock
::
time_point
GetTimeStamp
()
=
0
;
virtual
void
Read
(
std
::
vector
<
std
::
string
>&
)
=
0
;
virtual
void
Read
(
AbstractParamDict
*
)
=
0
;
virtual
~
AbstractDictReader
()
=
0
;
protected:
std
::
string
filename_
;
...
...
kvdb/include/kvdb/
mock_kv
db_impl.h
→
kvdb/include/kvdb/
rocks
db_impl.h
浏览文件 @
cafa0983
...
...
@@ -30,18 +30,18 @@ public:
static
int
db_count
;
};
class
Mock
DictReader
:
public
AbstractDictReader
{
class
RocksDB
DictReader
:
public
AbstractDictReader
{
public:
std
::
string
GetFileName
();
void
SetFileName
(
std
::
string
);
std
::
string
GetMD5
();
bool
CheckDiff
();
std
::
chrono
::
system_clock
::
time_point
GetTimeStamp
();
void
Read
(
std
::
vector
<
std
::
string
>&
);
~
Mock
DictReader
();
void
Read
(
AbstractParamDict
*
);
~
RocksDB
DictReader
();
};
class
Mock
ParamDict
:
public
AbstractParamDict
{
class
RocksDB
ParamDict
:
public
AbstractParamDict
{
public:
std
::
vector
<
AbsDictReaderPtr
>
GetDictReaderLst
();
void
SetDictReaderLst
(
std
::
vector
<
AbsDictReaderPtr
>
);
...
...
@@ -59,7 +59,7 @@ public:
void
SetKVDB
(
std
::
pair
<
AbsKVDBPtr
,
AbsKVDBPtr
>
);
void
CreateKVDB
();
~
Mock
ParamDict
();
~
RocksDB
ParamDict
();
};
kvdb/src/gtest_db_func.cpp
浏览文件 @
cafa0983
...
...
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "kvdb/
mock_kv
db_impl.h"
#include "kvdb/
rocks
db_impl.h"
#include "kvdb/kvdb_impl.h"
#include "kvdb/paddle_rocksdb.h"
#include <gtest/gtest.h>
...
...
kvdb/src/gtest_db_thread.cpp
浏览文件 @
cafa0983
...
...
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "kvdb/
mock_kv
db_impl.h"
#include "kvdb/
rocks
db_impl.h"
#include "kvdb/kvdb_impl.h"
#include "kvdb/paddle_rocksdb.h"
#include <gtest/gtest.h>
...
...
kvdb/src/gtest_kvdb.cpp
浏览文件 @
cafa0983
...
...
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "kvdb/
mock_kv
db_impl.h"
#include "kvdb/
rocks
db_impl.h"
#include "kvdb/kvdb_impl.h"
#include "kvdb/paddle_rocksdb.h"
#include <gtest/gtest.h>
...
...
@@ -28,8 +28,8 @@ protected:
static
void
SetUpTestCase
()
{
kvdb
=
std
::
make_shared
<
RocksKVDB
>
();
dict_reader
=
std
::
make_shared
<
Mock
DictReader
>
();
param_dict
=
std
::
make_shared
<
Mock
ParamDict
>
();
dict_reader
=
std
::
make_shared
<
RocksDB
DictReader
>
();
param_dict
=
std
::
make_shared
<
RocksDB
ParamDict
>
();
}
static
AbsKVDBPtr
kvdb
;
...
...
@@ -81,7 +81,7 @@ TEST_F(KVDBTest, AbstractDictReader_Unit_Test) {
ASSERT_NE
(
timestamp_2
,
timestamp_3
);
}
#include <cmath>
TEST_F
(
KVDBTest
,
Mock
ParamDict_Unit_Test
)
{
TEST_F
(
KVDBTest
,
RocksDB
ParamDict_Unit_Test
)
{
std
::
string
test_in_filename
=
"abs_dict_reader_test_in.txt"
;
param_dict
->
SetDictReaderLst
({
dict_reader
});
param_dict
->
CreateKVDB
();
...
...
kvdb/src/mock_param_dict_impl.cpp
浏览文件 @
cafa0983
...
...
@@ -12,22 +12,22 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "kvdb/
mock_kv
db_impl.h"
#include "kvdb/
rocks
db_impl.h"
#include <thread>
#include <iterator>
#include <fstream>
#include <sstream>
std
::
string
Mock
DictReader
::
GetFileName
()
{
std
::
string
RocksDB
DictReader
::
GetFileName
()
{
return
this
->
filename_
;
}
void
Mock
DictReader
::
SetFileName
(
std
::
string
filename
)
{
void
RocksDB
DictReader
::
SetFileName
(
std
::
string
filename
)
{
this
->
filename_
=
filename
;
this
->
last_md5_val_
=
this
->
GetMD5
();
this
->
time_stamp_
=
std
::
chrono
::
system_clock
::
now
();
}
std
::
string
Mock
DictReader
::
GetMD5
()
{
std
::
string
RocksDB
DictReader
::
GetMD5
()
{
auto
getCmdOut
=
[]
(
std
::
string
cmd
)
{
std
::
string
data
;
FILE
*
stream
=
nullptr
;
...
...
@@ -50,40 +50,40 @@ std::string MockDictReader::GetMD5() {
return
md5val
;
}
bool
Mock
DictReader
::
CheckDiff
()
{
bool
RocksDB
DictReader
::
CheckDiff
()
{
return
this
->
GetMD5
()
==
this
->
last_md5_val_
;
}
std
::
chrono
::
system_clock
::
time_point
MockDictReader
::
GetTimeStamp
()
{
//TODO: Implement Get Time Stamp of dict file
std
::
chrono
::
system_clock
::
time_point
RocksDBDictReader
::
GetTimeStamp
()
{
return
this
->
time_stamp_
;
}
void
MockDictReader
::
Read
(
std
::
vector
<
std
::
string
>&
res
)
{
void
RocksDBDictReader
::
Read
(
AbstractParamDict
*
param_dict
)
{
std
::
string
line
;
std
::
ifstream
infile
(
this
->
filename_
);
if
(
infile
.
is_open
())
{
while
(
getline
(
infile
,
line
))
{
res
.
push_back
(
line
);
//TODO: Write String Parse Here
// param_dict->InsertSparseValue();
}
}
infile
.
close
();
}
MockDictReader
::~
Mock
DictReader
()
{
RocksDBDictReader
::~
RocksDB
DictReader
()
{
//TODO: I imageine nothing to do here
}
std
::
vector
<
AbsDictReaderPtr
>
Mock
ParamDict
::
GetDictReaderLst
()
{
std
::
vector
<
AbsDictReaderPtr
>
RocksDB
ParamDict
::
GetDictReaderLst
()
{
return
this
->
dict_reader_lst_
;
}
void
Mock
ParamDict
::
SetDictReaderLst
(
std
::
vector
<
AbsDictReaderPtr
>
lst
)
{
void
RocksDB
ParamDict
::
SetDictReaderLst
(
std
::
vector
<
AbsDictReaderPtr
>
lst
)
{
this
->
dict_reader_lst_
=
lst
;
}
std
::
vector
<
float
>
Mock
ParamDict
::
GetSparseValue
(
std
::
string
feasign
,
std
::
string
slot
)
{
std
::
vector
<
float
>
RocksDB
ParamDict
::
GetSparseValue
(
std
::
string
feasign
,
std
::
string
slot
)
{
auto
BytesToFloat
=
[](
uint8_t
*
byteArray
){
return
*
((
float
*
)
byteArray
);
};
...
...
@@ -100,15 +100,15 @@ std::vector<float> MockParamDict::GetSparseValue(std::string feasign, std::strin
return
value
;
}
std
::
vector
<
float
>
Mock
ParamDict
::
GetSparseValue
(
int64_t
feasign
,
int64_t
slot
)
{
std
::
vector
<
float
>
RocksDB
ParamDict
::
GetSparseValue
(
int64_t
feasign
,
int64_t
slot
)
{
return
this
->
GetSparseValue
(
std
::
to_string
(
feasign
),
std
::
to_string
(
slot
));
}
bool
Mock
ParamDict
::
InsertSparseValue
(
int64_t
feasign
,
int64_t
slot
,
const
std
::
vector
<
float
>&
values
)
{
bool
RocksDB
ParamDict
::
InsertSparseValue
(
int64_t
feasign
,
int64_t
slot
,
const
std
::
vector
<
float
>&
values
)
{
return
this
->
InsertSparseValue
(
std
::
to_string
(
feasign
),
std
::
to_string
(
slot
),
values
);
}
bool
Mock
ParamDict
::
InsertSparseValue
(
std
::
string
feasign
,
std
::
string
slot
,
const
std
::
vector
<
float
>&
values
)
{
bool
RocksDB
ParamDict
::
InsertSparseValue
(
std
::
string
feasign
,
std
::
string
slot
,
const
std
::
vector
<
float
>&
values
)
{
auto
FloatToBytes
=
[](
float
fvalue
,
uint8_t
*
arr
){
unsigned
char
*
pf
=
nullptr
;
unsigned
char
*
px
=
nullptr
;
...
...
@@ -136,12 +136,12 @@ bool MockParamDict::InsertSparseValue(std::string feasign, std::string slot, con
return
true
;
}
void
Mock
ParamDict
::
UpdateBaseModel
()
{
void
RocksDB
ParamDict
::
UpdateBaseModel
()
{
std
::
thread
t
([
&
]
()
{
for
(
AbsDictReaderPtr
dict_reader
:
this
->
dict_reader_lst_
)
{
if
(
dict_reader
->
CheckDiff
())
{
std
::
vector
<
std
::
string
>
strs
;
dict_reader
->
Read
(
str
s
);
dict_reader
->
Read
(
thi
s
);
for
(
const
std
::
string
&
str
:
strs
)
{
std
::
vector
<
std
::
string
>
arr
;
std
::
istringstream
in
(
str
);
...
...
@@ -162,27 +162,27 @@ void MockParamDict::UpdateBaseModel() {
}
void
Mock
ParamDict
::
UpdateDeltaModel
()
{
void
RocksDB
ParamDict
::
UpdateDeltaModel
()
{
UpdateBaseModel
();
}
std
::
pair
<
AbsKVDBPtr
,
AbsKVDBPtr
>
Mock
ParamDict
::
GetKVDB
()
{
std
::
pair
<
AbsKVDBPtr
,
AbsKVDBPtr
>
RocksDB
ParamDict
::
GetKVDB
()
{
return
{
front_db
,
back_db
};
}
void
Mock
ParamDict
::
SetKVDB
(
std
::
pair
<
AbsKVDBPtr
,
AbsKVDBPtr
>
kvdbs
)
{
void
RocksDB
ParamDict
::
SetKVDB
(
std
::
pair
<
AbsKVDBPtr
,
AbsKVDBPtr
>
kvdbs
)
{
this
->
front_db
=
kvdbs
.
first
;
this
->
back_db
=
kvdbs
.
second
;
}
void
Mock
ParamDict
::
CreateKVDB
()
{
void
RocksDB
ParamDict
::
CreateKVDB
()
{
this
->
front_db
=
std
::
make_shared
<
RocksKVDB
>
();
this
->
back_db
=
std
::
make_shared
<
RocksKVDB
>
();
this
->
front_db
->
CreateDB
();
this
->
back_db
->
CreateDB
();
}
MockParamDict
::~
Mock
ParamDict
()
{
RocksDBParamDict
::~
RocksDB
ParamDict
()
{
}
...
...
kvdb/src/rockskvdb_impl.cpp
浏览文件 @
cafa0983
...
...
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "kvdb/
mock_kv
db_impl.h"
#include "kvdb/
rocks
db_impl.h"
int
RocksKVDB
::
db_count
;
void
RocksKVDB
::
CreateDB
()
{
...
...
kvdb/src/test_rocksdb.cpp
浏览文件 @
cafa0983
...
...
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "kvdb/
mock_kv
db_impl.h"
#include "kvdb/
rocks
db_impl.h"
#include "kvdb/paddle_rocksdb.h"
#include <iostream>
void
test_rockskvdb
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录