forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce arbitrary order desc creator
- Loading branch information
Showing
6 changed files
with
79 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/plugins/intel_cpu/src/nodes/common/arbitrary_order_desc_creator.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (C) 2018-2023 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include "arbitrary_order_desc_creator.h" | ||
|
||
namespace ov { | ||
namespace intel_cpu { | ||
|
||
ArbitraryOrderDescCreator::ArbitraryOrderDescCreator(VectorDims order) : | ||
m_order(std::move(order)) { | ||
OPENVINO_ASSERT(std::adjacent_find(m_order.begin(), m_order.end()) == m_order.end(), | ||
"Can't construct ArbitraryOrderDescCreator, order vector contains repetitive elements", | ||
vec2str(m_order)); | ||
} | ||
|
||
CpuBlockedMemoryDesc | ||
ArbitraryOrderDescCreator::createDesc(const ov::element::Type& precision, const Shape& srcShape) const { | ||
auto&& dims = srcShape.getDims(); | ||
OPENVINO_ASSERT(dims.size() == m_order.size(), | ||
"Couldn't create a tensor descriptor, shape and order size mismatch. Shape: ", | ||
vec2str(dims), | ||
" order: ", | ||
vec2str(m_order)); | ||
|
||
VectorDims blkDims(dims.size()); | ||
for (size_t i = 0; i < dims.size(); ++i) { | ||
blkDims[i] = dims[m_order[i]]; | ||
} | ||
|
||
return CpuBlockedMemoryDesc(precision, srcShape, blkDims, m_order); | ||
} | ||
|
||
size_t ArbitraryOrderDescCreator::getMinimalRank() const { | ||
return m_order.size(); | ||
} | ||
|
||
} // namespace intel_cpu | ||
} // namespace ov |
24 changes: 24 additions & 0 deletions
24
src/plugins/intel_cpu/src/nodes/common/arbitrary_order_desc_creator.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (C) 2018-2023 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include "blocked_desc_creator.h" | ||
|
||
namespace ov { | ||
namespace intel_cpu { | ||
|
||
class ArbitraryOrderDescCreator : public BlockedDescCreator { | ||
public: | ||
ArbitraryOrderDescCreator(VectorDims order); | ||
|
||
CpuBlockedMemoryDesc createDesc(const ov::element::Type& precision, const Shape& srcShape) const override; | ||
size_t getMinimalRank() const override; | ||
|
||
private: | ||
VectorDims m_order; | ||
}; | ||
|
||
} // namespace intel_cpu | ||
} // namespace ov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters