Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
52de798e
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
52de798e
编写于
5月 09, 2018
作者:
W
weixing02
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' of
https://github.com/PaddlePaddle/Paddle
into v2_deadlinks
上级
333e26d3
c7c62e07
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
181 addition
and
1 deletion
+181
-1
paddle/fluid/inference/CMakeLists.txt
paddle/fluid/inference/CMakeLists.txt
+2
-0
paddle/fluid/inference/analysis/CMakeLists.txt
paddle/fluid/inference/analysis/CMakeLists.txt
+1
-0
paddle/fluid/inference/analysis/dot.cc
paddle/fluid/inference/analysis/dot.cc
+23
-0
paddle/fluid/inference/analysis/dot.h
paddle/fluid/inference/analysis/dot.h
+154
-0
python/paddle/dataset/wmt16.py
python/paddle/dataset/wmt16.py
+1
-1
未找到文件。
paddle/fluid/inference/CMakeLists.txt
浏览文件 @
52de798e
...
...
@@ -21,6 +21,8 @@ endif()
if
(
WITH_TESTING
)
add_subdirectory
(
tests/book
)
# analysis test depends the models that generate by python/paddle/fluid/tests/book
add_subdirectory
(
analysis
)
endif
()
if
(
TENSORRT_FOUND
)
...
...
paddle/fluid/inference/analysis/CMakeLists.txt
0 → 100644
浏览文件 @
52de798e
cc_library
(
dot SRCS dot.cc
)
paddle/fluid/inference/analysis/dot.cc
0 → 100644
浏览文件 @
52de798e
// Copyright (c) 2018 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.
#include "paddle/fluid/inference/analysis/dot.h"
namespace
paddle
{
namespace
inference
{
namespace
analysis
{
size_t
Dot
::
counter
=
0
;
}
// namespace analysis
}
// namespace inference
}
// namespace paddle
paddle/fluid/inference/analysis/dot.h
0 → 100644
浏览文件 @
52de798e
// Copyright (c) 2018 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.
/*
* This file implements some helper classes and methods for DOT programming
* support. It will give a visualization of the graph and that helps to debug
* the logics of each Pass.
*/
#pragma once
#include <glog/logging.h>
#include <sstream>
#include <unordered_map>
#include <vector>
namespace
paddle
{
namespace
inference
{
namespace
analysis
{
/*
* A Dot template that helps to build a DOT graph definition.
*/
class
Dot
{
public:
static
size_t
counter
;
struct
Attr
{
std
::
string
key
;
std
::
string
value
;
Attr
(
const
std
::
string
&
key
,
const
std
::
string
&
value
)
:
key
(
key
),
value
(
value
)
{}
std
::
string
repr
()
const
{
std
::
stringstream
ss
;
ss
<<
key
<<
"="
<<
'"'
<<
value
<<
'"'
;
return
ss
.
str
();
}
};
struct
Node
{
std
::
string
name
;
std
::
vector
<
Attr
>
attrs
;
Node
(
const
std
::
string
&
name
,
const
std
::
vector
<
Attr
>&
attrs
)
:
name
(
name
),
attrs
(
attrs
),
id_
(
"node_"
+
std
::
to_string
(
Dot
::
counter
++
))
{}
std
::
string
id
()
const
{
return
id_
;
}
std
::
string
repr
()
const
{
std
::
stringstream
ss
;
CHECK
(
!
name
.
empty
());
ss
<<
id_
;
for
(
size_t
i
=
0
;
i
<
attrs
.
size
();
i
++
)
{
if
(
i
==
0
)
{
ss
<<
"[label="
<<
'"'
<<
name
<<
'"'
<<
" "
;
}
ss
<<
attrs
[
i
].
repr
();
ss
<<
((
i
<
attrs
.
size
()
-
1
)
?
" "
:
"]"
);
}
return
ss
.
str
();
}
private:
std
::
string
id_
;
};
struct
Edge
{
std
::
string
source
;
std
::
string
target
;
std
::
vector
<
Attr
>
attrs
;
Edge
(
const
std
::
string
&
source
,
const
std
::
string
&
target
,
const
std
::
vector
<
Attr
>&
attrs
)
:
source
(
source
),
target
(
target
),
attrs
(
attrs
)
{}
std
::
string
repr
()
const
{
std
::
stringstream
ss
;
CHECK
(
!
source
.
empty
());
CHECK
(
!
target
.
empty
());
ss
<<
source
<<
"->"
<<
target
;
for
(
size_t
i
=
0
;
i
<
attrs
.
size
();
i
++
)
{
if
(
i
==
0
)
{
ss
<<
"["
;
}
ss
<<
attrs
[
i
].
repr
();
ss
<<
((
i
<
attrs
.
size
()
-
1
)
?
" "
:
"]"
);
}
return
ss
.
str
();
}
};
Dot
()
=
default
;
explicit
Dot
(
const
std
::
vector
<
Attr
>&
attrs
)
:
attrs_
(
attrs
)
{}
void
AddNode
(
const
std
::
string
&
name
,
const
std
::
vector
<
Attr
>&
attrs
)
{
CHECK
(
!
nodes_
.
count
(
name
))
<<
"duplicate Node '"
<<
name
<<
"'"
;
nodes_
.
emplace
(
name
,
Node
{
name
,
attrs
});
}
void
AddEdge
(
const
std
::
string
&
source
,
const
std
::
string
&
target
,
const
std
::
vector
<
Attr
>&
attrs
)
{
CHECK
(
!
source
.
empty
());
CHECK
(
!
target
.
empty
());
auto
sid
=
nodes_
.
at
(
source
).
id
();
auto
tid
=
nodes_
.
at
(
target
).
id
();
edges_
.
emplace_back
(
sid
,
tid
,
attrs
);
}
// Compile to DOT language codes.
std
::
string
Build
()
const
{
std
::
stringstream
ss
;
const
std
::
string
indent
=
" "
;
ss
<<
"digraph G {"
<<
'\n'
;
// Add graph attrs
for
(
const
auto
&
attr
:
attrs_
)
{
ss
<<
indent
<<
attr
.
repr
()
<<
'\n'
;
}
// add nodes
for
(
auto
&
item
:
nodes_
)
{
ss
<<
indent
<<
item
.
second
.
repr
()
<<
'\n'
;
}
// add edges
for
(
auto
&
edge
:
edges_
)
{
ss
<<
indent
<<
edge
.
repr
()
<<
'\n'
;
}
ss
<<
"} // end G"
;
return
ss
.
str
();
}
private:
std
::
unordered_map
<
std
::
string
,
Node
>
nodes_
;
std
::
vector
<
Edge
>
edges_
;
std
::
vector
<
Attr
>
attrs_
;
};
}
// namespace analysis
}
// namespace inference
}
// namespace paddle
python/paddle/dataset/wmt16.py
浏览文件 @
52de798e
...
...
@@ -96,7 +96,7 @@ def __get_dict_size(src_dict_size, trg_dict_size, src_lang):
src_dict_size
=
min
(
src_dict_size
,
(
TOTAL_EN_WORDS
if
src_lang
==
"en"
else
TOTAL_DE_WORDS
))
trg_dict_size
=
min
(
trg_dict_size
,
(
TOTAL_DE_WORDS
if
src_lang
==
"en"
else
TOTAL_EN
G
_WORDS
))
TOTAL_EN_WORDS
))
return
src_dict_size
,
trg_dict_size
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录