From 0e9d602389d6e604ab49c1210ce6ad324f5a174a Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Wed, 14 Jan 2026 08:11:11 -0800 Subject: [PATCH 1/2] 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/2] 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()