Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
87054fe3
P
Paddle
项目概览
PaddlePaddle
/
Paddle
接近 2 年 前同步成功
通知
2323
Star
20933
Fork
5424
代码
文件
提交
分支
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看板
未验证
提交
87054fe3
编写于
6月 20, 2023
作者:
H
HongyuJia
提交者:
GitHub
6月 20, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Fix Bug] Fix random fail of CustomOp due to python lock (#54772)
上级
46c57674
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
76 addition
and
79 deletion
+76
-79
paddle/fluid/pybind/eager_functions.cc
paddle/fluid/pybind/eager_functions.cc
+76
-79
未找到文件。
paddle/fluid/pybind/eager_functions.cc
浏览文件 @
87054fe3
...
@@ -521,11 +521,8 @@ static PyObject* eager_api_run_custom_op(PyObject* self,
...
@@ -521,11 +521,8 @@ static PyObject* eager_api_run_custom_op(PyObject* self,
std
::
string
op_type
=
CastPyArg2AttrString
(
PyTuple_GET_ITEM
(
args
,
0
),
0
);
std
::
string
op_type
=
CastPyArg2AttrString
(
PyTuple_GET_ITEM
(
args
,
0
),
0
);
VLOG
(
7
)
<<
"Get things from python for Custom Op: "
<<
op_type
;
VLOG
(
7
)
<<
"Get things from python for Custom Op: "
<<
op_type
;
paddle
::
CustomOpKernelContext
ctx
;
paddle
::
CustomOpKernelContext
ctx
;
{
eager_gil_scoped_release
guard
;
auto
meta_info_map
=
egr
::
Controller
::
Instance
().
GetOpMetaInfoMap
();
auto
meta_info_map
=
egr
::
Controller
::
Instance
().
GetOpMetaInfoMap
();
PADDLE_ENFORCE_NE
(
PADDLE_ENFORCE_NE
(
meta_info_map
.
find
(
op_type
),
meta_info_map
.
find
(
op_type
),
meta_info_map
.
end
(),
meta_info_map
.
end
(),
paddle
::
platform
::
errors
::
NotFound
(
paddle
::
platform
::
errors
::
NotFound
(
"Can't find %s in Eager OpMetaInfoMap which should be "
"Can't find %s in Eager OpMetaInfoMap which should be "
...
@@ -536,8 +533,7 @@ static PyObject* eager_api_run_custom_op(PyObject* self,
...
@@ -536,8 +533,7 @@ static PyObject* eager_api_run_custom_op(PyObject* self,
const
auto
&
inputs
=
paddle
::
OpMetaInfoHelper
::
GetInputs
(
vec_map
[
0
]);
const
auto
&
inputs
=
paddle
::
OpMetaInfoHelper
::
GetInputs
(
vec_map
[
0
]);
const
auto
&
attrs
=
paddle
::
OpMetaInfoHelper
::
GetAttrs
(
vec_map
[
0
]);
const
auto
&
attrs
=
paddle
::
OpMetaInfoHelper
::
GetAttrs
(
vec_map
[
0
]);
const
auto
&
outputs
=
paddle
::
OpMetaInfoHelper
::
GetOutputs
(
vec_map
[
0
]);
const
auto
&
outputs
=
paddle
::
OpMetaInfoHelper
::
GetOutputs
(
vec_map
[
0
]);
const
auto
&
inplace_map
=
const
auto
&
inplace_map
=
paddle
::
OpMetaInfoHelper
::
GetInplaceMap
(
vec_map
[
0
]);
paddle
::
OpMetaInfoHelper
::
GetInplaceMap
(
vec_map
[
0
]);
for
(
size_t
i
=
0
;
i
<
inputs
.
size
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
inputs
.
size
();
++
i
)
{
const
auto
&
input
=
inputs
.
at
(
i
);
const
auto
&
input
=
inputs
.
at
(
i
);
// Parse op_type first, so that use i + 1
// Parse op_type first, so that use i + 1
...
@@ -570,8 +566,7 @@ static PyObject* eager_api_run_custom_op(PyObject* self,
...
@@ -570,8 +566,7 @@ static PyObject* eager_api_run_custom_op(PyObject* self,
std
::
vector
<
std
::
string
>
attr_name_and_type
=
paddle
::
ParseAttrStr
(
attr
);
std
::
vector
<
std
::
string
>
attr_name_and_type
=
paddle
::
ParseAttrStr
(
attr
);
auto
attr_type_str
=
attr_name_and_type
[
1
];
auto
attr_type_str
=
attr_name_and_type
[
1
];
VLOG
(
7
)
<<
"Custom operator add attrs "
<<
attr_name_and_type
[
0
]
VLOG
(
7
)
<<
"Custom operator add attrs "
<<
attr_name_and_type
[
0
]
<<
" to CustomOpKernelContext. Attribute type = "
<<
" to CustomOpKernelContext. Attribute type = "
<<
attr_type_str
;
<<
attr_type_str
;
PyObject
*
obj
=
PyTuple_GET_ITEM
(
args
,
attr_start_idx
+
i
);
PyObject
*
obj
=
PyTuple_GET_ITEM
(
args
,
attr_start_idx
+
i
);
if
(
attr_type_str
==
"bool"
)
{
if
(
attr_type_str
==
"bool"
)
{
ctx
.
EmplaceBackAttr
(
CastPyArg2AttrBoolean
(
obj
,
attr_start_idx
+
i
));
ctx
.
EmplaceBackAttr
(
CastPyArg2AttrBoolean
(
obj
,
attr_start_idx
+
i
));
...
@@ -602,6 +597,8 @@ static PyObject* eager_api_run_custom_op(PyObject* self,
...
@@ -602,6 +597,8 @@ static PyObject* eager_api_run_custom_op(PyObject* self,
attr_type_str
));
attr_type_str
));
}
}
}
}
{
eager_gil_scoped_release
guard
;
ctx
.
ConstructInplaceIndex
(
inputs
,
outputs
,
inplace_map
);
ctx
.
ConstructInplaceIndex
(
inputs
,
outputs
,
inplace_map
);
const
auto
&
inplace_reverse_idx_map
=
ctx
.
GetInplaceReverseIndexMap
();
const
auto
&
inplace_reverse_idx_map
=
ctx
.
GetInplaceReverseIndexMap
();
for
(
size_t
out_idx
=
0
;
out_idx
<
outputs
.
size
();
++
out_idx
)
{
for
(
size_t
out_idx
=
0
;
out_idx
<
outputs
.
size
();
++
out_idx
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录