mirror of
https://github.com/ml-explore/mlx.git
synced 2025-12-16 01:49:05 +08:00
fix power (#2523)
This commit is contained in:
@@ -204,6 +204,10 @@ struct Power {
|
||||
__device__ T operator()(T base, T exp) {
|
||||
if constexpr (cuda::std::is_integral_v<T>) {
|
||||
T res = 1;
|
||||
// Raising an integer to a negative power is undefined
|
||||
if (exp < 0) {
|
||||
return 0;
|
||||
}
|
||||
while (exp) {
|
||||
if (exp & 1) {
|
||||
res *= base;
|
||||
|
||||
Reference in New Issue
Block a user