Skip to content

Commit 9553c5b

Browse files
committed
Use static cast and remove unneeded castings
1 parent aa91616 commit 9553c5b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Diff for: ggml/src/ggml-sycl/element_wise.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static void relu(const T * x, T * dst, const int k,
8383
if (i >= k) {
8484
return;
8585
}
86-
dst[i] = sycl::fmax((T)(x[i]), (T)0);
86+
dst[i] = sycl::fmax((x[i]), static_cast<T>(0));
8787
}
8888

8989
template<typename T>
@@ -208,7 +208,7 @@ static void step(const T * x, T * dst, const int k,
208208
if (i >= k) {
209209
return;
210210
}
211-
dst[i] = x[i] > (T)0.0f;
211+
dst[i] = x[i] > static_cast<T>(0.0f);
212212
}
213213

214214
template<typename T>
@@ -219,8 +219,8 @@ static void leaky_relu(const T *x, T *dst, const int k, const float negative_slo
219219
if (i >= k) {
220220
return;
221221
}
222-
dst[i] = sycl::fmax((T)(x[i]), (T)0) +
223-
sycl::fmin((T)(x[i]), (T)0.0f) * negative_slope;
222+
dst[i] = sycl::fmax((x[i]), static_cast<T>(0)) +
223+
sycl::fmin((x[i]), static_cast<T>(0.0f)) * negative_slope;
224224
}
225225

226226
template<typename T>
@@ -291,7 +291,7 @@ static void clamp(const T * x, T * dst, const float min, const float max, const
291291
return;
292292
}
293293

294-
dst[i] = x[i] < (T)min ? (T)min : (x[i] > (T)max ? (T)max : x[i]);
294+
dst[i] = x[i] < static_cast<T>(min) ? static_cast<T>(min) : (x[i] > static_cast<T>(max) ? static_cast<T>(max) : x[i]);
295295
}
296296

297297
static void acc_f32_sycl(const float *x, const float *y, float *dst,

0 commit comments

Comments
 (0)