Abs layer support (#6475)

* [MyriadX] Abs op support
This commit is contained in:
Daria Mityagina 2021-07-20 21:13:52 +03:00 committed by GitHub
parent b62d93efff
commit b0ebea1cda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 25 additions and 7 deletions

View File

@ -6,14 +6,14 @@ include_guard(GLOBAL)
set(VPU_SUPPORTED_FIRMWARES usb-ma2x8x pcie-ma2x8x)
set(VPU_SUPPORTED_FIRMWARES_HASH
"420b300d193f7fcfe7e3f9bbec6c247d65b784a500b5cd2effb7cb1ec6e1b209"
"bfe3caf270b168b9de18ef88f04bde3907d7d12a679f1fa7cc580423c35db637")
"d55a824838accec31733e4d4c45e8774bdd5690da8beefe41360f1983476e3d0"
"61797a77b38fc677be4cc63d730e8871bbf169686b88eabb7066b01f9d156129")
#
# Default packages
#
set(FIRMWARE_PACKAGE_VERSION 1688)
set(FIRMWARE_PACKAGE_VERSION 1714)
set(VPU_CLC_MA2X8X_VERSION "movi-cltools-20.09.2")
#

View File

@ -1025,7 +1025,8 @@ public:
Logical_OR,
Logical_XOR,
Logical_NOT,
Mean
Mean,
Abs,
};
/**

View File

@ -127,6 +127,7 @@ const Transformations& getDefaultTransformations() {
{ngraph::opset3::Exp::type_info, dynamicToStaticUnaryElementwise},
{ngraph::opset3::Sqrt::type_info, dynamicToStaticUnaryElementwise},
{ngraph::opset3::LogicalNot::type_info, dynamicToStaticUnaryElementwise},
{ngraph::opset3::Abs::type_info, dynamicToStaticUnaryElementwise},
{ngraph::opset5::ScatterElementsUpdate::type_info, dynamicToStaticUnaryElementwise},
{ngraph::opset3::StridedSlice::type_info, dynamicToStaticShapeStridedSlice},
{ngraph::opset3::Squeeze::type_info, dynamicToStaticShapeSqueeze},

View File

@ -162,6 +162,7 @@ public:
void parseCeiling(const Model& model, const ie::CNNLayerPtr& layer, const DataVector& inputs, const DataVector& outputs) const;
void parseRound(const Model& model, const ie::CNNLayerPtr& layer, const DataVector& inputs, const DataVector& outputs) const;
void parseCTCGreedyDecoderSeqLen(const Model& model, const ie::CNNLayerPtr& layer, const DataVector& inputs, const DataVector& outputs) const;
void parseAbs(const Model& model, const ie::CNNLayerPtr& layer, const DataVector& inputs, const DataVector& outputs) const;
//
// Special layers

View File

@ -177,6 +177,7 @@ VPU_DECLARE_ENUM(StageType,
GatherElements = 139,
Round = 140,
CTCGreedyDecoderSeqLen = 141,
Abs = 142,
)
//

View File

@ -156,6 +156,7 @@ FrontEnd::FrontEnd(StageBuilder::Ptr stageBuilder, const std::shared_ptr<ie::ICo
{"ExpGatherElements", LAYER_PARSER(parseGatherElements)},
{"Round", LAYER_PARSER(parseRound)},
{"CTCGreedyDecoderSeqLen", LAYER_PARSER(parseCTCGreedyDecoderSeqLen)},
{"Abs", LAYER_PARSER(parseAbs)}
}} {
VPU_THROW_UNLESS(_core != nullptr, "Argument core is null");
}

View File

@ -69,7 +69,8 @@ void PassImpl::run(const Model& model) {
eltwiseStage->type() != StageType::Logical_AND &&
eltwiseStage->type() != StageType::Logical_OR &&
eltwiseStage->type() != StageType::Logical_XOR &&
eltwiseStage->type() != StageType::Logical_NOT) {
eltwiseStage->type() != StageType::Logical_NOT &&
eltwiseStage->type() != StageType::Abs) {
continue;
}

View File

@ -16,9 +16,18 @@ void FrontEnd::parseLogicalNot(const Model &model, const ie::CNNLayerPtr &layer,
parseEltwise(model, res, inputs, outputs);
}
void FrontEnd::parseAbs(const Model &model, const ie::CNNLayerPtr &layer, const DataVector &inputs, const DataVector &outputs) const {
LayerParams params = {layer->name, "Eltwise", layer->precision};
auto res = std::make_shared<InferenceEngine::EltwiseLayer>(params);
res->_operation = InferenceEngine::EltwiseLayer::Abs;
parseEltwise(model, res, inputs, outputs);
}
void FrontEnd::parseActivation(const Model& model, const ie::CNNLayerPtr& layer, const DataVector& inputs, const DataVector& outputs) const {
const ie::details::caseless_map<std::string, LayerParser> activationParsers {
{"not", LAYER_PARSER(parseLogicalNot)},
{"abs", LAYER_PARSER(parseAbs)},
};
const auto type = layer->GetParamAsString("type");

View File

@ -72,6 +72,7 @@ static const std::map<ie::EltwiseLayer::eOperation, std::function<StageType(ie::
MAP_ELEMENTS(Logical_XOR, moreThanOneInput),
MAP_ELEMENTS(Pow, onlyTwoInputs),
MAP_ELEMENTS(Floor_mod, onlyTwoInputs),
MAP_ELEMENTS(Abs, onlyOneInput),
};
class EltwiseStage final : public StageNode {
@ -150,7 +151,8 @@ private:
StageType::Div,
StageType::Min,
StageType::Logical_NOT,
StageType::Logical_AND
StageType::Logical_AND,
StageType::Abs,
};
auto supportedDataTypesInput0 = EnumSet<DataType>{DataType::FP16};
if (stageTypesWhichSupportS32.count(operation)) {
@ -264,7 +266,7 @@ void FrontEnd::parseEltwise(const Model& model, const ie::CNNLayerPtr& _layer, c
DataVector tempInputs(3);
tempInputs[0] = inputs[0];
if (stageType == StageType::Logical_NOT)
if (stageType == StageType::Logical_NOT || stageType == StageType::Abs)
tempInputs[1] = model->addFakeData();
else
tempInputs[1] = inputs[1];

View File

@ -16,6 +16,7 @@ const std::vector<InferenceEngine::Precision> netPrecisions = {
};
const std::map<ActivationTypes, std::vector<std::vector<float>>> activationTypes = {
{Abs, {}},
{Sigmoid, {}},
{Tanh, {}},
{Relu, {}},