|
| 1 | +// Copyright (C) 2018-2025 Intel Corporation |
| 2 | +// SPDX-License-Identifier: Apache-2.0 |
| 3 | +// |
| 4 | + |
| 5 | +#include <vector> |
| 6 | + |
| 7 | +#include "common_test_utils/ov_test_utils.hpp" |
| 8 | + |
| 9 | +#include "snippets/runtime_configurator.hpp" |
| 10 | +#include "snippets/utils/utils.hpp" |
| 11 | + |
| 12 | +namespace ov { |
| 13 | +namespace test { |
| 14 | +namespace snippets { |
| 15 | + |
| 16 | +namespace { |
| 17 | + |
| 18 | +class TestRuntimeConfigurator : public ov::snippets::RuntimeConfigurator { |
| 19 | +public: |
| 20 | + TestRuntimeConfigurator() : RuntimeConfigurator(std::make_shared<ov::snippets::RuntimeConfig>()) {} |
| 21 | + |
| 22 | + void set_state(size_t in_num, |
| 23 | + const std::vector<ov::snippets::VectorDims>& shapes, |
| 24 | + const std::vector<ov::snippets::VectorDims>& latest_shapes, |
| 25 | + const std::vector<std::vector<size_t>>& layouts, |
| 26 | + const std::vector<size_t>& data_sizes, |
| 27 | + size_t tensor_rank, |
| 28 | + const std::vector<ov::snippets::VectorDims>& offsets) { |
| 29 | + m_in_num = in_num; |
| 30 | + m_io_num = shapes.size(); |
| 31 | + m_io_data_sizes = data_sizes; |
| 32 | + m_config->tensor_rank = tensor_rank; |
| 33 | + m_config->io_shapes = shapes; |
| 34 | + m_config->latest_shapes = latest_shapes; |
| 35 | + m_config->io_layouts = layouts; |
| 36 | + m_config->io_data_offsets = offsets; |
| 37 | + } |
| 38 | + |
| 39 | + // Helper to expose the protected update_data_offsets for this test |
| 40 | + void run_update_data_offsets() { |
| 41 | + update_data_offsets(); |
| 42 | + } |
| 43 | +}; |
| 44 | + |
| 45 | +} // namespace |
| 46 | + |
| 47 | +TEST(RuntimeConfiguratorOffsets, KeepsPreviousDynamicPortsAndUpdatesLaterPorts) { |
| 48 | + const auto dynamic = ov::snippets::utils::get_dynamic_value<size_t>(); |
| 49 | + |
| 50 | + TestRuntimeConfigurator configurator; |
| 51 | + configurator.set_state(1, |
| 52 | + {ov::snippets::VectorDims{dynamic, 5}, ov::snippets::VectorDims{2, 3}}, |
| 53 | + std::vector<ov::snippets::VectorDims>(2), |
| 54 | + {std::vector<size_t>{}, std::vector<size_t>{}}, |
| 55 | + {1, 1}, |
| 56 | + 2, |
| 57 | + std::vector<ov::snippets::VectorDims>(2)); |
| 58 | + |
| 59 | + configurator.run_update_data_offsets(); |
| 60 | + |
| 61 | + const auto config = configurator.get_config(); |
| 62 | + ASSERT_EQ(config->io_data_offsets.size(), 2); |
| 63 | + EXPECT_TRUE(config->io_data_offsets[0].empty()); |
| 64 | + EXPECT_EQ(config->io_data_offsets[1], (ov::snippets::VectorDims{3, 1})); |
| 65 | +} |
| 66 | + |
| 67 | +} // namespace snippets |
| 68 | +} // namespace test |
| 69 | +} // namespace ov |
0 commit comments