forked from kokkos/pykokkos-base
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add support for 8-bit signed integers with values that should exist on the interval `[-128, 127]` for conformance with the array API: https://data-apis.org/array-api/latest/API_specification/data_types.html kokkos/pykokkos#57 * add a regression test for kokkos<->NumPy type equivalencies that includes the new `int8` type; I was hoping to do some simple arithmetic testing as well, but not sure how practical that is within `pykokkos-base` proper (maybe defer that kind of thing to `pykokkos`?)
- Loading branch information
1 parent
87290b3
commit a38531a
Showing
6 changed files
with
41 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import kokkos | ||
|
||
import numpy as np | ||
import pytest | ||
|
||
|
||
@pytest.mark.parametrize("type_val, expected_np_type", [ | ||
(kokkos.int8, np.int8), | ||
(kokkos.int16, np.int16), | ||
(kokkos.int32, np.int32), | ||
(kokkos.int64, np.int64), | ||
(kokkos.uint16, np.uint16), | ||
(kokkos.uint32, np.uint32), | ||
(kokkos.uint64, np.uint64), | ||
(kokkos.float32, np.float32), | ||
(kokkos.float64, np.float64), | ||
(kokkos.float, np.float32), | ||
(kokkos.double, np.float64), | ||
(kokkos.short, np.int16), | ||
(kokkos.int, np.int32), | ||
(kokkos.long, np.int64), | ||
]) | ||
def test_basic_type_equiv(type_val, expected_np_type): | ||
# test some view to NumPy array type equivalencies | ||
kokkos.initialize() | ||
view = kokkos.array([2], | ||
dtype=type_val, | ||
space=kokkos.DefaultHostMemorySpace) | ||
|
||
# NOTE: copy can still happen (attempt no copy, | ||
# not guarantee) | ||
arr = np.array(view, copy=False) | ||
assert arr.dtype == expected_np_type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters