From 0e9d602389d6e604ab49c1210ce6ad324f5a174a Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Wed, 14 Jan 2026 08:11:11 -0800 Subject: [PATCH 1/3] Fix repeat() to avoid non-0D scalar conversion --- dpctl/tensor/_manipulation_functions.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dpctl/tensor/_manipulation_functions.py b/dpctl/tensor/_manipulation_functions.py index 65b027e2ba..a1ab047b16 100644 --- a/dpctl/tensor/_manipulation_functions.py +++ b/dpctl/tensor/_manipulation_functions.py @@ -829,7 +829,12 @@ def repeat(x, repeats, /, *, axis=None): if repeats.size == 1: scalar = True # bring the single element to the host - repeats = int(repeats) + if repeats.ndim == 0: + repeats = int(repeats) + else: + # Get the single element explicitly + # since non-0D arrays can not be converted to scalars + repeats = int(repeats[0]) if repeats < 0: raise ValueError("`repeats` elements must be positive") else: From cba240e67ca6ff3dbe99885b2e357837b51b7a22 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Wed, 14 Jan 2026 08:33:10 -0800 Subject: [PATCH 2/3] Extend repeat tests to cover size-1 repeats case --- dpctl/tests/test_usm_ndarray_manipulation.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/dpctl/tests/test_usm_ndarray_manipulation.py b/dpctl/tests/test_usm_ndarray_manipulation.py index 09c10340ef..b278761811 100644 --- a/dpctl/tests/test_usm_ndarray_manipulation.py +++ b/dpctl/tests/test_usm_ndarray_manipulation.py @@ -1342,6 +1342,21 @@ def test_repeat_strided_repeats(): assert dpt.all(res == x) +def test_repeat_size1_repeats(): + get_queue_or_skip() + + x = dpt.arange(5, dtype="i4") + expected_res = dpt.repeat(x, 2) + # 0D repeats + reps_0d = dpt.asarray(2, dtype="i8") + res = dpt.repeat(x, reps_0d) + assert dpt.all(res == expected_res) + # 1D repeats + reps_1d = dpt.asarray([2], dtype="i8") + res = dpt.repeat(x, reps_1d) + assert dpt.all(res == expected_res) + + def test_repeat_arg_validation(): get_queue_or_skip() From 6e22d8d797e326c33519863604fefd496bc9918b Mon Sep 17 00:00:00 2001 From: antonwolfy <100830759+antonwolfy@users.noreply.github.com> Date: Sat, 17 Jan 2026 02:59:27 +0000 Subject: [PATCH 3/3] chore: update pre-commit hooks --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0ff7481506..27b49b24d9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -38,7 +38,7 @@ repos: - id: clang-format args: ["-i"] - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks - rev: v2.15.0 + rev: v2.16.0 hooks: - id: pretty-format-toml args: [--autofix]