mirror of
https://github.com/ml-explore/mlx.git
synced 2025-10-21 18:28:11 +08:00
fix power (#2523)
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user