Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
food-round2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Joel Joseph
food-round2
Commits
62304425
Commit
62304425
authored
6 years ago
by
Kai Chen
Browse files
Options
Downloads
Patches
Plain Diff
use extension.h instead of torch.h and code formatting
parent
441015ea
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mmdet/ops/dcn/src/deform_conv_cuda.cpp
+647
-586
647 additions, 586 deletions
mmdet/ops/dcn/src/deform_conv_cuda.cpp
mmdet/ops/dcn/src/deform_pool_cuda.cpp
+67
-124
67 additions, 124 deletions
mmdet/ops/dcn/src/deform_pool_cuda.cpp
with
714 additions
and
710 deletions
mmdet/ops/dcn/src/deform_conv_cuda.cpp
+
647
−
586
View file @
62304425
This diff is collapsed.
Click to expand it.
mmdet/ops/dcn/src/deform_pool_cuda.cpp
+
67
−
124
View file @
62304425
// modify from
// https://github.com/chengdazhi/Deformable-Convolution-V2-PyTorch/blob/mmdetection/mmdet/ops/dcn/src/modulated_dcn_cuda.c
// based on
// author: Charles Shang
// https://github.com/torch/cunn/blob/master/lib/THCUNN/generic/SpatialConvolutionMM.cu
// modify from https://github.com/chengdazhi/Deformable-Convolution-V2-PyTorch/blob /mmdetection/mmdet/ops/dcn/src/modulated_dcn_cuda.c
#include
<torch/torch.h>
#include
<torch/extension.h>
#include
<cmath>
#include
<vector>
void
DeformablePSROIPoolForward
(
const
at
::
Tensor
data
,
const
at
::
Tensor
bbox
,
const
at
::
Tensor
trans
,
at
::
Tensor
out
,
at
::
Tensor
top_count
,
const
int
batch
,
const
int
channels
,
const
int
height
,
const
int
width
,
const
int
num_bbox
,
const
int
channels_trans
,
const
int
no_trans
,
const
float
spatial_scale
,
const
int
output_dim
,
const
int
group_size
,
const
int
pooled_size
,
const
int
part_size
,
const
int
sample_per_part
,
const
float
trans_std
);
void
DeformablePSROIPoolForward
(
const
at
::
Tensor
data
,
const
at
::
Tensor
bbox
,
const
at
::
Tensor
trans
,
at
::
Tensor
out
,
at
::
Tensor
top_count
,
const
int
batch
,
const
int
channels
,
const
int
height
,
const
int
width
,
const
int
num_bbox
,
const
int
channels_trans
,
const
int
no_trans
,
const
float
spatial_scale
,
const
int
output_dim
,
const
int
group_size
,
const
int
pooled_size
,
const
int
part_size
,
const
int
sample_per_part
,
const
float
trans_std
);
void
DeformablePSROIPoolBackwardAcc
(
const
at
::
Tensor
out_grad
,
const
at
::
Tensor
data
,
const
at
::
Tensor
bbox
,
const
at
::
Tensor
trans
,
const
at
::
Tensor
top_count
,
at
::
Tensor
in_grad
,
at
::
Tensor
trans_grad
,
const
int
batch
,
const
int
channels
,
const
int
height
,
const
int
width
,
const
int
num_bbox
,
const
int
channels_trans
,
const
int
no_trans
,
const
float
spatial_scale
,
const
int
output_dim
,
const
int
group_size
,
const
int
pooled_size
,
const
int
part_size
,
const
int
sample_per_part
,
const
float
trans_std
);
void
DeformablePSROIPoolBackwardAcc
(
const
at
::
Tensor
out_grad
,
const
at
::
Tensor
data
,
const
at
::
Tensor
bbox
,
const
at
::
Tensor
trans
,
const
at
::
Tensor
top_count
,
at
::
Tensor
in_grad
,
at
::
Tensor
trans_grad
,
const
int
batch
,
const
int
channels
,
const
int
height
,
const
int
width
,
const
int
num_bbox
,
const
int
channels_trans
,
const
int
no_trans
,
const
float
spatial_scale
,
const
int
output_dim
,
const
int
group_size
,
const
int
pooled_size
,
const
int
part_size
,
const
int
sample_per_part
,
const
float
trans_std
);
void
deform_psroi_pooling_cuda_forward
(
at
::
Tensor
input
,
at
::
Tensor
bbox
,
at
::
Tensor
trans
,
at
::
Tensor
out
,
at
::
Tensor
top_count
,
const
int
no_trans
,
const
float
spatial_scale
,
const
int
output_dim
,
const
int
group_size
,
const
int
pooled_size
,
const
int
part_size
,
const
int
sample_per_part
,
const
float
trans_std
)
{
AT_CHECK
(
input
.
is_contiguous
(),
"input tensor has to be contiguous"
);
void
deform_psroi_pooling_cuda_forward
(
at
::
Tensor
input
,
at
::
Tensor
bbox
,
at
::
Tensor
trans
,
at
::
Tensor
out
,
at
::
Tensor
top_count
,
const
int
no_trans
,
const
float
spatial_scale
,
const
int
output_dim
,
const
int
group_size
,
const
int
pooled_size
,
const
int
part_size
,
const
int
sample_per_part
,
const
float
trans_std
)
{
AT_CHECK
(
input
.
is_contiguous
(),
"input tensor has to be contiguous"
);
const
int
batch
=
input
.
size
(
0
);
const
int
channels
=
input
.
size
(
1
);
const
int
height
=
input
.
size
(
2
);
const
int
width
=
input
.
size
(
3
);
const
int
channels_trans
=
no_trans
?
2
:
trans
.
size
(
1
);
const
int
batch
=
input
.
size
(
0
);
const
int
channels
=
input
.
size
(
1
);
const
int
height
=
input
.
size
(
2
);
const
int
width
=
input
.
size
(
3
);
const
int
channels_trans
=
no_trans
?
2
:
trans
.
size
(
1
);
const
int
num_bbox
=
bbox
.
size
(
0
);
if
(
num_bbox
!=
out
.
size
(
0
))
AT_ERROR
(
"Output shape and bbox number wont match: (%d vs %d)."
,
out
.
size
(
0
),
num_bbox
);
const
int
num_bbox
=
bbox
.
size
(
0
);
if
(
num_bbox
!=
out
.
size
(
0
))
AT_ERROR
(
"Output shape and bbox number wont match: (%d vs %d)."
,
out
.
size
(
0
),
num_bbox
);
DeformablePSROIPoolForward
(
input
,
bbox
,
trans
,
out
,
top_count
,
batch
,
channels
,
height
,
width
,
num_bbox
,
channels_trans
,
no_trans
,
spatial_scale
,
output_dim
,
group_size
,
pooled_size
,
part_size
,
sample_per_part
,
trans_std
);
DeformablePSROIPoolForward
(
input
,
bbox
,
trans
,
out
,
top_count
,
batch
,
channels
,
height
,
width
,
num_bbox
,
channels_trans
,
no_trans
,
spatial_scale
,
output_dim
,
group_size
,
pooled_size
,
part_size
,
sample_per_part
,
trans_std
);
}
void
deform_psroi_pooling_cuda_backward
(
at
::
Tensor
out_grad
,
at
::
Tensor
input
,
at
::
Tensor
bbox
,
at
::
Tensor
trans
,
at
::
Tensor
top_count
,
at
::
Tensor
input_grad
,
at
::
Tensor
trans_grad
,
const
int
no_trans
,
const
float
spatial_scale
,
const
int
output_dim
,
const
int
group_size
,
const
int
pooled_size
,
const
int
part_size
,
const
int
sample_per_part
,
const
float
trans_std
)
{
AT_CHECK
(
out_grad
.
is_contiguous
(),
"out_grad tensor has to be contiguous"
);
AT_CHECK
(
input
.
is_contiguous
(),
"input tensor has to be contiguous"
);
void
deform_psroi_pooling_cuda_backward
(
at
::
Tensor
out_grad
,
at
::
Tensor
input
,
at
::
Tensor
bbox
,
at
::
Tensor
trans
,
at
::
Tensor
top_count
,
at
::
Tensor
input_grad
,
at
::
Tensor
trans_grad
,
const
int
no_trans
,
const
float
spatial_scale
,
const
int
output_dim
,
const
int
group_size
,
const
int
pooled_size
,
const
int
part_size
,
const
int
sample_per_part
,
const
float
trans_std
)
{
AT_CHECK
(
out_grad
.
is_contiguous
(),
"out_grad tensor has to be contiguous"
);
AT_CHECK
(
input
.
is_contiguous
(),
"input tensor has to be contiguous"
);
const
int
batch
=
input
.
size
(
0
);
const
int
channels
=
input
.
size
(
1
);
const
int
height
=
input
.
size
(
2
);
const
int
width
=
input
.
size
(
3
);
const
int
channels_trans
=
no_trans
?
2
:
trans
.
size
(
1
);
const
int
batch
=
input
.
size
(
0
);
const
int
channels
=
input
.
size
(
1
);
const
int
height
=
input
.
size
(
2
);
const
int
width
=
input
.
size
(
3
);
const
int
channels_trans
=
no_trans
?
2
:
trans
.
size
(
1
);
const
int
num_bbox
=
bbox
.
size
(
0
);
if
(
num_bbox
!=
out_grad
.
size
(
0
))
AT_ERROR
(
"Output shape and bbox number wont match: (%d vs %d)."
,
out_grad
.
size
(
0
),
num_bbox
);
const
int
num_bbox
=
bbox
.
size
(
0
);
if
(
num_bbox
!=
out_grad
.
size
(
0
))
AT_ERROR
(
"Output shape and bbox number wont match: (%d vs %d)."
,
out_grad
.
size
(
0
),
num_bbox
);
DeformablePSROIPoolBackwardAcc
(
out_grad
,
input
,
bbox
,
trans
,
top_count
,
input_grad
,
trans_grad
,
batch
,
channels
,
height
,
width
,
num_bbox
,
channels_trans
,
no_trans
,
spatial_scale
,
output_dim
,
group_size
,
pooled_size
,
part_size
,
sample_per_part
,
trans_std
);
DeformablePSROIPoolBackwardAcc
(
out_grad
,
input
,
bbox
,
trans
,
top_count
,
input_grad
,
trans_grad
,
batch
,
channels
,
height
,
width
,
num_bbox
,
channels_trans
,
no_trans
,
spatial_scale
,
output_dim
,
group_size
,
pooled_size
,
part_size
,
sample_per_part
,
trans_std
);
}
PYBIND11_MODULE
(
TORCH_EXTENSION_NAME
,
m
)
{
m
.
def
(
"deform
_psroi_pooling_cuda_forward"
,
&
deform_
psroi
_
pooling
_cuda_
forward
,
"deform
psroi
pooling
forward(CUDA)"
);
m
.
def
(
"deform_psroi_pooling_cuda_backward"
,
&
deform_psroi_pooling_cuda_backward
,
"deform psroi pooling backward(CUDA)"
);
PYBIND11_MODULE
(
TORCH_EXTENSION_NAME
,
m
)
{
m
.
def
(
"deform_psroi_pooling_cuda_forward"
,
&
deform_psroi_pooling_cuda_forward
,
"deform
psroi
pooling
forward
(CUDA)"
);
m
.
def
(
"deform
_
psroi
_
pooling
_cuda_backward"
,
&
deform_psroi_pooling_cuda_backward
,
"deform psroi pooling backward(CUDA)"
);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment