Skip to content

Commit f7ccb44

Browse files
authored
add triu_indices (#2191)
1 parent a8851d7 commit f7ccb44

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

mindtorch/_apis/cpu.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1236,4 +1236,7 @@ def search_sorted(sorted_sequence, values, sorter, dtype, right):
12361236
return legacy.search_sorted(sorted_sequence, values, sorter, dtype, right)
12371237

12381238
def scatter_nd_update(input, indices, updates):
1239-
return legacy.scatter_nd_update(input, indices, updates, True)
1239+
return legacy.scatter_nd_update(input, indices, updates, True)
1240+
1241+
def triu_indices(row, col, offset, dtype):
1242+
return legacy.triu_indices(row, col, offset, dtype)

mindtorch/_apis/gpu.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,3 +1245,5 @@ def fft(input, n=None, dim=-1, norm="backward"):
12451245
input = narrow(input, dim, 0, n)
12461246
return legacy.fft_with_size(input, input.ndim, False, False, norm, True, ())
12471247

1248+
def triu_indices(row, col, offset, dtype):
1249+
return legacy.triu_indices(row, col, offset, dtype)

mindtorch/_apis/npu.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,3 +1631,6 @@ def repeat_interleave_int(input, repeats, dim, output_size):
16311631

16321632
def repeat_interleave_tensor(input, repeats, dim, output_size):
16331633
return pyboost.repeat_interleave_tensor_op(input, repeats, dim, output_size)
1634+
1635+
def triu_indices(row, col, offset, dtype):
1636+
return legacy.triu_indices(row, col, offset, dtype)

mindtorch/ops/other.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,8 @@ def triu(input, diagonal=0):
939939
return execute('triu', input, diagonal)
940940

941941
# triu_indices
942+
def triu_indices(row, col, offset=0, *, dtype=mindtorch.long, device='cpu', layout=mindtorch.strided):
943+
return execute('triu_indices', row, col, offset, dtype, device=device)
942944

943945

944946
# unflatten
@@ -1145,6 +1147,7 @@ def cosine_similarity(x1, x2, dim=1, eps=1e-8):
11451147
"stop_gradient",
11461148
"tril",
11471149
"triu",
1150+
"triu_indices",
11481151
"unflatten",
11491152
"unfold",
11501153
"contiguous",

0 commit comments

Comments
 (0)