diff --git a/src/core/src/op/fake_quantize.cpp b/src/core/src/op/fake_quantize.cpp index 5b7370d5828..c9d48a19502 100644 --- a/src/core/src/op/fake_quantize.cpp +++ b/src/core/src/op/fake_quantize.cpp @@ -88,6 +88,8 @@ bool evaluate(const HostTensorPtr& arg0, const ngraph::op::FakeQuantize* parent) { OV_OP_SCOPE(v0_FakeQuantize_evaluate); using T = typename element_type_traits::value_type; + out->set_shape(arg0->get_shape()); + out->set_element_type(arg0->get_element_type()); runtime::reference::fake_quantize(arg0->get_data_ptr(), arg1->get_data_ptr(), arg2->get_data_ptr(), diff --git a/src/core/tests/eval.cpp b/src/core/tests/eval.cpp index a5ef83f0e0d..80ef4c71ffe 100644 --- a/src/core/tests/eval.cpp +++ b/src/core/tests/eval.cpp @@ -27,6 +27,7 @@ #include "ngraph/op/cosh.hpp" #include "ngraph/op/erf.hpp" #include "ngraph/op/exp.hpp" +#include "ngraph/op/fake_quantize.hpp" #include "ngraph/op/floor.hpp" #include "ngraph/op/gather.hpp" #include "ngraph/op/log.hpp" @@ -59,6 +60,7 @@ #include "ngraph/op/unsqueeze.hpp" #include "ngraph/runtime/host_tensor.hpp" #include "ngraph/validation_util.hpp" +#include "sequnce_generator.hpp" #include "util/all_close_f.hpp" #include "util/ndarray.hpp" #include "util/test_tools.hpp" @@ -1814,3 +1816,29 @@ TEST(eval, evaluate_softsign_9) { for (size_t i = 0; i < result_tensor[0].get_size(); ++i) EXPECT_NEAR(result_data[i], out[i], 1e-6F); } + +TEST(eval, evaluate_fake_quantize_dynamic_input) { + using namespace testing; + constexpr auto et = element::f32; + + auto param = make_shared(et, PartialShape::dynamic()); + auto in_low = op::v0::Constant::create(et, Shape{}, {0.f}); + auto in_high = op::v0::Constant::create(et, Shape{}, {5.f}); + auto out_low = op::v0::Constant::create(et, Shape{}, {2.f}); + auto out_high = op::v0::Constant::create(et, Shape{}, {4.f}); + + auto op = make_shared(param, in_low, in_high, out_low, out_high, 4); + auto f = make_shared(OutputVector{op}, ParameterVector{param}); + + const auto exp_shape = Shape{1, 3, 2}; + std::vector input_data; + std::generate_n(std::back_inserter(input_data), shape_size(exp_shape), ov::SeqGen(0.f)); + + auto result = make_shared(); + ASSERT_TRUE(f->evaluate({result}, {make_host_tensor(exp_shape, input_data)})); + + EXPECT_EQ(result->get_element_type(), et); + EXPECT_EQ(result->get_shape(), exp_shape); + EXPECT_THAT(read_vector(result), + Pointwise(FloatEq(), std::vector{2.f, 2.6666667f, 2.6666667f, 3.3333333f, 3.3333333f, 4.f})); +}