Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
ae87c1e4
Unverified
Commit
ae87c1e4
authored
Jan 14, 2021
by
Vasilis Vryniotis
Committed by
GitHub
Jan 14, 2021
Browse files
Update to clang-format 11. (#3254)
parent
7bf6e7b1
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
233 additions
and
195 deletions
+233
-195
torchvision/csrc/ops/autograd/ps_roi_align_kernel.cpp
torchvision/csrc/ops/autograd/ps_roi_align_kernel.cpp
+7
-6
torchvision/csrc/ops/autograd/ps_roi_pool_kernel.cpp
torchvision/csrc/ops/autograd/ps_roi_pool_kernel.cpp
+6
-5
torchvision/csrc/ops/autograd/roi_align_kernel.cpp
torchvision/csrc/ops/autograd/roi_align_kernel.cpp
+8
-7
torchvision/csrc/ops/autograd/roi_pool_kernel.cpp
torchvision/csrc/ops/autograd/roi_pool_kernel.cpp
+6
-5
torchvision/csrc/ops/cpu/deform_conv2d_kernel.cpp
torchvision/csrc/ops/cpu/deform_conv2d_kernel.cpp
+103
-86
torchvision/csrc/ops/cuda/deform_conv2d_kernel.cu
torchvision/csrc/ops/cuda/deform_conv2d_kernel.cu
+103
-86
No files found.
torchvision/csrc/ops/autograd/ps_roi_align_kernel.cpp
View file @
ae87c1e4
...
@@ -62,12 +62,13 @@ class PSROIAlignFunction
...
@@ -62,12 +62,13 @@ class PSROIAlignFunction
input_shape
[
2
],
input_shape
[
2
],
input_shape
[
3
]);
input_shape
[
3
]);
return
{
grad_in
,
return
{
torch
::
autograd
::
Variable
(),
grad_in
,
torch
::
autograd
::
Variable
(),
torch
::
autograd
::
Variable
(),
torch
::
autograd
::
Variable
(),
torch
::
autograd
::
Variable
(),
torch
::
autograd
::
Variable
(),
torch
::
autograd
::
Variable
(),
torch
::
autograd
::
Variable
()};
torch
::
autograd
::
Variable
(),
torch
::
autograd
::
Variable
()};
}
}
};
};
...
...
torchvision/csrc/ops/autograd/ps_roi_pool_kernel.cpp
View file @
ae87c1e4
...
@@ -53,11 +53,12 @@ class PSROIPoolFunction : public torch::autograd::Function<PSROIPoolFunction> {
...
@@ -53,11 +53,12 @@ class PSROIPoolFunction : public torch::autograd::Function<PSROIPoolFunction> {
input_shape
[
2
],
input_shape
[
2
],
input_shape
[
3
]);
input_shape
[
3
]);
return
{
grad_in
,
return
{
torch
::
autograd
::
Variable
(),
grad_in
,
torch
::
autograd
::
Variable
(),
torch
::
autograd
::
Variable
(),
torch
::
autograd
::
Variable
(),
torch
::
autograd
::
Variable
(),
torch
::
autograd
::
Variable
()};
torch
::
autograd
::
Variable
(),
torch
::
autograd
::
Variable
()};
}
}
};
};
...
...
torchvision/csrc/ops/autograd/roi_align_kernel.cpp
View file @
ae87c1e4
...
@@ -57,13 +57,14 @@ class ROIAlignFunction : public torch::autograd::Function<ROIAlignFunction> {
...
@@ -57,13 +57,14 @@ class ROIAlignFunction : public torch::autograd::Function<ROIAlignFunction> {
input_shape
[
3
],
input_shape
[
3
],
ctx
->
saved_data
[
"sampling_ratio"
].
toInt
(),
ctx
->
saved_data
[
"sampling_ratio"
].
toInt
(),
ctx
->
saved_data
[
"aligned"
].
toBool
());
ctx
->
saved_data
[
"aligned"
].
toBool
());
return
{
grad_in
,
return
{
torch
::
autograd
::
Variable
(),
grad_in
,
torch
::
autograd
::
Variable
(),
torch
::
autograd
::
Variable
(),
torch
::
autograd
::
Variable
(),
torch
::
autograd
::
Variable
(),
torch
::
autograd
::
Variable
(),
torch
::
autograd
::
Variable
(),
torch
::
autograd
::
Variable
(),
torch
::
autograd
::
Variable
(),
torch
::
autograd
::
Variable
()};
torch
::
autograd
::
Variable
(),
torch
::
autograd
::
Variable
()};
}
}
};
};
...
...
torchvision/csrc/ops/autograd/roi_pool_kernel.cpp
View file @
ae87c1e4
...
@@ -53,11 +53,12 @@ class ROIPoolFunction : public torch::autograd::Function<ROIPoolFunction> {
...
@@ -53,11 +53,12 @@ class ROIPoolFunction : public torch::autograd::Function<ROIPoolFunction> {
input_shape
[
2
],
input_shape
[
2
],
input_shape
[
3
]);
input_shape
[
3
]);
return
{
grad_in
,
return
{
torch
::
autograd
::
Variable
(),
grad_in
,
torch
::
autograd
::
Variable
(),
torch
::
autograd
::
Variable
(),
torch
::
autograd
::
Variable
(),
torch
::
autograd
::
Variable
(),
torch
::
autograd
::
Variable
()};
torch
::
autograd
::
Variable
(),
torch
::
autograd
::
Variable
()};
}
}
};
};
...
...
torchvision/csrc/ops/cpu/deform_conv2d_kernel.cpp
View file @
ae87c1e4
...
@@ -634,44 +634,50 @@ std::tuple<at::Tensor, at::Tensor, at::Tensor> backward_gradient_inputs(
...
@@ -634,44 +634,50 @@ std::tuple<at::Tensor, at::Tensor, at::Tensor> backward_gradient_inputs(
input
=
input
.
reshape
(
input
=
input
.
reshape
(
{
batch_sz
/
n_parallel_imgs
,
n_parallel_imgs
,
n_in_channels
,
in_h
,
in_w
});
{
batch_sz
/
n_parallel_imgs
,
n_parallel_imgs
,
n_in_channels
,
in_h
,
in_w
});
grad_offset
=
grad_offset
.
reshape
({
batch_sz
/
n_parallel_imgs
,
grad_offset
=
grad_offset
.
reshape
(
n_parallel_imgs
,
{
batch_sz
/
n_parallel_imgs
,
n_offset_grps
*
2
*
weight_h
*
weight_w
,
n_parallel_imgs
,
out_h
,
n_offset_grps
*
2
*
weight_h
*
weight_w
,
out_w
});
out_h
,
offset
=
offset
.
reshape
({
batch_sz
/
n_parallel_imgs
,
out_w
});
n_parallel_imgs
,
offset
=
offset
.
reshape
(
n_offset_grps
*
2
*
weight_h
*
weight_w
,
{
batch_sz
/
n_parallel_imgs
,
out_h
,
n_parallel_imgs
,
out_w
});
n_offset_grps
*
2
*
weight_h
*
weight_w
,
out_h
,
out_w
});
if
(
use_mask
)
{
if
(
use_mask
)
{
grad_mask
=
grad_mask
.
reshape
({
batch_sz
/
n_parallel_imgs
,
grad_mask
=
grad_mask
.
reshape
(
n_parallel_imgs
,
{
batch_sz
/
n_parallel_imgs
,
n_offset_grps
*
weight_h
*
weight_w
,
n_parallel_imgs
,
out_h
,
n_offset_grps
*
weight_h
*
weight_w
,
out_w
});
out_h
,
mask
=
mask
.
reshape
({
batch_sz
/
n_parallel_imgs
,
out_w
});
n_parallel_imgs
,
mask
=
mask
.
reshape
(
n_offset_grps
*
weight_h
*
weight_w
,
{
batch_sz
/
n_parallel_imgs
,
out_h
,
n_parallel_imgs
,
out_w
});
n_offset_grps
*
weight_h
*
weight_w
,
out_h
,
out_w
});
}
}
grad_out
=
grad_out
grad_out
=
grad_out
.
reshape
({
batch_sz
/
n_parallel_imgs
,
.
reshape
(
n_parallel_imgs
,
{
batch_sz
/
n_parallel_imgs
,
n_weight_grps
,
n_parallel_imgs
,
n_out_channels
/
n_weight_grps
,
n_weight_grps
,
out_h
,
n_out_channels
/
n_weight_grps
,
out_w
})
out_h
,
out_w
})
.
permute
({
0
,
2
,
3
,
1
,
4
,
5
});
.
permute
({
0
,
2
,
3
,
1
,
4
,
5
});
weight
=
weight
.
reshape
({
n_weight_grps
,
weight
=
weight
.
reshape
(
weight
.
size
(
0
)
/
n_weight_grps
,
{
n_weight_grps
,
weight
.
size
(
1
),
weight
.
size
(
0
)
/
n_weight_grps
,
weight
.
size
(
2
),
weight
.
size
(
1
),
weight
.
size
(
3
)});
weight
.
size
(
2
),
weight
.
size
(
3
)});
columns
=
columns
.
view
(
columns
=
columns
.
view
(
{
n_weight_grps
,
columns
.
size
(
0
)
/
n_weight_grps
,
columns
.
size
(
1
)});
{
n_weight_grps
,
columns
.
size
(
0
)
/
n_weight_grps
,
columns
.
size
(
1
)});
...
@@ -775,37 +781,41 @@ at::Tensor backward_gradient_parameters(
...
@@ -775,37 +781,41 @@ at::Tensor backward_gradient_parameters(
}
}
at
::
Tensor
grad_out_buf
=
grad_out
at
::
Tensor
grad_out_buf
=
grad_out
.
reshape
({
batch_sz
/
n_parallel_imgs
,
.
reshape
(
n_parallel_imgs
,
{
batch_sz
/
n_parallel_imgs
,
n_weight_grps
,
n_parallel_imgs
,
n_out_channels
/
n_weight_grps
,
n_weight_grps
,
out_h
,
n_out_channels
/
n_weight_grps
,
out_w
})
out_h
,
out_w
})
.
permute
({
0
,
2
,
3
,
1
,
4
,
5
})
.
permute
({
0
,
2
,
3
,
1
,
4
,
5
})
.
contiguous
();
.
contiguous
();
input
=
input
.
reshape
(
input
=
input
.
reshape
(
{
batch_sz
/
n_parallel_imgs
,
n_parallel_imgs
,
n_in_channels
,
in_h
,
in_w
});
{
batch_sz
/
n_parallel_imgs
,
n_parallel_imgs
,
n_in_channels
,
in_h
,
in_w
});
offset
=
offset
.
reshape
({
batch_sz
/
n_parallel_imgs
,
offset
=
offset
.
reshape
(
n_parallel_imgs
,
{
batch_sz
/
n_parallel_imgs
,
n_offset_grps
*
2
*
weight_h
*
weight_w
,
n_parallel_imgs
,
out_h
,
n_offset_grps
*
2
*
weight_h
*
weight_w
,
out_w
});
out_h
,
out_w
});
if
(
use_mask
)
{
if
(
use_mask
)
{
mask
=
mask
.
reshape
({
batch_sz
/
n_parallel_imgs
,
mask
=
mask
.
reshape
(
n_parallel_imgs
,
{
batch_sz
/
n_parallel_imgs
,
n_offset_grps
*
weight_h
*
weight_w
,
n_parallel_imgs
,
out_h
,
n_offset_grps
*
weight_h
*
weight_w
,
out_w
});
out_h
,
out_w
});
}
}
grad_weight
=
grad_weight
.
view
({
n_weight_grps
,
grad_weight
=
grad_weight
.
view
(
grad_weight
.
size
(
0
)
/
n_weight_grps
,
{
n_weight_grps
,
grad_weight
.
size
(
1
),
grad_weight
.
size
(
0
)
/
n_weight_grps
,
grad_weight
.
size
(
2
),
grad_weight
.
size
(
1
),
grad_weight
.
size
(
3
)});
grad_weight
.
size
(
2
),
grad_weight
.
size
(
3
)});
auto
columns
=
at
::
empty
(
auto
columns
=
at
::
empty
(
{
n_weight_grps
,
{
n_weight_grps
,
...
@@ -846,10 +856,11 @@ at::Tensor backward_gradient_parameters(
...
@@ -846,10 +856,11 @@ at::Tensor backward_gradient_parameters(
}
}
}
}
grad_weight
=
grad_weight
.
view
({
grad_weight
.
size
(
0
)
*
grad_weight
.
size
(
1
),
grad_weight
=
grad_weight
.
view
(
grad_weight
.
size
(
2
),
{
grad_weight
.
size
(
0
)
*
grad_weight
.
size
(
1
),
grad_weight
.
size
(
3
),
grad_weight
.
size
(
2
),
grad_weight
.
size
(
4
)});
grad_weight
.
size
(
3
),
grad_weight
.
size
(
4
)});
return
grad_weight
;
return
grad_weight
;
}
}
...
@@ -976,26 +987,29 @@ at::Tensor deform_conv2d_forward_kernel(
...
@@ -976,26 +987,29 @@ at::Tensor deform_conv2d_forward_kernel(
}
}
// Separate batches into blocks
// Separate batches into blocks
out
=
out
.
view
({
batch_sz
/
n_parallel_imgs
,
out
=
out
.
view
(
n_parallel_imgs
,
{
batch_sz
/
n_parallel_imgs
,
out_channels
,
n_parallel_imgs
,
out_h
,
out_channels
,
out_w
});
out_h
,
out_w
});
input_c
=
input_c
.
view
(
input_c
=
input_c
.
view
(
{
batch_sz
/
n_parallel_imgs
,
n_parallel_imgs
,
n_in_channels
,
in_h
,
in_w
});
{
batch_sz
/
n_parallel_imgs
,
n_parallel_imgs
,
n_in_channels
,
in_h
,
in_w
});
offset_c
=
offset_c
.
view
({
batch_sz
/
n_parallel_imgs
,
offset_c
=
offset_c
.
view
(
n_parallel_imgs
,
{
batch_sz
/
n_parallel_imgs
,
n_offset_grps
*
2
*
weight_h
*
weight_w
,
n_parallel_imgs
,
out_h
,
n_offset_grps
*
2
*
weight_h
*
weight_w
,
out_w
});
out_h
,
out_w
});
if
(
use_mask
)
{
if
(
use_mask
)
{
mask_c
=
mask_c
.
view
({
batch_sz
/
n_parallel_imgs
,
mask_c
=
mask_c
.
view
(
n_parallel_imgs
,
{
batch_sz
/
n_parallel_imgs
,
n_offset_grps
*
weight_h
*
weight_w
,
n_parallel_imgs
,
out_h
,
n_offset_grps
*
weight_h
*
weight_w
,
out_w
});
out_h
,
out_w
});
}
}
at
::
Tensor
out_buf
=
at
::
zeros
(
at
::
Tensor
out_buf
=
at
::
zeros
(
...
@@ -1006,16 +1020,18 @@ at::Tensor deform_conv2d_forward_kernel(
...
@@ -1006,16 +1020,18 @@ at::Tensor deform_conv2d_forward_kernel(
out
.
options
());
out
.
options
());
// Separate channels into convolution groups
// Separate channels into convolution groups
out_buf
=
out_buf
.
view
({
out_buf
.
size
(
0
),
out_buf
=
out_buf
.
view
(
n_weight_grps
,
{
out_buf
.
size
(
0
),
out_buf
.
size
(
1
)
/
n_weight_grps
,
n_weight_grps
,
out_buf
.
size
(
2
),
out_buf
.
size
(
1
)
/
n_weight_grps
,
out_buf
.
size
(
3
)});
out_buf
.
size
(
2
),
weight_c
=
weight_c
.
view
({
n_weight_grps
,
out_buf
.
size
(
3
)});
weight_c
.
size
(
0
)
/
n_weight_grps
,
weight_c
=
weight_c
.
view
(
weight_c
.
size
(
1
),
{
n_weight_grps
,
weight_c
.
size
(
2
),
weight_c
.
size
(
0
)
/
n_weight_grps
,
weight_c
.
size
(
3
)});
weight_c
.
size
(
1
),
weight_c
.
size
(
2
),
weight_c
.
size
(
3
)});
// Sample points and perform convolution
// Sample points and perform convolution
auto
columns
=
at
::
zeros
(
auto
columns
=
at
::
zeros
(
...
@@ -1056,11 +1072,12 @@ at::Tensor deform_conv2d_forward_kernel(
...
@@ -1056,11 +1072,12 @@ at::Tensor deform_conv2d_forward_kernel(
columns
.
view
({
columns
.
size
(
0
)
*
columns
.
size
(
1
),
columns
.
size
(
2
)});
columns
.
view
({
columns
.
size
(
0
)
*
columns
.
size
(
1
),
columns
.
size
(
2
)});
}
}
out_buf
=
out_buf
.
view
({
batch_sz
/
n_parallel_imgs
,
out_buf
=
out_buf
.
view
(
out_channels
,
{
batch_sz
/
n_parallel_imgs
,
n_parallel_imgs
,
out_channels
,
out_h
,
n_parallel_imgs
,
out_w
});
out_h
,
out_w
});
out_buf
.
transpose_
(
1
,
2
);
out_buf
.
transpose_
(
1
,
2
);
out
.
copy_
(
out_buf
);
out
.
copy_
(
out_buf
);
out
=
out
.
view
({
batch_sz
,
out_channels
,
out_h
,
out_w
});
out
=
out
.
view
({
batch_sz
,
out_channels
,
out_h
,
out_w
});
...
...
torchvision/csrc/ops/cuda/deform_conv2d_kernel.cu
View file @
ae87c1e4
...
@@ -677,44 +677,50 @@ std::tuple<at::Tensor, at::Tensor, at::Tensor> backward_gradient_inputs(
...
@@ -677,44 +677,50 @@ std::tuple<at::Tensor, at::Tensor, at::Tensor> backward_gradient_inputs(
input
=
input
.
reshape
(
input
=
input
.
reshape
(
{
batch_sz
/
n_parallel_imgs
,
n_parallel_imgs
,
n_in_channels
,
in_h
,
in_w
});
{
batch_sz
/
n_parallel_imgs
,
n_parallel_imgs
,
n_in_channels
,
in_h
,
in_w
});
grad_offset
=
grad_offset
.
reshape
({
batch_sz
/
n_parallel_imgs
,
grad_offset
=
grad_offset
.
reshape
(
n_parallel_imgs
,
{
batch_sz
/
n_parallel_imgs
,
n_offset_grps
*
2
*
weight_h
*
weight_w
,
n_parallel_imgs
,
out_h
,
n_offset_grps
*
2
*
weight_h
*
weight_w
,
out_w
});
out_h
,
offset
=
offset
.
reshape
({
batch_sz
/
n_parallel_imgs
,
out_w
});
n_parallel_imgs
,
offset
=
offset
.
reshape
(
n_offset_grps
*
2
*
weight_h
*
weight_w
,
{
batch_sz
/
n_parallel_imgs
,
out_h
,
n_parallel_imgs
,
out_w
});
n_offset_grps
*
2
*
weight_h
*
weight_w
,
out_h
,
out_w
});
if
(
use_mask
)
{
if
(
use_mask
)
{
grad_mask
=
grad_mask
.
reshape
({
batch_sz
/
n_parallel_imgs
,
grad_mask
=
grad_mask
.
reshape
(
n_parallel_imgs
,
{
batch_sz
/
n_parallel_imgs
,
n_offset_grps
*
weight_h
*
weight_w
,
n_parallel_imgs
,
out_h
,
n_offset_grps
*
weight_h
*
weight_w
,
out_w
});
out_h
,
mask
=
mask
.
reshape
({
batch_sz
/
n_parallel_imgs
,
out_w
});
n_parallel_imgs
,
mask
=
mask
.
reshape
(
n_offset_grps
*
weight_h
*
weight_w
,
{
batch_sz
/
n_parallel_imgs
,
out_h
,
n_parallel_imgs
,
out_w
});
n_offset_grps
*
weight_h
*
weight_w
,
out_h
,
out_w
});
}
}
grad_out
=
grad_out
grad_out
=
grad_out
.
reshape
({
batch_sz
/
n_parallel_imgs
,
.
reshape
(
n_parallel_imgs
,
{
batch_sz
/
n_parallel_imgs
,
n_weight_grps
,
n_parallel_imgs
,
n_out_channels
/
n_weight_grps
,
n_weight_grps
,
out_h
,
n_out_channels
/
n_weight_grps
,
out_w
})
out_h
,
out_w
})
.
permute
({
0
,
2
,
3
,
1
,
4
,
5
});
.
permute
({
0
,
2
,
3
,
1
,
4
,
5
});
weight
=
weight
.
reshape
({
n_weight_grps
,
weight
=
weight
.
reshape
(
weight
.
size
(
0
)
/
n_weight_grps
,
{
n_weight_grps
,
weight
.
size
(
1
),
weight
.
size
(
0
)
/
n_weight_grps
,
weight
.
size
(
2
),
weight
.
size
(
1
),
weight
.
size
(
3
)});
weight
.
size
(
2
),
weight
.
size
(
3
)});
columns
=
columns
.
view
(
columns
=
columns
.
view
(
{
n_weight_grps
,
columns
.
size
(
0
)
/
n_weight_grps
,
columns
.
size
(
1
)});
{
n_weight_grps
,
columns
.
size
(
0
)
/
n_weight_grps
,
columns
.
size
(
1
)});
...
@@ -819,37 +825,41 @@ at::Tensor backward_gradient_parameters(
...
@@ -819,37 +825,41 @@ at::Tensor backward_gradient_parameters(
}
}
at
::
Tensor
grad_out_buf
=
grad_out
at
::
Tensor
grad_out_buf
=
grad_out
.
reshape
({
batch_sz
/
n_parallel_imgs
,
.
reshape
(
n_parallel_imgs
,
{
batch_sz
/
n_parallel_imgs
,
n_weight_grps
,
n_parallel_imgs
,
n_out_channels
/
n_weight_grps
,
n_weight_grps
,
out_h
,
n_out_channels
/
n_weight_grps
,
out_w
})
out_h
,
out_w
})
.
permute
({
0
,
2
,
3
,
1
,
4
,
5
})
.
permute
({
0
,
2
,
3
,
1
,
4
,
5
})
.
contiguous
();
.
contiguous
();
input
=
input
.
reshape
(
input
=
input
.
reshape
(
{
batch_sz
/
n_parallel_imgs
,
n_parallel_imgs
,
n_in_channels
,
in_h
,
in_w
});
{
batch_sz
/
n_parallel_imgs
,
n_parallel_imgs
,
n_in_channels
,
in_h
,
in_w
});
offset
=
offset
.
reshape
({
batch_sz
/
n_parallel_imgs
,
offset
=
offset
.
reshape
(
n_parallel_imgs
,
{
batch_sz
/
n_parallel_imgs
,
n_offset_grps
*
2
*
weight_h
*
weight_w
,
n_parallel_imgs
,
out_h
,
n_offset_grps
*
2
*
weight_h
*
weight_w
,
out_w
});
out_h
,
out_w
});
if
(
use_mask
)
{
if
(
use_mask
)
{
mask
=
mask
.
reshape
({
batch_sz
/
n_parallel_imgs
,
mask
=
mask
.
reshape
(
n_parallel_imgs
,
{
batch_sz
/
n_parallel_imgs
,
n_offset_grps
*
weight_h
*
weight_w
,
n_parallel_imgs
,
out_h
,
n_offset_grps
*
weight_h
*
weight_w
,
out_w
});
out_h
,
out_w
});
}
}
grad_weight
=
grad_weight
.
reshape
({
n_weight_grps
,
grad_weight
=
grad_weight
.
reshape
(
grad_weight
.
size
(
0
)
/
n_weight_grps
,
{
n_weight_grps
,
grad_weight
.
size
(
1
),
grad_weight
.
size
(
0
)
/
n_weight_grps
,
grad_weight
.
size
(
2
),
grad_weight
.
size
(
1
),
grad_weight
.
size
(
3
)});
grad_weight
.
size
(
2
),
grad_weight
.
size
(
3
)});
auto
columns
=
at
::
empty
(
auto
columns
=
at
::
empty
(
{
n_weight_grps
,
{
n_weight_grps
,
...
@@ -890,10 +900,11 @@ at::Tensor backward_gradient_parameters(
...
@@ -890,10 +900,11 @@ at::Tensor backward_gradient_parameters(
}
}
}
}
grad_weight
=
grad_weight
.
view
({
grad_weight
.
size
(
0
)
*
grad_weight
.
size
(
1
),
grad_weight
=
grad_weight
.
view
(
grad_weight
.
size
(
2
),
{
grad_weight
.
size
(
0
)
*
grad_weight
.
size
(
1
),
grad_weight
.
size
(
3
),
grad_weight
.
size
(
2
),
grad_weight
.
size
(
4
)});
grad_weight
.
size
(
3
),
grad_weight
.
size
(
4
)});
return
grad_weight
;
return
grad_weight
;
}
}
...
@@ -1021,26 +1032,29 @@ at::Tensor deform_conv2d_forward_kernel(
...
@@ -1021,26 +1032,29 @@ at::Tensor deform_conv2d_forward_kernel(
}
}
// Separate batches into blocks
// Separate batches into blocks
out
=
out
.
view
({
batch_sz
/
n_parallel_imgs
,
out
=
out
.
view
(
n_parallel_imgs
,
{
batch_sz
/
n_parallel_imgs
,
out_channels
,
n_parallel_imgs
,
out_h
,
out_channels
,
out_w
});
out_h
,
out_w
});
input_c
=
input_c
.
view
(
input_c
=
input_c
.
view
(
{
batch_sz
/
n_parallel_imgs
,
n_parallel_imgs
,
in_channels
,
in_h
,
in_w
});
{
batch_sz
/
n_parallel_imgs
,
n_parallel_imgs
,
in_channels
,
in_h
,
in_w
});
offset_c
=
offset_c
.
view
({
batch_sz
/
n_parallel_imgs
,
offset_c
=
offset_c
.
view
(
n_parallel_imgs
,
{
batch_sz
/
n_parallel_imgs
,
n_offset_grps
*
2
*
weight_h
*
weight_w
,
n_parallel_imgs
,
out_h
,
n_offset_grps
*
2
*
weight_h
*
weight_w
,
out_w
});
out_h
,
out_w
});
if
(
use_mask
)
{
if
(
use_mask
)
{
mask_c
=
mask_c
.
view
({
batch_sz
/
n_parallel_imgs
,
mask_c
=
mask_c
.
view
(
n_parallel_imgs
,
{
batch_sz
/
n_parallel_imgs
,
n_offset_grps
*
weight_h
*
weight_w
,
n_parallel_imgs
,
out_h
,
n_offset_grps
*
weight_h
*
weight_w
,
out_w
});
out_h
,
out_w
});
}
}
at
::
Tensor
out_buf
=
at
::
zeros
(
at
::
Tensor
out_buf
=
at
::
zeros
(
...
@@ -1051,16 +1065,18 @@ at::Tensor deform_conv2d_forward_kernel(
...
@@ -1051,16 +1065,18 @@ at::Tensor deform_conv2d_forward_kernel(
out
.
options
());
out
.
options
());
// Separate channels into convolution groups
// Separate channels into convolution groups
out_buf
=
out_buf
.
view
({
out_buf
.
size
(
0
),
out_buf
=
out_buf
.
view
(
n_weight_grps
,
{
out_buf
.
size
(
0
),
out_buf
.
size
(
1
)
/
n_weight_grps
,
n_weight_grps
,
out_buf
.
size
(
2
),
out_buf
.
size
(
1
)
/
n_weight_grps
,
out_buf
.
size
(
3
)});
out_buf
.
size
(
2
),
weight_c
=
weight_c
.
view
({
n_weight_grps
,
out_buf
.
size
(
3
)});
weight_c
.
size
(
0
)
/
n_weight_grps
,
weight_c
=
weight_c
.
view
(
weight_c
.
size
(
1
),
{
n_weight_grps
,
weight_c
.
size
(
2
),
weight_c
.
size
(
0
)
/
n_weight_grps
,
weight_c
.
size
(
3
)});
weight_c
.
size
(
1
),
weight_c
.
size
(
2
),
weight_c
.
size
(
3
)});
// Sample points and perform convolution
// Sample points and perform convolution
auto
columns
=
at
::
zeros
(
auto
columns
=
at
::
zeros
(
...
@@ -1101,11 +1117,12 @@ at::Tensor deform_conv2d_forward_kernel(
...
@@ -1101,11 +1117,12 @@ at::Tensor deform_conv2d_forward_kernel(
columns
.
view
({
columns
.
size
(
0
)
*
columns
.
size
(
1
),
columns
.
size
(
2
)});
columns
.
view
({
columns
.
size
(
0
)
*
columns
.
size
(
1
),
columns
.
size
(
2
)});
}
}
out_buf
=
out_buf
.
view
({
batch_sz
/
n_parallel_imgs
,
out_buf
=
out_buf
.
view
(
out_channels
,
{
batch_sz
/
n_parallel_imgs
,
n_parallel_imgs
,
out_channels
,
out_h
,
n_parallel_imgs
,
out_w
});
out_h
,
out_w
});
out_buf
.
transpose_
(
1
,
2
);
out_buf
.
transpose_
(
1
,
2
);
out
.
copy_
(
out_buf
);
out
.
copy_
(
out_buf
);
out
=
out
.
view
({
batch_sz
,
out_channels
,
out_h
,
out_w
});
out
=
out
.
view
({
batch_sz
,
out_channels
,
out_h
,
out_w
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment