Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
ac4a422d
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看板
未验证
提交
ac4a422d
编写于
4月 04, 2022
作者:
A
Aurelius84
提交者:
GitHub
4月 04, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Eager]Fix tile API final_state and Backward bug (#41385)
* [Eager]Fix tile API final_state bug * fix backward bug
上级
489b8a88
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
14 addition
and
3 deletion
+14
-3
paddle/fluid/eager/backward.cc
paddle/fluid/eager/backward.cc
+3
-3
paddle/fluid/pybind/eager_utils.cc
paddle/fluid/pybind/eager_utils.cc
+6
-0
python/paddle/tensor/manipulation.py
python/paddle/tensor/manipulation.py
+5
-0
未找到文件。
paddle/fluid/eager/backward.cc
浏览文件 @
ac4a422d
...
@@ -580,8 +580,9 @@ std::vector<paddle::experimental::Tensor> RunBackward(
...
@@ -580,8 +580,9 @@ std::vector<paddle::experimental::Tensor> RunBackward(
node_input_buffers_dict
[
grad_node
]
=
node_input_buffers_dict
[
grad_node
]
=
std
::
make_unique
<
GradTensorHolder
>
(
grad_node
->
InputMeta
());
std
::
make_unique
<
GradTensorHolder
>
(
grad_node
->
InputMeta
());
}
}
bool
copy_from_grad_t
=
if
(
grad_tensors
.
size
()
>
0
)
{
grad_tensors
.
size
()
>
0
&&
grad_tensors
[
i
].
initialized
();
if
(
copy_from_grad_t
)
{
PADDLE_ENFORCE
(
PADDLE_ENFORCE
(
grad_tensors
.
size
()
==
tensors
.
size
(),
grad_tensors
.
size
()
==
tensors
.
size
(),
paddle
::
platform
::
errors
::
Fatal
(
paddle
::
platform
::
errors
::
Fatal
(
...
@@ -594,7 +595,6 @@ std::vector<paddle::experimental::Tensor> RunBackward(
...
@@ -594,7 +595,6 @@ std::vector<paddle::experimental::Tensor> RunBackward(
// Deep copy
// Deep copy
node_input_buffers_dict
[
grad_node
]
->
CopyValueFromTensor
(
node_input_buffers_dict
[
grad_node
]
->
CopyValueFromTensor
(
input_info
.
first
,
input_info
.
second
,
grad_tensors
[
i
]);
input_info
.
first
,
input_info
.
second
,
grad_tensors
[
i
]);
}
else
{
}
else
{
VLOG
(
6
)
<<
"Fill grad input tensor "
<<
i
<<
" with 1.0"
;
VLOG
(
6
)
<<
"Fill grad input tensor "
<<
i
<<
" with 1.0"
;
// Initialize tensor with 1.0
// Initialize tensor with 1.0
...
...
paddle/fluid/pybind/eager_utils.cc
浏览文件 @
ac4a422d
...
@@ -213,6 +213,9 @@ std::vector<paddle::experimental::Tensor> CastPyArg2VectorOfTensor(
...
@@ -213,6 +213,9 @@ std::vector<paddle::experimental::Tensor> CastPyArg2VectorOfTensor(
if
(
PyObject_IsInstance
(
item
,
if
(
PyObject_IsInstance
(
item
,
reinterpret_cast
<
PyObject
*>
(
p_tensor_type
)))
{
reinterpret_cast
<
PyObject
*>
(
p_tensor_type
)))
{
result
.
emplace_back
(
reinterpret_cast
<
TensorObject
*>
(
item
)
->
tensor
);
result
.
emplace_back
(
reinterpret_cast
<
TensorObject
*>
(
item
)
->
tensor
);
}
else
if
(
item
==
Py_None
)
{
// emplace empty Tensor for None
result
.
emplace_back
();
}
else
{
}
else
{
PADDLE_THROW
(
platform
::
errors
::
InvalidArgument
(
PADDLE_THROW
(
platform
::
errors
::
InvalidArgument
(
"argument (position %d) must be "
"argument (position %d) must be "
...
@@ -229,6 +232,9 @@ std::vector<paddle::experimental::Tensor> CastPyArg2VectorOfTensor(
...
@@ -229,6 +232,9 @@ std::vector<paddle::experimental::Tensor> CastPyArg2VectorOfTensor(
if
(
PyObject_IsInstance
(
item
,
if
(
PyObject_IsInstance
(
item
,
reinterpret_cast
<
PyObject
*>
(
p_tensor_type
)))
{
reinterpret_cast
<
PyObject
*>
(
p_tensor_type
)))
{
result
.
emplace_back
(
reinterpret_cast
<
TensorObject
*>
(
item
)
->
tensor
);
result
.
emplace_back
(
reinterpret_cast
<
TensorObject
*>
(
item
)
->
tensor
);
}
else
if
(
item
==
Py_None
)
{
// emplace empty Tensor for None
result
.
emplace_back
();
}
else
{
}
else
{
PADDLE_THROW
(
platform
::
errors
::
InvalidArgument
(
PADDLE_THROW
(
platform
::
errors
::
InvalidArgument
(
"argument (position %d) must be "
"argument (position %d) must be "
...
...
python/paddle/tensor/manipulation.py
浏览文件 @
ac4a422d
...
@@ -1751,6 +1751,11 @@ def tile(x, repeat_times, name=None):
...
@@ -1751,6 +1751,11 @@ def tile(x, repeat_times, name=None):
# [[1, 2, 3, 1, 2, 3]]
# [[1, 2, 3, 1, 2, 3]]
"""
"""
if
in_dygraph_mode
():
if
in_dygraph_mode
():
if
isinstance
(
repeat_times
,
core
.
eager
.
Tensor
):
assert
(
repeat_times
.
ndim
==
1
,
"Only support ndim == 1 while repeat_times is a Tensor."
)
repeat_times
=
repeat_times
.
numpy
().
tolist
()
return
_C_ops
.
final_state_tile
(
x
,
repeat_times
)
return
_C_ops
.
final_state_tile
(
x
,
repeat_times
)
if
_in_legacy_dygraph
():
if
_in_legacy_dygraph
():
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录