• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

IntelPython / dpnp / 12246242208

09 Dec 2024 11:30PM UTC coverage: 65.087% (-1.3%) from 66.389%
12246242208

push

github

web-flow
Align with numpy 2.2 (#2226)

The PR proposes to align with changes implemented in `numpy 2.2`:
- Update `dpnp.cov` to properly transpose 2d array with `rowvar=False`.
- Handle boolean arrays in `dpnp.insert` as a mask.
- Mute or workaround tests with fail due to numpy issues in
`numpy.insert` and `numpy.cov`.
- Mute tests with are not passing due to new numpy behavior (new
`matvec` and `vecmat` ufuncs, support of 2d array in `trim_zeros`).

`matvec` and `vecmat` ufuncs and `trim_zeros` functions will be
separately.

4560 of 11468 branches covered (39.76%)

Branch coverage included in aggregate %.

4 of 4 new or added lines in 2 files covered. (100.0%)

235 existing lines in 10 files now uncovered.

16946 of 21574 relevant lines covered (78.55%)

19822.36 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

70.48
/dpnp/backend/extensions/statistics/common.cpp
1
//*****************************************************************************
2
// Copyright (c) 2024, Intel Corporation
3
// All rights reserved.
4
//
5
// Redistribution and use in source and binary forms, with or without
6
// modification, are permitted provided that the following conditions are met:
7
// - Redistributions of source code must retain the above copyright notice,
8
//   this list of conditions and the following disclaimer.
9
// - Redistributions in binary form must reproduce the above copyright notice,
10
//   this list of conditions and the following disclaimer in the documentation
11
//   and/or other materials provided with the distribution.
12
//
13
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
17
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
// THE POSSIBILITY OF SUCH DAMAGE.
24
//*****************************************************************************
25

26
#include "common.hpp"
27
#include "utils/type_dispatch.hpp"
28
#include <pybind11/pybind11.h>
29

30
namespace dpctl_td_ns = dpctl::tensor::type_dispatch;
31

32
namespace statistics::common
33
{
34
size_t get_max_local_size(const sycl::device &device)
35
{
1,173✔
36
    constexpr const int default_max_cpu_local_size = 256;
1,173✔
37
    constexpr const int default_max_gpu_local_size = 0;
1,173✔
38

39
    return get_max_local_size(device, default_max_cpu_local_size,
1,173✔
40
                              default_max_gpu_local_size);
1,173✔
41
}
1,173✔
42

43
size_t get_max_local_size(const sycl::device &device,
44
                          int cpu_local_size_limit,
45
                          int gpu_local_size_limit)
46
{
1,173✔
47
    int max_work_group_size =
1,173✔
48
        device.get_info<sycl::info::device::max_work_group_size>();
1,173✔
49
    if (device.is_cpu() && cpu_local_size_limit > 0) {
1,173!
50
        return std::min(cpu_local_size_limit, max_work_group_size);
1,173✔
51
    }
1,173✔
UNCOV
52
    else if (device.is_gpu() && gpu_local_size_limit > 0) {
×
UNCOV
53
        return std::min(gpu_local_size_limit, max_work_group_size);
×
UNCOV
54
    }
×
55

56
    return max_work_group_size;
×
57
}
1,173✔
58

59
sycl::nd_range<1>
60
    make_ndrange(size_t global_size, size_t local_range, size_t work_per_item)
61
{
1,173✔
62
    return make_ndrange(sycl::range<1>(global_size),
1,173✔
63
                        sycl::range<1>(local_range),
1,173✔
64
                        sycl::range<1>(work_per_item));
1,173✔
65
}
1,173✔
66

67
size_t get_local_mem_size_in_bytes(const sycl::device &device)
68
{
833✔
69
    // Reserving 1kb for runtime needs
70
    constexpr const size_t reserve = 1024;
833✔
71

72
    return get_local_mem_size_in_bytes(device, reserve);
833✔
73
}
833✔
74

75
size_t get_local_mem_size_in_bytes(const sycl::device &device, size_t reserve)
76
{
833✔
77
    size_t local_mem_size =
833✔
78
        device.get_info<sycl::info::device::local_mem_size>();
833✔
79
    return local_mem_size - reserve;
833✔
80
}
833✔
81

82
pybind11::dtype dtype_from_typenum(int dst_typenum)
83
{
222✔
84
    dpctl_td_ns::typenum_t dst_typenum_t =
222✔
85
        static_cast<dpctl_td_ns::typenum_t>(dst_typenum);
222✔
86
    switch (dst_typenum_t) {
222✔
UNCOV
87
    case dpctl_td_ns::typenum_t::BOOL:
×
UNCOV
88
        return py::dtype("?");
×
UNCOV
89
    case dpctl_td_ns::typenum_t::INT8:
×
90
        return py::dtype("i1");
×
91
    case dpctl_td_ns::typenum_t::UINT8:
×
92
        return py::dtype("u1");
×
93
    case dpctl_td_ns::typenum_t::INT16:
×
94
        return py::dtype("i2");
×
95
    case dpctl_td_ns::typenum_t::UINT16:
×
96
        return py::dtype("u2");
×
97
    case dpctl_td_ns::typenum_t::INT32:
2✔
98
        return py::dtype("i4");
2✔
99
    case dpctl_td_ns::typenum_t::UINT32:
2✔
100
        return py::dtype("u4");
2✔
101
    case dpctl_td_ns::typenum_t::INT64:
50✔
102
        return py::dtype("i8");
50✔
103
    case dpctl_td_ns::typenum_t::UINT64:
24✔
104
        return py::dtype("u8");
24✔
UNCOV
105
    case dpctl_td_ns::typenum_t::HALF:
×
UNCOV
106
        return py::dtype("f2");
×
107
    case dpctl_td_ns::typenum_t::FLOAT:
40✔
108
        return py::dtype("f4");
40✔
109
    case dpctl_td_ns::typenum_t::DOUBLE:
40✔
110
        return py::dtype("f8");
40✔
111
    case dpctl_td_ns::typenum_t::CFLOAT:
32✔
112
        return py::dtype("c8");
32✔
113
    case dpctl_td_ns::typenum_t::CDOUBLE:
32✔
114
        return py::dtype("c16");
32✔
UNCOV
115
    default:
×
UNCOV
116
        throw py::value_error("Unrecognized dst_typeid");
×
117
    }
222✔
118
}
222✔
119

120
} // namespace statistics::common
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc