Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
9e85d023
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
9e85d023
编写于
4月 12, 2020
作者:
Y
Yiqun Liu
提交者:
GitHub
4月 12, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Avoid crash when calling ctx->HasInputs and add the check of shape in fill_copnstant op. (#23698)
上级
ac4da77a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
25 addition
and
3 deletion
+25
-3
paddle/fluid/framework/op_desc.cc
paddle/fluid/framework/op_desc.cc
+12
-0
paddle/fluid/operators/fill_constant_op.cc
paddle/fluid/operators/fill_constant_op.cc
+10
-0
python/paddle/fluid/tests/unittests/test_rnn_decode_api.py
python/paddle/fluid/tests/unittests/test_rnn_decode_api.py
+3
-3
未找到文件。
paddle/fluid/framework/op_desc.cc
浏览文件 @
9e85d023
...
...
@@ -721,6 +721,9 @@ CompileTimeInferShapeContext::CompileTimeInferShapeContext(
:
op_
(
op
),
block_
(
block
)
{}
bool
CompileTimeInferShapeContext
::
HasInput
(
const
std
::
string
&
name
)
const
{
if
(
op_
.
Inputs
().
find
(
name
)
==
op_
.
Inputs
().
end
())
{
return
false
;
}
const
std
::
vector
<
std
::
string
>
&
input_names
=
op_
.
Input
(
name
);
auto
length
=
input_names
.
size
();
if
(
length
==
0
)
{
...
...
@@ -734,6 +737,9 @@ bool CompileTimeInferShapeContext::HasInput(const std::string &name) const {
}
bool
CompileTimeInferShapeContext
::
HasOutput
(
const
std
::
string
&
name
)
const
{
if
(
op_
.
Outputs
().
find
(
name
)
==
op_
.
Outputs
().
end
())
{
return
false
;
}
const
std
::
vector
<
std
::
string
>
&
output_names
=
op_
.
Output
(
name
);
auto
length
=
output_names
.
size
();
if
(
length
==
0
)
{
...
...
@@ -747,6 +753,9 @@ bool CompileTimeInferShapeContext::HasOutput(const std::string &name) const {
}
bool
CompileTimeInferShapeContext
::
HasInputs
(
const
std
::
string
&
name
)
const
{
if
(
op_
.
Inputs
().
find
(
name
)
==
op_
.
Inputs
().
end
())
{
return
false
;
}
const
std
::
vector
<
std
::
string
>
&
input_names
=
op_
.
Input
(
name
);
if
(
input_names
.
empty
())
{
return
false
;
...
...
@@ -758,6 +767,9 @@ bool CompileTimeInferShapeContext::HasInputs(const std::string &name) const {
}
bool
CompileTimeInferShapeContext
::
HasOutputs
(
const
std
::
string
&
name
)
const
{
if
(
op_
.
Outputs
().
find
(
name
)
==
op_
.
Outputs
().
end
())
{
return
false
;
}
const
std
::
vector
<
std
::
string
>
&
output_names
=
op_
.
Output
(
name
);
if
(
output_names
.
empty
())
{
return
false
;
...
...
paddle/fluid/operators/fill_constant_op.cc
浏览文件 @
9e85d023
...
...
@@ -25,6 +25,16 @@ class FillConstantOp : public framework::OperatorWithKernel {
OP_INOUT_CHECK
(
ctx
->
HasOutput
(
"Out"
),
"Output"
,
"Out"
,
"FillConstant"
);
auto
&
shape
=
ctx
->
Attrs
().
Get
<
std
::
vector
<
int64_t
>>
(
"shape"
);
if
(
!
ctx
->
HasInput
(
"ShapeTensor"
)
&&
!
ctx
->
HasInputs
(
"ShapeTensorList"
))
{
for
(
size_t
i
=
0
;
i
<
shape
.
size
();
++
i
)
{
PADDLE_ENFORCE_GE
(
shape
[
i
],
0
,
platform
::
errors
::
InvalidArgument
(
"Each value of attribute 'shape' is expected to be greater "
"than 0. But recieved: shape[%u] = %d; shape = [%s]."
,
i
,
shape
[
i
],
framework
::
make_ddim
(
shape
)));
}
}
if
(
shape
.
empty
()
&&
ctx
->
HasInput
(
"ShapeTensor"
))
{
auto
shape_dims
=
ctx
->
GetInputDim
(
"ShapeTensor"
);
...
...
python/paddle/fluid/tests/unittests/test_rnn_decode_api.py
浏览文件 @
9e85d023
...
...
@@ -369,11 +369,11 @@ class SeqPGAgent(object):
self
.
probs
,
self
.
samples
,
self
.
sample_length
=
self
.
model
(
source
,
source_length
,
target
,
target_length
)
self
.
samples
.
stop_gradient
=
True
self
.
reward
=
fluid
.
layers
.
create_global_var
(
self
.
reward
=
fluid
.
data
(
name
=
"reward"
,
shape
=
[
-
1
,
-
1
],
# batch_size, seq_len
value
=
"1"
,
shape
=
[
None
,
None
],
# batch_size, seq_len
dtype
=
self
.
probs
.
dtype
)
self
.
samples
.
stop_gradient
=
False
self
.
cost
=
self
.
alg
.
learn
(
self
.
probs
,
self
.
samples
,
self
.
reward
,
self
.
sample_length
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录