Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
VisualDL
提交
25b91deb
V
VisualDL
项目概览
PaddlePaddle
/
VisualDL
1 年多 前同步成功
通知
88
Star
4655
Fork
642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
5
Wiki
分析
仓库
DevOps
项目成员
Pages
V
VisualDL
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
5
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
25b91deb
编写于
11月 22, 2017
作者:
S
superjom
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
set num_records to total_records
上级
09119d38
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
100 addition
and
91 deletion
+100
-91
CMakeLists.txt
CMakeLists.txt
+0
-2
visualdl/backend/logic/im.cc
visualdl/backend/logic/im.cc
+7
-8
visualdl/backend/storage/storage.cc
visualdl/backend/storage/storage.cc
+5
-5
visualdl/backend/storage/storage.proto
visualdl/backend/storage/storage.proto
+88
-76
未找到文件。
CMakeLists.txt
浏览文件 @
25b91deb
...
...
@@ -16,7 +16,6 @@ link_directories(${PROJECT_SOURCE_DIR}/thirdparty/local/lib)
add_library
(
storage
${
PROJECT_SOURCE_DIR
}
/visualdl/backend/storage/storage.cc
${
PROJECT_SOURCE_DIR
}
/visualdl/backend/storage/storage.pb.cc
)
add_library
(
c_api
${
PROJECT_SOURCE_DIR
}
/visualdl/backend/logic/c_api.cc
)
add_library
(
sdk
${
PROJECT_SOURCE_DIR
}
/visualdl/backend/logic/sdk.cc
)
add_library
(
im
${
PROJECT_SOURCE_DIR
}
/visualdl/backend/logic/im.cc
)
...
...
@@ -29,4 +28,3 @@ add_executable(vl_test
${
PROJECT_SOURCE_DIR
}
/visualdl/backend/test.cc
${
PROJECT_SOURCE_DIR
}
/visualdl/backend/logic/im_test.cc
)
target_link_libraries
(
vl_test storage im gtest glog protobuf gflags
)
visualdl/backend/logic/im.cc
浏览文件 @
25b91deb
#include <ctime>
#include <glog/logging.h>
#include <ctime>
#include "visualdl/backend/logic/im.h"
...
...
@@ -45,15 +45,14 @@ void InformationMaintainer::AddRecord(const std::string &tag,
auto
*
tablet
=
storage_
.
Find
(
tag
);
CHECK
(
tablet
);
auto
num_records
=
tablet
->
num
_records
();
auto
num_records
=
tablet
->
total
_records
();
const
auto
num_samples
=
tablet
->
num_samples
();
int
offset
;
// use reservoir sampling or not
if
(
num_samples
>
0
)
{
offset
=
ReserviorSample
(
num_samples
,
num_records
+
1
);
if
(
offset
<
0
)
return
;
if
(
offset
<
0
)
return
;
}
else
{
offset
=
num_records
;
}
...
...
@@ -66,11 +65,11 @@ void InformationMaintainer::AddRecord(const std::string &tag,
}
*
record
=
data
;
tablet
->
set_
num
_records
(
num_records
+
1
);
tablet
->
set_
total
_records
(
num_records
+
1
);
}
void
InformationMaintainer
::
Clear
()
{
auto
*
data
=
storage
().
mutable_data
();
auto
*
data
=
storage
().
mutable_data
();
data
->
clear_tablets
();
data
->
clear_dir
();
data
->
clear_timestamp
();
...
...
@@ -79,7 +78,7 @@ void InformationMaintainer::Clear() {
void
InformationMaintainer
::
PersistToDisk
()
{
CHECK
(
!
storage_
.
data
().
dir
().
empty
())
<<
"path of storage should be set"
;
// TODO make dir first
//MakeDir(storage_.data().dir());
//
MakeDir(storage_.data().dir());
storage_
.
Save
(
storage_
.
data
().
dir
()
+
"/storage.pb"
);
}
...
...
visualdl/backend/storage/storage.cc
浏览文件 @
25b91deb
#include <fstream>
#include <glog/logging.h>
#include <fstream>
#include "visualdl/backend/storage/storage.h"
...
...
@@ -24,15 +24,15 @@ storage::Record *Storage::NewRecord(const std::string &tag) {
CHECK
(
tablet
)
<<
"Tablet"
<<
tag
<<
" should be create first"
;
auto
*
record
=
tablet
->
mutable_records
()
->
Add
();
// increase num_records
int
num_records
=
tablet
->
num
_records
();
tablet
->
set_
num
_records
(
num_records
+
1
);
int
num_records
=
tablet
->
total
_records
();
tablet
->
set_
total
_records
(
num_records
+
1
);
return
record
;
}
storage
::
Record
*
Storage
::
GetRecord
(
const
std
::
string
&
tag
,
int
offset
)
{
auto
*
tablet
=
Find
(
tag
);
CHECK
(
tablet
)
<<
"Tablet"
<<
tag
<<
" should be create first"
;
auto
num_records
=
tablet
->
num
_records
();
auto
num_records
=
tablet
->
total
_records
();
CHECK_LT
(
offset
,
num_records
)
<<
"invalid offset"
;
return
tablet
->
mutable_records
()
->
Mutable
(
offset
);
}
...
...
visualdl/backend/storage/storage.proto
浏览文件 @
25b91deb
...
...
@@ -42,7 +42,8 @@ message Entry {
}
/*
The Record proto is designed to represent any data structure for any component, for
The Record proto is designed to represent any data structure for any component,
for
example, to store a record of Scalar component
Record {
...
...
@@ -63,19 +64,23 @@ Record {
meta = [100, 200]
}
for other complex structure which have more fields than `timestamp`, `id` and meta, the additional fields
can store in the `data` field, for it can store a list of values in different basic data types.
for other complex structure which have more fields than `timestamp`, `id` and
meta, the additional fields
can store in the `data` field, for it can store a list of values in different
basic data types.
A component handlers in logic layer should know how to write or load a record for the corresponding component.
A component handlers in logic layer should know how to write or load a record
for the corresponding component.
*/
message
Record
{
// one record might have multiple fields, one specific component should know how
// one record might have multiple fields, one specific component should know
// how
// to parse the records.
repeated
Entry
data
=
1
;
// NOTE the timestamp, id, dtype might be useless for that all the meta info can
// NOTE the timestamp, id, dtype might be useless for that all the meta info
// can
// be stored in `data` field.
int64
timestamp
=
2
;
// store the count of writing operations to the tablet.
int64
id
=
3
;
DataType
dtype
=
4
;
// shape or some other meta infomation for this record, if all the records
...
...
@@ -85,9 +90,12 @@ message Record {
}
/*
A Tablet stores the records of a component which type is `component` and indidates as `tag`.
The records will be saved in a file which name contains `tag`. During the running period,
`num_records` will be accumulated, and `num_samples` indicates the size of sample set the
A Tablet stores the records of a component which type is `component` and
indidates as `tag`.
The records will be saved in a file which name contains `tag`. During the
running period,
`num_records` will be accumulated, and `num_samples` indicates the size of
sample set the
reservoir sampling algorithm will collect.
*/
message
Tablet
{
...
...
@@ -97,18 +105,22 @@ message Tablet {
kHistogram
=
1
;
kGraph
=
2
;
}
// type of the component, different component should have different storage format.
// type of the component, different component should have different storage
// format.
Type
component
=
1
;
// records the total count of records, each Write operation should increate this value.
int64
num_records
=
2
;
// indicate the number of instances to sample, this should be a constant value.
// records the total count of records, each Write operation should increate
// this value.
int64
total_records
=
2
;
// indicate the number of instances to sample, this should be a constant
// value.
int32
num_samples
=
3
;
repeated
Record
records
=
4
;
// store a meta infomation if all the records share.
Entry
meta
=
5
;
// the unique identification for this `Tablet`.
string
tag
=
6
;
// one tablet might have multiple captions, for example, a scalar component might have
// one tablet might have multiple captions, for example, a scalar component
// might have
// two plots labeled "train" and "test".
repeated
string
captions
=
7
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录