Skip to content

Commit ca8685c

Browse files
authored
Merge branch 'master' into exception_on_numpy_fallback
2 parents bdeaf12 + 8516d9a commit ca8685c

12 files changed

+51
-37
lines changed

.github/workflows/conda-package.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ jobs:
456456
needs: test_windows
457457

458458
if: |
459-
!github.event.pull_request.head.repo.fork &&
459+
!github.event.pull_request.head.repo.fork && !github.event.push.repository.fork &&
460460
(github.ref == 'refs/heads/master' || (startsWith(github.ref, 'refs/heads/release') == true) || github.event_name == 'push' && contains(github.ref, 'refs/tags/'))
461461
462462
runs-on: windows-latest

doc/conf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
author = 'Intel'
3232

3333
# The short X.Y version
34-
version = '0.10'
34+
version = '0.11'
3535
# The full version, including alpha/beta/rc tags
36-
release = '0.10.3'
36+
release = '0.11.0'
3737

3838

3939
# -- General configuration ---------------------------------------------------

dpnp/backend/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727

2828
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
2929

30-
# set(DPNP_VERSION 0.10.3)
31-
# set(DPNP_API_VERSION 0.10)
30+
# set(DPNP_VERSION 0.11.0)
31+
# set(DPNP_API_VERSION 0.11)
3232

3333
# set directory where the custom finders live
3434
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules")

dpnp/backend/doc/Doxyfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PROJECT_NAME = "DPNP C++ backend kernel library"
3838
# could be handy for archiving the generated documentation or if some version
3939
# control system is used.
4040

41-
PROJECT_NUMBER = 0.10.3
41+
PROJECT_NUMBER = 0.11.0
4242

4343
# Using the PROJECT_BRIEF tag one can provide an optional one line description
4444
# for a project that appears at the top of each page and should give viewer a

dpnp/backend/src/dpnp_utils.hpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//*****************************************************************************
2-
// Copyright (c) 2016-2020, Intel Corporation
2+
// Copyright (c) 2016-2022, Intel Corporation
33
// All rights reserved.
44
//
55
// Redistribution and use in source and binary forms, with or without
@@ -40,6 +40,15 @@
4040
(__LIBSYCL_MAJOR_VERSION > major) || (__LIBSYCL_MAJOR_VERSION == major and __LIBSYCL_MINOR_VERSION > minor) || \
4141
(__LIBSYCL_MAJOR_VERSION == major and __LIBSYCL_MINOR_VERSION == minor and __LIBSYCL_PATCH_VERSION >= patch)
4242

43+
/**
44+
* Version of SYCL DPC++ 2023 compiler at which transition to SYCL 2020 occurs.
45+
* Intel(R) oneAPI DPC++ 2022.2.1 compiler has version 20221020L on Linux and
46+
* 20221101L on Windows.
47+
*/
48+
#ifndef __SYCL_COMPILER_2023_SWITCHOVER
49+
#define __SYCL_COMPILER_2023_SWITCHOVER 20221102L
50+
#endif
51+
4352
/**
4453
* @defgroup BACKEND_UTILS Backend C++ library utilities
4554
* @{

dpnp/backend/src/dpnpc_memory_adapter.hpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//*****************************************************************************
2-
// Copyright (c) 2016-2020, Intel Corporation
2+
// Copyright (c) 2016-2022, Intel Corporation
33
// All rights reserved.
44
//
55
// Redistribution and use in source and binary forms, with or without
@@ -28,6 +28,7 @@
2828
#define DPNP_MEMORY_ADAPTER_H
2929

3030
#include "queue_sycl.hpp"
31+
#include "dpnp_utils.hpp"
3132

3233
/**
3334
* @ingroup BACKEND_UTILS
@@ -84,8 +85,10 @@ class DPNPC_ptr_adapter final
8485
std::cerr << "\n\t size_in_bytes=" << size_in_bytes;
8586
std::cerr << "\n\t pointer type=" << (long)src_ptr_type;
8687
std::cerr << "\n\t queue inorder=" << queue.is_in_order();
88+
#if (__SYCL_COMPILER_VERSION < __SYCL_COMPILER_2023_SWITCHOVER)
8789
std::cerr << "\n\t queue is_host=" << queue.is_host();
8890
std::cerr << "\n\t queue device is_host=" << queue.get_device().is_host();
91+
#endif
8992
std::cerr << "\n\t queue device is_cpu=" << queue.get_device().is_cpu();
9093
std::cerr << "\n\t queue device is_gpu=" << queue.get_device().is_gpu();
9194
std::cerr << "\n\t queue device is_accelerator=" << queue.get_device().is_accelerator();

dpnp/backend/src/queue_sycl.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
#include <dpnp_iface.hpp>
3131
#include "queue_sycl.hpp"
32+
#include "dpnp_utils.hpp"
3233

3334
#if defined(DPNP_LOCAL_QUEUE)
3435
sycl::queue* backend_sycl::queue = nullptr;
@@ -211,10 +212,14 @@ bool backend_sycl::backend_sycl_is_cpu()
211212
{
212213
sycl::queue& qptr = get_queue();
213214

214-
if (qptr.is_host() || qptr.get_device().is_cpu() || qptr.get_device().is_host())
215-
{
215+
if (qptr.get_device().is_cpu()) {
216+
return true;
217+
}
218+
#if (__SYCL_COMPILER_VERSION < __SYCL_COMPILER_2023_SWITCHOVER)
219+
else if (qptr.is_host() || qptr.get_device().is_host()) {
216220
return true;
217221
}
222+
#endif
218223

219224
return false;
220225
}

dpnp/dpnp_array.py

+4
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ def sycl_context(self):
115115
def device(self):
116116
return self._array_obj.device
117117

118+
@property
119+
def usm_type(self):
120+
return self._array_obj.usm_type
121+
118122
def __abs__(self):
119123
return dpnp.abs(self)
120124

dpnp/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@
2929
DPNP version module
3030
"""
3131

32-
__version__: str = '0.10.3'
32+
__version__: str = '0.11.0'
3333

3434
version: str = __version__

tests/test_arraycreation.py

+1-12
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
[0, -5, 10, -2.5, 9.7],
1313
ids=['0', '-5', '10', '-2.5', '9.7'])
1414
@pytest.mark.parametrize("stop",
15-
[None, 10, -2, 20.5, 10**5],
15+
[None, 10, -2, 20.5, 1000],
1616
ids=['None', '10', '-2', '20.5', '10**5'])
1717
@pytest.mark.parametrize("step",
1818
[None, 1, 2.7, -1.6, 100],
@@ -26,17 +26,6 @@ def test_arange(start, stop, step, dtype):
2626
# numpy casts to float32 type when computes float16 data
2727
rtol_mult = 4
2828

29-
# secure there is no 'inf' elements in resulting array
30-
max = numpy.finfo(dtype).max
31-
if stop is not None and stop > max:
32-
# consider comulative accuracy while generating array
33-
# to calculate maximum allowed 'stop' value for dtype=float16
34-
arr_len = (max - start) / (step if step is not None else 1)
35-
arr_ilen = int(arr_len)
36-
arr_len = (arr_ilen + 1) if float(arr_ilen) < arr_len else arr_ilen
37-
acc = rtol_mult * numpy.finfo(dtype).eps
38-
stop = max - acc * arr_len
39-
4029
exp_array = numpy.arange(start, stop=stop, step=step, dtype=dtype)
4130

4231
dpnp_array = dpnp.arange(start, stop=stop, step=step, dtype=dtype)

tests/test_random_state.py

+16-10
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
)
1616

1717

18+
def assert_cfd(data, exp_sycl_queue, exp_usm_type=None):
19+
assert exp_sycl_queue == data.sycl_queue
20+
if exp_usm_type:
21+
assert exp_usm_type == data.usm_type
22+
23+
1824
class TestNormal:
1925
@pytest.mark.parametrize("dtype",
2026
[dpnp.float32, dpnp.float64, None],
@@ -47,7 +53,7 @@ def test_distr(self, dtype, usm_type):
4753
assert_array_almost_equal(dpnp.asnumpy(data), desired, decimal=precision)
4854

4955
# check if compute follows data isn't broken
50-
assert sycl_queue == data.sycl_queue
56+
assert_cfd(data, sycl_queue, usm_type)
5157

5258

5359
@pytest.mark.parametrize("dtype",
@@ -138,7 +144,7 @@ def test_fallback(self, loc, scale):
138144
assert_array_almost_equal(actual, desired, decimal=precision)
139145

140146
# check if compute follows data isn't broken
141-
assert sycl_queue == data.sycl_queue
147+
assert_cfd(data, sycl_queue)
142148

143149

144150
@pytest.mark.parametrize("dtype",
@@ -174,17 +180,17 @@ def test_distr(self, usm_type):
174180

175181
precision = numpy.finfo(dtype=numpy.float64).precision
176182
assert_array_almost_equal(dpnp.asnumpy(data), desired, decimal=precision)
177-
assert sycl_queue == data.sycl_queue
183+
assert_cfd(data, sycl_queue, usm_type)
178184

179185
# call with the same seed has to draw the same values
180186
data = RandomState(seed, sycl_queue=sycl_queue).rand(3, 2, usm_type=usm_type)
181187
assert_array_almost_equal(dpnp.asnumpy(data), desired, decimal=precision)
182-
assert sycl_queue == data.sycl_queue
188+
assert_cfd(data, sycl_queue, usm_type)
183189

184190
# call with omitted dimensions has to draw the first element from desired
185191
data = RandomState(seed, sycl_queue=sycl_queue).rand(usm_type=usm_type)
186192
assert_array_almost_equal(dpnp.asnumpy(data), desired[0, 0], decimal=precision)
187-
assert sycl_queue == data.sycl_queue
193+
assert_cfd(data, sycl_queue, usm_type)
188194

189195
# rand() is an alias on random_sample(), map arguments
190196
with mock.patch('dpnp.random.RandomState.random_sample') as m:
@@ -245,7 +251,7 @@ def test_distr(self, dtype, usm_type):
245251
[5, 3],
246252
[5, 7]], dtype=numpy.int32)
247253
assert_array_equal(dpnp.asnumpy(data), desired)
248-
assert sycl_queue == data.sycl_queue
254+
assert_cfd(data, sycl_queue, usm_type)
249255

250256
# call with the same seed has to draw the same values
251257
data = RandomState(seed, sycl_queue=sycl_queue).randint(low=low,
@@ -254,15 +260,15 @@ def test_distr(self, dtype, usm_type):
254260
dtype=dtype,
255261
usm_type=usm_type)
256262
assert_array_equal(dpnp.asnumpy(data), desired)
257-
assert sycl_queue == data.sycl_queue
263+
assert_cfd(data, sycl_queue, usm_type)
258264

259265
# call with omitted dimensions has to draw the first element from desired
260266
data = RandomState(seed, sycl_queue=sycl_queue).randint(low=low,
261267
high=high,
262268
dtype=dtype,
263269
usm_type=usm_type)
264270
assert_array_equal(dpnp.asnumpy(data), desired[0, 0])
265-
assert sycl_queue == data.sycl_queue
271+
assert_cfd(data, sycl_queue, usm_type)
266272

267273
# rand() is an alias on random_sample(), map arguments
268274
with mock.patch('dpnp.random.RandomState.uniform') as m:
@@ -701,7 +707,7 @@ def test_distr(self, bounds, dtype, usm_type):
701707
assert_array_equal(dpnp.asnumpy(data), desired)
702708

703709
# check if compute follows data isn't broken
704-
assert sycl_queue == data.sycl_queue
710+
assert_cfd(data, sycl_queue, usm_type)
705711

706712

707713
@pytest.mark.parametrize("dtype",
@@ -766,7 +772,7 @@ def test_fallback(self, low, high):
766772
assert_array_almost_equal(actual, desired, decimal=precision)
767773

768774
# check if compute follows data isn't broken
769-
assert sycl_queue == data.sycl_queue
775+
assert_cfd(data, sycl_queue)
770776

771777

772778
@pytest.mark.parametrize("dtype",

tests/test_sycl_queue.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,7 @@ def test_uniform(usm_type, size):
278278
high = 2.0
279279
res = dpnp.random.uniform(low, high, size=size, usm_type=usm_type)
280280

281-
res_usm_type = res.get_array().usm_type
282-
assert usm_type == res_usm_type
281+
assert usm_type == res.usm_type
283282

284283

285284
@pytest.mark.parametrize("usm_type",
@@ -295,8 +294,7 @@ def test_rs_uniform(usm_type, seed):
295294
rs = dpnp.random.RandomState(seed, sycl_queue=sycl_queue)
296295
res = rs.uniform(low, high, usm_type=usm_type)
297296

298-
res_usm_type = res.get_array().usm_type
299-
assert usm_type == res_usm_type
297+
assert usm_type == res.usm_type
300298

301299
res_sycl_queue = res.get_array().sycl_queue
302300
assert_sycl_queue_equal(res_sycl_queue, sycl_queue)

0 commit comments

Comments
 (0)