Skip to content

Commit f3d4792

Browse files
authored
[GPU] Use [[fallthrough]] in tensor flattening switch (#33957)
### Details: Resolve TODO that was left before C++17 to reduce code duplication ### Tickets: - N/A
1 parent 9ddd803 commit f3d4792

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed

src/plugins/intel_gpu/src/kernel_selector/tensor_type.cpp

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -443,14 +443,7 @@ DataTensor DataTensor::FlattenFeatureAndSpatials() const {
443443

444444
case Tensor::fyxb:
445445
targetLayout = Tensor::fb;
446-
447-
// TODO: [FUTURE] Use C++17 [[fallthrough]] instead of code duplication to get portable warning avoidance.
448-
if (f.pitch == y.v * x.v * x.pitch) { // no padding in X/Y axis
449-
l = targetLayout;
450-
break;
451-
}
452-
throw std::runtime_error("Unsupported - cannot flatten with padding");
453-
446+
[[fallthrough]];
454447
case Tensor::bfyx:
455448
if (f.pitch == y.v * x.v * x.pitch) { // no padding in X/Y axis
456449
l = targetLayout;
@@ -472,16 +465,7 @@ DataTensor DataTensor::FlattenFeatureAndSpatials() const {
472465
throw std::runtime_error("Unsupported - cannot flatten with padding");
473466
case Tensor::yxfb:
474467
targetLayout = Tensor::fb;
475-
476-
// TODO: [FUTURE] Use C++17 [[fallthrough]] instead of code duplication to get portable warning avoidance.
477-
if ((x.pitch == f.pitch && y.pitch == x.v * x.pitch) || // YX - no Features (val/pitch)
478-
(y.v == 1 && x.v == 1 && x.pitch == f.pitch && y.pitch == f.pitch) || // Feature only
479-
(f.v * f.pitch == x.pitch && f.v * f.pitch == y.pitch && y.v == 1 && x.v == 1)) { // Feature only
480-
l = targetLayout;
481-
break;
482-
}
483-
throw std::runtime_error("Unsupported - cannot flatten yxf to f if f/yx != 1");
484-
468+
[[fallthrough]];
485469
case Tensor::byxf:
486470
if ((x.pitch == f.pitch && y.pitch == x.v * x.pitch) || // YX - no Features (val/pitch)
487471
(y.v == 1 && x.v == 1 && x.pitch == f.pitch && y.pitch == f.pitch) || // Feature only

0 commit comments

Comments
 (0)