This commit is contained in:
Awni Hannun
2025-08-21 06:46:01 -07:00
committed by GitHub
parent 0c5fc63a36
commit e843c4d8d5
4 changed files with 24 additions and 3 deletions

View File

@@ -223,6 +223,11 @@ struct Power {
template <typename T>
metal::enable_if_t<metal::is_integral_v<T>, T> operator()(T base, T exp) {
T res = 1;
// Undefined to raise integer to negative power
if (exp < 0) {
return 0;
}
while (exp) {
if (exp & 1) {
res *= base;