Skip to content

Commit 30ebc6f

Browse files
committed
Add fallback definition for isnan
1 parent fa647ab commit 30ebc6f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

mistralrs-quant/src/metal_kernels/utils.metal

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,15 @@ inline bfloat16_t uint16_to_bfloat16(const uint16_t x) {
263263
return _MLX_BFloat16(x, _MLX_BFloat16::bits_to_bfloat());
264264
}
265265

266+
// Resolve ambiguous call to metal::isnan for bfloat16_t by providing an
267+
// exact‑match overload. This prevents the compiler from having to choose
268+
// between the existing float and half overloads when the argument is a
269+
// bfloat16_t value.
270+
METAL_FUNC inline bool isnan(bfloat16_t x) {
271+
// Delegate to the float overload after an explicit cast.
272+
return metal::isnan(static_cast<float>(x));
273+
}
274+
266275
#endif
267276

268277
///////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)