Skip to content

Commit de3e5ad

Browse files
authored
Merge branch 'master' into use_dpctl_full
2 parents f3c149d + b2aa36b commit de3e5ad

File tree

6 files changed

+132
-140
lines changed

6 files changed

+132
-140
lines changed

.github/workflows/conda-package.yml

Lines changed: 34 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -24,80 +24,24 @@ env:
2424
VER_SCRIPT2: "d = j['dpnp'][0]; print('='.join((d[s] for s in ('version', 'build'))))"
2525

2626
jobs:
27-
build_linux:
28-
runs-on: ubuntu-latest
29-
30-
defaults:
31-
run:
32-
shell: bash -l {0}
27+
build:
28+
name: Build ['${{ matrix.os }}', python='${{ matrix.python }}']
3329

3430
strategy:
3531
matrix:
3632
python: ['3.8', '3.9']
33+
os: [ubuntu-latest, windows-latest]
34+
include:
35+
- python: '3.10'
36+
os: ubuntu-latest
3737

38-
env:
39-
conda-pkgs: '/home/runner/conda_pkgs_dir/'
40-
41-
steps:
42-
- name: Cancel Previous Runs
43-
uses: styfle/[email protected]
44-
with:
45-
access_token: ${{ github.token }}
46-
47-
- name: Checkout DPNP repo
48-
uses: actions/[email protected]
49-
with:
50-
fetch-depth: 0
51-
52-
- name: Setup miniconda
53-
uses: conda-incubator/[email protected]
54-
with:
55-
auto-update-conda: true
56-
python-version: ${{ matrix.python }}
57-
miniconda-version: 'latest'
58-
activate-environment: 'build'
59-
use-only-tar-bz2: true
60-
61-
- name: Store conda paths as envs
62-
run: echo "CONDA_BLD=$CONDA_PREFIX/conda-bld/linux-64/" >> $GITHUB_ENV
63-
64-
- name: Install conda-build
65-
run: conda install conda-build
66-
67-
- name: Cache conda packages
68-
uses: actions/[email protected]
69-
env:
70-
CACHE_NUMBER: 1 # Increase to reset cache
71-
with:
72-
path: ${{ env.conda-pkgs }}
73-
key:
74-
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('**/meta.yaml') }}
75-
restore-keys: |
76-
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
77-
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
78-
79-
- name: Build conda package
80-
run: conda build --no-test --python ${{ matrix.python }} ${{ env.CHANNELS }} conda-recipe
81-
82-
- name: Upload artifact
83-
uses: actions/[email protected]
84-
with:
85-
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
86-
path: ${{ env.CONDA_BLD }}${{ env.PACKAGE_NAME }}-*.tar.bz2
87-
88-
build_windows:
89-
runs-on: windows-latest
38+
runs-on: ${{ matrix.os }}
9039

9140
defaults:
9241
run:
93-
shell: cmd /C CALL {0}
42+
shell: ${{ matrix.os == 'windows-latest' && 'cmd /C CALL {0}' || 'bash -l {0}' }}
9443

95-
strategy:
96-
matrix:
97-
python: ['3.8', '3.9']
98-
99-
env:
100-
conda-pkgs: 'C:\Users\runneradmin\conda_pkgs_dir\'
44+
continue-on-error: false
10145

10246
steps:
10347
- name: Cancel Previous Runs
@@ -119,26 +63,31 @@ jobs:
11963
activate-environment: 'build'
12064
use-only-tar-bz2: true
12165

122-
- name: Store conda paths as envs
66+
- if: matrix.os == 'ubuntu-latest'
67+
name: Store conda paths as envs on Linux
68+
run: echo "CONDA_BLD=$CONDA_PREFIX/conda-bld/linux-64/" >> $GITHUB_ENV
69+
70+
- if: matrix.os == 'windows-latest'
71+
name: Store conda paths as envs on Win
12372
run: |
12473
@echo on
12574
(echo CONDA_BLD=%CONDA_PREFIX%\conda-bld\win-64\) >> %GITHUB_ENV%
12675
76+
- name: Install conda-build
77+
run: conda install conda-build
78+
12779
- name: Cache conda packages
12880
uses: actions/[email protected]
12981
env:
13082
CACHE_NUMBER: 1 # Increase to reset cache
13183
with:
132-
path: ${{ env.conda-pkgs }}
84+
path: ${{ env.CONDA_PKGS_DIR }}
13385
key:
13486
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('**/meta.yaml') }}
13587
restore-keys: |
13688
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
13789
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
13890
139-
- name: Install conda-build
140-
run: conda install conda-build
141-
14291
- name: Build conda package
14392
run: conda build --no-test --python ${{ matrix.python }} ${{ env.CHANNELS }} conda-recipe
14493

@@ -149,7 +98,9 @@ jobs:
14998
path: ${{ env.CONDA_BLD }}${{ env.PACKAGE_NAME }}-*.tar.bz2
15099

151100
test_linux:
152-
needs: build_linux
101+
name: Test ['ubuntu-latest', python='${{ matrix.python }}']
102+
103+
needs: build
153104

154105
runs-on: ubuntu-latest
155106

@@ -250,7 +201,9 @@ jobs:
250201
working-directory: ${{ env.tests-path }}
251202

252203
test_windows:
253-
needs: build_windows
204+
name: Test ['windows-latest', python='${{ matrix.python }}']
205+
206+
needs: build
254207

255208
runs-on: windows-latest
256209

@@ -422,61 +375,28 @@ jobs:
422375
python -m pytest -q -ra --disable-warnings -vv ${{ env.TEST_SCOPE }}
423376
working-directory: ${{ env.tests-path }}
424377

425-
upload_linux:
426-
needs: test_linux
427-
428-
if: |
429-
(github.repository == 'IntelPython/dpnp') &&
430-
(github.ref == 'refs/heads/master' || (startsWith(github.ref, 'refs/heads/release') == true) || github.event_name == 'push' && contains(github.ref, 'refs/tags/'))
431-
432-
runs-on: ubuntu-latest
378+
upload:
379+
name: Upload ['${{ matrix.os }}', python='${{ matrix.python }}']
433380

434-
defaults:
435-
run:
436-
shell: bash -l {0}
381+
needs: [test_linux, test_windows]
437382

438383
strategy:
439384
matrix:
440385
python: ['3.8', '3.9']
386+
os: [ubuntu-latest, windows-latest]
441387

442-
steps:
443-
- name: Download artifact
444-
uses: actions/[email protected]
445-
with:
446-
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
447-
448-
- name: Setup miniconda
449-
uses: conda-incubator/[email protected]
450-
with:
451-
auto-update-conda: true
452-
python-version: ${{ matrix.python }}
453-
miniconda-version: 'latest'
454-
activate-environment: 'upload'
388+
runs-on: ${{ matrix.os }}
455389

456-
- name: Install anaconda-client
457-
run: conda install anaconda-client
458-
459-
- name: Upload
460-
run: anaconda --token ${{ env.ANACONDA_TOKEN }} upload --user dppy --label dev ${{ env.PACKAGE_NAME }}-*.tar.bz2
461-
env:
462-
ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
390+
defaults:
391+
run:
392+
shell: ${{ matrix.os == 'windows-latest' && 'cmd /C CALL {0}' || 'bash -l {0}' }}
463393

464-
upload_windows:
465-
needs: test_windows
394+
continue-on-error: false
466395

467396
if: |
468397
(github.repository == 'IntelPython/dpnp') &&
469398
(github.ref == 'refs/heads/master' || (startsWith(github.ref, 'refs/heads/release') == true) || github.event_name == 'push' && contains(github.ref, 'refs/tags/'))
470399
471-
runs-on: windows-latest
472-
473-
defaults:
474-
run:
475-
shell: cmd /C CALL {0}
476-
477-
strategy:
478-
matrix:
479-
python: ['3.8', '3.9']
480400
steps:
481401
- name: Download artifact
482402
uses: actions/[email protected]

README.md

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,15 @@
22
[![codecov](https://codecov.io/gh/IntelPython/dpnp/branch/master/graph/badge.svg)](https://codecov.io/gh/IntelPython/dpnp)
33
[![Build Sphinx](https://github.com/IntelPython/dpnp/workflows/Build%20Sphinx/badge.svg)](https://intelpython.github.io/dpnp)
44

5-
# DPNP: NumPy Drop-In Replacement for Intel(R) XPU
5+
# DPNP - Data Parallel Extension for NumPy*
66
[API coverage summary](https://intelpython.github.io/dpnp/reference/comparison.html#summary)
77

88
[Full documentation](https://intelpython.github.io/dpnp/)
99

1010
[DPNP C++ backend documentation](https://intelpython.github.io/dpnp/backend_doc/)
1111

12-
The project contains:
13-
- Python interface with NumPy-like API
14-
- C++ library with SYCL based kernels
15-
16-
## How to run
17-
By default main CPU SYCL queue is used. To use Intel GPU please use:
18-
```bash
19-
DPNP_QUEUE_GPU=1 python examples/example1.py
20-
```
21-
2212
## Build from source:
23-
Ensure you have the following prerequisite packages installed:
13+
Ensure you have the following prerequisite packages installed:
2414

2515
- `mkl-devel-dpcpp`
2616
- `dpcpp_linux-64` or `dpcpp_win-64` (depending on your OS)

dpnp/dpnp_iface_linearalgebra.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"""
4141

4242

43+
from dpnp.dpnp_array import dpnp_array
4344
from dpnp.dpnp_algo import *
4445
from dpnp.dpnp_utils import *
4546
import dpnp
@@ -312,10 +313,15 @@ def outer(x1, x2, **kwargs):
312313
313314
"""
314315

315-
x1_desc = dpnp.get_dpnp_descriptor(x1, copy_when_nondefault_queue=False)
316-
x2_desc = dpnp.get_dpnp_descriptor(x2, copy_when_nondefault_queue=False)
317-
if x1_desc and x2_desc and not kwargs:
318-
return dpnp_outer(x1_desc, x2_desc).get_pyobj()
316+
if not kwargs:
317+
if isinstance(x1, dpnp_array) and isinstance(x2, dpnp_array):
318+
ravel = lambda x: x.flatten() if x.ndim > 1 else x
319+
return ravel(x1)[:, None] * ravel(x2)[None, :]
320+
321+
x1_desc = dpnp.get_dpnp_descriptor(x1, copy_when_nondefault_queue=False)
322+
x2_desc = dpnp.get_dpnp_descriptor(x2, copy_when_nondefault_queue=False)
323+
if x1_desc and x2_desc:
324+
return dpnp_outer(x1_desc, x2_desc).get_pyobj()
319325

320326
return call_origin(numpy.outer, x1, x2, **kwargs)
321327

tests/skipped_tests_gpu.tbl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ tests/third_party/cupy/linalg_tests/test_einsum.py::TestEinSumError::test_too_fe
286286
tests/third_party/cupy/linalg_tests/test_einsum.py::TestEinSumError::test_too_many_dimension3
287287
tests/third_party/cupy/linalg_tests/test_einsum.py::TestListArgEinSumError::test_dim_mismatch3
288288
tests/third_party/cupy/linalg_tests/test_einsum.py::TestListArgEinSumError::test_too_many_dims3
289-
tests/third_party/cupy/linalg_tests/test_product.py::TestProduct::test_outer
289+
290290
tests/third_party/cupy/linalg_tests/test_product.py::TestProduct::test_reversed_outer
291291
tests/third_party/cupy/linalg_tests/test_product.py::TestProduct::test_reversed_vdot
292292
tests/third_party/cupy/manipulation_tests/test_basic.py::TestCopytoFromScalar_param_7_{dst_shape=(0,), src=3.2}::test_copyto_where
@@ -347,8 +347,6 @@ tests/third_party/cupy/sorting_tests/test_sort.py::TestPartition_param_2_{extern
347347
tests/third_party/cupy/statistics_tests/test_correlation.py::TestCov::test_cov_empty
348348
tests/third_party/cupy/statistics_tests/test_meanvar.py::TestMeanVar::test_external_mean_axis
349349

350-
tests/third_party/cupy/linalg_tests/test_product.py::TestProduct::test_multidim_outer
351-
352350
tests/third_party/cupy/sorting_tests/test_sort.py::TestPartition_param_3_{external=True, length=20000}::test_partition_axis
353351
tests/third_party/cupy/sorting_tests/test_sort.py::TestPartition_param_3_{external=True, length=20000}::test_partition_negative_axis
354352
tests/third_party/cupy/sorting_tests/test_sort.py::TestPartition_param_3_{external=True, length=20000}::test_partition_none_axis

tests/test_outer.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import unittest
2+
from tests.third_party.cupy import testing
3+
4+
import dpnp as dp
5+
import numpy as np
6+
7+
from numpy.testing import assert_raises
8+
9+
10+
class TestOuter(unittest.TestCase):
11+
12+
@testing.for_all_dtypes()
13+
@testing.numpy_cupy_allclose()
14+
def test_two_vectors(self, xp, dtype):
15+
a = xp.ones((10, ), dtype=dtype)
16+
b = xp.linspace(-2, 2, 5, dtype=dtype)
17+
18+
return xp.outer(a, b)
19+
20+
@testing.for_all_dtypes()
21+
@testing.numpy_cupy_allclose()
22+
def test_two_matrix(self, xp, dtype):
23+
a = xp.ones((10, 10, 10), dtype=dtype)
24+
b = xp.full(shape=(3, 7), fill_value=42, dtype=dtype)
25+
26+
return xp.outer(a, b)
27+
28+
@testing.for_all_dtypes()
29+
@testing.numpy_cupy_allclose()
30+
def test_the_same_vector(self, xp, dtype):
31+
a = xp.full(shape=(100, ), fill_value=7, dtype=dtype)
32+
return xp.outer(a, a)
33+
34+
@testing.for_all_dtypes()
35+
@testing.numpy_cupy_allclose()
36+
def test_the_same_matrix(self, xp, dtype):
37+
a = xp.arange(27, dtype=dtype).reshape(3, 3, 3)
38+
return xp.outer(a, a)
39+
40+
41+
class TestScalarOuter(unittest.TestCase):
42+
43+
@unittest.skip("A scalar isn't currently supported as input")
44+
@testing.for_all_dtypes()
45+
@testing.numpy_cupy_allclose()
46+
def test_first_is_scalar(self, xp, dtype):
47+
scalar = xp.int64(4)
48+
a = xp.arange(5**3, dtype=dtype).reshape(5, 5, 5)
49+
return xp.outer(scalar, a)
50+
51+
@unittest.skip("A scalar isn't currently supported as input")
52+
@testing.for_all_dtypes()
53+
@testing.numpy_cupy_allclose()
54+
def test_second_is_scalar(self, xp, dtype):
55+
scalar = xp.int32(7)
56+
a = xp.arange(5**3, dtype=dtype).reshape(5, 5, 5)
57+
return xp.outer(a, scalar)
58+
59+
@unittest.skip("A scalar isn't currently supported as input")
60+
@testing.numpy_cupy_array_equal()
61+
def test_both_inputs_as_scalar(self, xp):
62+
a = xp.int64(4)
63+
b = xp.int32(17)
64+
return xp.outer(a, b)
65+
66+
67+
class TestListOuter(unittest.TestCase):
68+
69+
def test_list(self):
70+
a = np.arange(27).reshape(3, 3, 3)
71+
b: list[list[list[int]]] = a.tolist()
72+
dp_a = dp.array(a)
73+
74+
with assert_raises(NotImplementedError):
75+
dp.outer(b, dp_a)
76+
dp.outer(dp_a, b)
77+
dp.outer(b, b)

0 commit comments

Comments
 (0)