Skip to content

Commit df15308

Browse files
authored
Merge branch 'master' into resize_rot90
2 parents caa9971 + d4ee71e commit df15308

File tree

5 files changed

+145
-6
lines changed

5 files changed

+145
-6
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [0.17.0] - MM/DD/2025
8+
9+
### Added
10+
11+
### Change
12+
13+
### Fixed
14+
15+
716
## [0.16.0] - 09/DD/2024
817

918
This release reaches an important milestone by making offloading fully asynchronous. Calls to `dpnp` submit tasks for execution to DPC++ runtime and return without waiting for execution of these tasks to finish. The sequential semantics a user comes to expect from execution of Python script is preserved though.

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.21...3.27 FATAL_ERROR)
22

33
project(dpnp
4-
VERSION 0.16
4+
VERSION 0.17
55
LANGUAGES CXX
66
DESCRIPTION "NumPy-like API accelerated by SYCL."
77
)

dpnp/dpnp_iface_mathematical.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,7 @@ def _gradient_num_diff_2nd_order_interior(
224224
# fix the shape for broadcasting
225225
shape = [1] * ndim
226226
shape[axis] = -1
227-
# TODO: use shape.setter once dpctl#1699 is resolved
228-
# a.shape = b.shape = c.shape = shape
227+
229228
a = a.reshape(shape)
230229
b = b.reshape(shape)
231230
c = c.reshape(shape)
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
import sys
2+
import unittest
3+
4+
import numpy
5+
import pytest
6+
7+
import dpnp as cupy
8+
from tests.third_party.cupy import testing
9+
10+
11+
class TestSize(unittest.TestCase):
12+
# def tearDown(self):
13+
# # Free huge memory for slow test
14+
# cupy.get_default_memory_pool().free_all_blocks()
15+
16+
@testing.for_all_dtypes()
17+
@testing.numpy_cupy_equal()
18+
def test_size(self, xp, dtype):
19+
a = xp.ndarray((2, 3), dtype=dtype)
20+
return xp.size(a)
21+
22+
@testing.for_all_dtypes()
23+
@testing.numpy_cupy_equal()
24+
def test_size_axis(self, xp, dtype):
25+
a = xp.ndarray((2, 3), dtype=dtype)
26+
return xp.size(a, axis=1)
27+
28+
@testing.for_all_dtypes()
29+
def test_size_axis_error(self, dtype):
30+
for xp in (numpy, cupy):
31+
a = xp.ndarray((2, 3), dtype=dtype)
32+
with pytest.raises(IndexError):
33+
return xp.size(a, axis=3)
34+
35+
@testing.numpy_cupy_equal()
36+
@testing.slow
37+
def test_size_huge(self, xp):
38+
a = xp.ndarray(2**32, "b") # 4 GiB
39+
return xp.size(a)
40+
41+
42+
_orders = {
43+
order_arg: order_expect
44+
for order_expect, order_args in [
45+
("C", ["C", "c", "CONTIGUOUS", "", None]),
46+
("F", ["F", "f", "FORTRAN"]),
47+
]
48+
for order_arg in order_args
49+
}
50+
51+
52+
@pytest.mark.skip("no cupy._core submodule")
53+
class TestOrder(unittest.TestCase):
54+
@testing.for_orders(_orders.keys())
55+
def test_ndarray(self, order):
56+
order_expect = _orders[order]
57+
a = core.ndarray((2, 3), order=order)
58+
expect_c = order_expect == "C"
59+
expect_f = order_expect == "F"
60+
assert a.flags.c_contiguous == expect_c
61+
assert a.flags.f_contiguous == expect_f
62+
63+
64+
@pytest.mark.skip("min_scalar_type() is not supported")
65+
class TestMinScalarType:
66+
def test_scalar(self):
67+
for v in (-129, -128, 0, 1.2, numpy.inf):
68+
assert cupy.min_scalar_type(v) is numpy.min_scalar_type(v)
69+
70+
@testing.for_all_dtypes()
71+
def test_numpy_scalar(self, dtype):
72+
sc = dtype(1)
73+
for v in (sc, [sc, sc]):
74+
assert cupy.min_scalar_type(v) is numpy.min_scalar_type(v)
75+
76+
@testing.for_all_dtypes()
77+
def test_cupy_scalar(self, dtype):
78+
sc = cupy.array(-1).astype(dtype)
79+
for v in (sc, [sc, sc]):
80+
assert cupy.min_scalar_type(v) is sc.dtype
81+
82+
@testing.for_all_dtypes()
83+
def test_numpy_ndarray(self, dtype):
84+
arr = numpy.array([[-1, 1]]).astype(dtype)
85+
for v in (arr, (arr, arr)):
86+
assert cupy.min_scalar_type(v) is numpy.min_scalar_type(v)
87+
88+
@testing.for_all_dtypes()
89+
def test_cupy_ndarray(self, dtype):
90+
arr = cupy.array([[-1, 1]]).astype(dtype)
91+
for v in (arr, (arr, arr)):
92+
assert cupy.min_scalar_type(v) is arr.dtype
93+
94+
95+
@testing.parameterize(
96+
*testing.product(
97+
{
98+
"cxx": (None, "--std=c++11"),
99+
}
100+
)
101+
)
102+
@pytest.mark.skip("compiling cupy headers are not supported")
103+
class TestCuPyHeaders(unittest.TestCase):
104+
def setUp(self):
105+
self.temporary_cache_dir_context = test_raw.use_temporary_cache_dir()
106+
self.cache_dir = self.temporary_cache_dir_context.__enter__()
107+
self.header = "\n".join(
108+
["#include <" + h + ">" for h in core._cupy_header_list]
109+
)
110+
111+
def tearDown(self):
112+
self.temporary_cache_dir_context.__exit__(*sys.exc_info())
113+
114+
def test_compiling_core_header(self):
115+
code = r"""
116+
extern "C" __global__ void _test_ker_() { }
117+
"""
118+
code = self.header + code
119+
options = () if self.cxx is None else (self.cxx,)
120+
ker = cupy.RawKernel(
121+
code, "_test_ker_", options=options, backend="nvrtc"
122+
)
123+
ker((1,), (1,), ())
124+
cupy.cuda.Device().synchronize()

tests/third_party/cupy/core_tests/test_ndarray.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,18 @@ def test_unsupported_type(self):
154154
with pytest.raises(TypeError):
155155
cupy.array(arr)
156156

157+
@pytest.mark.skip("no ndim limit")
158+
@testing.with_requires("numpy>=2.0")
159+
@testing.numpy_cupy_array_equal()
160+
def test_upper_limit_ndim(self, xp):
161+
shape = [1 for i in range(64)]
162+
return xp.zeros(shape, dtype=xp.int8)
163+
157164
@pytest.mark.skip("no ndim limit")
158165
def test_excessive_ndim(self):
159166
for xp in (numpy, cupy):
160167
with pytest.raises(ValueError):
161-
xp.ndarray(shape=[1 for i in range(33)], dtype=xp.int8)
168+
xp.ndarray(shape=[1 for i in range(65)], dtype=xp.int8)
162169

163170

164171
@testing.parameterize(
@@ -265,7 +272,8 @@ def test_shape_set(self, xp):
265272
return xp.array(arr.shape)
266273

267274
@pytest.mark.skip(
268-
"dpctl-1699: shape setter does not work with negative shape"
275+
"dpctl-1699: shape setter does not work with negative shape "
276+
"(no plan to support that)"
269277
)
270278
@testing.numpy_cupy_array_equal()
271279
def test_shape_set_infer(self, xp):
@@ -588,7 +596,6 @@ def test_output_type_mismatch(self):
588596
wrap_take(a, i)
589597

590598

591-
@pytest.mark.skip("size() is not supported")
592599
class TestSize(unittest.TestCase):
593600
@testing.numpy_cupy_equal()
594601
def test_size_without_axis(self, xp):

0 commit comments

Comments
 (0)