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

[Bug fix] Add new unittests for gIOHW format in conv_transpose_mkldnn_op #37344

Merged
merged 7 commits into from
Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions paddle/fluid/operators/mkldnn/conv_transpose_mkldnn_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,12 @@ using Tensor = framework::Tensor;
using framework::DataLayout;

inline dnnl::memory::dims GetWeightsTz(const Tensor* filter, const int groups) {
auto iohw_weights_tz = framework::vectorize(filter->dims());
auto weights_tz = iohw_weights_tz;

// IOHW -> OIHW
weights_tz[0] = iohw_weights_tz[1];
weights_tz[1] = iohw_weights_tz[0];
auto weights_tz = framework::vectorize(filter->dims());
int g = std::max(groups, 1);
int g_dim = (g > 1) ? 1 : 0;
platform::GetGroupConvWeightsTz(weights_tz, g);
// gIOHW -> gOIHW || IOHW -> OIHW
std::swap(weights_tz[g_dim + 0], weights_tz[g_dim + 1]);
return weights_tz;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,27 @@ def init_test_case(self):
self.padding_algorithm = "EXPLICIT"


class TestMKLDNNWithGroups(TestConv2DTransposeMKLDNNOp):
def init_test_case(self):
TestConv2DTransposeMKLDNNOp.init_test_case(self)
self.pad = [1, 1]
self.groups = 2
self.input_size = [2, 4, 5, 5] # NCHW
f_c = self.input_size[1]
self.filter_size = [f_c, 3, 3, 3]


class TestMKLDNNWithGroups_NHWC(TestConv2DTransposeMKLDNNOp):
def init_test_case(self):
TestConv2DTransposeMKLDNNOp.init_test_case(self)
self.pad = [1, 1]
self.groups = 2
self.input_size = [2, 5, 5, 4] # NHWC
f_c = self.input_size[-1]
self.filter_size = [f_c, 3, 3, 3]
self.data_format = 'NHWC'


if __name__ == '__main__':
enable_static()
unittest.main()