|
1 | 1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
2 | 2 | # SPDX-License-Identifier: BSD-2-Clause |
3 | 3 |
|
| 4 | +import sys |
4 | 5 | import numpy as np |
5 | 6 | from numba.cuda.testing import ( |
6 | 7 | skip_unless_cc_53, |
@@ -84,6 +85,11 @@ def math_exp(A, B): |
84 | 85 | B[i] = math.exp(A[i]) |
85 | 86 |
|
86 | 87 |
|
| 88 | +def math_exp2(A, B): |
| 89 | + i = cuda.grid(1) |
| 90 | + B[i] = math.exp2(A[i]) |
| 91 | + |
| 92 | + |
87 | 93 | def math_erf(A, B): |
88 | 94 | i = cuda.grid(1) |
89 | 95 | B[i] = math.erf(A[i]) |
@@ -401,6 +407,8 @@ def test_math_fp16(self): |
401 | 407 | self.unary_template_float16(math_sqrt, np.sqrt) |
402 | 408 | self.unary_template_float16(math_ceil, np.ceil) |
403 | 409 | self.unary_template_float16(math_floor, np.floor) |
| 410 | + if sys.version_info >= (3, 11): |
| 411 | + self.unary_template_float16(math_exp2, np.exp2) |
404 | 412 |
|
405 | 413 | @skip_on_cudasim("numpy does not support trunc for float16") |
406 | 414 | @skip_unless_cc_53 |
@@ -496,6 +504,16 @@ def test_math_exp(self): |
496 | 504 | self.unary_template_int64(math_exp, np.exp) |
497 | 505 | self.unary_template_uint64(math_exp, np.exp) |
498 | 506 |
|
| 507 | + # --------------------------------------------------------------------------- |
| 508 | + # test_math_exp2 |
| 509 | + |
| 510 | + @unittest.skipUnless(sys.version_info >= (3, 11), "Python 3.11+ required") |
| 511 | + def test_math_exp2(self): |
| 512 | + self.unary_template_float32(math_exp2, np.exp2) |
| 513 | + self.unary_template_float64(math_exp2, np.exp2) |
| 514 | + self.unary_template_int64(math_exp2, np.exp2) |
| 515 | + self.unary_template_uint64(math_exp2, np.exp2) |
| 516 | + |
499 | 517 | # --------------------------------------------------------------------------- |
500 | 518 | # test_math_expm1 |
501 | 519 |
|
|
0 commit comments