-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CPU] Dynamic shapes support using fallback on reference (#6882)
- Loading branch information
Showing
197 changed files
with
5,537 additions
and
3,627 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
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
395 changes: 0 additions & 395 deletions
395
inference-engine/src/mkldnn_plugin/cpu_memory_desc_utils.cpp
This file was deleted.
Oops, something went wrong.
88 changes: 0 additions & 88 deletions
88
inference-engine/src/mkldnn_plugin/cpu_memory_desc_utils.h
This file was deleted.
Oops, something went wrong.
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,49 @@ | ||
// Copyright (C) 2021 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include "cpu_shape.h" | ||
#include "utils/general_utils.h" | ||
#include "memory_desc/cpu_memory_desc_utils.h" | ||
|
||
using namespace MKLDNNPlugin; | ||
|
||
bool Shape::isCompatible(const VectorDims &vecDims) const { | ||
if (getRank() != vecDims.size()) { | ||
return false; | ||
} | ||
|
||
auto comparator = [](Dim lhs, Dim rhs) { | ||
return (lhs == rhs) || (lhs == Shape::UNDEFINED_DIM); | ||
}; | ||
|
||
if (!std::equal(getDims().begin(), getDims().end(), vecDims.begin(), comparator)) { | ||
return false; | ||
} | ||
|
||
if (!std::equal(getMaxDims().begin(), getMaxDims().end(), vecDims.begin(), [](Dim lhs, Dim rhs) { return lhs >= rhs; })) { | ||
return false; | ||
} | ||
|
||
if (!std::equal(getMinDims().begin(), getMinDims().end(), vecDims.begin(), [](Dim lhs, Dim rhs) { return lhs <= rhs; })) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
std::string Shape::toString() const { | ||
std::stringstream output; | ||
output << "{"; | ||
|
||
size_t i = 0; | ||
do { | ||
if (dims[i] == Shape::UNDEFINED_DIM) { | ||
output << MemoryDescUtils::dim2str(minDims[i]) << " - " << MemoryDescUtils::dim2str(maxDims[i]); | ||
} else { | ||
output << dims[i]; | ||
} | ||
} while (++i < dims.size() && output << ", "); | ||
|
||
output << "}"; | ||
return output.str(); | ||
} |
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
34 changes: 34 additions & 0 deletions
34
inference-engine/src/mkldnn_plugin/memory_desc/blocked_memory_desc.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,34 @@ | ||
// Copyright (C) 2021 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include "blocked_memory_desc.h" | ||
#include "utils/general_utils.h" | ||
|
||
using namespace MKLDNNPlugin; | ||
|
||
bool BlockedMemoryDesc::isCompatible(const BlockedMemoryDesc &rhs) const { | ||
if (this->getShape() != rhs.getShape() || this->getPrecision() != rhs.getPrecision()) | ||
return false; | ||
|
||
if (!dimsEqualWeak(this->getBlockDims(), rhs.getBlockDims())) { | ||
return false; | ||
} | ||
|
||
if (!dimsEqualWeak(this->getOffsetPaddingToData(), rhs.getOffsetPaddingToData())) { | ||
return false; | ||
} | ||
|
||
// this check needed to avoid inserting unnecessary reorders if the memory is used in place and the batch size is equal to 1 | ||
size_t skipAxis = this->getShape().getRank() > 0 && this->getShape().getDims().front() == 1 ? 0 : | ||
Shape::UNDEFINED_DIM; //ignore batch axis if batch size == 1 | ||
if (!dimsEqualWeak(this->getStrides(), rhs.getStrides(), skipAxis)) { | ||
return false; | ||
} | ||
|
||
if (!dimsEqualWeak(this->getOrder(), rhs.getOrder())) { | ||
return false; | ||
} | ||
|
||
return dimsEqualWeak(this->getOffsetPadding(), rhs.getOffsetPadding()); | ||
} |
Oops, something went wrong.