Skip to content

Commit 4f31055

Browse files
authored
[CINN] Align pow int for base=0 and exponent<0 (#74450)
1 parent e6b4496 commit 4f31055

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

paddle/cinn/runtime/cuda/cinn_cuda_runtime_source.cuh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ extern "C" {
338338

339339
__device__ inline int FN_INT32(pow)(int a, int b) {
340340
if (a == 0 && b < 0) {
341-
return -1;
341+
return 0;
342342
}
343343
float res = pow(__int2float_rd(a), __int2float_rd(b));
344344
return __float2int_rn(res);
@@ -418,6 +418,9 @@ __device__ inline long long int FN_INT64(exp)(long long int a) {
418418

419419
__device__ inline long long int FN_INT64(pow)(long long int a,
420420
long long int b) {
421+
if (a == 0 && b < 0) {
422+
return 0;
423+
}
421424
double res = pow(__ll2double_rd(a), __ll2double_rd(b));
422425
return __double2ll_rn(res);
423426
}

0 commit comments

Comments
 (0)