[IE][VPU]: Fix for Swish layer (#2034)

* Fix Swish layer serialization.
* Added shared test for Swish
* Firmware update 1326 -> 1349
This commit is contained in:
Nikita Kudriavtsev 2020-09-04 11:52:13 +03:00 committed by GitHub
parent 0c1b2f836b
commit 35357f686d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 7 deletions

View File

@ -19,7 +19,7 @@ set(VPU_SUPPORTED_FIRMWARES usb-ma2450 usb-ma2x8x pcie-ma248x)
# Default packages
#
set(FIRMWARE_PACKAGE_VERSION 1326)
set(FIRMWARE_PACKAGE_VERSION 1349)
set(VPU_CLC_MA2X8X_VERSION "movi-cltools-20.02.0")
#

View File

@ -18,21 +18,27 @@ private:
return std::make_shared<SwishStage>(*this);
}
void serializeParamsImpl(BlobSerializer&) const override {
void serializeParamsImpl(BlobSerializer& serializer) const override {
auto beta = attrs().get<float>("beta");
serializer.append(static_cast<float>(beta));
}
};
} // namespace
void FrontEnd::parseSwish(const Model& model, const ie::CNNLayerPtr& layer, const DataVector& inputs, const DataVector& outputs) const {
VPU_THROW_UNLESS((inputs.size() == 1) || ((inputs.size() == 2)),
"Swish stage with name %s must have 1 or 2 inputs, "
VPU_THROW_UNLESS((inputs.size() == 1),
"Swish stage with name %s must have 1 input, "
"actually provided %d", layer->name, inputs.size());
VPU_THROW_UNLESS(outputs.size() == 1,
"Swish stage with name %s must have only 1 output, "
"actually provided %d", layer->name, outputs.size());
model->addNewStage<SwishStage>(layer->name, StageType::Swish, layer, inputs, outputs);
auto stage = model->addNewStage<SwishStage>(
layer->name, StageType::Swish, layer, inputs, outputs);
stage->attrs().set<float>("beta", layer->GetParamAsFloat("alpha"));
}
} // namespace vpu

View File

@ -23,7 +23,8 @@ const std::vector<ActivationTypes> activationTypes = {
Log,
Gelu,
Mish,
SoftPlus
SoftPlus,
Swish
};
std::map<std::vector<size_t>, std::vector<std::vector<size_t>>> basic = {

View File

@ -70,6 +70,7 @@ static std::map<ngraph::helpers::ActivationTypes, std::string> activationNames =
{ngraph::helpers::ActivationTypes::Mish, "Mish"},
{ngraph::helpers::ActivationTypes::HSwish, "HSwish"},
{ngraph::helpers::ActivationTypes::SoftPlus, "SoftPlus"},
{ngraph::helpers::ActivationTypes::Swish, "Swish"},
};
typedef std::tuple<

View File

@ -110,7 +110,8 @@ enum ActivationTypes {
PReLu,
Mish,
HSwish,
SoftPlus
SoftPlus,
Swish
};
enum EltwiseTypes {

View File

@ -97,6 +97,10 @@ std::shared_ptr<ngraph::Node> makeActivation(const ngraph::Output<Node> &in,
return std::make_shared<ngraph::op::v4::HSwish>(in);
case ngraph::helpers::ActivationTypes::SoftPlus:
return std::make_shared<ngraph::op::v4::SoftPlus>(in);
case ngraph::helpers::ActivationTypes::Swish: {
auto beta = std::make_shared<ngraph::op::Constant>(type, inShape, 1.0f);
return std::make_shared<ngraph::op::v4::Swish>(in, beta);
}
default:
throw std::runtime_error("Can't create layer for this activation type");
}