|
| 1 | +# Data Parallel Control (dpctl) |
| 2 | +# |
| 3 | +# Copyright 2020-2022 Intel Corporation |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | + |
| 17 | + |
| 18 | +# import numpy as np |
| 19 | +# import pytest |
| 20 | +from helper import get_queue_or_skip |
| 21 | + |
| 22 | +# import dpctl |
| 23 | +import dpctl.tensor as dpt |
| 24 | + |
| 25 | +# from helper import skip_if_dtype_not_supported |
| 26 | + |
| 27 | + |
| 28 | +def test_basic_slice1(): |
| 29 | + q = get_queue_or_skip() |
| 30 | + x = dpt.empty(10, dtype="u2", sycl_queue=q) |
| 31 | + y = x[0] |
| 32 | + assert isinstance(y, dpt.usm_ndarray) |
| 33 | + assert y.ndim == 0 |
| 34 | + assert y.shape == tuple() |
| 35 | + assert y.strides == tuple() |
| 36 | + |
| 37 | + |
| 38 | +def test_basic_slice2(): |
| 39 | + q = get_queue_or_skip() |
| 40 | + x = dpt.empty(10, dtype="i2", sycl_queue=q) |
| 41 | + y = x[(0,)] |
| 42 | + assert isinstance(y, dpt.usm_ndarray) |
| 43 | + assert y.ndim == 0 |
| 44 | + assert y.shape == tuple() |
| 45 | + assert y.strides == tuple() |
| 46 | + |
| 47 | + |
| 48 | +def test_basic_slice3(): |
| 49 | + q = get_queue_or_skip() |
| 50 | + x = dpt.empty(10, dtype="i2", sycl_queue=q) |
| 51 | + y = x[:] |
| 52 | + assert isinstance(y, dpt.usm_ndarray) |
| 53 | + assert y.ndim == x.ndim |
| 54 | + assert y.shape == x.shape |
| 55 | + assert y.strides == x.strides |
| 56 | + y = x[(slice(None, None, None),)] |
| 57 | + assert isinstance(y, dpt.usm_ndarray) |
| 58 | + assert y.ndim == x.ndim |
| 59 | + assert y.shape == x.shape |
| 60 | + assert y.strides == x.strides |
0 commit comments