Remove ops from Layer Creator/ Node Converter - part 7 (#3961)
* remove result op from layer creator * remove squareddifference op from layer creator * remove regionyolo op from layer creator * fix indentation
This commit is contained in:
parent
71253153ac
commit
9a5267f47b
@ -1550,11 +1550,29 @@ InferenceEngine::details::CNNLayerCreator::CNNLayerCreator(const std::shared_ptr
|
||||
return res;
|
||||
});
|
||||
|
||||
addSpecificCreator({"TensorIterator"}, [](const std::shared_ptr<::ngraph::Node>& node, const std::map<std::string, std::string>& params) -> CNNLayerPtr {
|
||||
addSpecificCreator({"TensorIterator"}, [](const std::shared_ptr<::ngraph::Node>& node,
|
||||
const std::map<std::string, std::string>& params) -> CNNLayerPtr {
|
||||
auto res = createSubGraphLayer(node);
|
||||
res->type = "TensorIterator";
|
||||
return res;
|
||||
});
|
||||
|
||||
addSpecificCreator({"SquaredDifference"}, [](const std::shared_ptr<::ngraph::Node>& node,
|
||||
const std::map<std::string, std::string>& params) -> CNNLayerPtr {
|
||||
LayerParams attrs = {node->get_friendly_name(), "Eltwise", details::convertPrecision(node->get_output_element_type(0))};
|
||||
auto res = std::make_shared<InferenceEngine::EltwiseLayer>(attrs);
|
||||
res->params["operation"] = "squared_diff";
|
||||
return res;
|
||||
});
|
||||
|
||||
addSpecificCreator({"RegionYolo"}, [](const std::shared_ptr<::ngraph::Node>& node,
|
||||
const std::map<std::string, std::string>& params) -> CNNLayerPtr {
|
||||
LayerParams attrs = {node->get_friendly_name(), "RegionYolo", details::convertPrecision(node->get_output_element_type(0))};
|
||||
auto res = std::make_shared<InferenceEngine::CNNLayer>(attrs);
|
||||
res->params = params;
|
||||
res->params["do_softmax"] = res->getBoolStrParamAsIntStr("do_softmax");
|
||||
return res;
|
||||
});
|
||||
}
|
||||
|
||||
CNNLayerPtr InferenceEngine::details::CNNLayerCreator::create() {
|
||||
@ -1590,11 +1608,9 @@ void convertFunctionToICNNNetwork(const std::shared_ptr<const ::ngraph::Function
|
||||
std::make_shared<Builder::NodeConverter<::ngraph::op::PowerIE>>(),
|
||||
std::make_shared<Builder::NodeConverter<::ngraph::op::ReLUIE>>(),
|
||||
std::make_shared<Builder::NodeConverter<::ngraph::op::ResampleV2>>(),
|
||||
std::make_shared<Builder::NodeConverter<::ngraph::op::RegionYolo>>(),
|
||||
std::make_shared<Builder::NodeConverter<::ngraph::op::ReorgYolo>>(),
|
||||
std::make_shared<Builder::NodeConverter<::ngraph::op::PSROIPooling>>(),
|
||||
std::make_shared<Builder::NodeConverter<::ngraph::op::ScaleShiftIE>>(),
|
||||
std::make_shared<Builder::NodeConverter<::ngraph::op::SquaredDifference>>(),
|
||||
std::make_shared<Builder::NodeConverter<::ngraph::op::VariadicSplit>>(),
|
||||
std::make_shared<Builder::NodeConverter<::ngraph::opset5::Loop>>(),
|
||||
std::make_shared<Builder::NodeConverter<::ngraph::op::ShuffleChannels>>(),
|
||||
|
@ -570,15 +570,6 @@ CNNLayer::Ptr NodeConverter<ngraph::op::ScaleShiftIE>::createLayer(const std::sh
|
||||
return res;
|
||||
}
|
||||
|
||||
template <>
|
||||
CNNLayer::Ptr NodeConverter<ngraph::op::SquaredDifference>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
|
||||
LayerParams params = {layer->get_friendly_name(), "Eltwise",
|
||||
details::convertPrecision(layer->get_output_element_type(0))};
|
||||
auto res = std::make_shared<InferenceEngine::EltwiseLayer>(params);
|
||||
res->params["operation"] = "squared_diff";
|
||||
return res;
|
||||
}
|
||||
|
||||
template <>
|
||||
CNNLayer::Ptr NodeConverter<ngraph::op::ShuffleChannels>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
|
||||
LayerParams params = {layer->get_friendly_name(), "ShuffleChannels", details::convertPrecision(layer->get_output_element_type(0))};
|
||||
@ -842,39 +833,6 @@ CNNLayer::Ptr NodeConverter<ExecGraphInfoSerialization::ExecutionNode>::createLa
|
||||
return res;
|
||||
}
|
||||
|
||||
template <>
|
||||
CNNLayer::Ptr NodeConverter<ngraph::op::RegionYolo>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
|
||||
LayerParams params = {layer->get_friendly_name(), "RegionYolo",
|
||||
details::convertPrecision(layer->get_output_element_type(0))};
|
||||
auto res = std::make_shared<InferenceEngine::CNNLayer>(params);
|
||||
auto castedLayer = ngraph::as_type_ptr<ngraph::op::RegionYolo>(layer);
|
||||
if (castedLayer == nullptr) THROW_IE_EXCEPTION << "Cannot get " << params.type << " layer " << params.name;
|
||||
|
||||
std::string value;
|
||||
for (const auto& val : castedLayer->get_mask()) {
|
||||
if (!value.empty()) value += ",";
|
||||
value += asString(val);
|
||||
}
|
||||
res->params["mask"] = value;
|
||||
|
||||
value = "";
|
||||
for (const auto& val : castedLayer->get_anchors()) {
|
||||
if (!value.empty())
|
||||
value += ",";
|
||||
value += asString(val);
|
||||
}
|
||||
res->params["anchors"] = value;
|
||||
|
||||
res->params["coords"] = asString(castedLayer->get_num_coords());
|
||||
res->params["classes"] = asString(castedLayer->get_num_classes());
|
||||
res->params["num"] = asString(castedLayer->get_num_regions());
|
||||
res->params["do_softmax"] = castedLayer->get_do_softmax() ? "1" : "0";
|
||||
res->params["axis"] = asString(castedLayer->get_axis());
|
||||
res->params["end_axis"] = asString(castedLayer->get_end_axis());
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
template <>
|
||||
CNNLayer::Ptr NodeConverter<ngraph::op::ReorgYolo>::createLayer(const std::shared_ptr<ngraph::Node>& layer) const {
|
||||
LayerParams params = {layer->get_friendly_name(), "ReorgYolo",
|
||||
|
@ -622,13 +622,10 @@ std::shared_ptr<ngraph::Node> V10Parser::XmlDeserializer::createNode(
|
||||
const GenericLayerParams& params) {
|
||||
static const InferenceEngine::details::caseless_unordered_map<std::string, std::shared_ptr<LayerBaseCreator>> creators = {
|
||||
{ "GreaterEqual", std::make_shared<LayerCreator<ngraph::op::v1::GreaterEqual>>("GreaterEqual") },
|
||||
{ "SquaredDifference", std::make_shared<LayerCreator<ngraph::op::SquaredDifference>>("SquaredDifference") },
|
||||
{ "LessEqual", std::make_shared<LayerCreator<ngraph::op::v1::LessEqual>>("LessEqual") },
|
||||
{ "Equal", std::make_shared<LayerCreator<ngraph::op::v1::Equal>>("Equal") },
|
||||
{ "LSTMCell", std::make_shared<LayerCreator<ngraph::op::v0::LSTMCell>>("LSTMCell") },
|
||||
{ "ReorgYolo", std::make_shared<LayerCreator<ngraph::op::ReorgYolo>>("ReorgYolo") },
|
||||
{ "RegionYolo", std::make_shared<LayerCreator<ngraph::op::RegionYolo>>("RegionYolo") },
|
||||
{ "Result", std::make_shared<LayerCreator<ngraph::op::Result>>("Result") },
|
||||
{ "PSROIPooling", std::make_shared<LayerCreator<ngraph::op::PSROIPooling>>("PSROIPooling") },
|
||||
{ "VariadicSplit", std::make_shared<LayerCreator<ngraph::op::VariadicSplit>>("VariadicSplit") },
|
||||
{ "Loop", std::make_shared<LayerCreator<ngraph::opset5::Loop>>("Loop") },
|
||||
@ -1010,15 +1007,6 @@ std::shared_ptr<ngraph::Node> V10Parser::LayerCreator<ngraph::op::v0::LSTMCell>:
|
||||
activations, activations_alpha, activations_beta, clip);
|
||||
}
|
||||
|
||||
// SquaredDifference layer
|
||||
template <>
|
||||
std::shared_ptr<ngraph::Node> V10Parser::LayerCreator<ngraph::op::SquaredDifference>::createLayer(
|
||||
const ngraph::OutputVector& inputs, const pugi::xml_node& node, const Blob::CPtr& weights,
|
||||
const GenericLayerParams& layerParsePrms) {
|
||||
checkParameters(inputs, layerParsePrms, 2);
|
||||
return std::make_shared<ngraph::op::SquaredDifference>(inputs[0], inputs[1]);
|
||||
}
|
||||
|
||||
// GreaterEqual layer
|
||||
template <>
|
||||
std::shared_ptr<ngraph::Node> V10Parser::LayerCreator<ngraph::op::v1::GreaterEqual>::createLayer(
|
||||
@ -1069,39 +1057,6 @@ std::shared_ptr<ngraph::Node> V10Parser::LayerCreator<ngraph::op::DepthToSpace>:
|
||||
return std::make_shared<ngraph::op::DepthToSpace>(inputs[0], GetStrAttr(dn, "mode"), GetIntAttr(dn, "block_size", 1));
|
||||
}
|
||||
|
||||
// Result layer
|
||||
template <>
|
||||
std::shared_ptr<ngraph::Node> V10Parser::LayerCreator<ngraph::op::Result>::createLayer(
|
||||
const ngraph::OutputVector& inputs, const pugi::xml_node& node, const Blob::CPtr& weights,
|
||||
const GenericLayerParams& layerParsePrms) {
|
||||
checkParameters(inputs, layerParsePrms, 1);
|
||||
return std::make_shared<ngraph::op::Result>(inputs[0]);
|
||||
}
|
||||
|
||||
// RegionYolo layer
|
||||
template <>
|
||||
std::shared_ptr<ngraph::Node> V10Parser::LayerCreator<ngraph::op::RegionYolo>::createLayer(
|
||||
const ngraph::OutputVector& inputs, const pugi::xml_node& node, const Blob::CPtr& weights,
|
||||
const GenericLayerParams& layerParsePrms) {
|
||||
checkParameters(inputs, layerParsePrms, 1);
|
||||
pugi::xml_node dn = node.child("data");
|
||||
|
||||
if (dn.empty())
|
||||
THROW_IE_EXCEPTION << "Cannot read parameter for " << getType() << " layer with name: " << layerParsePrms.name;
|
||||
|
||||
auto axis = GetIntAttr(dn, "axis");
|
||||
auto classes = GetUIntAttr(dn, "classes");
|
||||
auto coords = GetUIntAttr(dn, "coords");
|
||||
auto do_softmax = GetBoolAttr(dn, "do_softmax");
|
||||
auto end_axis = GetIntAttr(dn, "end_axis");
|
||||
auto num = GetUIntAttr(dn, "num");
|
||||
auto mask = getParameters<int64_t>(dn, "mask", {});
|
||||
auto anchors = getParameters<float>(dn, "anchors", {});
|
||||
|
||||
return std::make_shared<ngraph::op::RegionYolo>(inputs[0], coords, classes, num, do_softmax,
|
||||
mask, axis, end_axis, anchors);
|
||||
}
|
||||
|
||||
// ReorgYolo layer
|
||||
template <>
|
||||
std::shared_ptr<ngraph::Node> V10Parser::LayerCreator<ngraph::op::ReorgYolo>::createLayer(
|
||||
|
Loading…
Reference in New Issue
Block a user