Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
f5d93368
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f5d93368
编写于
1月 30, 2018
作者:
L
Liu Yiqun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Unify the definition of kFeedOpType and kFetchOpType.
上级
119da449
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
25 addition
and
32 deletion
+25
-32
paddle/framework/executor.cc
paddle/framework/executor.cc
+0
-3
paddle/framework/feed_fetch_type.h
paddle/framework/feed_fetch_type.h
+4
-0
paddle/framework/program_desc.cc
paddle/framework/program_desc.cc
+11
-13
paddle/framework/program_desc.h
paddle/framework/program_desc.h
+2
-3
paddle/framework/prune.cc
paddle/framework/prune.cc
+1
-2
paddle/inference/io.cc
paddle/inference/io.cc
+4
-3
paddle/inference/io.h
paddle/inference/io.h
+0
-5
paddle/inference/tests/book/test_inference_recognize_digits.cc
...e/inference/tests/book/test_inference_recognize_digits.cc
+3
-3
未找到文件。
paddle/framework/executor.cc
浏览文件 @
f5d93368
...
@@ -33,9 +33,6 @@ DEFINE_bool(check_nan_inf, false,
...
@@ -33,9 +33,6 @@ DEFINE_bool(check_nan_inf, false,
namespace
paddle
{
namespace
paddle
{
namespace
framework
{
namespace
framework
{
const
std
::
string
kFeedOpType
=
"feed"
;
const
std
::
string
kFetchOpType
=
"fetch"
;
Executor
::
Executor
(
const
platform
::
Place
&
place
)
:
place_
(
place
)
{}
Executor
::
Executor
(
const
platform
::
Place
&
place
)
:
place_
(
place
)
{}
static
void
CreateTensor
(
Variable
*
var
,
proto
::
VarDesc
::
VarType
var_type
)
{
static
void
CreateTensor
(
Variable
*
var
,
proto
::
VarDesc
::
VarType
var_type
)
{
...
...
paddle/framework/feed_fetch_type.h
浏览文件 @
f5d93368
...
@@ -13,6 +13,7 @@ See the License for the specific language governing permissions and
...
@@ -13,6 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#pragma once
#pragma once
#include <string>
#include <vector>
#include <vector>
#include "paddle/framework/lod_tensor.h"
#include "paddle/framework/lod_tensor.h"
...
@@ -20,5 +21,8 @@ namespace paddle {
...
@@ -20,5 +21,8 @@ namespace paddle {
namespace
framework
{
namespace
framework
{
using
FeedFetchType
=
LoDTensor
;
using
FeedFetchType
=
LoDTensor
;
using
FeedFetchList
=
std
::
vector
<
FeedFetchType
>
;
using
FeedFetchList
=
std
::
vector
<
FeedFetchType
>
;
static
const
std
::
string
kFeedOpType
=
"feed"
;
static
const
std
::
string
kFetchOpType
=
"fetch"
;
}
// namespace framework
}
// namespace framework
}
// namespace paddle
}
// namespace paddle
paddle/framework/program_desc.cc
浏览文件 @
f5d93368
...
@@ -14,13 +14,11 @@ limitations under the License. */
...
@@ -14,13 +14,11 @@ limitations under the License. */
#include "paddle/framework/program_desc.h"
#include "paddle/framework/program_desc.h"
#include "paddle/framework/block_desc.h"
#include "paddle/framework/block_desc.h"
#include "paddle/framework/feed_fetch_type.h"
namespace
paddle
{
namespace
paddle
{
namespace
framework
{
namespace
framework
{
const
std
::
string
kFeedOpType
=
"feed"
;
const
std
::
string
kFetchOpType
=
"fetch"
;
BlockDesc
*
ProgramDesc
::
AppendBlock
(
const
BlockDesc
&
parent
)
{
BlockDesc
*
ProgramDesc
::
AppendBlock
(
const
BlockDesc
&
parent
)
{
auto
*
b
=
desc_
.
add_blocks
();
auto
*
b
=
desc_
.
add_blocks
();
b
->
set_parent_idx
(
parent
.
ID
());
b
->
set_parent_idx
(
parent
.
ID
());
...
@@ -67,26 +65,26 @@ ProgramDesc::ProgramDesc(const std::string &binary_str) {
...
@@ -67,26 +65,26 @@ ProgramDesc::ProgramDesc(const std::string &binary_str) {
}
}
}
}
const
std
::
vector
<
std
::
string
>
ProgramDesc
::
GetFeed
Var
Names
()
{
const
std
::
vector
<
std
::
string
>
ProgramDesc
::
GetFeed
Target
Names
()
{
BlockDesc
*
global_block
=
blocks_
[
0
].
get
();
BlockDesc
*
global_block
=
blocks_
[
0
].
get
();
std
::
vector
<
std
::
string
>
feed_
var
_names
;
std
::
vector
<
std
::
string
>
feed_
target
_names
;
for
(
auto
*
op
:
global_block
->
AllOps
())
{
for
(
auto
*
op
:
global_block
->
AllOps
())
{
if
(
op
->
Type
()
==
"feed"
)
{
if
(
op
->
Type
()
==
kFeedOpType
)
{
feed_
var_names
.
insert
(
feed_var
_names
.
begin
(),
op
->
Output
(
"Out"
)[
0
]);
feed_
target_names
.
insert
(
feed_target
_names
.
begin
(),
op
->
Output
(
"Out"
)[
0
]);
}
}
}
}
return
feed_
var
_names
;
return
feed_
target
_names
;
}
}
const
std
::
vector
<
std
::
string
>
ProgramDesc
::
GetFetch
Var
Names
()
{
const
std
::
vector
<
std
::
string
>
ProgramDesc
::
GetFetch
Target
Names
()
{
BlockDesc
*
global_block
=
blocks_
[
0
].
get
();
BlockDesc
*
global_block
=
blocks_
[
0
].
get
();
std
::
vector
<
std
::
string
>
fetch_
var
_names
;
std
::
vector
<
std
::
string
>
fetch_
target
_names
;
for
(
auto
*
op
:
global_block
->
AllOps
())
{
for
(
auto
*
op
:
global_block
->
AllOps
())
{
if
(
op
->
Type
()
==
"fetch"
)
{
if
(
op
->
Type
()
==
kFetchOpType
)
{
fetch_
var
_names
.
push_back
(
op
->
Input
(
"X"
)[
0
]);
fetch_
target
_names
.
push_back
(
op
->
Input
(
"X"
)[
0
]);
}
}
}
}
return
fetch_
var
_names
;
return
fetch_
target
_names
;
}
}
}
// namespace framework
}
// namespace framework
...
...
paddle/framework/program_desc.h
浏览文件 @
f5d93368
...
@@ -45,9 +45,8 @@ class ProgramDesc {
...
@@ -45,9 +45,8 @@ class ProgramDesc {
proto
::
ProgramDesc
*
Proto
();
proto
::
ProgramDesc
*
Proto
();
const
std
::
vector
<
std
::
string
>
GetFeedVarNames
();
const
std
::
vector
<
std
::
string
>
GetFeedTargetNames
();
const
std
::
vector
<
std
::
string
>
GetFetchTargetNames
();
const
std
::
vector
<
std
::
string
>
GetFetchVarNames
();
private:
private:
proto
::
ProgramDesc
desc_
;
proto
::
ProgramDesc
desc_
;
...
...
paddle/framework/prune.cc
浏览文件 @
f5d93368
...
@@ -21,12 +21,11 @@ limitations under the License. */
...
@@ -21,12 +21,11 @@ limitations under the License. */
#include <vector>
#include <vector>
#include <glog/logging.h>
#include <glog/logging.h>
#include "paddle/framework/feed_fetch_type.h"
namespace
paddle
{
namespace
paddle
{
namespace
framework
{
namespace
framework
{
const
std
::
string
kFeedOpType
=
"feed"
;
const
std
::
string
kFetchOpType
=
"fetch"
;
const
std
::
string
kDropOutOpType
=
"dropout"
;
const
std
::
string
kDropOutOpType
=
"dropout"
;
const
std
::
string
kBatchNormOpType
=
"batch_norm"
;
const
std
::
string
kBatchNormOpType
=
"batch_norm"
;
...
...
paddle/inference/io.cc
浏览文件 @
f5d93368
...
@@ -13,13 +13,14 @@ See the License for the specific language governing permissions and
...
@@ -13,13 +13,14 @@ See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#include "paddle/inference/io.h"
#include "paddle/inference/io.h"
#include <fstream>
#include <fstream>
#include "paddle/framework/block_desc.h"
#include "paddle/framework/feed_fetch_type.h"
namespace
paddle
{
namespace
paddle
{
namespace
inference
{
namespace
inference
{
const
std
::
string
kFeedOpType
=
"feed"
;
bool
IsParameter
(
const
framework
::
VarDesc
*
var
,
bool
IsParameter
(
const
framework
::
VarDesc
*
var
,
const
framework
::
ProgramDesc
*
main_program
)
{
const
framework
::
ProgramDesc
*
main_program
)
{
if
(
var
->
Persistable
())
{
if
(
var
->
Persistable
())
{
...
@@ -27,7 +28,7 @@ bool IsParameter(const framework::VarDesc* var,
...
@@ -27,7 +28,7 @@ bool IsParameter(const framework::VarDesc* var,
for
(
size_t
i
=
0
;
i
<
main_program
->
Size
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
main_program
->
Size
();
++
i
)
{
const
framework
::
BlockDesc
&
block
=
main_program
->
Block
(
i
);
const
framework
::
BlockDesc
&
block
=
main_program
->
Block
(
i
);
for
(
auto
*
op
:
block
.
AllOps
())
{
for
(
auto
*
op
:
block
.
AllOps
())
{
if
(
op
->
Type
()
==
kFeedOpType
)
{
if
(
op
->
Type
()
==
framework
::
kFeedOpType
)
{
continue
;
continue
;
}
}
for
(
auto
input_argument_name
:
op
->
InputArgumentNames
())
{
for
(
auto
input_argument_name
:
op
->
InputArgumentNames
())
{
...
...
paddle/inference/io.h
浏览文件 @
f5d93368
...
@@ -16,18 +16,13 @@ limitations under the License. */
...
@@ -16,18 +16,13 @@ limitations under the License. */
#include <string>
#include <string>
#include <vector>
#include <vector>
#include "paddle/framework/block_desc.h"
#include "paddle/framework/executor.h"
#include "paddle/framework/executor.h"
#include "paddle/framework/program_desc.h"
#include "paddle/framework/program_desc.h"
#include "paddle/framework/scope.h"
#include "paddle/framework/scope.h"
#include "paddle/framework/var_desc.h"
namespace
paddle
{
namespace
paddle
{
namespace
inference
{
namespace
inference
{
bool
IsParameter
(
const
framework
::
VarDesc
*
var
,
const
framework
::
ProgramDesc
*
main_program
);
void
LoadPersistables
(
framework
::
Executor
&
executor
,
void
LoadPersistables
(
framework
::
Executor
&
executor
,
framework
::
Scope
&
scope
,
framework
::
Scope
&
scope
,
const
std
::
string
&
dirname
,
const
std
::
string
&
dirname
,
...
...
paddle/inference/tests/book/test_inference_recognize_digits.cc
浏览文件 @
f5d93368
...
@@ -33,11 +33,11 @@ void TestInference(const std::string& dirname,
...
@@ -33,11 +33,11 @@ void TestInference(const std::string& dirname,
// 2. Initialize the inference_program and load all parameters from file
// 2. Initialize the inference_program and load all parameters from file
auto
*
inference_program
=
paddle
::
inference
::
Load
(
executor
,
*
scope
,
dirname
);
auto
*
inference_program
=
paddle
::
inference
::
Load
(
executor
,
*
scope
,
dirname
);
// 3. Get the feed_
var_names and fetch_var
_names
// 3. Get the feed_
target_names and fetch_target
_names
const
std
::
vector
<
std
::
string
>&
feed_target_names
=
const
std
::
vector
<
std
::
string
>&
feed_target_names
=
inference_program
->
GetFeed
Var
Names
();
inference_program
->
GetFeed
Target
Names
();
const
std
::
vector
<
std
::
string
>&
fetch_target_names
=
const
std
::
vector
<
std
::
string
>&
fetch_target_names
=
inference_program
->
GetFetch
Var
Names
();
inference_program
->
GetFetch
Target
Names
();
// 4. Prepare inputs
// 4. Prepare inputs
std
::
map
<
std
::
string
,
const
paddle
::
framework
::
LoDTensor
*>
feed_targets
;
std
::
map
<
std
::
string
,
const
paddle
::
framework
::
LoDTensor
*>
feed_targets
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录