Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
吃玉米的猫
Paddle
提交
7b9fcaca
P
Paddle
项目概览
吃玉米的猫
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
0
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
7b9fcaca
编写于
4月 14, 2021
作者:
C
Chen Weihang
提交者:
GitHub
4月 14, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add marco cond for multi function (#32239)
上级
63abd500
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
68 addition
and
32 deletion
+68
-32
paddle/fluid/platform/complex128.h
paddle/fluid/platform/complex128.h
+34
-16
paddle/fluid/platform/complex64.h
paddle/fluid/platform/complex64.h
+34
-16
未找到文件。
paddle/fluid/platform/complex128.h
浏览文件 @
7b9fcaca
...
...
@@ -47,6 +47,10 @@
#define HOST
#endif
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
#define PADDLE_WITH_CUDA_OR_HIP_COMPLEX128
#endif
namespace
paddle
{
namespace
platform
{
...
...
@@ -217,7 +221,8 @@ struct PADDLE_ALIGN(16) complex128 {
HOSTDEVICE
inline
complex128
operator
+
(
const
complex128
&
a
,
const
complex128
&
b
)
{
#if defined(__CUDA_ARCH__) || defined(__HIPCC__)
#if defined(PADDLE_WITH_CUDA_OR_HIP_COMPLEX128) && \
(defined(__CUDA_ARCH__) || defined(__HIPCC__))
return
complex128
(
thrust
::
complex
<
double
>
(
a
.
real
,
a
.
imag
)
+
thrust
::
complex
<
double
>
(
b
.
real
,
b
.
imag
));
#else
...
...
@@ -227,7 +232,8 @@ HOSTDEVICE inline complex128 operator+(const complex128& a,
HOSTDEVICE
inline
complex128
operator
-
(
const
complex128
&
a
,
const
complex128
&
b
)
{
#if defined(__CUDA_ARCH__) || defined(__HIPCC__)
#if defined(PADDLE_WITH_CUDA_OR_HIP_COMPLEX128) && \
(defined(__CUDA_ARCH__) || defined(__HIPCC__))
return
complex128
(
thrust
::
complex
<
double
>
(
a
.
real
,
a
.
imag
)
-
thrust
::
complex
<
double
>
(
b
.
real
,
b
.
imag
));
#else
...
...
@@ -237,7 +243,8 @@ HOSTDEVICE inline complex128 operator-(const complex128& a,
HOSTDEVICE
inline
complex128
operator
*
(
const
complex128
&
a
,
const
complex128
&
b
)
{
#if defined(__CUDA_ARCH__) || defined(__HIPCC__)
#if defined(PADDLE_WITH_CUDA_OR_HIP_COMPLEX128) && \
(defined(__CUDA_ARCH__) || defined(__HIPCC__))
return
complex128
(
thrust
::
complex
<
double
>
(
a
.
real
,
a
.
imag
)
*
thrust
::
complex
<
double
>
(
b
.
real
,
b
.
imag
));
#else
...
...
@@ -248,7 +255,8 @@ HOSTDEVICE inline complex128 operator*(const complex128& a,
HOSTDEVICE
inline
complex128
operator
/
(
const
complex128
&
a
,
const
complex128
&
b
)
{
#if defined(__CUDA_ARCH__) || defined(__HIPCC__)
#if defined(PADDLE_WITH_CUDA_OR_HIP_COMPLEX128) && \
(defined(__CUDA_ARCH__) || defined(__HIPCC__))
return
complex128
(
thrust
::
complex
<
double
>
(
a
.
real
,
a
.
imag
)
/
thrust
::
complex
<
double
>
(
b
.
real
,
b
.
imag
));
#else
...
...
@@ -259,7 +267,8 @@ HOSTDEVICE inline complex128 operator/(const complex128& a,
}
HOSTDEVICE
inline
complex128
operator
-
(
const
complex128
&
a
)
{
#if defined(__CUDA_ARCH__) || defined(__HIPCC__)
#if defined(PADDLE_WITH_CUDA_OR_HIP_COMPLEX128) && \
(defined(__CUDA_ARCH__) || defined(__HIPCC__))
return
complex128
(
-
thrust
::
complex
<
double
>
(
a
.
real
,
a
.
imag
));
#else
complex128
res
;
...
...
@@ -271,7 +280,8 @@ HOSTDEVICE inline complex128 operator-(const complex128& a) {
HOSTDEVICE
inline
complex128
&
operator
+=
(
complex128
&
a
,
// NOLINT
const
complex128
&
b
)
{
#if defined(__CUDA_ARCH__) || defined(__HIPCC__)
#if defined(PADDLE_WITH_CUDA_OR_HIP_COMPLEX128) && \
(defined(__CUDA_ARCH__) || defined(__HIPCC__))
a
=
complex128
(
thrust
::
complex
<
double
>
(
a
.
real
,
a
.
imag
)
+=
thrust
::
complex
<
double
>
(
b
.
real
,
b
.
imag
));
return
a
;
...
...
@@ -284,7 +294,8 @@ HOSTDEVICE inline complex128& operator+=(complex128& a, // NOLINT
HOSTDEVICE
inline
complex128
&
operator
-=
(
complex128
&
a
,
// NOLINT
const
complex128
&
b
)
{
#if defined(__CUDA_ARCH__) || defined(__HIPCC__)
#if defined(PADDLE_WITH_CUDA_OR_HIP_COMPLEX128) && \
(defined(__CUDA_ARCH__) || defined(__HIPCC__))
a
=
complex128
(
thrust
::
complex
<
double
>
(
a
.
real
,
a
.
imag
)
-=
thrust
::
complex
<
double
>
(
b
.
real
,
b
.
imag
));
return
a
;
...
...
@@ -297,7 +308,8 @@ HOSTDEVICE inline complex128& operator-=(complex128& a, // NOLINT
HOSTDEVICE
inline
complex128
&
operator
*=
(
complex128
&
a
,
// NOLINT
const
complex128
&
b
)
{
#if defined(__CUDA_ARCH__) || defined(__HIPCC__)
#if defined(PADDLE_WITH_CUDA_OR_HIP_COMPLEX128) && \
(defined(__CUDA_ARCH__) || defined(__HIPCC__))
a
=
complex128
(
thrust
::
complex
<
double
>
(
a
.
real
,
a
.
imag
)
*=
thrust
::
complex
<
double
>
(
b
.
real
,
b
.
imag
));
return
a
;
...
...
@@ -310,7 +322,8 @@ HOSTDEVICE inline complex128& operator*=(complex128& a, // NOLINT
HOSTDEVICE
inline
complex128
&
operator
/=
(
complex128
&
a
,
// NOLINT
const
complex128
&
b
)
{
#if defined(__CUDA_ARCH__) || defined(__HIPCC__)
#if defined(PADDLE_WITH_CUDA_OR_HIP_COMPLEX128) && \
(defined(__CUDA_ARCH__) || defined(__HIPCC__))
a
=
complex128
(
thrust
::
complex
<
double
>
(
a
.
real
,
a
.
imag
)
/=
thrust
::
complex
<
double
>
(
b
.
real
,
b
.
imag
));
return
a
;
...
...
@@ -353,7 +366,7 @@ HOSTDEVICE inline bool operator>=(const complex128& a, const complex128& b) {
}
HOSTDEVICE
inline
bool
(
isnan
)(
const
complex128
&
a
)
{
#if defined(__CUDA_ARCH__)
#if defined(
PADDLE_WITH_CUDA) && defined(
__CUDA_ARCH__)
// __isnanf not supported on HIP platform
return
__isnan
(
a
.
real
)
||
__isnan
(
a
.
imag
);
#else
...
...
@@ -362,7 +375,7 @@ HOSTDEVICE inline bool(isnan)(const complex128& a) {
}
HOSTDEVICE
inline
bool
(
isinf
)(
const
complex128
&
a
)
{
#if defined(__CUDA_ARCH__)
#if defined(
PADDLE_WITH_CUDA) && defined(
__CUDA_ARCH__)
// __isinf not supported on HIP platform
return
__isinf
(
a
.
real
)
||
__isinf
(
a
.
imag
);
#else
...
...
@@ -375,7 +388,8 @@ HOSTDEVICE inline bool(isfinite)(const complex128& a) {
}
HOSTDEVICE
inline
double
(
abs
)(
const
complex128
&
a
)
{
#if defined(__CUDA_ARCH__) || defined(__HIPCC__)
#if defined(PADDLE_WITH_CUDA_OR_HIP_COMPLEX128) && \
(defined(__CUDA_ARCH__) || defined(__HIPCC__))
return
thrust
::
abs
(
thrust
::
complex
<
double
>
(
a
.
real
,
a
.
imag
));
#else
return
std
::
abs
(
std
::
complex
<
double
>
(
a
.
real
,
a
.
imag
));
...
...
@@ -383,7 +397,8 @@ HOSTDEVICE inline double(abs)(const complex128& a) {
}
HOSTDEVICE
inline
complex128
(
pow
)(
const
complex128
&
a
,
const
complex128
&
b
)
{
#if defined(__CUDA_ARCH__) || defined(__HIPCC__)
#if defined(PADDLE_WITH_CUDA_OR_HIP_COMPLEX128) && \
(defined(__CUDA_ARCH__) || defined(__HIPCC__))
return
complex128
(
thrust
::
pow
(
thrust
::
complex
<
double
>
(
a
.
real
,
a
.
imag
),
thrust
::
complex
<
double
>
(
b
.
real
,
b
.
imag
)));
#else
...
...
@@ -392,7 +407,8 @@ HOSTDEVICE inline complex128(pow)(const complex128& a, const complex128& b) {
}
HOSTDEVICE
inline
complex128
(
sqrt
)(
const
complex128
&
a
)
{
#if defined(__CUDA_ARCH__) || defined(__HIPCC__)
#if defined(PADDLE_WITH_CUDA_OR_HIP_COMPLEX128) && \
(defined(__CUDA_ARCH__) || defined(__HIPCC__))
return
complex128
(
thrust
::
sqrt
(
thrust
::
complex
<
double
>
(
a
.
real
,
a
.
imag
)));
#else
return
std
::
sqrt
(
std
::
complex
<
double
>
(
a
));
...
...
@@ -400,7 +416,8 @@ HOSTDEVICE inline complex128(sqrt)(const complex128& a) {
}
HOSTDEVICE
inline
complex128
(
tanh
)(
const
complex128
&
a
)
{
#if defined(__CUDA_ARCH__) || defined(__HIPCC__)
#if defined(PADDLE_WITH_CUDA_OR_HIP_COMPLEX128) && \
(defined(__CUDA_ARCH__) || defined(__HIPCC__))
return
complex128
(
thrust
::
tanh
(
thrust
::
complex
<
double
>
(
a
.
real
,
a
.
imag
)));
#else
return
std
::
tanh
(
std
::
complex
<
double
>
(
a
));
...
...
@@ -408,7 +425,8 @@ HOSTDEVICE inline complex128(tanh)(const complex128& a) {
}
HOSTDEVICE
inline
complex128
(
log
)(
const
complex128
&
a
)
{
#if defined(__CUDA_ARCH__) || defined(__HIPCC__)
#if defined(PADDLE_WITH_CUDA_OR_HIP_COMPLEX128) && \
(defined(__CUDA_ARCH__) || defined(__HIPCC__))
return
complex128
(
thrust
::
log
(
thrust
::
complex
<
double
>
(
a
.
real
,
a
.
imag
)));
#else
return
complex128
(
std
::
log
(
std
::
complex
<
double
>
(
a
)));
...
...
paddle/fluid/platform/complex64.h
浏览文件 @
7b9fcaca
...
...
@@ -47,6 +47,10 @@
#define HOST
#endif
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
#define PADDLE_WITH_CUDA_OR_HIP_COMPLEX64
#endif
#include "complex128.h" // NOLINT
namespace
paddle
{
...
...
@@ -224,7 +228,8 @@ struct PADDLE_ALIGN(8) complex64 {
};
HOSTDEVICE
inline
complex64
operator
+
(
const
complex64
&
a
,
const
complex64
&
b
)
{
#if defined(__CUDA_ARCH__) || defined(__HIPCC__)
#if defined(PADDLE_WITH_CUDA_OR_HIP_COMPLEX64) && \
(defined(__CUDA_ARCH__) || defined(__HIPCC__))
return
complex64
(
thrust
::
complex
<
float
>
(
a
.
real
,
a
.
imag
)
+
thrust
::
complex
<
float
>
(
b
.
real
,
b
.
imag
));
#else
...
...
@@ -233,7 +238,8 @@ HOSTDEVICE inline complex64 operator+(const complex64& a, const complex64& b) {
}
HOSTDEVICE
inline
complex64
operator
-
(
const
complex64
&
a
,
const
complex64
&
b
)
{
#if defined(__CUDA_ARCH__) || defined(__HIPCC__)
#if defined(PADDLE_WITH_CUDA_OR_HIP_COMPLEX64) && \
(defined(__CUDA_ARCH__) || defined(__HIPCC__))
return
complex64
(
thrust
::
complex
<
float
>
(
a
.
real
,
a
.
imag
)
-
thrust
::
complex
<
float
>
(
b
.
real
,
b
.
imag
));
#else
...
...
@@ -242,7 +248,8 @@ HOSTDEVICE inline complex64 operator-(const complex64& a, const complex64& b) {
}
HOSTDEVICE
inline
complex64
operator
*
(
const
complex64
&
a
,
const
complex64
&
b
)
{
#if defined(__CUDA_ARCH__) || defined(__HIPCC__)
#if defined(PADDLE_WITH_CUDA_OR_HIP_COMPLEX64) && \
(defined(__CUDA_ARCH__) || defined(__HIPCC__))
return
complex64
(
thrust
::
complex
<
float
>
(
a
.
real
,
a
.
imag
)
*
thrust
::
complex
<
float
>
(
b
.
real
,
b
.
imag
));
#else
...
...
@@ -252,7 +259,8 @@ HOSTDEVICE inline complex64 operator*(const complex64& a, const complex64& b) {
}
HOSTDEVICE
inline
complex64
operator
/
(
const
complex64
&
a
,
const
complex64
&
b
)
{
#if defined(__CUDA_ARCH__) || defined(__HIPCC__)
#if defined(PADDLE_WITH_CUDA_OR_HIP_COMPLEX64) && \
(defined(__CUDA_ARCH__) || defined(__HIPCC__))
return
complex64
(
thrust
::
complex
<
float
>
(
a
.
real
,
a
.
imag
)
/
thrust
::
complex
<
float
>
(
b
.
real
,
b
.
imag
));
#else
...
...
@@ -263,7 +271,8 @@ HOSTDEVICE inline complex64 operator/(const complex64& a, const complex64& b) {
}
HOSTDEVICE
inline
complex64
operator
-
(
const
complex64
&
a
)
{
#if defined(__CUDA_ARCH__) || defined(__HIPCC__)
#if defined(PADDLE_WITH_CUDA_OR_HIP_COMPLEX64) && \
(defined(__CUDA_ARCH__) || defined(__HIPCC__))
return
complex64
(
-
thrust
::
complex
<
float
>
(
a
.
real
,
a
.
imag
));
#else
complex64
res
;
...
...
@@ -275,7 +284,8 @@ HOSTDEVICE inline complex64 operator-(const complex64& a) {
HOSTDEVICE
inline
complex64
&
operator
+=
(
complex64
&
a
,
// NOLINT
const
complex64
&
b
)
{
#if defined(__CUDA_ARCH__) || defined(__HIPCC__)
#if defined(PADDLE_WITH_CUDA_OR_HIP_COMPLEX64) && \
(defined(__CUDA_ARCH__) || defined(__HIPCC__))
a
=
complex64
(
thrust
::
complex
<
float
>
(
a
.
real
,
a
.
imag
)
+=
thrust
::
complex
<
float
>
(
b
.
real
,
b
.
imag
));
return
a
;
...
...
@@ -288,7 +298,8 @@ HOSTDEVICE inline complex64& operator+=(complex64& a, // NOLINT
HOSTDEVICE
inline
complex64
&
operator
-=
(
complex64
&
a
,
// NOLINT
const
complex64
&
b
)
{
#if defined(__CUDA_ARCH__) || defined(__HIPCC__)
#if defined(PADDLE_WITH_CUDA_OR_HIP_COMPLEX64) && \
(defined(__CUDA_ARCH__) || defined(__HIPCC__))
a
=
complex64
(
thrust
::
complex
<
float
>
(
a
.
real
,
a
.
imag
)
-=
thrust
::
complex
<
float
>
(
b
.
real
,
b
.
imag
));
return
a
;
...
...
@@ -301,7 +312,8 @@ HOSTDEVICE inline complex64& operator-=(complex64& a, // NOLINT
HOSTDEVICE
inline
complex64
&
operator
*=
(
complex64
&
a
,
// NOLINT
const
complex64
&
b
)
{
#if defined(__CUDA_ARCH__) || defined(__HIPCC__)
#if defined(PADDLE_WITH_CUDA_OR_HIP_COMPLEX64) && \
(defined(__CUDA_ARCH__) || defined(__HIPCC__))
a
=
complex64
(
thrust
::
complex
<
float
>
(
a
.
real
,
a
.
imag
)
*=
thrust
::
complex
<
float
>
(
b
.
real
,
b
.
imag
));
return
a
;
...
...
@@ -314,7 +326,8 @@ HOSTDEVICE inline complex64& operator*=(complex64& a, // NOLINT
HOSTDEVICE
inline
complex64
&
operator
/=
(
complex64
&
a
,
// NOLINT
const
complex64
&
b
)
{
#if defined(__CUDA_ARCH__) || defined(__HIPCC__)
#if defined(PADDLE_WITH_CUDA_OR_HIP_COMPLEX64) && \
(defined(__CUDA_ARCH__) || defined(__HIPCC__))
a
=
complex64
(
thrust
::
complex
<
float
>
(
a
.
real
,
a
.
imag
)
/=
thrust
::
complex
<
float
>
(
b
.
real
,
b
.
imag
));
return
a
;
...
...
@@ -357,7 +370,7 @@ HOSTDEVICE inline bool operator>=(const complex64& a, const complex64& b) {
}
HOSTDEVICE
inline
bool
(
isnan
)(
const
complex64
&
a
)
{
#if defined(__CUDA_ARCH__)
#if defined(
PADDLE_WITH_CUDA) && defined(
__CUDA_ARCH__)
// __isnanf not supported on HIP platform
return
__isnanf
(
a
.
real
)
||
__isnanf
(
a
.
imag
);
#else
...
...
@@ -366,7 +379,7 @@ HOSTDEVICE inline bool(isnan)(const complex64& a) {
}
HOSTDEVICE
inline
bool
(
isinf
)(
const
complex64
&
a
)
{
#if defined(__CUDA_ARCH__)
#if defined(
PADDLE_WITH_CUDA) && defined(
__CUDA_ARCH__)
// __isinff not supported on HIP platform
return
__isinff
(
a
.
real
)
||
__isinff
(
a
.
imag
);
#else
...
...
@@ -379,7 +392,8 @@ HOSTDEVICE inline bool(isfinite)(const complex64& a) {
}
HOSTDEVICE
inline
float
(
abs
)(
const
complex64
&
a
)
{
#if defined(__CUDA_ARCH__) || defined(__HIPCC__)
#if defined(PADDLE_WITH_CUDA_OR_HIP_COMPLEX64) && \
(defined(__CUDA_ARCH__) || defined(__HIPCC__))
return
complex64
(
thrust
::
abs
(
thrust
::
complex
<
float
>
(
a
.
real
,
a
.
imag
)));
#else
return
std
::
abs
(
std
::
complex
<
float
>
(
a
.
real
,
a
.
imag
));
...
...
@@ -387,7 +401,8 @@ HOSTDEVICE inline float(abs)(const complex64& a) {
}
HOSTDEVICE
inline
complex64
(
pow
)(
const
complex64
&
a
,
const
complex64
&
b
)
{
#if defined(__CUDA_ARCH__) || defined(__HIPCC__)
#if defined(PADDLE_WITH_CUDA_OR_HIP_COMPLEX64) && \
(defined(__CUDA_ARCH__) || defined(__HIPCC__))
return
complex64
(
thrust
::
pow
(
thrust
::
complex
<
float
>
(
a
.
real
,
a
.
imag
),
thrust
::
complex
<
float
>
(
b
.
real
,
b
.
imag
)));
#else
...
...
@@ -396,7 +411,8 @@ HOSTDEVICE inline complex64(pow)(const complex64& a, const complex64& b) {
}
HOSTDEVICE
inline
complex64
(
sqrt
)(
const
complex64
&
a
)
{
#if defined(__CUDA_ARCH__) || defined(__HIPCC__)
#if defined(PADDLE_WITH_CUDA_OR_HIP_COMPLEX64) && \
(defined(__CUDA_ARCH__) || defined(__HIPCC__))
return
complex64
(
thrust
::
sqrt
(
thrust
::
complex
<
float
>
(
a
.
real
,
a
.
imag
)));
#else
return
std
::
sqrt
(
std
::
complex
<
float
>
(
a
));
...
...
@@ -404,7 +420,8 @@ HOSTDEVICE inline complex64(sqrt)(const complex64& a) {
}
HOSTDEVICE
inline
complex64
(
tanh
)(
const
complex64
&
a
)
{
#if defined(__CUDA_ARCH__) || defined(__HIPCC__)
#if defined(PADDLE_WITH_CUDA_OR_HIP_COMPLEX64) && \
(defined(__CUDA_ARCH__) || defined(__HIPCC__))
return
complex64
(
thrust
::
tanh
(
thrust
::
complex
<
float
>
(
a
.
real
,
a
.
imag
)));
#else
return
std
::
tanh
(
std
::
complex
<
float
>
(
a
));
...
...
@@ -412,7 +429,8 @@ HOSTDEVICE inline complex64(tanh)(const complex64& a) {
}
HOSTDEVICE
inline
complex64
(
log
)(
const
complex64
&
a
)
{
#if defined(__CUDA_ARCH__) || defined(__HIPCC__)
#if defined(PADDLE_WITH_CUDA_OR_HIP_COMPLEX64) && \
(defined(__CUDA_ARCH__) || defined(__HIPCC__))
return
complex64
(
thrust
::
log
(
thrust
::
complex
<
float
>
(
a
.
real
,
a
.
imag
)));
#else
return
std
::
log
(
std
::
complex
<
float
>
(
a
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录