[IE][VPU][GT]: Added support for SoftPlus & Swish layers (#1612)
* Implement SoftPlus stage * Implement Swish stage
This commit is contained in:
parent
fcb93b161d
commit
dc89cb1627
@ -156,6 +156,8 @@ public:
|
|||||||
void parseStaticShapeNMS(const Model& model, const ie::CNNLayerPtr& layer, const DataVector& inputs, const DataVector& outputs) const;
|
void parseStaticShapeNMS(const Model& model, const ie::CNNLayerPtr& layer, const DataVector& inputs, const DataVector& outputs) const;
|
||||||
void parseMish(const Model& model, const ie::CNNLayerPtr& layer, const DataVector& inputs, const DataVector& outputs) const;
|
void parseMish(const Model& model, const ie::CNNLayerPtr& layer, const DataVector& inputs, const DataVector& outputs) const;
|
||||||
void parseGelu(const Model& model, const ie::CNNLayerPtr& layer, const DataVector& inputs, const DataVector& outputs) const;
|
void parseGelu(const Model& model, const ie::CNNLayerPtr& layer, const DataVector& inputs, const DataVector& outputs) const;
|
||||||
|
void parseSoftPlus(const Model& model, const ie::CNNLayerPtr& layer, const DataVector& inputs, const DataVector& outputs) const;
|
||||||
|
void parseSwish(const Model& model, const ie::CNNLayerPtr& layer, const DataVector& inputs, const DataVector& outputs) const;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Special layers
|
// Special layers
|
||||||
|
@ -170,6 +170,8 @@ VPU_DECLARE_ENUM(StageType,
|
|||||||
Mish = 131,
|
Mish = 131,
|
||||||
Gelu = 132,
|
Gelu = 132,
|
||||||
StridedSlice = 133,
|
StridedSlice = 133,
|
||||||
|
SoftPlus = 134,
|
||||||
|
Swish = 135,
|
||||||
)
|
)
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -123,6 +123,8 @@ FrontEnd::FrontEnd(StageBuilder::Ptr stageBuilder, const ie::ICore* core)
|
|||||||
{"StaticShapeReshape", LAYER_PARSER(parseReshape)},
|
{"StaticShapeReshape", LAYER_PARSER(parseReshape)},
|
||||||
{"Mish", LAYER_PARSER(parseMish)},
|
{"Mish", LAYER_PARSER(parseMish)},
|
||||||
{"Gelu", LAYER_PARSER(parseGelu)},
|
{"Gelu", LAYER_PARSER(parseGelu)},
|
||||||
|
{"SoftPlus", LAYER_PARSER(parseSoftPlus)},
|
||||||
|
{"Swish", LAYER_PARSER(parseSwish)},
|
||||||
}} {
|
}} {
|
||||||
VPU_THROW_UNLESS(_core != nullptr, "Argument core is null");
|
VPU_THROW_UNLESS(_core != nullptr, "Argument core is null");
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
// Copyright (C) 2020 Intel Corporation
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <vpu/frontend/frontend.hpp>
|
||||||
|
#include <vpu/stages/post_op_stage.hpp>
|
||||||
|
|
||||||
|
namespace vpu {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
class SoftPlusStage final : public PostOpStage {
|
||||||
|
public:
|
||||||
|
using PostOpStage::PostOpStage;
|
||||||
|
|
||||||
|
private:
|
||||||
|
StagePtr cloneImpl() const override {
|
||||||
|
return std::make_shared<SoftPlusStage>(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void serializeParamsImpl(BlobSerializer&) const override {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
void FrontEnd::parseSoftPlus(const Model& model, const ie::CNNLayerPtr& layer, const DataVector& inputs, const DataVector& outputs) const {
|
||||||
|
VPU_THROW_UNLESS(inputs.size() == 1,
|
||||||
|
"SoftPlus stage with name %s must have only 1 input, "
|
||||||
|
"actually provided %d", layer->name, inputs.size());
|
||||||
|
VPU_THROW_UNLESS(outputs.size() == 1,
|
||||||
|
"SoftPlus stage with name %s must have only 1 output, "
|
||||||
|
"actually provided %d", layer->name, outputs.size());
|
||||||
|
|
||||||
|
model->addNewStage<SoftPlusStage>(layer->name, StageType::SoftPlus, layer, inputs, outputs);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace vpu
|
@ -0,0 +1,38 @@
|
|||||||
|
// Copyright (C) 2020 Intel Corporation
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <vpu/frontend/frontend.hpp>
|
||||||
|
#include <vpu/stages/post_op_stage.hpp>
|
||||||
|
|
||||||
|
namespace vpu {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
class SwishStage final : public PostOpStage {
|
||||||
|
public:
|
||||||
|
using PostOpStage::PostOpStage;
|
||||||
|
|
||||||
|
private:
|
||||||
|
StagePtr cloneImpl() const override {
|
||||||
|
return std::make_shared<SwishStage>(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void serializeParamsImpl(BlobSerializer&) const override {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // 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, "
|
||||||
|
"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);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace vpu
|
Loading…
Reference in New Issue
Block a user