Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add channels last support for thnn_conv2d (non-dilated) #49582

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
892ed9c
add channels last support for thnn_conv2d (non-dilated)
mingfeima Dec 18, 2020
ce08011
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima Dec 21, 2020
114a93c
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima Jan 1, 2021
8a9a7c5
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima Jan 5, 2021
7e2b955
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima Jan 8, 2021
6aab268
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima Jan 18, 2021
eae6036
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima Jan 20, 2021
27cad2b
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima Jan 20, 2021
ed4fac0
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima Jan 25, 2021
f235c59
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima Jan 25, 2021
c1bef15
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima Feb 5, 2021
a80f583
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima Feb 17, 2021
2966b0b
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima Feb 17, 2021
ab1aed8
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima Feb 20, 2021
91b4dae
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima Feb 22, 2021
7a5e176
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima Mar 30, 2021
00117ca
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima Mar 30, 2021
f81bd56
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima Mar 30, 2021
b4e3a60
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima Mar 31, 2021
307c956
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima Apr 1, 2021
18d6c48
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima Apr 8, 2021
d92fd70
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima Apr 13, 2021
5b870b0
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima Apr 22, 2021
244d767
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima Apr 23, 2021
d218ea0
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima Apr 27, 2021
3eff633
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima Apr 28, 2021
39244bb
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima May 11, 2021
d7983f8
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima May 13, 2021
1b6d647
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima May 15, 2021
73257fd
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima Jun 3, 2021
cb456c6
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima Jun 3, 2021
60e0d55
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima Jun 3, 2021
77f7ec2
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima Jun 11, 2021
1d739b0
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima Jun 11, 2021
3dd38e4
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima Jun 15, 2021
2762055
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima Jun 29, 2021
9cb085d
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima Jun 30, 2021
7279dd8
Update on "add channels last support for thnn_conv2d (non-dilated)"
mingfeima Jul 8, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 12 additions & 3 deletions aten/src/ATen/native/Convolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,8 +561,9 @@ static at::Tensor subtensor(at::Tensor& tensor, int dim, int groups, int g) {
if (!tensor.defined()) {
return at::Tensor();
}
auto memory_format = tensor.suggest_memory_format();
int64_t n = tensor.sizes()[dim] / groups;
return tensor.narrow(dim, n * g, n).contiguous();
return tensor.narrow(dim, n * g, n).contiguous(memory_format);
}


Expand Down Expand Up @@ -965,12 +966,20 @@ at::Tensor _convolution(
params.stride,
params.padding);
} else if (input.device().is_cpu() || input.is_cuda()) {
bool is_channels_last_supported = !params.transposed && (input.ndimension() == 4) &&
!params.use_nnpack(input, weight) && input.device().is_cpu() &&
!params.is_dilated();
if (is_channels_last_supported) {
auto memory_format = input.suggest_memory_format();
input = input.contiguous(memory_format);
} else {
input = input.contiguous();
}
if (params.groups == 1) {
output = at::_convolution_nogroup(
input.contiguous(), weight, bias, params.stride, params.padding, params.dilation, params.transposed, params.output_padding);
input, weight, bias, params.stride, params.padding, params.dilation, params.transposed, params.output_padding);
} else {
std::vector<Tensor> outputs(params.groups);
input = input.contiguous();
for (int g = 0; g < params.groups; ++g) {
auto input_g = subtensor(input, 1, params.groups, g);
auto weight_g = subtensor(weight, 0, params.groups, g);
Expand Down