Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
dc225ed2
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看板
未验证
提交
dc225ed2
编写于
4月 08, 2020
作者:
L
liym27
提交者:
GitHub
4月 08, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
OP (tensor_array_read_write) error message enhancement. test=develop (#23468)
上级
3cb5623d
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
17 addition
and
16 deletion
+17
-16
paddle/fluid/operators/array_operator.h
paddle/fluid/operators/array_operator.h
+7
-2
paddle/fluid/operators/controlflow/tensor_array_read_write_op.cc
...fluid/operators/controlflow/tensor_array_read_write_op.cc
+10
-14
未找到文件。
paddle/fluid/operators/array_operator.h
浏览文件 @
dc225ed2
...
@@ -31,9 +31,14 @@ class ArrayOp : public framework::OperatorBase {
...
@@ -31,9 +31,14 @@ class ArrayOp : public framework::OperatorBase {
size_t
GetOffset
(
const
framework
::
Scope
&
scope
,
size_t
GetOffset
(
const
framework
::
Scope
&
scope
,
const
platform
::
Place
&
place
)
const
{
const
platform
::
Place
&
place
)
const
{
auto
*
i
=
scope
.
FindVar
(
Input
(
"I"
));
auto
*
i
=
scope
.
FindVar
(
Input
(
"I"
));
PADDLE_ENFORCE
(
i
!=
nullptr
,
"I must be set"
);
PADDLE_ENFORCE_NOT_NULL
(
i
,
platform
::
errors
::
NotFound
(
"Input(I) is not found."
));
auto
&
i_tensor
=
i
->
Get
<
framework
::
LoDTensor
>
();
auto
&
i_tensor
=
i
->
Get
<
framework
::
LoDTensor
>
();
PADDLE_ENFORCE_EQ
(
i_tensor
.
numel
(),
1
);
PADDLE_ENFORCE_EQ
(
i_tensor
.
numel
(),
1
,
platform
::
errors
::
InvalidArgument
(
"Input(I) must have numel 1. "
"But received %d, and it's shape is [%s]."
,
i_tensor
.
numel
(),
i_tensor
.
dims
()));
// get device context from pool
// get device context from pool
platform
::
DeviceContextPool
&
pool
=
platform
::
DeviceContextPool
::
Instance
();
platform
::
DeviceContextPool
&
pool
=
platform
::
DeviceContextPool
::
Instance
();
...
...
paddle/fluid/operators/controlflow/tensor_array_read_write_op.cc
浏览文件 @
dc225ed2
...
@@ -83,8 +83,7 @@ class WriteToArrayInferShape : public framework::InferShapeBase {
...
@@ -83,8 +83,7 @@ class WriteToArrayInferShape : public framework::InferShapeBase {
void
operator
()(
framework
::
InferShapeContext
*
context
)
const
override
{
void
operator
()(
framework
::
InferShapeContext
*
context
)
const
override
{
PADDLE_ENFORCE_EQ
(
PADDLE_ENFORCE_EQ
(
context
->
HasInput
(
"I"
),
true
,
context
->
HasInput
(
"I"
),
true
,
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
NotFound
(
"Input(I) of WriteToArrayOp is not found."
));
"Read/Write array operation must set the subscript index."
));
// TODO(wangchaochaohu) control flow Op do not support runtime infer shape
// TODO(wangchaochaohu) control flow Op do not support runtime infer shape
// Later we add [ontext->GetInputDim("I")) == 1] check when it's supported
// Later we add [ontext->GetInputDim("I")) == 1] check when it's supported
...
@@ -93,11 +92,9 @@ class WriteToArrayInferShape : public framework::InferShapeBase {
...
@@ -93,11 +92,9 @@ class WriteToArrayInferShape : public framework::InferShapeBase {
return
;
return
;
}
}
PADDLE_ENFORCE_EQ
(
PADDLE_ENFORCE_EQ
(
context
->
HasOutput
(
"Out"
),
true
,
context
->
HasOutput
(
"Out"
),
true
,
platform
::
errors
::
NotFound
(
platform
::
errors
::
InvalidArgument
(
"Output(Out) of WriteToArrayOp is not found."
));
"Read/Write array operation must set the output Tensor "
"to get the result."
));
context
->
SetOutputDim
(
"Out"
,
context
->
GetInputDim
(
"X"
));
context
->
SetOutputDim
(
"Out"
,
context
->
GetInputDim
(
"X"
));
// When compile time, we need to:
// When compile time, we need to:
...
@@ -139,15 +136,14 @@ class ReadFromArrayOp : public ArrayOp {
...
@@ -139,15 +136,14 @@ class ReadFromArrayOp : public ArrayOp {
void
RunImpl
(
const
framework
::
Scope
&
scope
,
void
RunImpl
(
const
framework
::
Scope
&
scope
,
const
platform
::
Place
&
place
)
const
override
{
const
platform
::
Place
&
place
)
const
override
{
auto
*
x
=
scope
.
FindVar
(
Input
(
"X"
));
auto
*
x
=
scope
.
FindVar
(
Input
(
"X"
));
PADDLE_ENFORCE_NOT_NULL
(
PADDLE_ENFORCE_NOT_NULL
(
x
,
x
,
platform
::
errors
::
NotFound
(
platform
::
errors
::
InvalidArgument
(
"Input(X) of ReadFromArrayOp is not found."
));
"X(Input Variable) must be set when we call read array operation"
));
auto
&
x_array
=
x
->
Get
<
framework
::
LoDTensorArray
>
();
auto
&
x_array
=
x
->
Get
<
framework
::
LoDTensorArray
>
();
auto
*
out
=
scope
.
FindVar
(
Output
(
"Out"
));
auto
*
out
=
scope
.
FindVar
(
Output
(
"Out"
));
PADDLE_ENFORCE_NOT_NULL
(
out
,
platform
::
errors
::
InvalidArgument
(
PADDLE_ENFORCE_NOT_NULL
(
"Out(Output Varibale) must be set when we "
out
,
platform
::
errors
::
NotFound
(
"call read array operation
"
));
"Output(Out) of ReadFromArrayOp is not found.
"
));
size_t
offset
=
GetOffset
(
scope
,
place
);
size_t
offset
=
GetOffset
(
scope
,
place
);
if
(
offset
<
x_array
.
size
())
{
if
(
offset
<
x_array
.
size
())
{
auto
*
out_tensor
=
out
->
GetMutable
<
framework
::
LoDTensor
>
();
auto
*
out_tensor
=
out
->
GetMutable
<
framework
::
LoDTensor
>
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录