Skip to content

Commit 97707a5

Browse files
author
Diptorup Deb
committed
Unit test to compile IntEnumLiteral type object
1 parent d019681 commit 97707a5

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# SPDX-FileCopyrightText: 2023 Intel Corporation
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
import dpnp
6+
from numba.core import types
7+
from numba.extending import intrinsic, overload
8+
9+
import numba_dpex.experimental as exp_dpex
10+
from numba_dpex import Range, dpjit
11+
from numba_dpex.experimental.flag_enum import FlagEnum
12+
13+
14+
class MockFlags(FlagEnum):
15+
FLAG1 = 100
16+
FLAG2 = 200
17+
18+
19+
@exp_dpex.kernel(
20+
release_gil=False,
21+
no_compile=True,
22+
no_cpython_wrapper=True,
23+
no_cfunc_wrapper=True,
24+
)
25+
def update_with_flag(a):
26+
a[0] = MockFlags.FLAG1
27+
a[1] = MockFlags.FLAG2
28+
29+
30+
def test_compilation_of_flag_enum():
31+
"""Tests if a FlagEnum subclass can be used inside a kernel function."""
32+
a = dpnp.ones(10, dtype=dpnp.int64)
33+
exp_dpex.call_kernel(update_with_flag, Range(10), a)
34+
35+
assert a[0] == MockFlags.FLAG1
36+
assert a[1] == MockFlags.FLAG2
37+
for idx in range(2, 9):
38+
assert a[idx] == 1

0 commit comments

Comments
 (0)