Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
62fed4cb
P
PaddleDetection
项目概览
s920243400
/
PaddleDetection
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleDetection
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
62fed4cb
编写于
5月 03, 2018
作者:
C
chengduo
提交者:
dzhwinter
5月 03, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix __shfl_down (#10362)
上级
3000e994
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
35 addition
and
17 deletion
+35
-17
paddle/cuda/include/hl_base.h
paddle/cuda/include/hl_base.h
+5
-0
paddle/fluid/operators/row_conv_op.cu
paddle/fluid/operators/row_conv_op.cu
+10
-2
paddle/function/RowConvOpGpu.cu
paddle/function/RowConvOpGpu.cu
+20
-15
未找到文件。
paddle/cuda/include/hl_base.h
浏览文件 @
62fed4cb
...
@@ -229,6 +229,11 @@ extern __thread cudaStream_t default_stream;
...
@@ -229,6 +229,11 @@ extern __thread cudaStream_t default_stream;
// __shfl has been deprecated as of CUDA 9.0.
// __shfl has been deprecated as of CUDA 9.0.
#if CUDA_VERSION < 9000
#if CUDA_VERSION < 9000
template
<
typename
T
>
__forceinline__
__device__
T
__shfl_down_sync
(
unsigned
,
T
val
,
int
delta
)
{
return
__shfl_down
(
val
,
delta
);
}
template
<
typename
T
>
template
<
typename
T
>
__forceinline__
__device__
T
__forceinline__
__device__
T
__shfl_sync
(
unsigned
,
T
val
,
int
src_line
,
int
width
)
{
__shfl_sync
(
unsigned
,
T
val
,
int
src_line
,
int
width
)
{
...
...
paddle/fluid/operators/row_conv_op.cu
浏览文件 @
62fed4cb
...
@@ -189,6 +189,10 @@ __global__ void RowConvGradFilterImproved(const T *in, const T *dout,
...
@@ -189,6 +189,10 @@ __global__ void RowConvGradFilterImproved(const T *in, const T *dout,
}
}
__syncthreads
();
__syncthreads
();
// NOTE(zcd): temporary solution
unsigned
mask
=
0u
;
CREATE_SHFL_MASK
(
mask
,
true
);
for
(
int
i
=
0
;
i
<
num_sequence
;
i
++
)
{
for
(
int
i
=
0
;
i
<
num_sequence
;
i
++
)
{
int
start
=
static_cast
<
int
>
(
batch_indices
[
i
]);
int
start
=
static_cast
<
int
>
(
batch_indices
[
i
]);
int
end
=
static_cast
<
int
>
(
batch_indices
[
i
+
1
]);
int
end
=
static_cast
<
int
>
(
batch_indices
[
i
+
1
]);
...
@@ -220,7 +224,7 @@ __global__ void RowConvGradFilterImproved(const T *in, const T *dout,
...
@@ -220,7 +224,7 @@ __global__ void RowConvGradFilterImproved(const T *in, const T *dout,
for
(
int
offset
=
16
;
offset
>
0
;
for
(
int
offset
=
16
;
offset
>
0
;
offset
=
offset
/
2
)
{
// blockDim.x is 32.
offset
=
offset
/
2
)
{
// blockDim.x is 32.
val
+=
platform
::
__shfl_down_sync
(
0
,
val
,
offset
);
val
+=
platform
::
__shfl_down_sync
(
mask
,
val
,
offset
);
}
}
__syncthreads
();
__syncthreads
();
...
@@ -251,6 +255,10 @@ __global__ void RowConvGradFilter(const T *in, const T *dout, int num_sequence,
...
@@ -251,6 +255,10 @@ __global__ void RowConvGradFilter(const T *in, const T *dout, int num_sequence,
T
*
sh_in
=
mem
;
T
*
sh_in
=
mem
;
T
*
sh_dout
=
&
mem
[
block_x
*
block_y
];
T
*
sh_dout
=
&
mem
[
block_x
*
block_y
];
// NOTE(zcd): temporary solution
unsigned
mask
=
0u
;
CREATE_SHFL_MASK
(
mask
,
true
);
for
(
int
i
=
0
;
i
<
num_sequence
;
i
++
)
{
for
(
int
i
=
0
;
i
<
num_sequence
;
i
++
)
{
int
start
=
static_cast
<
int
>
(
batch_indices
[
i
]);
int
start
=
static_cast
<
int
>
(
batch_indices
[
i
]);
int
end
=
static_cast
<
int
>
(
batch_indices
[
i
+
1
]);
int
end
=
static_cast
<
int
>
(
batch_indices
[
i
+
1
]);
...
@@ -276,7 +284,7 @@ __global__ void RowConvGradFilter(const T *in, const T *dout, int num_sequence,
...
@@ -276,7 +284,7 @@ __global__ void RowConvGradFilter(const T *in, const T *dout, int num_sequence,
for
(
int
offset
=
16
;
offset
>
0
;
for
(
int
offset
=
16
;
offset
>
0
;
offset
=
offset
/
2
)
{
// blockDim.x is 32.
offset
=
offset
/
2
)
{
// blockDim.x is 32.
val
+=
platform
::
__shfl_down_sync
(
0
,
val
,
offset
);
val
+=
platform
::
__shfl_down_sync
(
mask
,
val
,
offset
);
}
}
__syncthreads
();
__syncthreads
();
...
...
paddle/function/RowConvOpGpu.cu
浏览文件 @
62fed4cb
...
@@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...
@@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#include "
RowConvOp
.h"
#include "
paddle/cuda/include/hl_base
.h"
#include "
hl_base
.h"
#include "
paddle/function/RowConvOp
.h"
namespace
paddle
{
namespace
paddle
{
...
@@ -94,7 +94,7 @@ __global__ void KeRowConv2(real* y,
...
@@ -94,7 +94,7 @@ __global__ void KeRowConv2(real* y,
}
}
template
<
>
template
<
>
void
RowConv
<
DEVICE_TYPE_GPU
>
(
GpuMatrix
&
out
,
void
RowConv
<
DEVICE_TYPE_GPU
>
(
GpuMatrix
&
out
,
// NOLINT
const
GpuMatrix
&
in
,
const
GpuMatrix
&
in
,
const
GpuMatrix
&
filter
,
const
GpuMatrix
&
filter
,
const
GpuIVector
&
seq
)
{
const
GpuIVector
&
seq
)
{
...
@@ -144,6 +144,10 @@ __global__ void KeRowConvBwWeight(real* dw,
...
@@ -144,6 +144,10 @@ __global__ void KeRowConvBwWeight(real* dw,
}
}
__syncthreads
();
__syncthreads
();
// NOTE(zcd): temporary solution
unsigned
mask
=
0u
;
CREATE_SHFL_MASK
(
mask
,
true
);
for
(
int
i
=
0
;
i
<
numSeq
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numSeq
;
++
i
)
{
const
int
start
=
starts
[
i
];
const
int
start
=
starts
[
i
];
const
int
end
=
starts
[
i
+
1
];
const
int
end
=
starts
[
i
+
1
];
...
@@ -170,11 +174,10 @@ __global__ void KeRowConvBwWeight(real* dw,
...
@@ -170,11 +174,10 @@ __global__ void KeRowConvBwWeight(real* dw,
real
val
=
sh_x
[
tidy
][
tidx
]
*
sh_dy
[
tidy
][
tidx
+
context
-
1
-
t
];
real
val
=
sh_x
[
tidy
][
tidx
]
*
sh_dy
[
tidy
][
tidx
+
context
-
1
-
t
];
__syncthreads
();
__syncthreads
();
// warp size and blockDim.x is 32.
// warp size and blockDim.x is 32.
val
+=
__shfl_down
(
val
,
16
);
val
+=
__shfl_down
(
val
,
8
);
for
(
int
offset
=
16
;
offset
>
0
;
offset
/=
2
)
val
+=
__shfl_down
(
val
,
4
);
val
+=
__shfl_down_sync
(
mask
,
val
,
offset
);
val
+=
__shfl_down
(
val
,
2
);
val
+=
__shfl_down
(
val
,
1
);
__syncthreads
();
__syncthreads
();
if
(
tidx
==
0
)
{
if
(
tidx
==
0
)
{
sh_dw
[
t
][
tidy
]
+=
val
;
sh_dw
[
t
][
tidy
]
+=
val
;
...
@@ -205,6 +208,10 @@ __global__ void KeRowConvBwWeight2(real* dw,
...
@@ -205,6 +208,10 @@ __global__ void KeRowConvBwWeight2(real* dw,
__shared__
real
sh_x
[
BLOCK_H
][
BLOCK_W
];
__shared__
real
sh_x
[
BLOCK_H
][
BLOCK_W
];
__shared__
real
sh_dy
[
BLOCK_H
][
BLOCK_W
];
__shared__
real
sh_dy
[
BLOCK_H
][
BLOCK_W
];
// NOTE(zcd): temporary solution
unsigned
mask
=
0u
;
CREATE_SHFL_MASK
(
mask
,
true
);
for
(
int
i
=
0
;
i
<
numSeq
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numSeq
;
++
i
)
{
const
int
start
=
starts
[
i
];
const
int
start
=
starts
[
i
];
const
int
end
=
starts
[
i
+
1
];
const
int
end
=
starts
[
i
+
1
];
...
@@ -230,11 +237,9 @@ __global__ void KeRowConvBwWeight2(real* dw,
...
@@ -230,11 +237,9 @@ __global__ void KeRowConvBwWeight2(real* dw,
real
val
=
sh_x
[
tidy
][
tidx
]
*
sh_dy
[
tidy
][
tidx
];
real
val
=
sh_x
[
tidy
][
tidx
]
*
sh_dy
[
tidy
][
tidx
];
__syncthreads
();
__syncthreads
();
// warp size and blockDim.x is 32.
// warp size and blockDim.x is 32.
val
+=
__shfl_down
(
val
,
16
);
for
(
int
offset
=
16
;
offset
>
0
;
offset
/=
2
)
val
+=
__shfl_down
(
val
,
8
);
val
+=
__shfl_down_sync
(
mask
,
val
,
offset
);
val
+=
__shfl_down
(
val
,
4
);
val
+=
__shfl_down
(
val
,
2
);
val
+=
__shfl_down
(
val
,
1
);
__syncthreads
();
__syncthreads
();
if
(
tidx
==
0
&&
(
gidx
+
tidy
)
<
width
)
{
if
(
tidx
==
0
&&
(
gidx
+
tidy
)
<
width
)
{
...
@@ -323,8 +328,8 @@ template <>
...
@@ -323,8 +328,8 @@ template <>
void
RowConvGrad
<
DEVICE_TYPE_GPU
>
(
const
GpuMatrix
&
outG
,
void
RowConvGrad
<
DEVICE_TYPE_GPU
>
(
const
GpuMatrix
&
outG
,
const
GpuMatrix
&
in
,
const
GpuMatrix
&
in
,
const
GpuMatrix
&
filter
,
const
GpuMatrix
&
filter
,
GpuMatrix
&
inG
,
GpuMatrix
&
inG
,
// NOLINT
GpuMatrix
&
filterG
,
GpuMatrix
&
filterG
,
// NOLINT
const
GpuIVector
&
seq
)
{
const
GpuIVector
&
seq
)
{
const
size_t
numSeq
=
seq
.
getSize
()
-
1
;
const
size_t
numSeq
=
seq
.
getSize
()
-
1
;
const
size_t
contextLength
=
filter
.
getHeight
();
const
size_t
contextLength
=
filter
.
getHeight
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录