Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
是我小仙女的笨笨呀
Paddle
提交
de967fce
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,发现更多精彩内容 >>
提交
de967fce
编写于
8月 10, 2017
作者:
Q
qijun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
set gemm support continuous memory now
上级
7eb07b33
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
40 addition
and
33 deletion
+40
-33
paddle/operators/math/math_function.cc
paddle/operators/math/math_function.cc
+23
-14
paddle/operators/math/math_function.cu
paddle/operators/math/math_function.cu
+14
-15
paddle/operators/math/math_function.h
paddle/operators/math/math_function.h
+2
-2
paddle/operators/mul_op.cu
paddle/operators/mul_op.cu
+1
-2
未找到文件。
paddle/operators/math/math_function.cc
浏览文件 @
de967fce
...
...
@@ -19,21 +19,30 @@ namespace operators {
namespace
math
{
template
<
>
void
gemm
<
platform
::
CPUPlace
,
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
)
{
void
gemm
<
platform
::
CPUPlace
,
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
float
*
B
,
const
float
beta
,
float
*
C
,
platform
::
DeviceContext
*
context
)
{
int
lda
=
K
;
int
ldb
=
N
;
int
ldc
=
N
;
cblas_sgemm
(
CblasRowMajor
,
transA
,
transB
,
M
,
N
,
K
,
alpha
,
A
,
lda
,
B
,
ldb
,
beta
,
C
,
ldc
);
}
template
<
>
void
gemm
<
platform
::
CPUPlace
,
double
>
(
const
CBLAS_TRANSPOSE
transA
,
const
CBLAS_TRANSPOSE
transB
,
const
int
M
,
const
int
N
,
const
int
K
,
const
double
alpha
,
const
double
*
A
,
const
int
lda
,
const
double
*
B
,
const
int
ldb
,
const
double
beta
,
double
*
C
,
const
int
ldc
,
platform
::
DeviceContext
*
context
)
{
void
gemm
<
platform
::
CPUPlace
,
double
>
(
const
CBLAS_TRANSPOSE
transA
,
const
CBLAS_TRANSPOSE
transB
,
const
int
M
,
const
int
N
,
const
int
K
,
const
double
alpha
,
const
double
*
A
,
const
double
*
B
,
const
double
beta
,
double
*
C
,
platform
::
DeviceContext
*
context
)
{
int
lda
=
K
;
int
ldb
=
N
;
int
ldc
=
N
;
cblas_dgemm
(
CblasRowMajor
,
transA
,
transB
,
M
,
N
,
K
,
alpha
,
A
,
lda
,
B
,
ldb
,
beta
,
C
,
ldc
);
}
...
...
@@ -67,8 +76,8 @@ void matmul<platform::CPUPlace, float>(const framework::Tensor& in1, bool in1_T,
CBLAS_TRANSPOSE
in2_Trans
=
(
in1_T
==
false
)
?
CblasNoTrans
:
CblasTrans
;
gemm
<
platform
::
CPUPlace
,
float
>
(
in1_Trans
,
in2_Trans
,
M
,
N
,
K
,
alpha
,
in1
.
data
<
float
>
(),
K
,
in2
.
data
<
float
>
(),
N
,
beta
,
out
->
data
<
float
>
(),
N
,
context
);
in1
.
data
<
float
>
(),
in2
.
data
<
float
>
(),
beta
,
out
->
data
<
float
>
()
,
context
);
}
template
<
>
...
...
@@ -100,8 +109,8 @@ void matmul<platform::CPUPlace, double>(const framework::Tensor& in1,
CBLAS_TRANSPOSE
in2_Trans
=
(
in1_T
==
false
)
?
CblasNoTrans
:
CblasTrans
;
gemm
<
platform
::
CPUPlace
,
double
>
(
in1_Trans
,
in2_Trans
,
M
,
N
,
K
,
alpha
,
in1
.
data
<
double
>
(),
K
,
in2
.
data
<
double
>
(),
N
,
beta
,
out
->
data
<
double
>
(),
N
,
context
);
in1
.
data
<
double
>
(),
in2
.
data
<
double
>
(),
beta
,
out
->
data
<
double
>
()
,
context
);
}
}
// namespace math
...
...
paddle/operators/math/math_function.cu
浏览文件 @
de967fce
...
...
@@ -18,14 +18,16 @@ 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
,
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
float
*
B
,
const
float
beta
,
float
*
C
,
platform
::
DeviceContext
*
context
)
{
// Note that cublas follows fortran order, so the order is different from
// the cblas convention.
/*
int
lda
=
(
transA
==
CblasNoTrans
)
?
K
:
M
;
int
ldb
=
(
transB
==
CblasNoTrans
)
?
N
:
K
;
cublasOperation_t
cuTransA
=
(
transA
==
CblasNoTrans
)
?
CUBLAS_OP_N
:
CUBLAS_OP_T
;
cublasOperation_t
cuTransB
=
...
...
@@ -34,8 +36,6 @@ void gemm<platform::GPUPlace, float>(
PADDLE_ENFORCE
(
platform
::
dynload
::
cublasSgemm
(
reinterpret_cast
<
platform
::
CUDADeviceContext
*>
(
context
)
->
cublas_handle
(),
cuTransB
,
cuTransA
,
N
,
M
,
K
,
&
alpha
,
B
,
ldb
,
A
,
lda
,
&
beta
,
C
,
ldc
));
*/
PADDLE_THROW
(
"not implemented now"
);
}
template
<
>
...
...
@@ -46,7 +46,8 @@ void gemm<platform::GPUPlace, double>(
const
int
ldc
,
platform
::
DeviceContext
*
context
)
{
// Note that cublas follows fortran order, so the order is different from
// the cblas convention.
/*
int
lda
=
(
transA
==
CblasNoTrans
)
?
K
:
M
;
int
ldb
=
(
transB
==
CblasNoTrans
)
?
N
:
K
;
cublasOperation_t
cuTransA
=
(
transA
==
CblasNoTrans
)
?
CUBLAS_OP_N
:
CUBLAS_OP_T
;
cublasOperation_t
cuTransB
=
...
...
@@ -54,8 +55,6 @@ void gemm<platform::GPUPlace, double>(
PADDLE_ENFORCE
(
platform
::
dynload
::
cublasDgemm
(
reinterpret_cast
<
platform
::
CUDADeviceContext
*>
(
context
)
->
cublas_handle
(),
cuTransB
,
cuTransA
,
N
,
M
,
K
,
&
alpha
,
B
,
ldb
,
A
,
lda
,
&
beta
,
C
,
ldc
));
*/
PADDLE_THROW
(
"not implemented now"
);
}
template
<
>
...
...
@@ -87,8 +86,8 @@ void matmul<platform::GPUPlace, float>(const framework::Tensor& in1, bool in1_T,
CBLAS_TRANSPOSE
in2_Trans
=
(
in1_T
==
false
)
?
CblasNoTrans
:
CblasTrans
;
gemm
<
platform
::
GPUPlace
,
float
>
(
in1_Trans
,
in2_Trans
,
M
,
N
,
K
,
alpha
,
in1
.
data
<
float
>
(),
K
,
in2
.
data
<
float
>
(),
N
,
beta
,
out
->
data
<
float
>
(),
N
,
context
);
in1
.
data
<
float
>
(),
in2
.
data
<
float
>
(),
beta
,
out
->
data
<
float
>
()
,
context
);
}
template
<
>
...
...
@@ -120,8 +119,8 @@ void matmul<platform::GPUPlace, double>(const framework::Tensor& in1,
CBLAS_TRANSPOSE
in2_Trans
=
(
in1_T
==
false
)
?
CblasNoTrans
:
CblasTrans
;
gemm
<
platform
::
GPUPlace
,
double
>
(
in1_Trans
,
in2_Trans
,
M
,
N
,
K
,
alpha
,
in1
.
data
<
double
>
(),
K
,
in2
.
data
<
double
>
(),
N
,
beta
,
out
->
data
<
double
>
(),
N
,
context
);
in1
.
data
<
double
>
(),
in2
.
data
<
double
>
(),
beta
,
out
->
data
<
double
>
()
,
context
);
}
}
// namespace math
}
// namespace operators
...
...
paddle/operators/math/math_function.h
浏览文件 @
de967fce
...
...
@@ -60,11 +60,11 @@ namespace paddle {
namespace
operators
{
namespace
math
{
// support continuous memory now
template
<
typename
Place
,
typename
T
>
void
gemm
(
const
CBLAS_TRANSPOSE
transA
,
const
CBLAS_TRANSPOSE
transB
,
const
int
M
,
const
int
N
,
const
int
K
,
const
T
alpha
,
const
T
*
A
,
const
int
lda
,
const
T
*
B
,
const
int
ldb
,
const
T
beta
,
T
*
C
,
const
int
ldc
,
platform
::
DeviceContext
*
context
);
const
T
*
B
,
const
T
beta
,
T
*
C
,
platform
::
DeviceContext
*
context
);
// matrix multiply with continuous memory
template
<
typename
Place
,
typename
T
>
...
...
paddle/operators/mul_op.cu
浏览文件 @
de967fce
...
...
@@ -16,5 +16,4 @@
#include "paddle/operators/mul_op.h"
namespace
ops
=
paddle
::
operators
;
// REGISTER_OP_GPU_KERNEL(mul, ops::MulKernel<paddle::platform::GPUPlace,
// float>);
REGISTER_OP_GPU_KERNEL
(
mul
,
ops
::
MulKernel
<
paddle
::
platform
::
GPUPlace
,
float
>
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录