Skip to content

Commit

Permalink
Abs layer support (openvinotoolkit#6475)
Browse files Browse the repository at this point in the history
* [MyriadX] Abs op support
  • Loading branch information
DariaMityagina authored and akuporos committed Sep 29, 2021
1 parent bfb4425 commit 023516c
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 7 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
"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")

#
Expand Down
3 changes: 2 additions & 1 deletion inference-engine/src/legacy_api/include/legacy/ie_layers.h
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,8 @@ class INFERENCE_ENGINE_INTERNAL_CNNLAYER_CLASS(EltwiseLayer): public CNNLayer {
Logical_OR,
Logical_XOR,
Logical_NOT,
Mean
Mean,
Abs,
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ class FrontEnd final {
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ VPU_DECLARE_ENUM(StageType,
GatherElements = 139,
Round = 140,
CTCGreedyDecoderSeqLen = 141,
Abs = 142,
)

//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -150,7 +151,8 @@ class EltwiseStage final : public StageNode {
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)) {
Expand Down Expand Up @@ -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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const std::vector<InferenceEngine::Precision> netPrecisions = {
};

const std::map<ActivationTypes, std::vector<std::vector<float>>> activationTypes = {
{Abs, {}},
{Sigmoid, {}},
{Tanh, {}},
{Relu, {}},
Expand Down

0 comments on commit 023516c

Please sign in to comment.