Skip to content

Commit cd83881

Browse files
committed
top_k raises when k > 1 and input is a scalar
1 parent fa74e5e commit cd83881

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

dpctl/tensor/_sorting.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,8 @@ def top_k(x, k, /, *, axis=None, mode="largest"):
337337
if axis is None:
338338
sz = x.size
339339
if nd == 0:
340+
if k > 1:
341+
raise ValueError(f"`k`={k} is out of bounds 1")
340342
return TopKResult(
341343
dpt.copy(x, order="C"),
342344
dpt.zeros_like(

0 commit comments

Comments
 (0)