Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
01baa0b6
P
Paddle
项目概览
机器未来
/
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看板
未验证
提交
01baa0b6
编写于
10月 12, 2022
作者:
W
Weilong Wu
提交者:
GitHub
10月 12, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Eager] polish the place setting code (#46840)
上级
67c9b0b3
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
49 addition
and
37 deletion
+49
-37
paddle/fluid/pybind/eager_math_op_patch.cc
paddle/fluid/pybind/eager_math_op_patch.cc
+49
-37
未找到文件。
paddle/fluid/pybind/eager_math_op_patch.cc
浏览文件 @
01baa0b6
...
...
@@ -195,8 +195,8 @@ static PyObject* tensor__add__method(TensorObject* self,
CastPyArg2Scalar
(
other_obj
,
"__add__"
,
0
);
{
eager_gil_scoped_release
guard
;
other_tensor
=
full_ad_func
(
self_tensor
.
shape
(),
value
,
self_tensor
.
dtype
(),
place
);
other_tensor
=
full_ad_func
(
self_tensor
.
shape
(),
value
,
self_tensor
.
dtype
(),
self_tensor
.
place
()
);
}
}
else
{
other_tensor
=
CastPyArg2Tensor
(
other_obj
,
0
);
...
...
@@ -292,8 +292,8 @@ static PyObject* tensor__sub__method(TensorObject* self,
CastPyArg2Scalar
(
other_obj
,
"__sub__"
,
0
);
{
eager_gil_scoped_release
guard
;
other_tensor
=
full_ad_func
(
self_tensor
.
shape
(),
value
,
self_tensor
.
dtype
(),
place
);
other_tensor
=
full_ad_func
(
self_tensor
.
shape
(),
value
,
self_tensor
.
dtype
(),
self_tensor
.
place
()
);
}
}
else
{
other_tensor
=
CastPyArg2Tensor
(
other_obj
,
0
);
...
...
@@ -385,8 +385,8 @@ static PyObject* tensor__rsub__method(TensorObject* self,
CastPyArg2Scalar
(
other_obj
,
"__rsub__"
,
0
);
{
eager_gil_scoped_release
guard
;
other_tensor
=
full_ad_func
(
self_tensor
.
shape
(),
value
,
self_tensor
.
dtype
(),
place
);
other_tensor
=
full_ad_func
(
self_tensor
.
shape
(),
value
,
self_tensor
.
dtype
(),
self_tensor
.
place
()
);
}
}
else
{
other_tensor
=
CastPyArg2Tensor
(
other_obj
,
0
);
...
...
@@ -480,11 +480,12 @@ static PyObject* tensor__mul__method(TensorObject* self,
CastPyArg2Scalar
(
other_obj
,
"__mul__"
,
0
);
if
(
PyComplex_Check
(
other_obj
))
{
eager_gil_scoped_release
guard
;
other_tensor
=
full_ad_func
({
1
},
value
,
DataType
::
COMPLEX64
,
place
);
other_tensor
=
full_ad_func
({
1
},
value
,
DataType
::
COMPLEX64
,
self_tensor
.
place
());
}
else
{
eager_gil_scoped_release
guard
;
other_tensor
=
full_ad_func
(
self_tensor
.
shape
(),
value
,
self_tensor
.
dtype
(),
place
);
other_tensor
=
full_ad_func
(
self_tensor
.
shape
(),
value
,
self_tensor
.
dtype
(),
self_tensor
.
place
()
);
}
}
else
{
other_tensor
=
CastPyArg2Tensor
(
other_obj
,
0
);
...
...
@@ -581,11 +582,12 @@ static PyObject* tensor__div__method(TensorObject* self,
CastPyArg2Scalar
(
other_obj
,
"__div__"
,
0
);
if
(
PyComplex_Check
(
other_obj
))
{
eager_gil_scoped_release
guard
;
other_tensor
=
full_ad_func
({
1
},
value
,
DataType
::
COMPLEX64
,
place
);
other_tensor
=
full_ad_func
({
1
},
value
,
DataType
::
COMPLEX64
,
self_tensor
.
place
());
}
else
{
eager_gil_scoped_release
guard
;
other_tensor
=
full_ad_func
(
self_tensor
.
shape
(),
value
,
self_tensor
.
dtype
(),
place
);
other_tensor
=
full_ad_func
(
self_tensor
.
shape
(),
value
,
self_tensor
.
dtype
(),
self_tensor
.
place
()
);
}
}
else
{
other_tensor
=
CastPyArg2Tensor
(
other_obj
,
0
);
...
...
@@ -696,11 +698,12 @@ static PyObject* tensor__rdiv__method(TensorObject* self,
CastPyArg2Scalar
(
other_obj
,
"__rdiv__"
,
0
);
if
(
PyComplex_Check
(
other_obj
))
{
eager_gil_scoped_release
guard
;
other_tensor
=
full_ad_func
({
1
},
value
,
DataType
::
COMPLEX64
,
place
);
other_tensor
=
full_ad_func
({
1
},
value
,
DataType
::
COMPLEX64
,
self_tensor
.
place
());
}
else
{
eager_gil_scoped_release
guard
;
other_tensor
=
full_ad_func
(
self_tensor
.
shape
(),
value
,
self_tensor
.
dtype
(),
place
);
other_tensor
=
full_ad_func
(
self_tensor
.
shape
(),
value
,
self_tensor
.
dtype
(),
self_tensor
.
place
()
);
}
}
else
{
other_tensor
=
CastPyArg2Tensor
(
other_obj
,
0
);
...
...
@@ -809,11 +812,12 @@ static PyObject* tensor__gt__method(TensorObject* self,
CastPyArg2Scalar
(
other_obj
,
"__gt__"
,
0
);
if
(
PyComplex_Check
(
other_obj
))
{
eager_gil_scoped_release
guard
;
other_tensor
=
full_ad_func
({
1
},
value
,
DataType
::
COMPLEX64
,
place
);
other_tensor
=
full_ad_func
({
1
},
value
,
DataType
::
COMPLEX64
,
self_tensor
.
place
());
}
else
{
eager_gil_scoped_release
guard
;
other_tensor
=
full_ad_func
(
self_tensor
.
shape
(),
value
,
self_tensor
.
dtype
(),
place
);
other_tensor
=
full_ad_func
(
self_tensor
.
shape
(),
value
,
self_tensor
.
dtype
(),
self_tensor
.
place
()
);
}
}
else
{
other_tensor
=
CastPyArg2Tensor
(
other_obj
,
0
);
...
...
@@ -894,11 +898,12 @@ static PyObject* tensor__ge__method(TensorObject* self,
CastPyArg2Scalar
(
other_obj
,
"__ge__"
,
0
);
if
(
PyComplex_Check
(
other_obj
))
{
eager_gil_scoped_release
guard
;
other_tensor
=
full_ad_func
({
1
},
value
,
DataType
::
COMPLEX64
,
place
);
other_tensor
=
full_ad_func
({
1
},
value
,
DataType
::
COMPLEX64
,
self_tensor
.
place
());
}
else
{
eager_gil_scoped_release
guard
;
other_tensor
=
full_ad_func
(
self_tensor
.
shape
(),
value
,
self_tensor
.
dtype
(),
place
);
other_tensor
=
full_ad_func
(
self_tensor
.
shape
(),
value
,
self_tensor
.
dtype
(),
self_tensor
.
place
()
);
}
}
else
{
other_tensor
=
CastPyArg2Tensor
(
other_obj
,
0
);
...
...
@@ -974,17 +979,18 @@ static PyObject* tensor__mod__method(TensorObject* self,
other_tensor
=
full_ad_func
(
self_tensor
.
shape
(),
phi
::
Scalar
(
other_float
),
self_tensor
.
dtype
(),
place
);
self_tensor
.
place
()
);
}
else
if
(
!
PyCheckTensor
(
other_obj
))
{
paddle
::
experimental
::
Scalar
value
=
CastPyArg2Scalar
(
other_obj
,
"__mod__"
,
0
);
if
(
PyComplex_Check
(
other_obj
))
{
eager_gil_scoped_release
guard
;
other_tensor
=
full_ad_func
({
1
},
value
,
DataType
::
COMPLEX64
,
place
);
other_tensor
=
full_ad_func
({
1
},
value
,
DataType
::
COMPLEX64
,
self_tensor
.
place
());
}
else
{
eager_gil_scoped_release
guard
;
other_tensor
=
full_ad_func
(
self_tensor
.
shape
(),
value
,
self_tensor
.
dtype
(),
place
);
other_tensor
=
full_ad_func
(
self_tensor
.
shape
(),
value
,
self_tensor
.
dtype
(),
self_tensor
.
place
()
);
}
}
else
{
other_tensor
=
CastPyArg2Tensor
(
other_obj
,
0
);
...
...
@@ -1056,17 +1062,21 @@ static PyObject* tensor__matmul__method(TensorObject* self,
paddle
::
experimental
::
Tensor
other_tensor
;
if
(
has_other_float
)
{
eager_gil_scoped_release
guard
;
other_tensor
=
full_ad_func
({
1
},
phi
::
Scalar
(
other_float
),
self_tensor
.
dtype
(),
place
);
other_tensor
=
full_ad_func
({
1
},
phi
::
Scalar
(
other_float
),
self_tensor
.
dtype
(),
self_tensor
.
place
());
}
else
if
(
!
PyCheckTensor
(
other_obj
))
{
paddle
::
experimental
::
Scalar
value
=
CastPyArg2Scalar
(
other_obj
,
"__matmul__"
,
0
);
if
(
PyComplex_Check
(
other_obj
))
{
eager_gil_scoped_release
guard
;
other_tensor
=
full_ad_func
({
1
},
value
,
DataType
::
COMPLEX64
,
place
);
other_tensor
=
full_ad_func
({
1
},
value
,
DataType
::
COMPLEX64
,
self_tensor
.
place
());
}
else
{
eager_gil_scoped_release
guard
;
other_tensor
=
full_ad_func
({
1
},
value
,
self_tensor
.
dtype
(),
place
);
other_tensor
=
full_ad_func
({
1
},
value
,
self_tensor
.
dtype
(),
self_tensor
.
place
());
}
}
else
{
other_tensor
=
CastPyArg2Tensor
(
other_obj
,
0
);
...
...
@@ -1159,17 +1169,18 @@ static PyObject* tensor__lt__method(TensorObject* self,
other_tensor
=
full_ad_func
(
self_tensor
.
shape
(),
phi
::
Scalar
(
other_float
),
self_tensor
.
dtype
(),
place
);
self_tensor
.
place
()
);
}
else
if
(
!
PyCheckTensor
(
other_obj
))
{
paddle
::
experimental
::
Scalar
value
=
CastPyArg2Scalar
(
other_obj
,
"__lt__"
,
0
);
if
(
PyComplex_Check
(
other_obj
))
{
eager_gil_scoped_release
guard
;
other_tensor
=
full_ad_func
({
1
},
value
,
DataType
::
COMPLEX64
,
place
);
other_tensor
=
full_ad_func
({
1
},
value
,
DataType
::
COMPLEX64
,
self_tensor
.
place
());
}
else
{
eager_gil_scoped_release
guard
;
other_tensor
=
full_ad_func
(
self_tensor
.
shape
(),
value
,
self_tensor
.
dtype
(),
place
);
other_tensor
=
full_ad_func
(
self_tensor
.
shape
(),
value
,
self_tensor
.
dtype
(),
self_tensor
.
place
()
);
}
}
else
{
other_tensor
=
CastPyArg2Tensor
(
other_obj
,
0
);
...
...
@@ -1244,17 +1255,18 @@ static PyObject* tensor__le__method(TensorObject* self,
other_tensor
=
full_ad_func
(
self_tensor
.
shape
(),
phi
::
Scalar
(
other_float
),
self_tensor
.
dtype
(),
place
);
self_tensor
.
place
()
);
}
else
if
(
!
PyCheckTensor
(
other_obj
))
{
paddle
::
experimental
::
Scalar
value
=
CastPyArg2Scalar
(
other_obj
,
"__le__"
,
0
);
if
(
PyComplex_Check
(
other_obj
))
{
eager_gil_scoped_release
guard
;
other_tensor
=
full_ad_func
({
1
},
value
,
DataType
::
COMPLEX64
,
place
);
other_tensor
=
full_ad_func
({
1
},
value
,
DataType
::
COMPLEX64
,
self_tensor
.
place
());
}
else
{
eager_gil_scoped_release
guard
;
other_tensor
=
full_ad_func
(
self_tensor
.
shape
(),
value
,
self_tensor
.
dtype
(),
place
);
other_tensor
=
full_ad_func
(
self_tensor
.
shape
(),
value
,
self_tensor
.
dtype
(),
self_tensor
.
place
()
);
}
}
else
{
other_tensor
=
CastPyArg2Tensor
(
other_obj
,
0
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录