Skip to content

Commit

Permalink
[SYCL][E2E] Add the FP16 tests to marray_relational.cpp (intel#12102)
Browse files Browse the repository at this point in the history
Thanks for your review.

Co-authored-by: Jin Z <[email protected]>
  • Loading branch information
jinz2014 and Jin Z authored Dec 22, 2023
1 parent a6d3445 commit e749f01
Showing 1 changed file with 42 additions and 10 deletions.
52 changes: 42 additions & 10 deletions sycl/test-e2e/Basic/built-ins/marray_relational.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,52 @@
#define EXPECTED(TYPE, ...) ((TYPE[]){__VA_ARGS__})

int main() {
sycl::queue deviceQueue;
sycl::device Dev;
sycl::queue deviceQueue(Dev);

sycl::marray<float, 2> ma1{1.0, 2.0};
sycl::marray<float, 2> ma2{1.0, 2.0};
sycl::marray<float, 2> ma3{2.0, 1.0};
sycl::marray<float, 2> ma4{2.0, 2.0};
sycl::marray<float, 3> ma5{2.0, 2.0, 1.0};
sycl::marray<float, 3> ma6{1.0, 5.0, 8.0};
sycl::marray<sycl::half, 2> ma1_f16{1.f, 2.f};
sycl::marray<sycl::half, 2> ma2_f16{1.f, 2.f};
sycl::marray<sycl::half, 2> ma3_f16{2.f, 1.f};
sycl::marray<sycl::half, 2> ma4_f16{2.f, 2.f};
sycl::marray<sycl::half, 3> ma5_f16{2.f, 2.f, 1.f};
sycl::marray<sycl::half, 3> ma6_f16{1.f, 5.f, 8.f};
sycl::marray<sycl::half, 2> ma8_f16{1.f, 1.f};
sycl::marray<sycl::half, 2> ma9_f16{0.5f, 0.5f};
sycl::marray<sycl::half, 2> ma10_f16{2.f, 2.f};

sycl::marray<float, 2> ma1{1.f, 2.f};
sycl::marray<float, 2> ma2{1.f, 2.f};
sycl::marray<float, 2> ma3{2.f, 1.f};
sycl::marray<float, 2> ma4{2.f, 2.f};
sycl::marray<float, 3> ma5{2.f, 2.f, 1.f};
sycl::marray<float, 3> ma6{1.f, 5.f, 8.f};
sycl::marray<int, 3> ma7{50, 2, 31};
sycl::marray<float, 2> ma8{1.0, 1.0};
sycl::marray<float, 2> ma9{0.5, 0.5};
sycl::marray<float, 2> ma10{2.0, 2.0};
sycl::marray<float, 2> ma8{1.f, 1.f};
sycl::marray<float, 2> ma9{0.5f, 0.5f};
sycl::marray<float, 2> ma10{2.f, 2.f};
sycl::marray<bool, 3> c(1, 0, 1);

if (Dev.has(sycl::aspect::fp16)) {
TEST(sycl::isequal, bool, EXPECTED(bool, 1, 1), 2, ma1_f16, ma2_f16);
TEST(sycl::isnotequal, bool, EXPECTED(bool, 0, 0), 2, ma1_f16, ma2_f16);
TEST(sycl::isgreater, bool, EXPECTED(bool, 0, 1), 2, ma1_f16, ma3_f16);
TEST(sycl::isgreaterequal, bool, EXPECTED(bool, 0, 1), 2, ma1_f16, ma4_f16);
TEST(sycl::isless, bool, EXPECTED(bool, 0, 1), 2, ma3_f16, ma1_f16);
TEST(sycl::islessequal, bool, EXPECTED(bool, 0, 1), 2, ma4_f16, ma1_f16);
TEST(sycl::islessgreater, bool, EXPECTED(bool, 0, 0), 2, ma1_f16, ma2_f16);
TEST(sycl::isfinite, bool, EXPECTED(bool, 1, 1), 2, ma1_f16);
TEST(sycl::isinf, bool, EXPECTED(bool, 0, 0), 2, ma1_f16);
TEST(sycl::isnan, bool, EXPECTED(bool, 0, 0), 2, ma1_f16);
TEST(sycl::isnormal, bool, EXPECTED(bool, 1, 1), 2, ma1_f16);
TEST(sycl::isordered, bool, EXPECTED(bool, 1, 1), 2, ma1_f16, ma2_f16);
TEST(sycl::isunordered, bool, EXPECTED(bool, 0, 0), 2, ma1_f16, ma2_f16);
TEST(sycl::signbit, bool, EXPECTED(bool, 0, 0), 2, ma1_f16);
TEST(sycl::bitselect, sycl::half, EXPECTED(float, 1.0, 1.0), 2, ma8_f16,
ma9_f16, ma10_f16);
TEST(sycl::select, sycl::half, EXPECTED(float, 1.0, 2.0, 8.0), 3, ma5_f16,
ma6_f16, c);
}

TEST(sycl::isequal, bool, EXPECTED(bool, 1, 1), 2, ma1, ma2);
TEST(sycl::isnotequal, bool, EXPECTED(bool, 0, 0), 2, ma1, ma2);
TEST(sycl::isgreater, bool, EXPECTED(bool, 0, 1), 2, ma1, ma3);
Expand Down

0 comments on commit e749f01

Please sign in to comment.