Skip to content

Commit

Permalink
Update only Reference implementation and tests (openvinotoolkit#8126)
Browse files Browse the repository at this point in the history
There were discovered a lot of issues in 'CompareWithRefs' tests when generated float inputs are not rounded to 'int'
  • Loading branch information
nosovmik authored Oct 27, 2021
1 parent 789c237 commit 7ef4ff6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions docs/template_plugin/tests/functional/op_reference/convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ INSTANTIATE_TEST_SUITE_P(
std::vector<ngraph::float16> {-1, -2, 0, 3}, std::vector<int8_t> {-1, -2, 0, 3}),
ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::bf16, ov::element::i8,
std::vector<ngraph::bfloat16> {-1, -2, 0, 3}, std::vector<int8_t> {-1, -2, 0, 3}),
ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::f32, ov::element::i8, std::vector<float> {-1, -2, 2, 3},
ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::f32, ov::element::i8, std::vector<float> {-1, -2, 2.2, 3.8},
std::vector<int8_t> {-1, -2, 2, 3}),
// destination i16
ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {8}, ov::element::u1, ov::element::i16, std::vector<uint8_t> {0x81},
Expand Down Expand Up @@ -162,7 +162,7 @@ INSTANTIATE_TEST_SUITE_P(
std::vector<ngraph::float16> {-1, -2, 0, 3}, std::vector<int16_t> {-1, -2, 0, 3}),
ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::bf16, ov::element::i16,
std::vector<ngraph::bfloat16> {-1, -2, 0, 3}, std::vector<int16_t> {-1, -2, 0, 3}),
ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::f32, ov::element::i16, std::vector<float> {-1, -2, 2, 3},
ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::f32, ov::element::i16, std::vector<float> {-1, -2, 2.2, 3.8},
std::vector<int16_t> {-1, -2, 2, 3}),
// destination i32
ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {8}, ov::element::u1, ov::element::i32, std::vector<uint8_t> {0x81},
Expand Down Expand Up @@ -191,7 +191,7 @@ INSTANTIATE_TEST_SUITE_P(
std::vector<ngraph::float16> {-1, -2, 0, 3}, std::vector<int32_t> {-1, -2, 0, 3}),
ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::bf16, ov::element::i32,
std::vector<ngraph::bfloat16> {-1, -2, 0, 3}, std::vector<int32_t> {-1, -2, 0, 3}),
ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::f32, ov::element::i32, std::vector<float> {-1, -2, 2, 3},
ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::f32, ov::element::i32, std::vector<float> {-1, -2, 2.2, 3.8},
std::vector<int32_t> {-1, -2, 2, 3}),
// destination i64
ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {8}, ov::element::u1, ov::element::i64, std::vector<uint8_t> {0x81},
Expand Down Expand Up @@ -220,7 +220,7 @@ INSTANTIATE_TEST_SUITE_P(
std::vector<ngraph::float16> {-1, -2, 0, 3}, std::vector<int64_t> {-1, -2, 0, 3}),
ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::bf16, ov::element::i64,
std::vector<ngraph::bfloat16> {-1, -2, 0, 3}, std::vector<int64_t> {-1, -2, 0, 3}),
ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::f32, ov::element::i64, std::vector<float> {-1, -2, 2, 3},
ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::f32, ov::element::i64, std::vector<float> {-1, -2, 2.2, 3.8},
std::vector<int64_t> {-1, -2, 2, 3}),

// destination u1
Expand Down Expand Up @@ -310,7 +310,7 @@ INSTANTIATE_TEST_SUITE_P(
std::vector<uint8_t> {1, 2, 0, 3}),
ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::bf16, ov::element::u8,
std::vector<ngraph::bfloat16> {1, 2, 0, 3}, std::vector<uint8_t> {1, 2, 0, 3}),
ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::f32, ov::element::u8, std::vector<float> {1, 2, 2, 3},
ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::f32, ov::element::u8, std::vector<float> {1, 2, 2.2, 3.8},
std::vector<uint8_t> {1, 2, 2, 3}),

// destination u16
Expand Down Expand Up @@ -340,7 +340,7 @@ INSTANTIATE_TEST_SUITE_P(
std::vector<uint16_t> {1, 2, 0, 3}),
ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::bf16, ov::element::u16,
std::vector<ngraph::bfloat16> {1, 2, 0, 3}, std::vector<uint16_t> {1, 2, 0, 3}),
ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::f32, ov::element::u16, std::vector<float> {1, 2, 2, 3},
ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::f32, ov::element::u16, std::vector<float> {1, 2, 2.2, 3.8},
std::vector<uint16_t> {1, 2, 2, 3}),

// destination u32
Expand Down Expand Up @@ -370,7 +370,7 @@ INSTANTIATE_TEST_SUITE_P(
std::vector<uint32_t> {1, 2, 0, 3}),
ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::bf16, ov::element::u32,
std::vector<ngraph::bfloat16> {1, 2, 0, 3}, std::vector<uint32_t> {1, 2, 0, 3}),
ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::f32, ov::element::u32, std::vector<float> {1, 2, 2, 3},
ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::f32, ov::element::u32, std::vector<float> {1, 2, 2.2, 3.8},
std::vector<uint32_t> {1, 2, 2, 3}),
// destination u64
ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {8}, ov::element::u1, ov::element::u64, std::vector<uint8_t> {0x81},
Expand Down Expand Up @@ -399,7 +399,7 @@ INSTANTIATE_TEST_SUITE_P(
std::vector<uint64_t> {1, 2, 0, 3}),
ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::bf16, ov::element::u64,
std::vector<ngraph::bfloat16> {1, 2, 0, 3}, std::vector<uint64_t> {1, 2, 0, 3}),
ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::f32, ov::element::u64, std::vector<float> {1, 2, 2, 3},
ConvertParams(ConversionTypes::CONVERT, ov::PartialShape {4}, ov::element::f32, ov::element::u64, std::vector<float> {1, 2, 2.2, 3.8},
std::vector<uint64_t> {1, 2, 2, 3})),
ReferenceConversionLayerTest::getTestCaseName);
} // namespace
Expand Down
4 changes: 2 additions & 2 deletions ngraph/core/reference/src/runtime/reference/convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void jit_convert_vec<float, int8_t>(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
Expand All @@ -80,7 +80,7 @@ void jit_convert_vec<float16, int8_t>(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
Expand Down

0 comments on commit 7ef4ff6

Please sign in to comment.