|
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, |
@@ -83,6 +84,11 @@ def math_exp(A, B): |
83 | 84 | B[i] = math.exp(A[i]) |
84 | 85 |
|
85 | 86 |
|
| 87 | +def math_exp2(A, B): |
| 88 | + i = cuda.grid(1) |
| 89 | + B[i] = math.exp2(A[i]) |
| 90 | + |
| 91 | + |
86 | 92 | def math_erf(A, B): |
87 | 93 | i = cuda.grid(1) |
88 | 94 | B[i] = math.erf(A[i]) |
@@ -400,6 +406,8 @@ def test_math_fp16(self): |
400 | 406 | self.unary_template_float16(math_sqrt, np.sqrt) |
401 | 407 | self.unary_template_float16(math_ceil, np.ceil) |
402 | 408 | self.unary_template_float16(math_floor, np.floor) |
| 409 | + if sys.version_info >= (3, 11): |
| 410 | + self.unary_template_float16(math_exp2, np.exp2) |
403 | 411 |
|
404 | 412 | @skip_on_cudasim("numpy does not support trunc for float16") |
405 | 413 | @skip_unless_cc_53 |
@@ -494,6 +502,15 @@ def test_math_exp(self): |
494 | 502 | self.unary_template_float64(math_exp, np.exp) |
495 | 503 | self.unary_template_int64(math_exp, np.exp) |
496 | 504 | self.unary_template_uint64(math_exp, np.exp) |
| 505 | + # --------------------------------------------------------------------------- |
| 506 | + # test_math_exp2 |
| 507 | + |
| 508 | + @unittest.skipUnless(sys.version_info >= (3, 11), "Python 3.11+ required") |
| 509 | + def test_math_exp2(self): |
| 510 | + self.unary_template_float32(math_exp2, np.exp2) |
| 511 | + self.unary_template_float64(math_exp2, np.exp2) |
| 512 | + self.unary_template_int64(math_exp2, np.exp2) |
| 513 | + self.unary_template_uint64(math_exp2, np.exp2) |
497 | 514 |
|
498 | 515 | # --------------------------------------------------------------------------- |
499 | 516 | # test_math_expm1 |
|
0 commit comments