Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit de5e495

Browse files
authored
[SYCL][Matrix] Add explicit cast for the conditional operator to avoid unexpected behavior (#727)
1 parent 1d4ed12 commit de5e495

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

SYCL/Matrix/element_wise_all_ops_half.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,9 @@ template <typename T, size_t NUM_ROWS, size_t NUM_COLS> struct big_matrix {
4141
};
4242

4343
template <typename T, size_t M, size_t N>
44-
void assert_ops_ref(/*const T &C*/ accessor<T, 2, access::mode::read,
45-
access::target::host_buffer>
46-
C,
47-
const float ref) {
44+
void assert_ops_ref(
45+
accessor<T, 2, access::mode::read, access::target::host_buffer> C,
46+
const float ref) {
4847
for (size_t i = 0; i < M; i++)
4948
for (size_t j = 0; j < N; j++) {
5049
auto diff = C[i][j] - ref;
@@ -204,7 +203,8 @@ void matrix_verify_logic(queue q, big_matrix<T, M, N> &A, nd_range<2> &r,
204203
if (wi_slice_a[i]) {
205204
if (wi_slice_a[i] > 2.0 || wi_slice_a[i] >= 2.0 ||
206205
wi_slice_a[i] < 2.0 || wi_slice_a[i] <= 2.0) {
207-
T val = (wi_slice_a[i] != 2.0) ? wi_slice_a[i] : 2.0;
206+
T val = (wi_slice_a[i] != 2.0) ? wi_slice_a[i]
207+
: static_cast<half>(2.0);
208208
val--;
209209
val++;
210210
if (wi_slice_a[i] == 2.0) {

0 commit comments

Comments
 (0)