[GPU] fix axis for pad/stride/dilation when 1d conv (#20746)

* fix axis for pad/stride/dilation when 1d conv
* add test-cases for 1d conv with explicit pad
This commit is contained in:
Sungeun Kim authored and GitHub committed 2023-10-30 19:06:29 +09:00
1 parent 81dbe4aedd
commit 4512141111
2 files changed
+16 -3

No files matched your search

@@ -42,7 +42,7 @@ public:
const auto& primitive = impl_param.typed_desc<convolution>();
auto stride = primitive->stride;
const auto& dilation = primitive->dilation;
auto dilation = primitive->dilation;
const auto& groups = primitive->groups;
const auto& deformable_groups = primitive->deformable_groups;
const auto transposed = primitive->transposed;
@@ -113,6 +113,12 @@ public:
uint32_t kz = weights_layout.spatial(2);
conv_params.filterSize = { kx, ky, kz };
// WA: If 1d conv and dynamic shape, 1d pad should be applied to y axis.
if (pads_begin.size() == 1) pads_begin.push_back(0);
if (pads_end.size() == 1) pads_end.push_back(0);
if (stride.size() == 1) stride.push_back(1);
if (dilation.size() == 1) dilation.push_back(1);
uint32_t pad_begin_z = std::max<std::ptrdiff_t>(pads_begin.size() >= 3 ? pads_begin[pads_begin.size() - 3] : 0, 0);
uint32_t pad_begin_y = std::max<std::ptrdiff_t>(pads_begin.size() >= 2 ? pads_begin[pads_begin.size() - 2] : 0, 0);
uint32_t pad_begin_x = std::max<std::ptrdiff_t>(pads_begin.size() >= 1 ? pads_begin[pads_begin.size() - 1] : 0, 0);
@@ -88,6 +88,13 @@ protected:
size_t convOutChannels;
std::tie(kernel, stride, padBegin, padEnd, dilation, convOutChannels, padType) = convParams;
// WA: check data when input shape is dynamic and pad is exist.
// If 1d conv, 1d pad should be applied to y axis. But there was a bug what it applied to x axis.
if (inputShape.first.is_dynamic() && padBegin.size() == 1 && padBegin[0] == 1 && padEnd.size() == 1 && padEnd[0] == 1) {
abs_threshold = 9;
rel_threshold = 0.002;
}
ov::ParameterVector inputParams;
for (auto&& shape : inputDynamicShapes) {
inputParams.push_back(std::make_shared<ov::op::v0::Parameter>(inType, shape));
@@ -149,8 +156,8 @@ INSTANTIATE_TEST_SUITE_P(smoke_ConvolutionLayerGPUTest_dynamic1DSymPad, Convolut
const std::vector<SizeVector> kernels1D = { {3}, {1} };
const std::vector<SizeVector> strides1D = { {1} };
const std::vector<std::vector<ptrdiff_t>> padBegins1D = { {0} };
const std::vector<std::vector<ptrdiff_t>> padEnds1D = { {0} };
const std::vector<std::vector<ptrdiff_t>> padBegins1D = { {0}, {1} };
const std::vector<std::vector<ptrdiff_t>> padEnds1D = { {0}, {1} };
const std::vector<SizeVector> dilations1D = { {1} };
const SizeVector numOutChannels = { 64, 63 };
const std::vector<InputShape> inputShapes1D = {