OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
Fix 8d&7d transpose (#31764)
Wang Wangwang5c7ed5c97673
diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernel_selector_utils.h b/src/plugins/intel_gpu/src/kernel_selector/kernel_selector_utils.hindex 099eab10770..d0700af0866 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernel_selector_utils.h+++ b/src/plugins/intel_gpu/src/kernel_selector/kernel_selector_utils.h@@ -16,8 +16,8 @@ struct DimensionAccessHelperBase {dims = {t.Batch(),t.Feature(),- t.U(),t.V(),+ t.U(),t.W(),t.Z(),t.Y(),@@ -29,8 +29,8 @@ struct DimensionAccessHelperBase {Tensor::Dim& y_dim() { return dims[6]; }Tensor::Dim& z_dim() { return dims[5]; }Tensor::Dim& w_dim() { return dims[4]; }- Tensor::Dim& v_dim() { return dims[3]; }- Tensor::Dim& u_dim() { return dims[2]; }+ Tensor::Dim& u_dim() { return dims[3]; }+ Tensor::Dim& v_dim() { return dims[2]; }Tensor::Dim& f_dim() { return dims[1]; }Tensor::Dim& b_dim() { return dims[0]; }@@ -63,16 +63,16 @@ struct DimensionAccessHelperJit : virtual DimensionAccessHelperBase {std::string y() { return dims_sizes[6]; }std::string z() { return dims_sizes[5]; }std::string w() { return dims_sizes[4]; }- std::string v() { return dims_sizes[3]; }- std::string u() { return dims_sizes[2]; }+ std::string u() { return dims_sizes[3]; }+ std::string v() { return dims_sizes[2]; }std::string f() { return dims_sizes[1]; }std::string b() { return dims_sizes[0]; }std::pair<std::string, std::string> x_pad() { return {pad_before_after_sizes[14], pad_before_after_sizes[15]}; }std::pair<std::string, std::string> y_pad() { return {pad_before_after_sizes[12], pad_before_after_sizes[13]}; }std::pair<std::string, std::string> z_pad() { return {pad_before_after_sizes[10], pad_before_after_sizes[11]}; }std::pair<std::string, std::string> w_pad() { return {pad_before_after_sizes[8], pad_before_after_sizes[9]}; }- std::pair<std::string, std::string> v_pad() { return {pad_before_after_sizes[6], pad_before_after_sizes[7]}; }- std::pair<std::string, std::string> u_pad() { return {pad_before_after_sizes[4], pad_before_after_sizes[5]}; }+ std::pair<std::string, std::string> u_pad() { return {pad_before_after_sizes[6], pad_before_after_sizes[7]}; }+ std::pair<std::string, std::string> v_pad() { return {pad_before_after_sizes[4], pad_before_after_sizes[5]}; }std::pair<std::string, std::string> f_pad() { return {pad_before_after_sizes[2], pad_before_after_sizes[3]}; }std::pair<std::string, std::string> b_pad() { return {pad_before_after_sizes[0], pad_before_after_sizes[1]}; }diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_base.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_base.cppindex d13ce0f65ac..fc7321b31a9 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_base.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_base.cpp@@ -18,7 +18,7 @@ bool PermuteKernelBase::Validate(const Params& p) const {}}- auto supported_dyn_layouts = {DataLayout::bfyx, DataLayout::bfzyx, DataLayout::bfwzyx};+ auto supported_dyn_layouts = {DataLayout::bfyx, DataLayout::bfzyx, DataLayout::bfwzyx, DataLayout::bfuwzyx, DataLayout::bfvuwzyx};if (params.has_dynamic_tensors() && (!layout_is_one_of(params.inputs, supported_dyn_layouts) || !layout_is_one_of(params.outputs, supported_dyn_layouts)))DO_NOT_USE_THIS_KERNEL(p.layerID);diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/transpose.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/transpose.cppindex dec3bed6617..4a64df332ae 100644--- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/transpose.cpp+++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/transpose.cpp@@ -3,7 +3,9 @@//#include "single_op_tests/transpose.hpp"+#include "common_test_utils/test_constants.hpp"+#include "shared_test_classes/single_op/transpose.hpp"namespace {using ov::test::TransposeLayerTest;@@ -114,3 +116,76 @@ INSTANTIATE_TEST_SUITE_P(smoke_Transpose_8D,TransposeLayerTest::getTestCaseName);} // namespace++namespace ov {+namespace test {++transposeParams make7DTransposeParams();+transposeParams make8DTransposeParams();++class TransposeInferTwiceBaseTest : public TransposeLayerTest {+protected:+ void run_infer_twice() {+ compile_model();+ auto infer_request = compiledModel.create_infer_request();++ generate_inputs(targetStaticShapes[0]);+ for (const auto& input : inputs) {+ infer_request.set_tensor(input.first, input.second);+ }+ infer_request.infer();+ auto actual_output1 = infer_request.get_output_tensor(0);+ auto expected_outputs1 = calculate_refs();+ ASSERT_EQ(expected_outputs1.size(), 1);+ compare(expected_outputs1, {actual_output1});++ inputs.clear();+ generate_inputs(targetStaticShapes[1]);+ for (const auto& input : inputs) {+ infer_request.set_tensor(input.first, input.second);+ }+ infer_request.infer();+ auto actual_output2 = infer_request.get_output_tensor(0);+ auto expected_outputs2 = calculate_refs();+ ASSERT_EQ(expected_outputs2.size(), 1);+ compare(expected_outputs2, {actual_output2});+ }+};++transposeParams make8DTransposeParams() {+ std::vector<size_t> input_order = {7, 6, 5, 4, 3, 2, 1, 0};+ ov::element::Type model_type = ov::element::f32;+ ov::PartialShape dynamic_shape = ov::PartialShape::dynamic(8);+ std::vector<ov::Shape> static_shapes = {{2, 3, 4, 5, 6, 7, 8, 9}, {2, 2, 4, 6, 6, 7, 2, 8}};+ std::vector<InputShape> input_shapes = {{dynamic_shape, static_shapes}};+ std::string target_device = ov::test::utils::DEVICE_GPU;+ return {input_order, model_type, input_shapes, target_device};+}++class Transpose8DInferTwiceTest : public TransposeInferTwiceBaseTest {};++TEST_P(Transpose8DInferTwiceTest, infer_twice_diff_shapes_same_request) {+ run_infer_twice();+}++INSTANTIATE_TEST_SUITE_P(smoke_Transpose_8D_Infer_Twice, Transpose8DInferTwiceTest, ::testing::Values(make8DTransposeParams()));++transposeParams make7DTransposeParams() {+ std::vector<size_t> input_order = {6, 5, 4, 3, 2, 1, 0};+ ov::element::Type model_type = ov::element::f32;+ ov::PartialShape dynamic_shape = ov::PartialShape::dynamic(7);+ std::vector<ov::Shape> static_shapes = {{2, 3, 4, 5, 6, 7, 8}, {2, 3, 4, 5, 6, 8, 7}};+ std::vector<InputShape> input_shapes = {{dynamic_shape, static_shapes}};+ std::string target_device = ov::test::utils::DEVICE_GPU;+ return {input_order, model_type, input_shapes, target_device};+}++class Transpose7DInferTwiceTest : public TransposeInferTwiceBaseTest {};++TEST_P(Transpose7DInferTwiceTest, infer_twice_diff_shapes_same_request) {+ run_infer_twice();+}++INSTANTIATE_TEST_SUITE_P(smoke_Transpose_7D_Infer_Twice, Transpose7DInferTwiceTest, ::testing::Values(make7DTransposeParams()));+} // namespace test+} // namespace ov\ No newline at end of file