Skip to content

Commit 60cdd99

Browse files
authored
[CPU, snippets] Use ov::Shape as alias type for VectorDims (#32687)
### Details: - Make `ov::intel_cpu::VectorDims` and `ov::snippets::VectorDims` aliasta to ov::Shape. The current alias is not always compatible with `ov::Shape` and additional conversion are required. - Reduce bin size for CPU plugin. - Add move ctor to `ov::Shape`. ### Tickets: - N/A --------- Signed-off-by: Raasz, Pawel <pawel.raasz@intel.com>
1 parent 5971e0f commit 60cdd99

File tree

18 files changed

+32
-26
lines changed

18 files changed

+32
-26
lines changed

src/common/snippets/include/snippets/lowered/pass/mha_parallel_wa_optimizer.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class MHAParallelWAOptimizer : public lowered::pass::RuntimeOptimizer {
5353

5454
std::vector<lowered::ExpandedLoopInfoPtr> m_loops_to_split;
5555
std::unordered_set<size_t> m_unsqueezed_params;
56-
std::vector<std::vector<size_t>> m_optimized_layouts;
56+
std::vector<VectorDims> m_optimized_layouts;
5757
std::vector<size_t> m_dim_M_idces;
5858
size_t m_concurrency = 0;
5959

src/common/snippets/include/snippets/op/buffer.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class Buffer : public ov::op::Op {
100100
// The buffers with this implementation mustn't have source (parents)
101101
class NewMemoryImpl : public BaseImpl {
102102
public:
103-
explicit NewMemoryImpl(const ov::Shape& shape, ov::element::Type element_type);
103+
explicit NewMemoryImpl(ov::Shape shape, ov::element::Type element_type);
104104

105105
[[nodiscard]] size_t get_allocation_size() const override;
106106
[[nodiscard]] std::shared_ptr<BaseImpl> clone() const override;
@@ -115,7 +115,7 @@ class Buffer : public ov::op::Op {
115115
ov::Shape m_shape;
116116

117117
public:
118-
explicit ShapeInfer(const ov::Shape& shape);
118+
explicit ShapeInfer(ov::Shape shape);
119119
Result infer(const std::vector<VectorDimsRef>& input_shapes) override;
120120
};
121121

src/common/snippets/include/snippets/runtime_configurator.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ class RuntimeConfigurator {
203203
/**
204204
* @brief Extract layouts from m_io_descs
205205
*/
206-
[[nodiscard]] std::vector<std::vector<size_t>> extract_layouts() const;
206+
[[nodiscard]] std::vector<ov::snippets::VectorDims> extract_layouts() const;
207207

208208
std::shared_ptr<RuntimeConfig> m_config = nullptr;
209209

src/common/snippets/include/snippets/shape_types.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@
99
#include <memory>
1010
#include <vector>
1111

12+
#include "openvino/core/shape.hpp"
13+
1214
namespace ov::snippets {
1315
/*
1416
* This header file contain declarations of shape-relevant classes used cross several snippets subsystems.
1517
* The main purpose of storing such declarations here is to eliminate false dependencies. For example,
1618
* both PortDescriptor and IShapeInferSnippets use VectorDims, but these two classes are completely independent
1719
* semantically.
1820
*/
19-
using VectorDims = std::vector<size_t>;
21+
using VectorDims = ov::Shape;
2022
using VectorDimsPtr = std::shared_ptr<VectorDims>;
2123
using VectorDimsCPtr = std::shared_ptr<const VectorDims>;
2224
using VectorDimsRef = std::reference_wrapper<const VectorDims>;

src/common/snippets/src/lowered/port_descriptor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ PortDescriptor::PortDescriptor(const ov::Input<ov::Node>& in, VectorDims subtens
2828
std::move(layout)) {}
2929

3030
PortDescriptor::PortDescriptor(const ov::Input<const ov::Node>& in,
31-
std::vector<size_t> subtensor_shape,
31+
VectorDims subtensor_shape,
3232
std::vector<size_t> layout)
3333
: PortDescriptor(utils::pshape_to_vdims(in.get_partial_shape()), std::move(subtensor_shape), std::move(layout)) {}
3434

@@ -38,7 +38,7 @@ PortDescriptor::PortDescriptor(const ov::Output<ov::Node>& out, VectorDims subte
3838
std::move(layout)) {}
3939

4040
PortDescriptor::PortDescriptor(const ov::Output<const ov::Node>& out,
41-
std::vector<size_t> subtensor_shape,
41+
VectorDims subtensor_shape,
4242
std::vector<size_t> layout)
4343
: PortDescriptor(utils::pshape_to_vdims(out.get_partial_shape()), std::move(subtensor_shape), std::move(layout)) {}
4444

src/common/snippets/src/op/buffer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ Buffer::IntermediateMemoryImpl::ShapeInfer::Result Buffer::IntermediateMemoryImp
8888
return {{input_shapes[0].get()}, ShapeInferStatus::success};
8989
}
9090

91-
Buffer::NewMemoryImpl::NewMemoryImpl(const ov::Shape& shape, ov::element::Type element_type)
92-
: m_shape(shape),
91+
Buffer::NewMemoryImpl::NewMemoryImpl(ov::Shape shape, ov::element::Type element_type)
92+
: m_shape(std::move(shape)),
9393
m_element_type(element_type) {}
9494

9595
size_t Buffer::NewMemoryImpl::get_allocation_size() const {
@@ -112,7 +112,7 @@ bool Buffer::NewMemoryImpl::visit_attributes(AttributeVisitor& visitor) {
112112
return true;
113113
}
114114

115-
Buffer::NewMemoryImpl::ShapeInfer::ShapeInfer(const ov::Shape& shape) : m_shape(shape) {}
115+
Buffer::NewMemoryImpl::ShapeInfer::ShapeInfer(ov::Shape shape) : m_shape(std::move(shape)) {}
116116

117117
Buffer::NewMemoryImpl::ShapeInfer::Result Buffer::NewMemoryImpl::ShapeInfer::infer(
118118
const std::vector<VectorDimsRef>& input_shapes) {

src/common/snippets/src/runtime_configurator.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ void RuntimeConfigurator::update_data_offsets() const {
357357
auto& offsets = m_config->io_data_offsets[i];
358358
const auto& layout = layouts[i];
359359
if (!layout.empty()) {
360-
std::vector<size_t> reordered_offsets(offsets.size());
360+
VectorDims reordered_offsets(offsets.size());
361361
const auto is_input = i < m_in_num;
362362
for (size_t i = 0; i < layout.size(); i++) {
363363
const auto& src_idx = is_input ? layout[i] : i;
@@ -377,8 +377,8 @@ std::vector<VectorDims> RuntimeConfigurator::extract_shapes() const {
377377
return shapes;
378378
}
379379

380-
std::vector<std::vector<size_t>> RuntimeConfigurator::extract_layouts() const {
381-
std::vector<std::vector<size_t>> layouts(m_io_num);
380+
std::vector<VectorDims> RuntimeConfigurator::extract_layouts() const {
381+
std::vector<VectorDims> layouts(m_io_num);
382382
for (size_t i = 0; i < m_io_num; ++i) {
383383
layouts[i] = m_io_descs[i]->get_layout();
384384
}

src/common/snippets/tests/src/runtime_configurator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class TestRuntimeConfigurator : public ov::snippets::RuntimeConfigurator {
2222
void set_state(size_t in_num,
2323
const std::vector<ov::snippets::VectorDims>& shapes,
2424
const std::vector<ov::snippets::VectorDims>& latest_shapes,
25-
const std::vector<std::vector<size_t>>& layouts,
25+
const std::vector<ov::snippets::VectorDims>& layouts,
2626
const std::vector<size_t>& data_sizes,
2727
size_t tensor_rank,
2828
const std::vector<ov::snippets::VectorDims>& offsets) {

src/core/include/openvino/core/shape.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class Shape : public std::vector<size_t> {
3030

3131
OPENVINO_API Shape(const Shape& axis_lengths);
3232

33+
OPENVINO_API Shape(Shape&& other);
34+
3335
OPENVINO_API explicit Shape(size_t n, size_t initial_value = 0);
3436

3537
OPENVINO_API ~Shape();

src/core/src/partial_shape.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ ov::Shape ov::PartialShape::to_shape() const {
266266
OPENVINO_THROW("to_shape was called on a dynamic shape.");
267267
}
268268

269-
std::vector<size_t> shape_dimensions(m_dimensions.size());
269+
ov::Shape shape_dimensions(m_dimensions.size());
270270
std::transform(m_dimensions.begin(), m_dimensions.end(), shape_dimensions.begin(), [](const Dimension& d) {
271271
return d.get_length();
272272
});

0 commit comments

Comments
 (0)