Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
c7ae6c62
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
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看板
未验证
提交
c7ae6c62
编写于
10月 12, 2019
作者:
G
Guo Sheng
提交者:
GitHub
10月 12, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix the assign data check (#20564)
* Fix the assign data check. test=develop * Fix test_assign_op.py. test=develop
上级
7faa3e95
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
4 addition
and
6 deletion
+4
-6
python/paddle/fluid/layers/tensor.py
python/paddle/fluid/layers/tensor.py
+3
-3
python/paddle/fluid/tests/unittests/test_assign_op.py
python/paddle/fluid/tests/unittests/test_assign_op.py
+1
-3
未找到文件。
python/paddle/fluid/layers/tensor.py
浏览文件 @
c7ae6c62
...
@@ -455,12 +455,12 @@ def assign(input, output=None):
...
@@ -455,12 +455,12 @@ def assign(input, output=None):
helper
=
LayerHelper
(
'assign'
,
**
locals
())
helper
=
LayerHelper
(
'assign'
,
**
locals
())
if
isinstance
(
input
,
Variable
):
if
isinstance
(
input
,
Variable
):
if
convert_dtype
(
input
.
dtype
)
not
in
[
if
convert_dtype
(
input
.
dtype
)
not
in
[
'float32'
,
'float64'
,
'int32'
,
'int64'
'float32'
,
'float64'
,
'int32'
,
'int64'
,
'bool'
]:
]:
raise
TypeError
(
raise
TypeError
(
"When the type of 'input' in assign is Variable, the data "
"When the type of 'input' in assign is Variable, the data "
"type of 'input' must be float32, float64, int32
or int64,
"
"type of 'input' must be float32, float64, int32
, int64 or
"
"but received %s."
%
convert_dtype
(
input
.
dtype
))
"b
ool, b
ut received %s."
%
convert_dtype
(
input
.
dtype
))
if
output
is
None
:
if
output
is
None
:
output
=
helper
.
create_variable_for_type_inference
(
output
=
helper
.
create_variable_for_type_inference
(
dtype
=
input
.
dtype
)
dtype
=
input
.
dtype
)
...
...
python/paddle/fluid/tests/unittests/test_assign_op.py
浏览文件 @
c7ae6c62
...
@@ -44,9 +44,7 @@ class TestAssignOpError(op_test.OpTest):
...
@@ -44,9 +44,7 @@ class TestAssignOpError(op_test.OpTest):
x1
=
fluid
.
create_lod_tensor
(
x1
=
fluid
.
create_lod_tensor
(
np
.
array
([[
-
1
]]),
[[
1
]],
fluid
.
CPUPlace
())
np
.
array
([[
-
1
]]),
[[
1
]],
fluid
.
CPUPlace
())
self
.
assertRaises
(
TypeError
,
fluid
.
layers
.
assign
,
x1
)
self
.
assertRaises
(
TypeError
,
fluid
.
layers
.
assign
,
x1
)
# When the type of input is Variable, the dtype of input must be float32, float64, int32, int64.
# When the type of input is Variable, the dtype of input must be float32, float64, int32, int64, bool.
x2
=
fluid
.
layers
.
data
(
name
=
'x2'
,
shape
=
[
4
],
dtype
=
"bool"
)
self
.
assertRaises
(
TypeError
,
fluid
.
layers
.
assign
,
x2
)
x3
=
fluid
.
layers
.
data
(
name
=
'x3'
,
shape
=
[
4
],
dtype
=
"float16"
)
x3
=
fluid
.
layers
.
data
(
name
=
'x3'
,
shape
=
[
4
],
dtype
=
"float16"
)
self
.
assertRaises
(
TypeError
,
fluid
.
layers
.
assign
,
x3
)
self
.
assertRaises
(
TypeError
,
fluid
.
layers
.
assign
,
x3
)
x4
=
fluid
.
layers
.
data
(
name
=
'x4'
,
shape
=
[
4
],
dtype
=
"uint8"
)
x4
=
fluid
.
layers
.
data
(
name
=
'x4'
,
shape
=
[
4
],
dtype
=
"uint8"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录