Skip to content

Commit 0aaf677

Browse files
authored
Merge branch 'master' into update-math-tests
2 parents e944bef + 2f335cd commit 0aaf677

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+791
-426
lines changed

.github/workflows/openssf-scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,6 @@ jobs:
6868

6969
# Upload the results to GitHub's code scanning dashboard.
7070
- name: "Upload to code-scanning"
71-
uses: github/codeql-action/upload-sarif@b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d # v3.28.10
71+
uses: github/codeql-action/upload-sarif@6bb031afdd8eb862ea3fc1848194185e076637e5 # v3.28.11
7272
with:
7373
sarif_file: results.sarif

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
* Added implementation of `dpnp.hamming` [#2341](https://github.com/IntelPython/dpnp/pull/2341), [#2357](https://github.com/IntelPython/dpnp/pull/2357)
1212
* Added implementation of `dpnp.hanning` [#2358](https://github.com/IntelPython/dpnp/pull/2358)
1313
* Added implementation of `dpnp.blackman` [#2363](https://github.com/IntelPython/dpnp/pull/2363)
14+
* Added implementation of `dpnp.bartlett` [#2366](https://github.com/IntelPython/dpnp/pull/2366)
1415

1516
### Changed
1617

18+
* Allowed input array of `uint64` dtype in `dpnp.bincount` [#2361](https://github.com/IntelPython/dpnp/pull/2361)
19+
1720
### Fixed
1821

1922

doc/reference/math.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,5 +232,3 @@ Miscellaneous
232232
dpnp.real_if_close
233233

234234
dpnp.interp
235-
236-
dpnp.bitwise_count

dpnp/backend/extensions/fft/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
set(python_module_name _fft_impl)
2828
set(_module_src
2929
${CMAKE_CURRENT_SOURCE_DIR}/fft_py.cpp
30-
${CMAKE_CURRENT_SOURCE_DIR}/in_place.cpp
31-
${CMAKE_CURRENT_SOURCE_DIR}/out_of_place.cpp
3230
)
3331

3432
pybind11_add_module(${python_module_name} MODULE ${_module_src})

dpnp/backend/extensions/fft/in_place.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,5 @@ std::pair<sycl::event, sycl::event>
4242
const std::vector<sycl::event> &depends);
4343

4444
} // namespace dpnp::extensions::fft
45+
46+
#include "in_place.tpp" // Include template definition

dpnp/backend/extensions/fft/in_place.cpp renamed to dpnp/backend/extensions/fft/in_place.tpp

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
// THE POSSIBILITY OF SUCH DAMAGE.
2424
//*****************************************************************************
2525

26+
#pragma once
2627
#include <stdexcept>
2728

2829
#include <oneapi/mkl.hpp>
@@ -32,7 +33,6 @@
3233

3334
#include "common.hpp"
3435
#include "fft_utils.hpp"
35-
#include "in_place.hpp"
3636
// dpctl tensor headers
3737
#include "utils/output_validation.hpp"
3838

@@ -107,21 +107,4 @@ std::pair<sycl::event, sycl::event>
107107
return std::make_pair(fft_event, args_ev);
108108
}
109109

110-
// Explicit instantiations
111-
// single precision c2c FFT
112-
template std::pair<sycl::event, sycl::event> compute_fft_in_place(
113-
DescriptorWrapper<mkl_dft::precision::SINGLE, mkl_dft::domain::COMPLEX>
114-
&descr,
115-
const dpctl::tensor::usm_ndarray &in_out,
116-
const bool is_forward,
117-
const std::vector<sycl::event> &depends);
118-
119-
// double precision c2c FFT
120-
template std::pair<sycl::event, sycl::event> compute_fft_in_place(
121-
DescriptorWrapper<mkl_dft::precision::DOUBLE, mkl_dft::domain::COMPLEX>
122-
&descr,
123-
const dpctl::tensor::usm_ndarray &in_out,
124-
const bool is_forward,
125-
const std::vector<sycl::event> &depends);
126-
127110
} // namespace dpnp::extensions::fft

dpnp/backend/extensions/fft/out_of_place.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,5 @@ std::pair<sycl::event, sycl::event>
4343
const std::vector<sycl::event> &depends);
4444

4545
} // namespace dpnp::extensions::fft
46+
47+
#include "out_of_place.tpp" // Include template definition

dpnp/backend/extensions/fft/out_of_place.cpp renamed to dpnp/backend/extensions/fft/out_of_place.tpp

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
// THE POSSIBILITY OF SUCH DAMAGE.
2424
//*****************************************************************************
2525

26+
#pragma once
2627
#include <stdexcept>
2728

2829
#include <oneapi/mkl.hpp>
@@ -32,7 +33,6 @@
3233

3334
#include "common.hpp"
3435
#include "fft_utils.hpp"
35-
#include "out_of_place.hpp"
3636
// dpctl tensor headers
3737
#include "utils/memory_overlap.hpp"
3838
#include "utils/output_validation.hpp"
@@ -167,38 +167,4 @@ std::pair<sycl::event, sycl::event>
167167
return std::make_pair(fft_event, args_ev);
168168
}
169169

170-
// Explicit instantiations
171-
// single precision c2c FFT
172-
template std::pair<sycl::event, sycl::event> compute_fft_out_of_place(
173-
DescriptorWrapper<mkl_dft::precision::SINGLE, mkl_dft::domain::COMPLEX>
174-
&descr,
175-
const dpctl::tensor::usm_ndarray &in,
176-
const dpctl::tensor::usm_ndarray &out,
177-
const bool is_forward,
178-
const std::vector<sycl::event> &depends);
179-
180-
// double precision c2c FFT
181-
template std::pair<sycl::event, sycl::event> compute_fft_out_of_place(
182-
DescriptorWrapper<mkl_dft::precision::DOUBLE, mkl_dft::domain::COMPLEX>
183-
&descr,
184-
const dpctl::tensor::usm_ndarray &in,
185-
const dpctl::tensor::usm_ndarray &out,
186-
const bool is_forward,
187-
const std::vector<sycl::event> &depends);
188-
189-
// single precision r2c/c2r FFT
190-
template std::pair<sycl::event, sycl::event> compute_fft_out_of_place(
191-
DescriptorWrapper<mkl_dft::precision::SINGLE, mkl_dft::domain::REAL> &descr,
192-
const dpctl::tensor::usm_ndarray &in,
193-
const dpctl::tensor::usm_ndarray &out,
194-
const bool is_forward,
195-
const std::vector<sycl::event> &depends);
196-
197-
// double precision r2c/c2r FFT
198-
template std::pair<sycl::event, sycl::event> compute_fft_out_of_place(
199-
DescriptorWrapper<mkl_dft::precision::DOUBLE, mkl_dft::domain::REAL> &descr,
200-
const dpctl::tensor::usm_ndarray &in,
201-
const dpctl::tensor::usm_ndarray &out,
202-
const bool is_forward,
203-
const std::vector<sycl::event> &depends);
204170
} // namespace dpnp::extensions::fft

dpnp/backend/extensions/lapack/gesv.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,16 @@ static sycl::event gesv_impl(sycl::queue &exec_q,
144144
is_exception_caught = true;
145145
gesv_utils::handle_lapack_exc(exec_q, lda, a, scratchpad_size,
146146
scratchpad, ipiv, e, error_msg);
147+
} catch (oneapi::mkl::computation_error const &e) {
148+
// TODO: remove this catch when gh-642(oneMath) is fixed
149+
// Workaround for oneMath interfaces
150+
// oneapi::mkl::computation_error is thrown instead of
151+
// oneapi::mkl::lapack::computation_error.
152+
if (scratchpad != nullptr)
153+
sycl_free_noexcept(scratchpad, exec_q);
154+
if (ipiv != nullptr)
155+
sycl_free_noexcept(ipiv, exec_q);
156+
throw LinAlgError("The input coefficient matrix is singular.");
147157
} catch (sycl::exception const &e) {
148158
is_exception_caught = true;
149159
error_msg << "Unexpected SYCL exception caught during getrf() or "

dpnp/backend/extensions/lapack/gesvd.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,12 @@ static sycl::event gesvd_impl(sycl::queue &exec_q,
9595
exec_q,
9696
jobu, // Character specifying how to compute the matrix U:
9797
// 'A' computes all columns of U,
98-
// 'S' computes the first min(m,n) columns of U,
98+
// 'S' computes the first min(m, n) columns of U,
9999
// 'O' overwrites A with the columns of U,
100100
// 'N' does not compute U.
101101
jobvt, // Character specifying how to compute the matrix VT:
102102
// 'A' computes all rows of VT,
103-
// 'S' computes the first min(m,n) rows of VT,
103+
// 'S' computes the first min(m, n) rows of VT,
104104
// 'O' overwrites A with the rows of VT,
105105
// 'N' does not compute VT.
106106
m, // The number of rows in the input matrix A (0 <= m).

dpnp/backend/extensions/lapack/gesvd_batch.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,12 @@ static sycl::event gesvd_batch_impl(sycl::queue &exec_q,
147147
exec_q,
148148
jobu, // Character specifying how to compute the matrix U:
149149
// 'A' computes all columns of U,
150-
// 'S' computes the first min(m,n) columns of U,
150+
// 'S' computes the first min(m, n) columns of U,
151151
// 'O' overwrites A with the columns of U,
152152
// 'N' does not compute U.
153153
jobvt, // Character specifying how to compute the matrix VT:
154154
// 'A' computes all rows of VT,
155-
// 'S' computes the first min(m,n) rows of VT,
155+
// 'S' computes the first min(m, n) rows of VT,
156156
// 'O' overwrites A with the rows of VT,
157157
// 'N' does not compute VT.
158158
m, // The number of rows in the input batch matrix A (0 <= m).

dpnp/backend/extensions/lapack/getrf.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,15 @@ static sycl::event getrf_impl(sycl::queue &exec_q,
120120
"call:\nreason: "
121121
<< e.what() << "\ninfo: " << e.info();
122122
}
123+
} catch (oneapi::mkl::computation_error const &e) {
124+
// TODO: remove this catch when gh-642(oneMath) is fixed
125+
// Workaround for oneMath interfaces
126+
// oneapi::mkl::computation_error is thrown instead of
127+
// oneapi::mkl::lapack::computation_error.
128+
is_exception_caught = false;
129+
// computation_error means the input matrix is singular
130+
// dev_info must be set to any positive value.
131+
dev_info[0] = 2;
123132
} catch (sycl::exception const &e) {
124133
is_exception_caught = true;
125134
error_msg << "Unexpected SYCL exception caught during getrf() call:\n"

dpnp/backend/extensions/statistics/bincount.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ struct BincountEdges
7272
template <typename dT>
7373
bool in_bounds(const dT *val, const boundsT &bounds) const
7474
{
75-
return check_in_bounds(val[0], std::get<0>(bounds),
75+
return check_in_bounds(static_cast<T>(val[0]), std::get<0>(bounds),
7676
std::get<1>(bounds));
7777
}
7878

@@ -81,16 +81,17 @@ struct BincountEdges
8181
T max;
8282
};
8383

84-
template <typename T, typename HistType = size_t>
84+
using DefaultHistType = int64_t;
85+
86+
template <typename T, typename HistType = DefaultHistType>
8587
struct BincountF
8688
{
8789
static sycl::event impl(sycl::queue &exec_q,
8890
const void *vin,
89-
const int64_t min,
90-
const int64_t max,
91+
const uint64_t min,
92+
const uint64_t max,
9193
const void *vweights,
9294
void *vout,
93-
const size_t,
9495
const size_t size,
9596
const std::vector<sycl::event> &depends)
9697
{
@@ -145,9 +146,12 @@ struct BincountF
145146
}
146147
};
147148

148-
using SupportedTypes = std::tuple<std::tuple<int64_t, int64_t>,
149+
using SupportedTypes = std::tuple<std::tuple<int64_t, DefaultHistType>,
150+
std::tuple<uint64_t, DefaultHistType>,
149151
std::tuple<int64_t, float>,
150-
std::tuple<int64_t, double>>;
152+
std::tuple<uint64_t, float>,
153+
std::tuple<int64_t, double>,
154+
std::tuple<uint64_t, double>>;
151155

152156
} // namespace
153157

@@ -158,8 +162,8 @@ Bincount::Bincount() : dispatch_table("sample", "histogram")
158162

159163
std::tuple<sycl::event, sycl::event> Bincount::call(
160164
const dpctl::tensor::usm_ndarray &sample,
161-
const int64_t min,
162-
const int64_t max,
165+
const uint64_t min,
166+
const uint64_t max,
163167
const std::optional<const dpctl::tensor::usm_ndarray> &weights,
164168
dpctl::tensor::usm_ndarray &histogram,
165169
const std::vector<sycl::event> &depends)
@@ -182,8 +186,7 @@ std::tuple<sycl::event, sycl::event> Bincount::call(
182186
weights.has_value() ? weights.value().get_data() : nullptr;
183187

184188
auto ev = bincount_func(exec_q, sample.get_data(), min, max, weights_ptr,
185-
histogram.get_data(), histogram.get_shape(0),
186-
sample.get_shape(0), depends);
189+
histogram.get_data(), sample.get_size(), depends);
187190

188191
sycl::event args_ev;
189192
if (weights.has_value()) {

dpnp/backend/extensions/statistics/bincount.hpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,11 @@ struct Bincount
3939
{
4040
using FnT = sycl::event (*)(sycl::queue &,
4141
const void *,
42-
const int64_t,
43-
const int64_t,
42+
const uint64_t,
43+
const uint64_t,
4444
const void *,
4545
void *,
4646
const size_t,
47-
const size_t,
4847
const std::vector<sycl::event> &);
4948

5049
common::DispatchTable2<FnT> dispatch_table;
@@ -53,8 +52,8 @@ struct Bincount
5352

5453
std::tuple<sycl::event, sycl::event>
5554
call(const dpctl::tensor::usm_ndarray &input,
56-
const int64_t min,
57-
const int64_t max,
55+
const uint64_t min,
56+
const uint64_t max,
5857
const std::optional<const dpctl::tensor::usm_ndarray> &weights,
5958
dpctl::tensor::usm_ndarray &output,
6059
const std::vector<sycl::event> &depends);

dpnp/backend/extensions/statistics/histogram.cpp

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ using CachedEdges = HistogramEdges<T, CachedData<const T, 1>>;
106106
template <typename T>
107107
using UncachedEdges = HistogramEdges<T, UncachedData<const T, 1>>;
108108

109-
template <typename T, typename BinsT, typename HistType = size_t>
109+
using DefaultHistType = int64_t;
110+
111+
template <typename T, typename BinsT, typename HistType = DefaultHistType>
110112
struct HistogramF
111113
{
112114
static sycl::event impl(sycl::queue &exec_q,
@@ -186,26 +188,27 @@ using HistogramF_ = HistogramF<SampleType, SampleType, HistType>;
186188

187189
} // namespace
188190

189-
using SupportedTypes = std::tuple<std::tuple<uint64_t, int64_t>,
190-
std::tuple<int64_t, int64_t>,
191-
std::tuple<uint64_t, float>,
192-
std::tuple<int64_t, float>,
193-
std::tuple<uint64_t, double>,
194-
std::tuple<int64_t, double>,
195-
std::tuple<uint64_t, std::complex<float>>,
196-
std::tuple<int64_t, std::complex<float>>,
197-
std::tuple<uint64_t, std::complex<double>>,
198-
std::tuple<int64_t, std::complex<double>>,
199-
std::tuple<float, int64_t>,
200-
std::tuple<double, int64_t>,
201-
std::tuple<float, float>,
202-
std::tuple<double, double>,
203-
std::tuple<float, std::complex<float>>,
204-
std::tuple<double, std::complex<double>>,
205-
std::tuple<std::complex<float>, int64_t>,
206-
std::tuple<std::complex<double>, int64_t>,
207-
std::tuple<std::complex<float>, float>,
208-
std::tuple<std::complex<double>, double>>;
191+
using SupportedTypes =
192+
std::tuple<std::tuple<uint64_t, DefaultHistType>,
193+
std::tuple<int64_t, DefaultHistType>,
194+
std::tuple<uint64_t, float>,
195+
std::tuple<int64_t, float>,
196+
std::tuple<uint64_t, double>,
197+
std::tuple<int64_t, double>,
198+
std::tuple<uint64_t, std::complex<float>>,
199+
std::tuple<int64_t, std::complex<float>>,
200+
std::tuple<uint64_t, std::complex<double>>,
201+
std::tuple<int64_t, std::complex<double>>,
202+
std::tuple<float, DefaultHistType>,
203+
std::tuple<double, DefaultHistType>,
204+
std::tuple<float, float>,
205+
std::tuple<double, double>,
206+
std::tuple<float, std::complex<float>>,
207+
std::tuple<double, std::complex<double>>,
208+
std::tuple<std::complex<float>, DefaultHistType>,
209+
std::tuple<std::complex<double>, DefaultHistType>,
210+
std::tuple<std::complex<float>, float>,
211+
std::tuple<std::complex<double>, double>>;
209212

210213
Histogram::Histogram() : dispatch_table("sample", "histogram")
211214
{

0 commit comments

Comments
 (0)