Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
436ea50d
P
Paddle
项目概览
Crayon鑫
/
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看板
提交
436ea50d
编写于
10月 10, 2017
作者:
Q
qijun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
follow comments
上级
062ff4d7
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
17 addition
and
14 deletion
+17
-14
paddle/framework/executor.cc
paddle/framework/executor.cc
+3
-1
paddle/framework/executor_test.cc
paddle/framework/executor_test.cc
+9
-8
paddle/framework/scope.cc
paddle/framework/scope.cc
+2
-2
paddle/framework/scope.h
paddle/framework/scope.h
+1
-1
paddle/operators/feed_op.h
paddle/operators/feed_op.h
+1
-1
paddle/operators/fetch_op.h
paddle/operators/fetch_op.h
+1
-1
未找到文件。
paddle/framework/executor.cc
浏览文件 @
436ea50d
...
...
@@ -44,7 +44,9 @@ Executor::Executor(const std::vector<platform::Place>& places) {
device_contexts_
[
i
]
=
new
platform
::
CUDADeviceContext
(
boost
::
get
<
platform
::
GPUPlace
>
(
places
[
i
]));
#else
PADDLE_THROW
(
"'GPUPlace' is not supported in CPU only device."
);
PADDLE_THROW
(
"'GPUPlace' is not supported, Please re-compile with WITH_GPU "
"option"
);
#endif
}
}
...
...
paddle/framework/executor_test.cc
浏览文件 @
436ea50d
...
...
@@ -67,7 +67,7 @@ void AddOp(const std::string& type, const VariableNameMap& inputs,
template
<
typename
T
>
void
SetFeedVariable
(
const
std
::
vector
<
std
::
vector
<
T
>>&
inputs
,
const
std
::
vector
<
std
::
vector
<
int64_t
>>&
dims
)
{
Variable
*
g_feed_value
=
GetGlobalScope
()
->
FindVar
(
"feed_value"
);
Variable
*
g_feed_value
=
GetGlobalScope
()
.
FindVar
(
"feed_value"
);
auto
&
feed_inputs
=
*
(
g_feed_value
->
GetMutable
<
std
::
vector
<
paddle
::
framework
::
Tensor
>>
());
size_t
size
=
inputs
.
size
();
...
...
@@ -82,7 +82,7 @@ void SetFeedVariable(const std::vector<std::vector<T>>& inputs,
// So we can memcpy the data from fetch_value to vector<T>
template
<
typename
T
>
std
::
vector
<
std
::
vector
<
T
>>
GetFetchVariable
()
{
Variable
*
g_fetch_value
=
GetGlobalScope
()
->
FindVar
(
"fetch_value"
);
Variable
*
g_fetch_value
=
GetGlobalScope
()
.
FindVar
(
"fetch_value"
);
auto
&
fetch_outputs
=
*
(
g_fetch_value
->
GetMutable
<
std
::
vector
<
paddle
::
framework
::
Tensor
>>
());
...
...
@@ -232,8 +232,9 @@ TEST_F(ExecutorTesterRandom, CPU) {
std
::
unique_ptr
<
Executor
>
executor
(
new
Executor
(
places
));
executor
->
Run
(
init_pdesc_
,
GetGlobalScope
(),
0
);
executor
->
Run
(
pdesc_
,
GetGlobalScope
(),
0
);
executor
->
Run
(
init_pdesc_
,
&
GetGlobalScope
(),
0
);
SetFeedVariable
<
float
>
(
inputs_
,
dims_
);
executor
->
Run
(
pdesc_
,
&
GetGlobalScope
(),
0
);
std
::
vector
<
std
::
vector
<
float
>>
result
=
GetFetchVariable
<
float
>
();
}
...
...
@@ -252,7 +253,7 @@ TEST_F(ExecutorTesterFeedAndFetch, CPU) {
for
(
int
batch_id
=
0
;
batch_id
<
3
;
batch_id
++
)
{
SetFeedVariable
<
float
>
(
inputs_
,
dims_
);
executor
->
Run
(
pdesc_
,
GetGlobalScope
(),
0
);
executor
->
Run
(
pdesc_
,
&
GetGlobalScope
(),
0
);
std
::
vector
<
std
::
vector
<
float
>>
result
=
GetFetchVariable
<
float
>
();
PADDLE_ENFORCE_EQ
(
result
.
size
(),
inputs_
.
size
());
for
(
size_t
i
=
0
;
i
<
result
.
size
();
++
i
)
{
...
...
@@ -280,10 +281,10 @@ TEST_F(ExecutorTesterRandom, GPU) {
std
::
unique_ptr
<
Executor
>
executor
(
new
Executor
(
places
));
executor
->
Run
(
init_pdesc_
,
GetGlobalScope
(),
0
);
executor
->
Run
(
init_pdesc_
,
&
GetGlobalScope
(),
0
);
for
(
int
batch_id
=
0
;
batch_id
<
3
;
batch_id
++
)
{
SetFeedVariable
<
float
>
(
inputs_
,
dims_
);
executor
->
Run
(
pdesc_
,
GetGlobalScope
(),
0
);
executor
->
Run
(
pdesc_
,
&
GetGlobalScope
(),
0
);
}
}
...
...
@@ -304,7 +305,7 @@ TEST_F(ExecutorTesterFeedAndFetch, GPU) {
for
(
int
batch_id
=
0
;
batch_id
<
3
;
batch_id
++
)
{
SetFeedVariable
<
float
>
(
inputs_
,
dims_
);
executor
->
Run
(
pdesc_
,
GetGlobalScope
(),
0
);
executor
->
Run
(
pdesc_
,
&
GetGlobalScope
(),
0
);
std
::
vector
<
std
::
vector
<
float
>>
result
=
GetFetchVariable
<
float
>
();
PADDLE_ENFORCE_EQ
(
result
.
size
(),
inputs_
.
size
());
for
(
size_t
i
=
0
;
i
<
result
.
size
();
++
i
)
{
...
...
paddle/framework/scope.cc
浏览文件 @
436ea50d
...
...
@@ -67,14 +67,14 @@ void Scope::DropKids() {
std
::
once_flag
feed_variable_flag
;
framework
::
Scope
*
GetGlobalScope
()
{
framework
::
Scope
&
GetGlobalScope
()
{
static
std
::
unique_ptr
<
framework
::
Scope
>
g_scope
{
nullptr
};
std
::
call_once
(
feed_variable_flag
,
[
&
]()
{
g_scope
.
reset
(
new
framework
::
Scope
());
g_scope
->
NewVar
(
"feed_value"
);
g_scope
->
NewVar
(
"fetch_value"
);
});
return
g_scope
.
get
(
);
return
*
(
g_scope
.
get
()
);
}
}
// namespace framework
...
...
paddle/framework/scope.h
浏览文件 @
436ea50d
...
...
@@ -73,7 +73,7 @@ class Scope {
DISABLE_COPY_AND_ASSIGN
(
Scope
);
};
framework
::
Scope
*
GetGlobalScope
();
framework
::
Scope
&
GetGlobalScope
();
}
// namespace framework
}
// namespace paddle
paddle/operators/feed_op.h
浏览文件 @
436ea50d
...
...
@@ -26,7 +26,7 @@ class FeedKernel : public framework::OpKernel<T> {
framework
::
Tensor
*
out
=
ctx
.
Output
<
framework
::
Tensor
>
(
"Out"
);
out
->
mutable_data
<
T
>
(
ctx
.
GetPlace
());
framework
::
Variable
*
g_feed_variable
=
framework
::
GetGlobalScope
()
->
FindVar
(
"feed_value"
);
framework
::
GetGlobalScope
()
.
FindVar
(
"feed_value"
);
const
auto
&
tensors
=
g_feed_variable
->
Get
<
std
::
vector
<
framework
::
Tensor
>>
();
int
col
=
ctx
.
template
Attr
<
int
>(
"col"
);
...
...
paddle/operators/fetch_op.h
浏览文件 @
436ea50d
...
...
@@ -25,7 +25,7 @@ class FetchKernel : public framework::OpKernel<T> {
void
Compute
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
const
framework
::
Tensor
*
input
=
ctx
.
Input
<
framework
::
Tensor
>
(
"Input"
);
framework
::
Variable
*
g_fetch_variable
=
framework
::
GetGlobalScope
()
->
FindVar
(
"fetch_value"
);
framework
::
GetGlobalScope
()
.
FindVar
(
"fetch_value"
);
auto
*
tensors
=
g_fetch_variable
->
GetMutable
<
std
::
vector
<
framework
::
Tensor
>>
();
int
col
=
ctx
.
template
Attr
<
int
>(
"col"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录