Skip to content

Commit 1088074

Browse files
typenum_to_src_id now recognized shadowed types, i.e. intc on Windows
1 parent a21c97f commit 1088074

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

dpctl/tensor/libtensor/include/utils/type_dispatch.hpp

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,22 @@ struct usm_ndarray_types
228228
else if (typenum == UAR_HALF_) {
229229
return static_cast<int>(typenum_t::HALF);
230230
}
231+
else if (typenum == UAR_INT || typenum == UAR_UINT) {
232+
switch (sizeof(int)) {
233+
case sizeof(std::int32_t):
234+
return ((typenum == UAR_INT)
235+
? static_cast<int>(typenum_t::INT32)
236+
: static_cast<int>(typenum_t::UINT32));
237+
case sizeof(std::int64_t):
238+
return ((typenum == UAR_INT)
239+
? static_cast<int>(typenum_t::INT64)
240+
: static_cast<int>(typenum_t::UINT64));
241+
default:
242+
throw_unrecognized_typenum_error(typenum);
243+
}
244+
}
231245
else {
232-
throw std::runtime_error("Unrecogized typenum " +
233-
std::to_string(typenum) + " encountered.");
246+
throw_unrecognized_typenum_error(typenum);
234247
}
235248
}
236249

@@ -286,6 +299,12 @@ struct usm_ndarray_types
286299

287300
return types;
288301
}
302+
303+
void throw_unrecognized_typenum_error(int typenum)
304+
{
305+
throw std::runtime_error("Unrecogized typenum " +
306+
std::to_string(typenum) + " encountered.");
307+
}
289308
};
290309

291310
} // namespace detail

0 commit comments

Comments
 (0)