Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
d15b264e
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看板
未验证
提交
d15b264e
编写于
4月 23, 2018
作者:
W
Wu Yi
提交者:
GitHub
4月 23, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #10124 from Yancey1989/create_scope_in_var_resp
Create sub socpe when it is necessary
上级
dd7a48bd
8023c6d7
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
24 addition
and
26 deletion
+24
-26
paddle/fluid/operators/detail/grpc_server.cc
paddle/fluid/operators/detail/grpc_server.cc
+2
-2
paddle/fluid/operators/detail/sendrecvop_utils.cc
paddle/fluid/operators/detail/sendrecvop_utils.cc
+1
-1
paddle/fluid/operators/detail/serde_test.cc
paddle/fluid/operators/detail/serde_test.cc
+4
-4
paddle/fluid/operators/detail/variable_response.cc
paddle/fluid/operators/detail/variable_response.cc
+3
-3
paddle/fluid/operators/detail/variable_response.h
paddle/fluid/operators/detail/variable_response.h
+14
-16
未找到文件。
paddle/fluid/operators/detail/grpc_server.cc
浏览文件 @
d15b264e
...
@@ -60,7 +60,7 @@ class RequestSend final : public RequestBase {
...
@@ -60,7 +60,7 @@ class RequestSend final : public RequestBase {
framework
::
Scope
*
scope
,
ReceivedQueue
*
queue
,
framework
::
Scope
*
scope
,
ReceivedQueue
*
queue
,
const
platform
::
DeviceContext
*
dev_ctx
)
const
platform
::
DeviceContext
*
dev_ctx
)
:
RequestBase
(
service
,
cq
,
dev_ctx
),
queue_
(
queue
),
responder_
(
&
ctx_
)
{
:
RequestBase
(
service
,
cq
,
dev_ctx
),
queue_
(
queue
),
responder_
(
&
ctx_
)
{
request_
.
reset
(
new
VariableResponse
(
false
,
scope
,
dev_ctx_
));
request_
.
reset
(
new
VariableResponse
(
scope
,
dev_ctx_
));
int
method_id
=
static_cast
<
int
>
(
detail
::
GrpcMethod
::
kSendVariable
);
int
method_id
=
static_cast
<
int
>
(
detail
::
GrpcMethod
::
kSendVariable
);
service_
->
RequestAsyncUnary
(
method_id
,
&
ctx_
,
request_
.
get
(),
&
responder_
,
service_
->
RequestAsyncUnary
(
method_id
,
&
ctx_
,
request_
.
get
(),
&
responder_
,
cq_
,
cq_
,
this
);
cq_
,
cq_
,
this
);
...
@@ -146,7 +146,7 @@ class RequestPrefetch final : public RequestBase {
...
@@ -146,7 +146,7 @@ class RequestPrefetch final : public RequestBase {
executor_
(
executor
),
executor_
(
executor
),
program_
(
program
),
program_
(
program
),
prefetch_ctx_
(
prefetch_ctx
)
{
prefetch_ctx_
(
prefetch_ctx
)
{
request_
.
reset
(
new
VariableResponse
(
false
,
scope
,
dev_ctx_
));
request_
.
reset
(
new
VariableResponse
(
scope
,
dev_ctx_
));
int
method_id
=
static_cast
<
int
>
(
detail
::
GrpcMethod
::
kPrefetchVariable
);
int
method_id
=
static_cast
<
int
>
(
detail
::
GrpcMethod
::
kPrefetchVariable
);
service_
->
RequestAsyncUnary
(
method_id
,
&
ctx_
,
request_
.
get
(),
&
responder_
,
service_
->
RequestAsyncUnary
(
method_id
,
&
ctx_
,
request_
.
get
(),
&
responder_
,
cq_
,
cq_
,
this
);
cq_
,
cq_
,
this
);
...
...
paddle/fluid/operators/detail/sendrecvop_utils.cc
浏览文件 @
d15b264e
...
@@ -186,7 +186,7 @@ void DeserializeFromByteBuffer(const ::grpc::ByteBuffer& msg,
...
@@ -186,7 +186,7 @@ void DeserializeFromByteBuffer(const ::grpc::ByteBuffer& msg,
const
platform
::
DeviceContext
&
ctx
,
const
platform
::
DeviceContext
&
ctx
,
const
framework
::
Scope
*
scope
,
const
framework
::
Scope
*
scope
,
framework
::
Variable
**
var
)
{
framework
::
Variable
**
var
)
{
operators
::
detail
::
VariableResponse
resp
(
false
,
scope
,
&
ctx
);
operators
::
detail
::
VariableResponse
resp
(
scope
,
&
ctx
);
PADDLE_ENFORCE
(
resp
.
Parse
(
msg
)
==
0
,
"parse bytebuffer to tensor error!"
);
PADDLE_ENFORCE
(
resp
.
Parse
(
msg
)
==
0
,
"parse bytebuffer to tensor error!"
);
*
var
=
resp
.
GetVar
();
*
var
=
resp
.
GetVar
();
}
}
...
...
paddle/fluid/operators/detail/serde_test.cc
浏览文件 @
d15b264e
...
@@ -51,7 +51,7 @@ void RunSerdeTestSelectedRows(platform::Place place) {
...
@@ -51,7 +51,7 @@ void RunSerdeTestSelectedRows(platform::Place place) {
::
grpc
::
ByteBuffer
msg
;
::
grpc
::
ByteBuffer
msg
;
operators
::
detail
::
SerializeToByteBuffer
(
"myvar"
,
&
var
,
ctx
,
&
msg
);
operators
::
detail
::
SerializeToByteBuffer
(
"myvar"
,
&
var
,
ctx
,
&
msg
);
EXPECT_GT
(
msg
.
Length
(),
0
);
EXPECT_GT
(
msg
.
Length
(),
static_cast
<
size_t
>
(
0
)
);
// deserialize
// deserialize
std
::
vector
<::
grpc
::
Slice
>
slices
;
std
::
vector
<::
grpc
::
Slice
>
slices
;
...
@@ -84,7 +84,7 @@ void RunSerdeTestSelectedRows(platform::Place place) {
...
@@ -84,7 +84,7 @@ void RunSerdeTestSelectedRows(platform::Place place) {
// operators::detail::DeserializeFromByteBuffer(msg, ctx, &var2);
// operators::detail::DeserializeFromByteBuffer(msg, ctx, &var2);
framework
::
Scope
scope
;
framework
::
Scope
scope
;
scope
.
Var
(
"myvar"
);
scope
.
Var
(
"myvar"
);
operators
::
detail
::
VariableResponse
resp
(
false
,
&
scope
,
&
ctx
);
operators
::
detail
::
VariableResponse
resp
(
&
scope
,
&
ctx
);
EXPECT_EQ
(
resp
.
Parse
(
msg
),
0
);
EXPECT_EQ
(
resp
.
Parse
(
msg
),
0
);
framework
::
Variable
*
var2
=
resp
.
GetVar
();
framework
::
Variable
*
var2
=
resp
.
GetVar
();
...
@@ -129,7 +129,7 @@ void RunTestLodTensor(platform::Place place, int from_type = 0) {
...
@@ -129,7 +129,7 @@ void RunTestLodTensor(platform::Place place, int from_type = 0) {
::
grpc
::
ByteBuffer
msg
;
::
grpc
::
ByteBuffer
msg
;
operators
::
detail
::
SerializeToByteBuffer
(
"myvar"
,
&
var
,
ctx
,
&
msg
);
operators
::
detail
::
SerializeToByteBuffer
(
"myvar"
,
&
var
,
ctx
,
&
msg
);
EXPECT_GT
(
msg
.
Length
(),
0
);
EXPECT_GT
(
msg
.
Length
(),
static_cast
<
size_t
>
(
0
)
);
// deserialize
// deserialize
std
::
vector
<::
grpc
::
Slice
>
slices
;
std
::
vector
<::
grpc
::
Slice
>
slices
;
...
@@ -171,7 +171,7 @@ void RunTestLodTensor(platform::Place place, int from_type = 0) {
...
@@ -171,7 +171,7 @@ void RunTestLodTensor(platform::Place place, int from_type = 0) {
// deserialize zero-copy
// deserialize zero-copy
framework
::
Scope
scope
;
framework
::
Scope
scope
;
scope
.
Var
(
"myvar"
);
scope
.
Var
(
"myvar"
);
operators
::
detail
::
VariableResponse
resp
(
false
,
&
scope
,
&
ctx
);
operators
::
detail
::
VariableResponse
resp
(
&
scope
,
&
ctx
);
if
(
from_type
==
0
)
{
if
(
from_type
==
0
)
{
EXPECT_EQ
(
resp
.
Parse
(
msg
),
0
);
EXPECT_EQ
(
resp
.
Parse
(
msg
),
0
);
}
else
{
}
else
{
...
...
paddle/fluid/operators/detail/variable_response.cc
浏览文件 @
d15b264e
...
@@ -114,7 +114,7 @@ bool VariableResponse::CopyLodTensorData(
...
@@ -114,7 +114,7 @@ bool VariableResponse::CopyLodTensorData(
::
google
::
protobuf
::
io
::
CodedInputStream
*
input
,
::
google
::
protobuf
::
io
::
CodedInputStream
*
input
,
const
platform
::
DeviceContext
&
ctx
,
const
framework
::
DDim
&
dims
,
const
platform
::
DeviceContext
&
ctx
,
const
framework
::
DDim
&
dims
,
int
length
)
{
int
length
)
{
auto
*
tensor
=
Ini
tVar
()
->
GetMutable
<
framework
::
LoDTensor
>
();
auto
*
tensor
=
Ge
tVar
()
->
GetMutable
<
framework
::
LoDTensor
>
();
tensor
->
Resize
(
dims
);
tensor
->
Resize
(
dims
);
framework
::
LoD
lod
;
framework
::
LoD
lod
;
...
@@ -150,7 +150,7 @@ bool VariableResponse::CopySelectRowsTensorData(
...
@@ -150,7 +150,7 @@ bool VariableResponse::CopySelectRowsTensorData(
::
google
::
protobuf
::
io
::
CodedInputStream
*
input
,
::
google
::
protobuf
::
io
::
CodedInputStream
*
input
,
const
platform
::
DeviceContext
&
ctx
,
const
framework
::
DDim
&
dims
,
const
platform
::
DeviceContext
&
ctx
,
const
framework
::
DDim
&
dims
,
int
length
)
{
int
length
)
{
auto
*
slr
=
Ini
tVar
()
->
GetMutable
<
framework
::
SelectedRows
>
();
auto
*
slr
=
Ge
tVar
()
->
GetMutable
<
framework
::
SelectedRows
>
();
slr
->
set_height
(
meta_
.
slr_height
());
slr
->
set_height
(
meta_
.
slr_height
());
auto
*
tensor
=
slr
->
mutable_value
();
auto
*
tensor
=
slr
->
mutable_value
();
tensor
->
Resize
(
dims
);
tensor
->
Resize
(
dims
);
...
@@ -172,7 +172,7 @@ bool VariableResponse::CopySelectRowsTensorData(
...
@@ -172,7 +172,7 @@ bool VariableResponse::CopySelectRowsTensorData(
bool
VariableResponse
::
CopySelectRowsData
(
bool
VariableResponse
::
CopySelectRowsData
(
::
google
::
protobuf
::
io
::
CodedInputStream
*
input
,
::
google
::
protobuf
::
io
::
CodedInputStream
*
input
,
const
platform
::
DeviceContext
&
ctx
,
int
length
)
{
const
platform
::
DeviceContext
&
ctx
,
int
length
)
{
auto
*
slr
=
Ini
tVar
()
->
GetMutable
<
framework
::
SelectedRows
>
();
auto
*
slr
=
Ge
tVar
()
->
GetMutable
<
framework
::
SelectedRows
>
();
slr
->
mutable_rows
()
->
resize
(
length
/
slr
->
mutable_rows
()
->
resize
(
length
/
framework
::
SizeOfType
(
typeid
(
int64_t
)));
// int64
framework
::
SizeOfType
(
typeid
(
int64_t
)));
// int64
int64_t
*
rows_data
=
slr
->
mutable_rows
()
->
data
();
int64_t
*
rows_data
=
slr
->
mutable_rows
()
->
data
();
...
...
paddle/fluid/operators/detail/variable_response.h
浏览文件 @
d15b264e
...
@@ -36,13 +36,18 @@ namespace detail {
...
@@ -36,13 +36,18 @@ namespace detail {
class
VariableResponse
{
class
VariableResponse
{
public:
public:
VariableResponse
(
bool
use_local_scope
,
const
framework
::
Scope
*
scope
,
VariableResponse
(
const
framework
::
Scope
*
scope
,
const
platform
::
DeviceContext
*
dev_ctx
)
const
platform
::
DeviceContext
*
dev_ctx
,
:
use_local_scope_
(
use_local_scope
),
scope_
(
scope
),
dev_ctx_
(
dev_ctx
)
{
bool
create_scope
=
false
)
local_scope_
=
&
scope
->
NewScope
();
:
scope_
(
scope
),
dev_ctx_
(
dev_ctx
),
create_scope_
(
create_scope
)
{
if
(
create_scope
)
{
local_scope_
=
&
scope
->
NewScope
();
}
}
}
virtual
~
VariableResponse
()
{
scope_
->
DeleteScope
(
local_scope_
);
}
virtual
~
VariableResponse
()
{
if
(
create_scope_
)
scope_
->
DeleteScope
(
local_scope_
);
}
// return:
// return:
// 0:ok.
// 0:ok.
...
@@ -63,17 +68,10 @@ class VariableResponse {
...
@@ -63,17 +68,10 @@ class VariableResponse {
// should call parse first.
// should call parse first.
framework
::
Variable
*
GetVar
()
{
framework
::
Variable
*
GetVar
()
{
return
local_scope_
->
FindVar
(
meta_
.
varname
());
if
(
create_scope_
)
{
}
framework
::
Variable
*
InitVar
()
{
if
(
use_local_scope_
)
{
bool
has_var
=
(
scope_
->
FindVar
(
meta_
.
varname
())
!=
nullptr
);
PADDLE_ENFORCE
(
has_var
);
return
local_scope_
->
Var
(
meta_
.
varname
());
return
local_scope_
->
Var
(
meta_
.
varname
());
}
else
{
return
scope_
->
FindVar
(
meta_
.
varname
());
}
}
return
scope_
->
FindVar
(
meta_
.
varname
());
}
}
private:
private:
...
@@ -89,10 +87,10 @@ class VariableResponse {
...
@@ -89,10 +87,10 @@ class VariableResponse {
const
framework
::
DDim
&
dims
,
int
length
);
const
framework
::
DDim
&
dims
,
int
length
);
private:
private:
bool
use_local_scope_
=
false
;
const
framework
::
Scope
*
scope_
;
const
framework
::
Scope
*
scope_
;
framework
::
Scope
*
local_scope_
=
nullptr
;
const
platform
::
DeviceContext
*
dev_ctx_
;
const
platform
::
DeviceContext
*
dev_ctx_
;
bool
create_scope_
=
false
;
framework
::
Scope
*
local_scope_
=
nullptr
;
// only Skeleton
// only Skeleton
sendrecv
::
VariableMessage
meta_
;
sendrecv
::
VariableMessage
meta_
;
};
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录