From 7ef4ff6385e8676dc0ab97e84e1d13ad7be58c9a Mon Sep 17 00:00:00 2001 From: Mikhail Nosov Date: Wed, 27 Oct 2021 12:29:37 +0300 Subject: [PATCH] Update only Reference implementation and tests (#8126) There were discovered a lot of issues in 'CompareWithRefs' tests when generated float inputs are not rounded to 'int' --- .../tests/functional/op_reference/convert.cpp | 16 ++++++++-------- .../reference/src/runtime/reference/convert.cpp | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/template_plugin/tests/functional/op_reference/convert.cpp b/docs/template_plugin/tests/functional/op_reference/convert.cpp index c90105a297c..6fcfd4fc8a9 100644 --- a/docs/template_plugin/tests/functional/op_reference/convert.cpp +++ b/docs/template_plugin/tests/functional/op_reference/convert.cpp @@ -133,7 +133,7 @@ INSTANTIATE_TEST_SUITE_P( std::vector {-1, -2, 0, 3}, std::vector {-1, -2, 0, 3}), ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::bf16, ov::element::i8, std::vector {-1, -2, 0, 3}, std::vector {-1, -2, 0, 3}), - ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::f32, ov::element::i8, std::vector {-1, -2, 2, 3}, + ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::f32, ov::element::i8, std::vector {-1, -2, 2.2, 3.8}, std::vector {-1, -2, 2, 3}), // destination i16 ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {8}, ov::element::u1, ov::element::i16, std::vector {0x81}, @@ -162,7 +162,7 @@ INSTANTIATE_TEST_SUITE_P( std::vector {-1, -2, 0, 3}, std::vector {-1, -2, 0, 3}), ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::bf16, ov::element::i16, std::vector {-1, -2, 0, 3}, std::vector {-1, -2, 0, 3}), - ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::f32, ov::element::i16, std::vector {-1, -2, 2, 3}, + ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::f32, ov::element::i16, std::vector {-1, -2, 2.2, 3.8}, std::vector {-1, -2, 2, 3}), // destination i32 ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {8}, ov::element::u1, ov::element::i32, std::vector {0x81}, @@ -191,7 +191,7 @@ INSTANTIATE_TEST_SUITE_P( std::vector {-1, -2, 0, 3}, std::vector {-1, -2, 0, 3}), ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::bf16, ov::element::i32, std::vector {-1, -2, 0, 3}, std::vector {-1, -2, 0, 3}), - ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::f32, ov::element::i32, std::vector {-1, -2, 2, 3}, + ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::f32, ov::element::i32, std::vector {-1, -2, 2.2, 3.8}, std::vector {-1, -2, 2, 3}), // destination i64 ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {8}, ov::element::u1, ov::element::i64, std::vector {0x81}, @@ -220,7 +220,7 @@ INSTANTIATE_TEST_SUITE_P( std::vector {-1, -2, 0, 3}, std::vector {-1, -2, 0, 3}), ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::bf16, ov::element::i64, std::vector {-1, -2, 0, 3}, std::vector {-1, -2, 0, 3}), - ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::f32, ov::element::i64, std::vector {-1, -2, 2, 3}, + ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::f32, ov::element::i64, std::vector {-1, -2, 2.2, 3.8}, std::vector {-1, -2, 2, 3}), // destination u1 @@ -310,7 +310,7 @@ INSTANTIATE_TEST_SUITE_P( std::vector {1, 2, 0, 3}), ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::bf16, ov::element::u8, std::vector {1, 2, 0, 3}, std::vector {1, 2, 0, 3}), - ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::f32, ov::element::u8, std::vector {1, 2, 2, 3}, + ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::f32, ov::element::u8, std::vector {1, 2, 2.2, 3.8}, std::vector {1, 2, 2, 3}), // destination u16 @@ -340,7 +340,7 @@ INSTANTIATE_TEST_SUITE_P( std::vector {1, 2, 0, 3}), ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::bf16, ov::element::u16, std::vector {1, 2, 0, 3}, std::vector {1, 2, 0, 3}), - ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::f32, ov::element::u16, std::vector {1, 2, 2, 3}, + ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::f32, ov::element::u16, std::vector {1, 2, 2.2, 3.8}, std::vector {1, 2, 2, 3}), // destination u32 @@ -370,7 +370,7 @@ INSTANTIATE_TEST_SUITE_P( std::vector {1, 2, 0, 3}), ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::bf16, ov::element::u32, std::vector {1, 2, 0, 3}, std::vector {1, 2, 0, 3}), - ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::f32, ov::element::u32, std::vector {1, 2, 2, 3}, + ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::f32, ov::element::u32, std::vector {1, 2, 2.2, 3.8}, std::vector {1, 2, 2, 3}), // destination u64 ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {8}, ov::element::u1, ov::element::u64, std::vector {0x81}, @@ -399,7 +399,7 @@ INSTANTIATE_TEST_SUITE_P( std::vector {1, 2, 0, 3}), ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::bf16, ov::element::u64, std::vector {1, 2, 0, 3}, std::vector {1, 2, 0, 3}), - ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::f32, ov::element::u64, std::vector {1, 2, 2, 3}, + ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::f32, ov::element::u64, std::vector {1, 2, 2.2, 3.8}, std::vector {1, 2, 2, 3})), ReferenceConversionLayerTest::getTestCaseName); } // namespace diff --git a/ngraph/core/reference/src/runtime/reference/convert.cpp b/ngraph/core/reference/src/runtime/reference/convert.cpp index 5aa44cd1579..5399fee1557 100644 --- a/ngraph/core/reference/src/runtime/reference/convert.cpp +++ b/ngraph/core/reference/src/runtime/reference/convert.cpp @@ -60,7 +60,7 @@ void jit_convert_vec(jit::Generator& gen, const Xbyak::RegExp& sr auto p32vec_lo = gen.xmm2; auto p32vec_hi = gen.xmm3; - gen.vcvtps2dq(p32vec, gen.yword[src]); // convert 8 floats to 8 ints + gen.vcvttps2dq(p32vec, gen.yword[src]); // convert 8 floats to 8 ints gen.vpshufb(p32vec, p32vec, order); // Shuffle the bytes according to the order gen.vextracti128(p32vec_hi, p32vec, 1); // extract upper part of p32vec gen.vpor(p32vec_lo, p32vec_lo, p32vec_hi); // p32vec_lo = p32vec_lo | p32vec_hi @@ -80,7 +80,7 @@ void jit_convert_vec(jit::Generator& gen, const Xbyak::RegExp& auto p32vec_hi = gen.xmm3; gen.vcvtph2ps(p32vec, gen.xword[src]); // convert 8 fp16's to 8 floats - gen.vcvtps2dq(p32vec, p32vec); // convert 8 floats to 8 ints + gen.vcvttps2dq(p32vec, p32vec); // convert 8 floats to 8 ints gen.vpshufb(p32vec, p32vec, order); // Shuffle the bytes according to the order gen.vextracti128(p32vec_hi, p32vec, 1); // extract upper part of p32vec gen.vpor(p32vec_lo, p32vec_lo, p32vec_hi); // p32vec_lo = p32vec_lo | p32vec_hi