Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
f190a795
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
Star
20931
Fork
5422
代码
文件
提交
分支
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看板
提交
f190a795
编写于
8月 03, 2017
作者:
Q
qijun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix gpu build error
上级
22dac40c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
39 addition
and
129 deletion
+39
-129
paddle/operators/math/math_function.cc
paddle/operators/math/math_function.cc
+2
-38
paddle/operators/math/math_function.cu
paddle/operators/math/math_function.cu
+21
-63
paddle/operators/math/math_function.h
paddle/operators/math/math_function.h
+1
-14
paddle/operators/mul_op.h
paddle/operators/mul_op.h
+15
-14
未找到文件。
paddle/operators/math/math_function.cc
浏览文件 @
f190a795
...
...
@@ -32,7 +32,7 @@ void gemm<platform::CPUPlace, float>(const CBLAS_TRANSPOSE transA,
const
float
beta
,
float
*
C
,
const
int
ldc
,
const
platform
::
DeviceContext
*
context
)
{
platform
::
DeviceContext
*
context
)
{
cblas_sgemm
(
CblasRowMajor
,
transA
,
transB
,
...
...
@@ -63,7 +63,7 @@ void gemm<platform::CPUPlace, double>(const CBLAS_TRANSPOSE transA,
const
double
beta
,
double
*
C
,
const
int
ldc
,
const
platform
::
DeviceContext
*
context
)
{
platform
::
DeviceContext
*
context
)
{
cblas_dgemm
(
CblasRowMajor
,
transA
,
transB
,
...
...
@@ -80,42 +80,6 @@ void gemm<platform::CPUPlace, double>(const CBLAS_TRANSPOSE transA,
ldc
);
}
template
<
>
void
axpy
<
platform
::
CPUPlace
,
float
>
(
const
int
n
,
const
float
alpha
,
const
float
*
x
,
float
*
y
,
const
platform
::
DeviceContext
*
context
)
{
cblas_saxpy
(
n
,
alpha
,
x
,
1
,
y
,
1
);
}
template
<
>
void
axpy
<
platform
::
CPUPlace
,
double
>
(
const
int
n
,
const
double
alpha
,
const
double
*
x
,
double
*
y
,
const
platform
::
DeviceContext
*
context
)
{
cblas_daxpy
(
n
,
alpha
,
x
,
1
,
y
,
1
);
}
template
<
>
float
dotProduct
<
platform
::
CPUPlace
,
float
>
(
const
int
n
,
const
float
*
x
,
const
float
*
y
,
const
platform
::
DeviceContext
*
context
)
{
return
cblas_sdot
(
n
,
x
,
1
,
y
,
1
);
}
template
<
>
double
dotProduct
<
platform
::
CPUPlace
,
double
>
(
const
int
n
,
const
double
*
x
,
const
double
*
y
,
const
platform
::
DeviceContext
*
context
)
{
return
cblas_ddot
(
n
,
x
,
1
,
y
,
1
);
}
}
// namespace math
}
// namespace operators
}
// namespace paddle
paddle/operators/math/math_function.cu
浏览文件 @
f190a795
...
...
@@ -20,29 +20,29 @@ namespace operators {
namespace
math
{
template
<
>
void
gemm
<
platform
::
GPUPlace
float
>
(
const
CBLAS_TRANSPOSE
transA
,
const
CBLAS_TRANSPOSE
transB
,
const
int
M
,
const
int
N
,
const
int
K
,
const
float
alpha
,
const
float
*
A
,
const
int
lda
,
const
float
*
B
,
const
int
ldb
,
const
float
beta
,
float
*
C
,
const
int
ldc
,
const
platform
::
DeviceContext
*
context
)
{
void
gemm
<
platform
::
GPUPlace
,
float
>
(
const
CBLAS_TRANSPOSE
transA
,
const
CBLAS_TRANSPOSE
transB
,
const
int
M
,
const
int
N
,
const
int
K
,
const
float
alpha
,
const
float
*
A
,
const
int
lda
,
const
float
*
B
,
const
int
ldb
,
const
float
beta
,
float
*
C
,
const
int
ldc
,
platform
::
DeviceContext
*
context
)
{
// Note that cublas follows fortran order, so the order is different from
// the cblas convention.
cublasOperation_t
cuTransA
=
(
T
ransA
==
CblasNoTrans
)
?
CUBLAS_OP_N
:
CUBLAS_OP_T
;
(
t
ransA
==
CblasNoTrans
)
?
CUBLAS_OP_N
:
CUBLAS_OP_T
;
cublasOperation_t
cuTransB
=
(
T
ransB
==
CblasNoTrans
)
?
CUBLAS_OP_N
:
CUBLAS_OP_T
;
(
t
ransB
==
CblasNoTrans
)
?
CUBLAS_OP_N
:
CUBLAS_OP_T
;
PADDLE_ENFORCE
(
platform
::
dynload
::
cublasSgemm
(
reinterpret_cast
<
const
platform
::
CUDADeviceContext
*>
(
context
)
->
reinterpret_cast
<
platform
::
CUDADeviceContext
*>
(
context
)
->
cublas_handle
(),
cuTransB
,
cuTransA
,
...
...
@@ -73,15 +73,15 @@ void gemm<platform::GPUPlace, double>(const CBLAS_TRANSPOSE transA,
const
double
beta
,
double
*
C
,
const
int
ldc
,
const
platform
::
DeviceContext
*
context
)
{
platform
::
DeviceContext
*
context
)
{
// Note that cublas follows fortran order, so the order is different from
// the cblas convention.
cublasOperation_t
cuTransA
=
(
T
ransA
==
CblasNoTrans
)
?
CUBLAS_OP_N
:
CUBLAS_OP_T
;
(
t
ransA
==
CblasNoTrans
)
?
CUBLAS_OP_N
:
CUBLAS_OP_T
;
cublasOperation_t
cuTransB
=
(
T
ransB
==
CblasNoTrans
)
?
CUBLAS_OP_N
:
CUBLAS_OP_T
;
(
t
ransB
==
CblasNoTrans
)
?
CUBLAS_OP_N
:
CUBLAS_OP_T
;
PADDLE_ENFORCE
(
platform
::
dynload
::
cublasDgemm
(
reinterpret_cast
<
const
platform
::
CUDADeviceContext
*>
(
context
)
->
reinterpret_cast
<
platform
::
CUDADeviceContext
*>
(
context
)
->
cublas_handle
(),
cuTransB
,
cuTransA
,
...
...
@@ -99,48 +99,6 @@ void gemm<platform::GPUPlace, double>(const CBLAS_TRANSPOSE transA,
}
template
<
>
void
axpy
<
platform
::
GPUPlace
,
float
>
(
const
int
n
,
const
float
alpha
,
const
float
*
x
,
float
*
y
,
const
platform
::
DeviceContext
*
context
)
{
CUBLAS_ENFORCE
(
platform
::
dynload
::
cublasSaxpy
(
reinterpret_cast
<
const
platform
::
CUDADeviceContext
*>
(
context
)
->
cublas_handle
(),
N
,
&
alpha
,
X
,
1
,
Y
,
1
));
}
template
<
>
void
axpy
<
platform
::
GPUPlace
,
double
>
(
const
int
n
,
const
double
alpha
,
const
double
*
x
,
double
*
y
,
const
platform
::
DeviceContext
*
context
)
{
CUBLAS_ENFORCE
(
platform
::
dynload
::
cublasDaxpy
(
reinterpret_cast
<
const
platform
::
CUDADeviceContext
*>
(
context
)
->
cublas_handle
(),
N
,
&
alpha
,
X
,
1
,
Y
,
1
));
}
template
<
>
float
dotProduct
<
platform
::
GPUPlace
,
float
>
(
const
int
n
,
const
float
*
x
,
const
float
*
y
,
const
platform
::
DeviceContext
*
context
)
{
CUBLAS_ENFORCE
(
platform
::
dynload
::
cublasSdot
(
reinterpret_cast
<
const
platform
::
CUDADeviceContext
*>
(
context
)
->
cublas_handle
(),
n
,
a
,
1
,
b
,
1
,
&
result
));
}
template
<
>
double
dotProduct
<
platform
::
GPUPlace
,
double
>
(
const
int
n
,
const
double
*
x
,
const
double
*
y
,
const
platform
::
DeviceContext
*
context
)
{
CUBLAS_ENFORCE
(
platform
::
dynload
::
cublasDdot
(
reinterpret_cast
<
const
platform
::
CUDADeviceContext
*>
(
context
)
->
cublas_handle
(),
n
,
a
,
1
,
b
,
1
,
&
result
));
}
}
// namespace math
}
// namespace operators
}
// namespace paddle
paddle/operators/math/math_function.h
浏览文件 @
f190a795
...
...
@@ -58,20 +58,7 @@ void gemm(const CBLAS_TRANSPOSE transA,
const
T
beta
,
T
*
C
,
const
int
ldc
,
const
platform
::
DeviceContext
*
context
);
template
<
typename
Place
,
typename
T
>
void
axpy
(
const
int
n
,
const
T
alpha
,
const
T
*
x
,
T
*
y
,
const
platform
::
DeviceContext
*
context
);
template
<
typename
Place
,
typename
T
>
T
dotProduct
(
const
int
n
,
const
T
*
x
,
const
T
*
y
,
const
platform
::
DeviceContext
*
context
);
platform
::
DeviceContext
*
context
);
}
// namespace math
}
// namespace operators
...
...
paddle/operators/mul_op.h
浏览文件 @
f190a795
...
...
@@ -37,20 +37,21 @@ public:
int
N
=
out_dim
[
1
];
int
K
=
in0_dim
[
1
];
paddle
::
operators
::
math
::
template
gemm
<
Place
,
T
>(
CblasNoTrans
,
CblasNoTrans
,
M
,
N
,
K
,
1
,
input0
->
data
<
T
>
(),
K
,
input1
->
data
<
T
>
(),
N
,
0
,
output
->
data
<
T
>
(),
N
,
&
context
.
device_context
());
paddle
::
operators
::
math
::
template
gemm
<
Place
,
T
>(
CblasNoTrans
,
CblasNoTrans
,
M
,
N
,
K
,
1
,
input0
->
data
<
T
>
(),
K
,
input1
->
data
<
T
>
(),
N
,
0
,
output
->
data
<
T
>
(),
N
,
&
const_cast
<
platform
::
DeviceContext
&>
(
context
.
device_context
()));
}
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录