Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
VisualDL
提交
64885033
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看板
提交
64885033
编写于
12月 22, 2017
作者:
S
superjom
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add scalar
上级
c103645a
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
80 addition
and
5 deletion
+80
-5
visualdl/logic/CMakeLists.txt
visualdl/logic/CMakeLists.txt
+2
-0
visualdl/logic/sdk.cc
visualdl/logic/sdk.cc
+59
-0
visualdl/logic/sdk.h
visualdl/logic/sdk.h
+19
-4
visualdl/storage/storage_test.cc
visualdl/storage/storage_test.cc
+0
-1
未找到文件。
visualdl/logic/CMakeLists.txt
浏览文件 @
64885033
#add_library(sdk ${PROJECT_SOURCE_DIR}/visualdl/logic/sdk.cc)
add_library
(
im
${
PROJECT_SOURCE_DIR
}
/visualdl/logic/im.cc
)
add_library
(
sdk
${
PROJECT_SOURCE_DIR
}
/visualdl/logic/sdk.cc
)
add_dependencies
(
im storage_proto
)
add_dependencies
(
sdk storage_proto
)
#add_dependencies(sdk storage_proto)
## pybind
...
...
visualdl/logic/sdk.cc
浏览文件 @
64885033
#include "visualdl/logic/sdk.h"
namespace
visualdl
{
namespace
components
{
template
<
typename
T
>
void
components
::
Scalar
<
T
>::
AddRecord
(
int
id
,
const
std
::
vector
<
T
>
&
values
)
{
// add record data
auto
record
=
tablet_
.
AddRecord
();
auto
entry
=
record
.
AddData
<
T
>
();
for
(
auto
v
:
values
)
{
entry
.
Add
(
v
);
}
// set record id
record
.
SetId
(
id
);
// set record timestamp
record
.
SetTimeStamp
(
time
(
NULL
));
}
template
<
typename
T
>
std
::
vector
<
T
>
ScalarReader
<
T
>::
records
()
const
{
std
::
vector
<
T
>
res
;
for
(
int
i
=
0
;
i
<
reader_
.
total_records
();
i
++
)
{
res
.
push_back
(
reader_
.
record
(
i
).
data
<
T
>
(
0
));
}
return
res
;
}
template
<
typename
T
>
std
::
vector
<
int
>
ScalarReader
<
T
>::
ids
()
const
{
std
::
vector
<
int
>
res
;
for
(
int
i
=
0
;
i
<
reader_
.
total_records
();
i
++
)
{
res
.
push_back
(
reader_
.
record
(
i
).
id
());
}
return
res
;
}
template
<
typename
T
>
std
::
vector
<
int
>
ScalarReader
<
T
>::
timestamps
()
const
{
std
::
vector
<
T
>
res
;
for
(
int
i
=
0
;
i
<
reader_
.
total_records
();
i
++
)
{
res
.
push_back
(
reader_
.
record
(
i
).
timestamp
());
}
return
res
;
}
template
<
typename
T
>
std
::
vector
<
std
::
string
>
ScalarReader
<
T
>::
captions
()
const
{
return
reader_
.
captions
();
}
template
<
typename
T
>
size_t
ScalarReader
<
T
>::
size
()
const
{
return
reader_
.
total_records
();
}
}
// namespace components
}
// namespace visualdl
visualdl/logic/sdk.h
浏览文件 @
64885033
...
...
@@ -11,17 +11,32 @@ namespace components {
* Read and write support for Scalar component.
*/
template
<
typename
T
>
class
Scalar
{
public:
Scalar
(
Tablet
tablet
)
:
tablet_
(
tablet
)
{
tablet_
->
SetTag
(
kScalar
);
}
struct
Scalar
{
Scalar
(
Tablet
tablet
)
:
tablet_
(
tablet
)
{
tablet_
.
SetType
(
Tablet
::
Type
::
kScalar
);}
void
SetCaption
(
const
std
::
string
cap
)
{
tablet_
->
SetCaptions
(
std
::
vector
<
std
::
string
>
({
cap
}));
tablet_
.
SetCaptions
(
std
::
vector
<
std
::
string
>
({
cap
}));
}
void
AddRecord
(
int
id
,
const
std
::
vector
<
T
>
&
values
);
private:
Tablet
tablet_
;
};
template
<
typename
T
>
struct
ScalarReader
{
ScalarReader
(
TabletReader
&&
reader
)
:
reader_
(
reader
)
{}
std
::
vector
<
T
>
records
()
const
;
std
::
vector
<
int
>
ids
()
const
;
std
::
vector
<
int
>
timestamps
()
const
;
std
::
vector
<
std
::
string
>
captions
()
const
;
size_t
size
()
const
;
private:
TabletReader
reader_
;
};
}
// namespace components
}
// namespace visualdl
...
...
visualdl/storage/storage_test.cc
浏览文件 @
64885033
...
...
@@ -21,7 +21,6 @@ TEST_F(StorageTest, main) {
auto
tag0
=
storage
.
AddTablet
(
"tag0"
);
auto
tag1
=
storage
.
AddTablet
(
"tag1"
);
StorageReader
reader
(
"./tmp/storage_test"
);
auto
modes
=
reader
.
Modes
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录