Skip to content

Commit

Permalink
[VPU] Added support for 2 axis for MVN layer - duplicate (openvinotoo…
Browse files Browse the repository at this point in the history
…lkit#6748)

* [VPU]Added support for 2 axis for MVN layer

Co-authored-by: Polina <[email protected]>
  • Loading branch information
2 people authored and akuporos committed Sep 29, 2021
1 parent cf99edb commit 5b1b819
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
6 changes: 3 additions & 3 deletions inference-engine/cmake/vpu_dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ include_guard(GLOBAL)

set(VPU_SUPPORTED_FIRMWARES usb-ma2x8x pcie-ma2x8x)
set(VPU_SUPPORTED_FIRMWARES_HASH
"d55a824838accec31733e4d4c45e8774bdd5690da8beefe41360f1983476e3d0"
"61797a77b38fc677be4cc63d730e8871bbf169686b88eabb7066b01f9d156129")
"54a732b5fb17a0124652bc5113fa628c718a5af40621bca309471cb5ffd9271b"
"5750b2831c77ef54b8e243d3840c5ed1c9509681d55aee7e369d558cef628735")

#
# Default packages
#

set(FIRMWARE_PACKAGE_VERSION 1714)
set(FIRMWARE_PACKAGE_VERSION 1717)
set(VPU_CLC_MA2X8X_VERSION "movi-cltools-20.09.2")

#
Expand Down
9 changes: 7 additions & 2 deletions inference-engine/src/vpu/graph_transformer/src/stages/mvn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ class MVNStage final : public StageNode {
void serializeParamsImpl(BlobSerializer& serializer) const override {
auto normalize = attrs().get<int>("normalize");
auto across_channels = attrs().get<int>("across_channels");
auto across_width = attrs().get<int>("across_width");
auto eps = attrs().get<float>("eps");

serializer.append(static_cast<int32_t>(normalize));
serializer.append(static_cast<int32_t>(across_channels));
serializer.append(static_cast<int32_t>(across_width));
serializer.append(static_cast<float>(eps));
}

Expand Down Expand Up @@ -88,11 +90,13 @@ void FrontEnd::parseMVN(const Model& model, const ie::CNNLayerPtr& layer, const
for (int i = 0; i < indicesSize; i++) {
axes.insert(getDimFromAxis(ndims, indicesPtr[i]));
}
const auto width = axes.count(Dim::W);

VPU_THROW_UNLESS(!axes.count(Dim::N) && axes.count(Dim::H) && axes.count(Dim::W),
VPU_THROW_UNLESS(!axes.count(Dim::N) && width,
"Unsupported combination of indices in layer \"%s\". "
"Only across channel and full batch supported.", layer->name);
"Only across channel, width and full batch supported.", layer->name);
const auto acrossChannels = axes.count(Dim::C) != 0;
const auto acrossWidth = width == 1 && axes.count(Dim::H) == 0;

const auto normVariance = layer->GetParamAsBool("normalize_variance");
const auto eps = layer->GetParamAsFloat("eps");
Expand All @@ -104,6 +108,7 @@ void FrontEnd::parseMVN(const Model& model, const ie::CNNLayerPtr& layer, const
auto stage = model->addNewStage<MVNStage>(layer->name, StageType::MVN, layer, inputs, outputs);
stage->attrs().set<int>("normalize", normVariance);
stage->attrs().set<int>("across_channels", acrossChannels);
stage->attrs().set<int>("across_width", acrossWidth);
stage->attrs().set<float>("eps", eps);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const std::vector<std::vector<int>> indices_4D = {
};

const std::vector<std::vector<int>> indices_3D = {
{2},
{0, 2},
{1, 2}, // equivalent MVN-1 across_channel=0
{0, 1, 2} // equivalent MVN-1 across_channel=1
};
Expand Down

0 comments on commit 5b1b819

Please sign in to comment.