From: Vladislav Vinogradov Date: Fri, 23 Oct 2020 16:21:02 +0000 (+0300) Subject: [IE] Fix UNITY build (#2799) X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d846969a1c5efef3350b5afc773ed661965db5e4;p=platform%2Fupstream%2Fdldt.git [IE] Fix UNITY build (#2799) --- diff --git a/inference-engine/src/transformations/src/transformations/low_precision/fake_quantize.cpp b/inference-engine/src/transformations/src/transformations/low_precision/fake_quantize.cpp index ed56764..2bc0a2c 100644 --- a/inference-engine/src/transformations/src/transformations/low_precision/fake_quantize.cpp +++ b/inference-engine/src/transformations/src/transformations/low_precision/fake_quantize.cpp @@ -119,6 +119,8 @@ bool FakeQuantizeTransformation::transform(TransformationContext& context, ngrap return true; } +namespace fq { + static std::shared_ptr updateShape(std::shared_ptr op, const Shape& targetShape) { const Shape shape = op->get_output_shape(0); if ((shape.size() < targetShape.size()) && (shape.size() > 1ul)) { @@ -154,8 +156,10 @@ static std::shared_ptr getConstant(const std::shared_ptr return as_type_ptr(eltwise->get_input_node_shared_ptr(0)); } +} // namespace fq + bool FakeQuantizeTransformation::checkElementwise(const std::shared_ptr& eltwise) { - std::shared_ptr constant = getConstant(eltwise); + std::shared_ptr constant = fq::getConstant(eltwise); if (constant == nullptr) { return false; } @@ -178,7 +182,7 @@ bool FakeQuantizeTransformation::checkElementwise(const std::shared_ptr& e } } - return getData(eltwise) != nullptr; + return fq::getData(eltwise) != nullptr; } std::shared_ptr FakeQuantizeTransformation::fuseElementwise( @@ -189,7 +193,7 @@ std::shared_ptr FakeQuantizeTransformation::fuseElementwis std::shared_ptr inputLowConst = fakeQuantize->get_input_node_shared_ptr(1); std::shared_ptr inputHightConst = fakeQuantize->get_input_node_shared_ptr(2); - std::shared_ptr constant = getConstant(eltwise); + std::shared_ptr constant = fq::getConstant(eltwise); if (is_type(eltwise) && checkElementwise(eltwise)) { const auto value = constant->get_output_element_type(0) == eltwise->get_output_element_type(0) ? constant : @@ -203,8 +207,8 @@ std::shared_ptr FakeQuantizeTransformation::fuseElementwis } } - inputLowConst = updateShape(fold(inputLowConst, value), fakeQuantize->get_output_shape(0)); - inputHightConst = updateShape(fold(inputHightConst, value), fakeQuantize->get_output_shape(0)); + inputLowConst = fq::updateShape(fold(inputLowConst, value), fakeQuantize->get_output_shape(0)); + inputHightConst = fq::updateShape(fold(inputHightConst, value), fakeQuantize->get_output_shape(0)); } else if (is_type(eltwise) && checkElementwise(eltwise)) { const auto value = constant->get_output_element_type(0) == eltwise->get_output_element_type(0) ? constant : @@ -218,18 +222,18 @@ std::shared_ptr FakeQuantizeTransformation::fuseElementwis } } - inputLowConst = updateShape(fold(inputLowConst, value), fakeQuantize->get_output_shape(0)); - inputHightConst = updateShape(fold(inputHightConst, value), fakeQuantize->get_output_shape(0)); + inputLowConst = fq::updateShape(fold(inputLowConst, value), fakeQuantize->get_output_shape(0)); + inputHightConst = fq::updateShape(fold(inputHightConst, value), fakeQuantize->get_output_shape(0)); } else if (is_type(eltwise) && checkElementwise(eltwise)) { const auto value = constant->get_output_element_type(0) == eltwise->get_output_element_type(0) ? constant : fold(constant, eltwise->get_output_element_type(0)); - inputLowConst = updateShape(fold(inputLowConst, value), fakeQuantize->get_output_shape(0)); - inputHightConst = updateShape(fold(inputHightConst, value), fakeQuantize->get_output_shape(0)); + inputLowConst = fq::updateShape(fold(inputLowConst, value), fakeQuantize->get_output_shape(0)); + inputHightConst = fq::updateShape(fold(inputHightConst, value), fakeQuantize->get_output_shape(0)); } else if (is_type(eltwise) && checkElementwise(eltwise)) { - if (is_type(getData(eltwise)) || - is_type(getData(eltwise))) { + if (is_type(fq::getData(eltwise)) || + is_type(fq::getData(eltwise))) { return nullptr; } @@ -237,8 +241,8 @@ std::shared_ptr FakeQuantizeTransformation::fuseElementwis constant : fold(constant, eltwise->get_output_element_type(0)); - inputLowConst = updateShape(fold(inputLowConst, value), fakeQuantize->get_output_shape(0)); - inputHightConst = updateShape(fold(inputHightConst, value), fakeQuantize->get_output_shape(0)); + inputLowConst = fq::updateShape(fold(inputLowConst, value), fakeQuantize->get_output_shape(0)); + inputHightConst = fq::updateShape(fold(inputHightConst, value), fakeQuantize->get_output_shape(0)); } else if (is_type(eltwise)) { // issue #40611 if ((eltwise->input(0).get_element_type() == element::i32) && (eltwise->output(0).get_element_type() == element::f32)) { @@ -249,7 +253,7 @@ std::shared_ptr FakeQuantizeTransformation::fuseElementwis } std::shared_ptr newFakeQuantize = as_type_ptr(fakeQuantize->clone_with_new_inputs({ - getData(eltwise), + fq::getData(eltwise), inputLowConst, inputHightConst, fakeQuantize->input_value(3), diff --git a/inference-engine/src/transformations/src/transformations/low_precision/fuse_fake_quantize.cpp b/inference-engine/src/transformations/src/transformations/low_precision/fuse_fake_quantize.cpp index 15fbce9..f43c9b3 100644 --- a/inference-engine/src/transformations/src/transformations/low_precision/fuse_fake_quantize.cpp +++ b/inference-engine/src/transformations/src/transformations/low_precision/fuse_fake_quantize.cpp @@ -24,6 +24,8 @@ bool FuseFakeQuantizeTransformation::transform(TransformationContext& context, n return true; } +namespace fuse_fq { + std::shared_ptr updateShape(std::shared_ptr op, const Shape& targetShape) { const Shape shape = op->get_output_shape(0); if ((shape.size() < targetShape.size()) && (shape.size() > 1ul)) { @@ -86,6 +88,8 @@ bool eltwiseWithConstant(const std::shared_ptr& eltwise) { return getData(eltwise) != nullptr; } +} // namespace fuse_fq + std::shared_ptr FuseFakeQuantizeTransformation::handle( TransformationContext& context, const std::shared_ptr& fakeQuantize) const { @@ -94,31 +98,31 @@ std::shared_ptr FuseFakeQuantizeTransformation::handle( std::shared_ptr inputLowConst = fakeQuantize->get_input_node_shared_ptr(1); std::shared_ptr inputHightConst = fakeQuantize->get_input_node_shared_ptr(2); - std::shared_ptr constant = getConstant(eltwise); - if (is_type(eltwise) && eltwiseWithConstant(eltwise)) { + std::shared_ptr constant = fuse_fq::getConstant(eltwise); + if (is_type(eltwise) && fuse_fq::eltwiseWithConstant(eltwise)) { const auto value = constant->get_output_element_type(0) == eltwise->get_output_element_type(0) ? constant : fold(constant, eltwise->get_output_element_type(0)); - inputLowConst = updateShape(fold(inputLowConst, value), fakeQuantize->get_output_shape(0)); - inputHightConst = updateShape(fold(inputHightConst, value), fakeQuantize->get_output_shape(0)); - } else if (is_type(eltwise) && eltwiseWithConstant(eltwise)) { + inputLowConst = fuse_fq::updateShape(fold(inputLowConst, value), fakeQuantize->get_output_shape(0)); + inputHightConst = fuse_fq::updateShape(fold(inputHightConst, value), fakeQuantize->get_output_shape(0)); + } else if (is_type(eltwise) && fuse_fq::eltwiseWithConstant(eltwise)) { const auto value = constant->get_output_element_type(0) == eltwise->get_output_element_type(0) ? constant : fold(constant, eltwise->get_output_element_type(0)); - inputLowConst = updateShape(fold(inputLowConst, value), fakeQuantize->get_output_shape(0)); - inputHightConst = updateShape(fold(inputHightConst, value), fakeQuantize->get_output_shape(0)); - } else if (is_type(eltwise) && eltwiseWithConstant(eltwise)) { + inputLowConst = fuse_fq::updateShape(fold(inputLowConst, value), fakeQuantize->get_output_shape(0)); + inputHightConst = fuse_fq::updateShape(fold(inputHightConst, value), fakeQuantize->get_output_shape(0)); + } else if (is_type(eltwise) && fuse_fq::eltwiseWithConstant(eltwise)) { const auto value = constant->get_output_element_type(0) == eltwise->get_output_element_type(0) ? constant : fold(constant, eltwise->get_output_element_type(0)); - inputLowConst = updateShape(fold(inputLowConst, value), fakeQuantize->get_output_shape(0)); - inputHightConst = updateShape(fold(inputHightConst, value), fakeQuantize->get_output_shape(0)); - } else if (is_type(eltwise) && eltwiseWithConstant(eltwise)) { - if (is_type(getData(eltwise)) || - is_type(getData(eltwise))) { + inputLowConst = fuse_fq::updateShape(fold(inputLowConst, value), fakeQuantize->get_output_shape(0)); + inputHightConst = fuse_fq::updateShape(fold(inputHightConst, value), fakeQuantize->get_output_shape(0)); + } else if (is_type(eltwise) && fuse_fq::eltwiseWithConstant(eltwise)) { + if (is_type(fuse_fq::getData(eltwise)) || + is_type(fuse_fq::getData(eltwise))) { return nullptr; } @@ -126,8 +130,8 @@ std::shared_ptr FuseFakeQuantizeTransformation::handle( constant : fold(constant, eltwise->get_output_element_type(0)); - inputLowConst = updateShape(fold(inputLowConst, value), fakeQuantize->get_output_shape(0)); - inputHightConst = updateShape(fold(inputHightConst, value), fakeQuantize->get_output_shape(0)); + inputLowConst = fuse_fq::updateShape(fold(inputLowConst, value), fakeQuantize->get_output_shape(0)); + inputHightConst = fuse_fq::updateShape(fold(inputHightConst, value), fakeQuantize->get_output_shape(0)); } else if (is_type(eltwise)) { // issue #40611 if ((eltwise->input(0).get_element_type() == element::i32) && (eltwise->output(0).get_element_type() == element::f32)) { @@ -138,7 +142,7 @@ std::shared_ptr FuseFakeQuantizeTransformation::handle( } std::shared_ptr newFakeQuantize = as_type_ptr(fakeQuantize->clone_with_new_inputs({ - getData(eltwise), + fuse_fq::getData(eltwise), inputLowConst, inputHightConst, fakeQuantize->input_value(3), diff --git a/inference-engine/src/transformations/src/transformations/low_precision/mvn.cpp b/inference-engine/src/transformations/src/transformations/low_precision/mvn.cpp index c29856d..4b619a1 100644 --- a/inference-engine/src/transformations/src/transformations/low_precision/mvn.cpp +++ b/inference-engine/src/transformations/src/transformations/low_precision/mvn.cpp @@ -18,7 +18,7 @@ using namespace ngraph; using namespace ngraph::pass; using namespace ngraph::pass::low_precision; -namespace { +namespace mvn { template std::shared_ptr createNewScalesConst(const ngraph::op::Constant& originalConst) { @@ -33,7 +33,7 @@ std::shared_ptr createNewScalesConst(const ngraph::op::Con return ngraph::op::Constant::create(type, originalConst.get_shape(), newData); } -} // namespace +} // namespace mvn bool MVNTransformation::canBeTransformed(const TransformationContext& context, std::shared_ptr operation) const { if (!LayerTransformation::canBeTransformed(context, operation)) { @@ -93,11 +93,11 @@ bool MVNTransformation::transform(TransformationContext &context, ngraph::patter if (normalizeVariance) { switch (type) { case ngraph::element::Type_t::f16: { - newScalesConst = createNewScalesConst::value_type>(*scalesConst); + newScalesConst = mvn::createNewScalesConst::value_type>(*scalesConst); break; } case ngraph::element::Type_t::f32: { - newScalesConst = createNewScalesConst::value_type>(*scalesConst); + newScalesConst = mvn::createNewScalesConst::value_type>(*scalesConst); break; } default: { diff --git a/inference-engine/src/transformations/src/transformations/low_precision/normalize_l2.cpp b/inference-engine/src/transformations/src/transformations/low_precision/normalize_l2.cpp index eaee3ef..41fac9b 100644 --- a/inference-engine/src/transformations/src/transformations/low_precision/normalize_l2.cpp +++ b/inference-engine/src/transformations/src/transformations/low_precision/normalize_l2.cpp @@ -17,7 +17,7 @@ using namespace ngraph; using namespace ngraph::pass; using namespace ngraph::pass::low_precision; -namespace { +namespace normalize_l2 { template std::shared_ptr createNewScalesConst(const ngraph::op::Constant& originalConst) { @@ -32,7 +32,7 @@ std::shared_ptr createNewScalesConst(const ngraph::op::Con return ngraph::op::Constant::create(type, originalConst.get_shape(), newData); } -} // namespace +} // namespace normalize_l2 bool NormalizeL2Transformation::canBeTransformed(const TransformationContext& context, std::shared_ptr operation) const { if (!LayerTransformation::canBeTransformed(context, operation)) { @@ -106,11 +106,11 @@ bool NormalizeL2Transformation::transform(TransformationContext &context, ngraph const auto type = scalesConst->get_output_element_type(0); switch (type) { case ngraph::element::Type_t::f16: { - newScalesConst = createNewScalesConst::value_type>(*scalesConst); + newScalesConst = normalize_l2::createNewScalesConst::value_type>(*scalesConst); break; } case ngraph::element::Type_t::f32: { - newScalesConst = createNewScalesConst::value_type>(*scalesConst); + newScalesConst = normalize_l2::createNewScalesConst::value_type>(*scalesConst); break; } default: { diff --git a/inference-engine/tests/functional/inference_engine/CMakeLists.txt b/inference-engine/tests/functional/inference_engine/CMakeLists.txt index f9b94b5..c3d37d3 100644 --- a/inference-engine/tests/functional/inference_engine/CMakeLists.txt +++ b/inference-engine/tests/functional/inference_engine/CMakeLists.txt @@ -44,7 +44,6 @@ addIeTargetTest( ) ie_faster_build(${TARGET_NAME} - UNITY PCH PRIVATE "precomp.hpp" )