Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
266fcbe0
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看板
未验证
提交
266fcbe0
编写于
9月 06, 2021
作者:
W
wangguanzhong
提交者:
GitHub
9月 06, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support double in deformable conv (#35330)
* support double in deformable conv * add double for dcn v2
上级
49797d85
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
55 addition
and
10 deletion
+55
-10
paddle/fluid/operators/deformable_conv_op.cu
paddle/fluid/operators/deformable_conv_op.cu
+6
-3
paddle/fluid/operators/deformable_conv_v1_op.cc
paddle/fluid/operators/deformable_conv_v1_op.cc
+4
-2
paddle/fluid/operators/deformable_conv_v1_op.cu
paddle/fluid/operators/deformable_conv_v1_op.cu
+6
-3
python/paddle/fluid/tests/unittests/test_deformable_conv_op.py
...n/paddle/fluid/tests/unittests/test_deformable_conv_op.py
+30
-1
python/paddle/fluid/tests/unittests/test_deformable_conv_v1_op.py
...addle/fluid/tests/unittests/test_deformable_conv_v1_op.py
+9
-1
未找到文件。
paddle/fluid/operators/deformable_conv_op.cu
浏览文件 @
266fcbe0
...
...
@@ -126,7 +126,8 @@ __global__ void ModulatedDeformableCol2imGpuKernel(
DmcnGetGradientWeight
(
cur_inv_h_data
,
cur_inv_w_data
,
cur_h
+
dy
,
cur_w
+
dx
,
height
,
width
);
atomicAdd
(
grad_im
+
cur_bottom_grad_pos
,
weight
*
cur_top_grad
);
platform
::
CudaAtomicAdd
(
grad_im
+
cur_bottom_grad_pos
,
weight
*
cur_top_grad
);
}
}
}
...
...
@@ -748,6 +749,8 @@ namespace ops = paddle::operators;
using
CUDA
=
paddle
::
platform
::
CUDADeviceContext
;
REGISTER_OP_CUDA_KERNEL
(
deformable_conv
,
ops
::
DeformableConvCUDAKernel
<
CUDA
,
float
>
);
ops
::
DeformableConvCUDAKernel
<
CUDA
,
float
>
,
ops
::
DeformableConvCUDAKernel
<
CUDA
,
double
>
);
REGISTER_OP_CUDA_KERNEL
(
deformable_conv_grad
,
ops
::
DeformableConvGradCUDAKernel
<
CUDA
,
float
>
);
ops
::
DeformableConvGradCUDAKernel
<
CUDA
,
float
>
,
ops
::
DeformableConvGradCUDAKernel
<
CUDA
,
double
>
);
paddle/fluid/operators/deformable_conv_v1_op.cc
浏览文件 @
266fcbe0
...
...
@@ -307,6 +307,8 @@ REGISTER_OPERATOR(deformable_conv_v1, ops::DeformableConvV1Op,
REGISTER_OPERATOR
(
deformable_conv_v1_grad
,
ops
::
DeformableConvV1GradOp
);
REGISTER_OP_CPU_KERNEL
(
deformable_conv_v1
,
ops
::
DeformableConvV1CPUKernel
<
float
>
);
ops
::
DeformableConvV1CPUKernel
<
float
>
,
ops
::
DeformableConvV1CPUKernel
<
double
>
);
REGISTER_OP_CPU_KERNEL
(
deformable_conv_v1_grad
,
ops
::
DeformableConvV1GradCPUKernel
<
float
>
);
ops
::
DeformableConvV1GradCPUKernel
<
float
>
,
ops
::
DeformableConvV1GradCPUKernel
<
double
>
);
paddle/fluid/operators/deformable_conv_v1_op.cu
浏览文件 @
266fcbe0
...
...
@@ -99,7 +99,8 @@ __global__ void DeformableCol2imCUDAKernel(
DmcnGetGradientWeight
(
cur_inv_h_data
,
cur_inv_w_data
,
cur_h
+
dy
,
cur_w
+
dx
,
height
,
width
);
atomicAdd
(
grad_im
+
cur_bottom_grad_pos
,
weight
*
cur_top_grad
);
platform
::
CudaAtomicAdd
(
grad_im
+
cur_bottom_grad_pos
,
weight
*
cur_top_grad
);
}
}
}
...
...
@@ -604,6 +605,8 @@ class DeformableConvV1GradCUDAKernel : public framework::OpKernel<T> {
namespace
ops
=
paddle
::
operators
;
REGISTER_OP_CUDA_KERNEL
(
deformable_conv_v1
,
ops
::
DeformableConvV1CUDAKernel
<
float
>
);
ops
::
DeformableConvV1CUDAKernel
<
float
>
,
ops
::
DeformableConvV1CUDAKernel
<
double
>
);
REGISTER_OP_CUDA_KERNEL
(
deformable_conv_v1_grad
,
ops
::
DeformableConvV1GradCUDAKernel
<
float
>
);
ops
::
DeformableConvV1GradCUDAKernel
<
float
>
,
ops
::
DeformableConvV1GradCUDAKernel
<
double
>
);
python/paddle/fluid/tests/unittests/test_deformable_conv_op.py
浏览文件 @
266fcbe0
...
...
@@ -111,7 +111,7 @@ def dconv_im2col_gemm(input, offset, mask, filter, group, conv_param):
class
TestModulatedDeformableConvOp
(
OpTest
):
def
setUp
(
self
):
self
.
op_type
=
"deformable_conv"
self
.
dtype
=
np
.
float32
self
.
init_type
()
self
.
init_group
()
self
.
init_dilation
()
self
.
init_test_case
()
...
...
@@ -183,6 +183,9 @@ class TestModulatedDeformableConvOp(OpTest):
def
init_group
(
self
):
self
.
groups
=
1
def
init_type
(
self
):
self
.
dtype
=
np
.
float32
class
TestWithStride
(
TestModulatedDeformableConvOp
):
def
init_test_case
(
self
):
...
...
@@ -258,6 +261,32 @@ class TestWithGroup(TestModulatedDeformableConvOp):
self
.
groups
=
2
class
TestWithDouble
(
TestModulatedDeformableConvOp
):
def
init_type
(
self
):
self
.
dtype
=
np
.
float64
def
init_test_case
(
self
):
self
.
pad
=
[
1
,
1
]
self
.
stride
=
[
1
,
1
]
self
.
dilations
=
[
1
,
1
]
self
.
input_size
=
[
2
,
6
,
4
,
4
]
# NCHW
assert
np
.
mod
(
self
.
input_size
[
1
],
self
.
groups
)
==
0
f_c
=
self
.
input_size
[
1
]
//
self
.
groups
self
.
filter_size
=
[
4
,
f_c
,
3
,
3
]
self
.
im2col_step
=
1
self
.
deformable_groups
=
1
offset_c
=
2
*
self
.
deformable_groups
*
self
.
filter_size
[
2
]
*
self
.
filter_size
[
3
]
mask_c
=
self
.
deformable_groups
*
self
.
filter_size
[
2
]
*
self
.
filter_size
[
3
]
self
.
offset_size
=
[
self
.
input_size
[
0
],
offset_c
,
self
.
input_size
[
2
],
self
.
input_size
[
3
]
]
self
.
mask_size
=
[
self
.
input_size
[
0
],
mask_c
,
self
.
input_size
[
2
],
self
.
input_size
[
3
]
]
class
TestModulatedDeformableConvInvalidInput
(
unittest
.
TestCase
):
def
test_error
(
self
):
def
test_invalid_input
():
...
...
python/paddle/fluid/tests/unittests/test_deformable_conv_v1_op.py
浏览文件 @
266fcbe0
...
...
@@ -108,7 +108,7 @@ def dconv_im2col_gemm(input, offset, filter, group, conv_param):
class
TestModulatedDeformableConvOp
(
OpTest
):
def
setUp
(
self
):
self
.
op_type
=
"deformable_conv_v1"
self
.
dtype
=
np
.
float32
self
.
init_type
()
self
.
init_group
()
self
.
init_dilation
()
self
.
init_test_case
()
...
...
@@ -177,6 +177,9 @@ class TestModulatedDeformableConvOp(OpTest):
def
init_group
(
self
):
self
.
groups
=
1
def
init_type
(
self
):
self
.
dtype
=
np
.
float32
class
TestWithStride
(
TestModulatedDeformableConvOp
):
def
init_test_case
(
self
):
...
...
@@ -253,6 +256,11 @@ class TestWithGroup(TestModulatedDeformableConvOp):
self
.
groups
=
2
class
TestWithDouble
(
TestModulatedDeformableConvOp
):
def
init_type
(
self
):
self
.
dtype
=
np
.
float64
class
TestModulatedDeformableConvV1InvalidInput
(
unittest
.
TestCase
):
def
test_error
(
self
):
def
test_invalid_input
():
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录