Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
b73a70d6
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看板
未验证
提交
b73a70d6
编写于
4月 07, 2022
作者:
0
0x45f
提交者:
GitHub
4月 07, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix eager try catch (#41438) (#41477)
[Cherry-Pick]Fix eager try catch (#41438)
上级
e34042af
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
13 addition
and
11 deletion
+13
-11
paddle/fluid/pybind/eager.cc
paddle/fluid/pybind/eager.cc
+3
-1
paddle/fluid/pybind/eager_properties.cc
paddle/fluid/pybind/eager_properties.cc
+4
-4
paddle/fluid/pybind/eager_py_layer.cc
paddle/fluid/pybind/eager_py_layer.cc
+4
-4
paddle/fluid/pybind/exception.h
paddle/fluid/pybind/exception.h
+2
-2
未找到文件。
paddle/fluid/pybind/eager.cc
浏览文件 @
b73a70d6
...
...
@@ -409,6 +409,7 @@ void AutoInitTensorByTensor(TensorObject* py_tensor_ptr,
* ** name: std::string)
* **/
int
TensorInit
(
PyObject
*
self
,
PyObject
*
args
,
PyObject
*
kwargs
)
{
EAGER_TRY
// set a flag to record use kwargs or not
bool
flag_kwargs
=
false
;
if
(
kwargs
)
flag_kwargs
=
true
;
...
...
@@ -703,7 +704,8 @@ int TensorInit(PyObject* self, PyObject* args, PyObject* kwargs) {
"make sure u call the existed constructor."
));
}
return
1
;
return
-
1
;
EAGER_CATCH_AND_THROW_RETURN_NEG
}
static
void
TensorDealloc
(
TensorObject
*
self
)
{
...
...
paddle/fluid/pybind/eager_properties.cc
浏览文件 @
b73a70d6
...
...
@@ -69,7 +69,7 @@ int tensor_properties_set_name(TensorObject* self, PyObject* value,
EAGER_TRY
self
->
tensor
.
set_name
(
CastPyArg2AttrString
(
value
,
0
));
return
0
;
EAGER_CATCH_AND_THROW_RETURN_
ZERO
EAGER_CATCH_AND_THROW_RETURN_
NEG
}
PyObject
*
tensor_properties_get_stop_gradient
(
TensorObject
*
self
,
...
...
@@ -110,7 +110,7 @@ int tensor_properties_set_grad(TensorObject* self, PyObject* value,
"the grad inside autograd_meta"
));
grad
->
copy_
(
src
,
self
->
tensor
.
inner_place
(),
true
);
return
0
;
EAGER_CATCH_AND_THROW_RETURN_
ZERO
EAGER_CATCH_AND_THROW_RETURN_
NEG
}
int
tensor_properties_set_stop_gradient
(
TensorObject
*
self
,
PyObject
*
value
,
...
...
@@ -122,7 +122,7 @@ int tensor_properties_set_stop_gradient(TensorObject* self, PyObject* value,
meta
->
SetGradNode
(
std
::
make_shared
<
egr
::
GradNodeAccumulation
>
(
meta
));
}
return
0
;
EAGER_CATCH_AND_THROW_RETURN_
ZERO
EAGER_CATCH_AND_THROW_RETURN_
NEG
}
PyObject
*
tensor_properties_get_persistable
(
TensorObject
*
self
,
void
*
closure
)
{
...
...
@@ -138,7 +138,7 @@ int tensor_properties_set_persistable(TensorObject* self, PyObject* value,
auto
meta
=
egr
::
EagerUtils
::
autograd_meta
(
&
self
->
tensor
);
meta
->
SetPersistable
(
CastPyArg2AttrBoolean
(
value
,
0
));
return
0
;
EAGER_CATCH_AND_THROW_RETURN_
ZERO
EAGER_CATCH_AND_THROW_RETURN_
NEG
}
PyObject
*
tensor_properties_get_shape
(
TensorObject
*
self
,
void
*
closure
)
{
...
...
paddle/fluid/pybind/eager_py_layer.cc
浏览文件 @
b73a70d6
...
...
@@ -395,7 +395,7 @@ int tensor_properties_set_container(PyLayerObject* self, PyObject* value,
Py_XDECREF
(
self
->
container
);
self
->
container
=
value
;
return
0
;
EAGER_CATCH_AND_THROW_RETURN_
ZERO
EAGER_CATCH_AND_THROW_RETURN_
NEG
}
PyObject
*
tensor_properties_get_non_differentiable
(
PyLayerObject
*
self
,
...
...
@@ -417,7 +417,7 @@ int tensor_properties_set_non_differentiable(PyLayerObject* self,
Py_XDECREF
(
self
->
non_differentiable
);
self
->
non_differentiable
=
value
;
return
0
;
EAGER_CATCH_AND_THROW_RETURN_
ZERO
EAGER_CATCH_AND_THROW_RETURN_
NEG
}
PyObject
*
tensor_properties_get_dirty_tensors
(
PyLayerObject
*
self
,
...
...
@@ -439,7 +439,7 @@ int tensor_properties_set_dirty_tensors(PyLayerObject* self, PyObject* value,
Py_XDECREF
(
self
->
dirty_tensors
);
self
->
dirty_tensors
=
value
;
return
0
;
EAGER_CATCH_AND_THROW_RETURN_
ZERO
EAGER_CATCH_AND_THROW_RETURN_
NEG
}
int
tensor_properties_set_materialize_grads
(
PyLayerObject
*
self
,
...
...
@@ -447,7 +447,7 @@ int tensor_properties_set_materialize_grads(PyLayerObject* self,
EAGER_TRY
self
->
materialize_grads
=
CastPyArg2AttrBoolean
(
value
,
0
);
return
0
;
EAGER_CATCH_AND_THROW_RETURN_
ZERO
EAGER_CATCH_AND_THROW_RETURN_
NEG
}
PyMethodDef
pylayer_methods
[]
=
{
...
...
paddle/fluid/pybind/exception.h
浏览文件 @
b73a70d6
...
...
@@ -26,11 +26,11 @@ limitations under the License. */
return nullptr; \
}
#define EAGER_CATCH_AND_THROW_RETURN_
ZERO
\
#define EAGER_CATCH_AND_THROW_RETURN_
NEG
\
} \
catch (...) { \
ThrowExceptionToPython(std::current_exception()); \
return
0;
\
return
-1;
\
}
namespace
paddle
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录