1use alloc::vec::Vec;
2use burn_backend::{
3 BoolDType, ExecutionError, FloatDType, IntDType, Scalar, Shape, Slice, TensorData,
4 ops::IntTensorOps,
5 tensor::{BoolTensor, FloatTensor, IndexingUpdateOp, IntTensor},
6};
7
8use crate::{Dispatch, DispatchDevice};
9
10impl IntTensorOps<Self> for Dispatch {
11 fn int_empty(shape: Shape, device: &DispatchDevice, dtype: IntDType) -> IntTensor<Self> {
12 creation_op!(Int, device, |device| B::int_empty(shape, device, dtype))
13 }
14
15 async fn int_into_data(tensor: IntTensor<Self>) -> Result<TensorData, ExecutionError> {
16 unary_op!(tensor, int, |tensor| B::int_into_data(tensor).await)
17 }
18
19 fn int_from_data(data: TensorData, device: &DispatchDevice) -> IntTensor<Self> {
20 creation_op!(Int, device, |device| B::int_from_data(data, device))
21 }
22
23 fn int_to_device(tensor: IntTensor<Self>, device: &DispatchDevice) -> IntTensor<Self> {
24 to_device!(Int, int, tensor, device, int_to_device, |inner, device| {
25 let data = burn_backend::read_sync(B1::int_into_data(inner)).expect("Should read data");
26 B2::int_from_data(data, device)
27 })
28 }
29
30 fn int_reshape(tensor: IntTensor<Self>, shape: Shape) -> IntTensor<Self> {
31 unary_op!(tensor, int, |tensor| B::int_reshape(tensor, shape) => Int)
32 }
33
34 fn int_slice(tensor: IntTensor<Self>, slices: &[Slice]) -> IntTensor<Self> {
35 unary_op!(tensor, int, |tensor| B::int_slice(tensor, slices) => Int)
36 }
37
38 fn int_slice_assign(
39 tensor: IntTensor<Self>,
40 slices: &[Slice],
41 value: IntTensor<Self>,
42 ) -> IntTensor<Self> {
43 binary_op!((tensor, int), (value, int), |tensor, value| B::int_slice_assign(tensor, slices, value) => Int)
44 }
45
46 fn int_into_float(tensor: IntTensor<Self>, out_dtype: FloatDType) -> FloatTensor<Self> {
47 unary_op!(tensor, int, |tensor| B::int_into_float(tensor, out_dtype) => Float)
48 }
49
50 fn int_mask_where(
51 tensor: IntTensor<Self>,
52 mask: BoolTensor<Self>,
53 value: IntTensor<Self>,
54 ) -> IntTensor<Self> {
55 multi_op!(
56 inputs[(tensor, int), (mask, bool), (value, int)], => Int,
57 B::int_mask_where(tensor, mask, value)
58 )
59 }
60
61 fn int_mask_fill(
62 tensor: IntTensor<Self>,
63 mask: BoolTensor<Self>,
64 value: Scalar,
65 ) -> IntTensor<Self> {
66 binary_op!((tensor, int), (mask, bool), |tensor, mask| B::int_mask_fill(tensor, mask, value) => Int)
67 }
68
69 async fn int_mask_select(tensor: IntTensor<Self>, mask: BoolTensor<Self>) -> IntTensor<Self> {
70 binary_op!((tensor, int), (mask, bool), |tensor, mask| B::int_mask_select(tensor, mask).await => Int)
71 }
72
73 fn int_gather(
74 dim: usize,
75 tensor: IntTensor<Self>,
76 indices: IntTensor<Self>,
77 ) -> IntTensor<Self> {
78 binary_op!((tensor, int), (indices, int), |tensor, indices| B::int_gather(dim, tensor, indices) => Int)
79 }
80
81 fn int_scatter_add(
82 dim: usize,
83 tensor: IntTensor<Self>,
84 indices: IntTensor<Self>,
85 value: IntTensor<Self>,
86 ) -> IntTensor<Self> {
87 multi_op!(
88 inputs[(tensor, int), (indices, int), (value, int)], => Int,
89 B::int_scatter_add(dim, tensor, indices, value)
90 )
91 }
92
93 fn int_scatter(
94 dim: usize,
95 tensor: IntTensor<Self>,
96 indices: IntTensor<Self>,
97 value: IntTensor<Self>,
98 update: IndexingUpdateOp,
99 ) -> IntTensor<Self> {
100 multi_op!(
101 inputs[(tensor, int), (indices, int), (value, int)], => Int,
102 B::int_scatter(dim, tensor, indices, value, update)
103 )
104 }
105
106 fn int_scatter_nd(
107 data: IntTensor<Self>,
108 indices: IntTensor<Self>,
109 values: IntTensor<Self>,
110 reduction: burn_backend::tensor::IndexingUpdateOp,
111 ) -> IntTensor<Self> {
112 multi_op!(
113 inputs[(data, int), (indices, int), (values, int)], => Int,
114 B::int_scatter_nd(data, indices, values, reduction)
115 )
116 }
117
118 fn int_gather_nd(data: IntTensor<Self>, indices: IntTensor<Self>) -> IntTensor<Self> {
119 binary_op!((data, int), (indices, int), |data, indices| B::int_gather_nd(data, indices) => Int)
120 }
121
122 fn int_select(
123 tensor: IntTensor<Self>,
124 dim: usize,
125 indices: IntTensor<Self>,
126 ) -> IntTensor<Self> {
127 binary_op!((tensor, int), (indices, int), |tensor, indices| B::int_select(tensor, dim, indices) => Int)
128 }
129
130 fn int_select_add(
131 tensor: IntTensor<Self>,
132 dim: usize,
133 indices: IntTensor<Self>,
134 value: IntTensor<Self>,
135 ) -> IntTensor<Self> {
136 multi_op!(
137 inputs[(tensor, int), (indices, int), (value, int)], => Int,
138 B::int_select_add(tensor, dim, indices, value)
139 )
140 }
141
142 fn int_select_assign(
143 tensor: IntTensor<Self>,
144 dim: usize,
145 indices: IntTensor<Self>,
146 value: IntTensor<Self>,
147 update: IndexingUpdateOp,
148 ) -> IntTensor<Self> {
149 multi_op!(
150 inputs[(tensor, int), (indices, int), (value, int)], => Int,
151 B::int_select_assign(tensor, dim, indices, value, update)
152 )
153 }
154
155 fn int_equal(
156 lhs: IntTensor<Self>,
157 rhs: IntTensor<Self>,
158 out_dtype: BoolDType,
159 ) -> BoolTensor<Self> {
160 binary_op!((lhs, int), (rhs, int), |lhs, rhs| B::int_equal(lhs, rhs, out_dtype) => Bool)
161 }
162
163 fn int_equal_elem(lhs: IntTensor<Self>, rhs: Scalar, out_dtype: BoolDType) -> BoolTensor<Self> {
164 unary_op!(lhs, int, |lhs| B::int_equal_elem(lhs, rhs, out_dtype) => Bool)
165 }
166
167 fn int_greater(
168 lhs: IntTensor<Self>,
169 rhs: IntTensor<Self>,
170 out_dtype: BoolDType,
171 ) -> BoolTensor<Self> {
172 binary_op!((lhs, int), (rhs, int), |lhs, rhs| B::int_greater(lhs, rhs, out_dtype) => Bool)
173 }
174
175 fn int_greater_elem(
176 lhs: IntTensor<Self>,
177 rhs: Scalar,
178 out_dtype: BoolDType,
179 ) -> BoolTensor<Self> {
180 unary_op!(lhs, int, |lhs| B::int_greater_elem(lhs, rhs, out_dtype) => Bool)
181 }
182
183 fn int_greater_equal(
184 lhs: IntTensor<Self>,
185 rhs: IntTensor<Self>,
186 out_dtype: BoolDType,
187 ) -> BoolTensor<Self> {
188 binary_op!((lhs, int), (rhs, int), |lhs, rhs| B::int_greater_equal(lhs, rhs, out_dtype) => Bool)
189 }
190
191 fn int_greater_equal_elem(
192 lhs: IntTensor<Self>,
193 rhs: Scalar,
194 out_dtype: BoolDType,
195 ) -> BoolTensor<Self> {
196 unary_op!(lhs, int, |lhs| B::int_greater_equal_elem(lhs, rhs, out_dtype) => Bool)
197 }
198
199 fn int_lower(
200 lhs: IntTensor<Self>,
201 rhs: IntTensor<Self>,
202 out_dtype: BoolDType,
203 ) -> BoolTensor<Self> {
204 binary_op!((lhs, int), (rhs, int), |lhs, rhs| B::int_lower(lhs, rhs, out_dtype) => Bool)
205 }
206
207 fn int_lower_elem(lhs: IntTensor<Self>, rhs: Scalar, out_dtype: BoolDType) -> BoolTensor<Self> {
208 unary_op!(lhs, int, |lhs| B::int_lower_elem(lhs, rhs, out_dtype) => Bool)
209 }
210
211 fn int_lower_equal(
212 lhs: IntTensor<Self>,
213 rhs: IntTensor<Self>,
214 out_dtype: BoolDType,
215 ) -> BoolTensor<Self> {
216 binary_op!((lhs, int), (rhs, int), |lhs, rhs| B::int_lower_equal(lhs, rhs, out_dtype) => Bool)
217 }
218
219 fn int_lower_equal_elem(
220 lhs: IntTensor<Self>,
221 rhs: Scalar,
222 out_dtype: BoolDType,
223 ) -> BoolTensor<Self> {
224 unary_op!(lhs, int, |lhs| B::int_lower_equal_elem(lhs, rhs, out_dtype) => Bool)
225 }
226
227 fn int_add(lhs: IntTensor<Self>, rhs: IntTensor<Self>) -> IntTensor<Self> {
228 binary_op!((lhs, int), (rhs, int), |lhs, rhs| B::int_add(lhs, rhs) => Int)
229 }
230
231 fn int_add_scalar(lhs: IntTensor<Self>, rhs: Scalar) -> IntTensor<Self> {
232 unary_op!(lhs, int, |lhs| B::int_add_scalar(lhs, rhs) => Int)
233 }
234
235 fn int_sub(lhs: IntTensor<Self>, rhs: IntTensor<Self>) -> IntTensor<Self> {
236 binary_op!((lhs, int), (rhs, int), |lhs, rhs| B::int_sub(lhs, rhs) => Int)
237 }
238
239 fn int_sub_scalar(lhs: IntTensor<Self>, rhs: Scalar) -> IntTensor<Self> {
240 unary_op!(lhs, int, |lhs| B::int_sub_scalar(lhs, rhs) => Int)
241 }
242
243 fn int_mul(lhs: IntTensor<Self>, rhs: IntTensor<Self>) -> IntTensor<Self> {
244 binary_op!((lhs, int), (rhs, int), |lhs, rhs| B::int_mul(lhs, rhs) => Int)
245 }
246
247 fn int_mul_scalar(lhs: IntTensor<Self>, rhs: Scalar) -> IntTensor<Self> {
248 unary_op!(lhs, int, |lhs| B::int_mul_scalar(lhs, rhs) => Int)
249 }
250
251 fn int_div(lhs: IntTensor<Self>, rhs: IntTensor<Self>) -> IntTensor<Self> {
252 binary_op!((lhs, int), (rhs, int), |lhs, rhs| B::int_div(lhs, rhs) => Int)
253 }
254
255 fn int_div_scalar(lhs: IntTensor<Self>, rhs: Scalar) -> IntTensor<Self> {
256 unary_op!(lhs, int, |lhs| B::int_div_scalar(lhs, rhs) => Int)
257 }
258
259 fn int_remainder(lhs: IntTensor<Self>, rhs: IntTensor<Self>) -> IntTensor<Self> {
260 binary_op!((lhs, int), (rhs, int), |lhs, rhs| B::int_remainder(lhs, rhs) => Int)
261 }
262
263 fn int_remainder_scalar(lhs: IntTensor<Self>, rhs: Scalar) -> IntTensor<Self> {
264 unary_op!(lhs, int, |lhs| B::int_remainder_scalar(lhs, rhs) => Int)
265 }
266
267 fn int_matmul(lhs: IntTensor<Self>, rhs: IntTensor<Self>) -> IntTensor<Self> {
268 binary_op!((lhs, int), (rhs, int), |lhs, rhs| B::int_matmul(lhs, rhs) => Int)
269 }
270
271 fn int_sum(tensor: IntTensor<Self>) -> IntTensor<Self> {
272 unary_op!(tensor, int, |tensor| B::int_sum(tensor) => Int)
273 }
274
275 fn int_sum_dim(tensor: IntTensor<Self>, dim: usize) -> IntTensor<Self> {
276 unary_op!(tensor, int, |tensor| B::int_sum_dim(tensor, dim) => Int)
277 }
278
279 fn int_prod(tensor: IntTensor<Self>) -> IntTensor<Self> {
280 unary_op!(tensor, int, |tensor| B::int_prod(tensor) => Int)
281 }
282
283 fn int_prod_dim(tensor: IntTensor<Self>, dim: usize) -> IntTensor<Self> {
284 unary_op!(tensor, int, |tensor| B::int_prod_dim(tensor, dim) => Int)
285 }
286
287 fn int_mean_dim(tensor: IntTensor<Self>, dim: usize) -> IntTensor<Self> {
288 unary_op!(tensor, int, |tensor| B::int_mean_dim(tensor, dim) => Int)
289 }
290
291 fn int_cumsum(tensor: IntTensor<Self>, dim: usize) -> IntTensor<Self> {
292 unary_op!(tensor, int, |tensor| B::int_cumsum(tensor, dim) => Int)
293 }
294
295 fn int_cumprod(tensor: IntTensor<Self>, dim: usize) -> IntTensor<Self> {
296 unary_op!(tensor, int, |tensor| B::int_cumprod(tensor, dim) => Int)
297 }
298
299 fn int_cummin(tensor: IntTensor<Self>, dim: usize) -> IntTensor<Self> {
300 unary_op!(tensor, int, |tensor| B::int_cummin(tensor, dim) => Int)
301 }
302
303 fn int_cummax(tensor: IntTensor<Self>, dim: usize) -> IntTensor<Self> {
304 unary_op!(tensor, int, |tensor| B::int_cummax(tensor, dim) => Int)
305 }
306
307 fn int_argmax(tensor: IntTensor<Self>, dim: usize) -> IntTensor<Self> {
308 unary_op!(tensor, int, |tensor| B::int_argmax(tensor, dim) => Int)
309 }
310
311 fn int_argtopk(tensor: IntTensor<Self>, dim: usize, k: usize) -> IntTensor<Self> {
312 unary_op!(tensor, int, |tensor| B::int_argtopk(tensor, dim, k) => Int)
313 }
314
315 fn int_topk(tensor: IntTensor<Self>, dim: usize, k: usize) -> IntTensor<Self> {
316 unary_op!(tensor, int, |tensor| B::int_topk(tensor, dim, k) => Int)
317 }
318
319 fn int_topk_with_indices(
320 tensor: IntTensor<Self>,
321 dim: usize,
322 k: usize,
323 ) -> (IntTensor<Self>, IntTensor<Self>) {
324 multi_op!(
325 inputs[(tensor, int)],
326 outputs[(out, Int), (indices, Int)],
327 B::int_topk_with_indices(tensor, dim, k)
328 )
329 }
330
331 fn int_argmin(tensor: IntTensor<Self>, dim: usize) -> IntTensor<Self> {
332 unary_op!(tensor, int, |tensor| B::int_argmin(tensor, dim) => Int)
333 }
334
335 fn int_abs(tensor: IntTensor<Self>) -> IntTensor<Self> {
336 unary_op!(tensor, int, |tensor| B::int_abs(tensor) => Int)
337 }
338
339 fn int_swap_dims(tensor: IntTensor<Self>, dim1: usize, dim2: usize) -> IntTensor<Self> {
340 unary_op!(tensor, int, |tensor| B::int_swap_dims(tensor, dim1, dim2) => Int)
341 }
342
343 fn int_permute(tensor: IntTensor<Self>, axes: &[usize]) -> IntTensor<Self> {
344 unary_op!(tensor, int, |tensor| B::int_permute(tensor, axes) => Int)
345 }
346
347 fn int_flip(tensor: IntTensor<Self>, axes: &[usize]) -> IntTensor<Self> {
348 unary_op!(tensor, int, |tensor| B::int_flip(tensor, axes) => Int)
349 }
350
351 fn int_random(
352 shape: Shape,
353 distribution: burn_backend::Distribution,
354 device: &DispatchDevice,
355 dtype: IntDType,
356 ) -> IntTensor<Self> {
357 creation_op!(Int, device, |device| {
358 B::int_random(shape, distribution, device, dtype)
359 })
360 }
361
362 fn int_expand(tensor: IntTensor<Self>, shape: Shape) -> IntTensor<Self> {
363 unary_op!(tensor, int, |tensor| B::int_expand(tensor, shape) => Int)
364 }
365
366 fn bitwise_and(lhs: IntTensor<Self>, rhs: IntTensor<Self>) -> IntTensor<Self> {
367 binary_op!((lhs, int), (rhs, int), |lhs, rhs| B::bitwise_and(lhs, rhs) => Int)
368 }
369
370 fn bitwise_and_scalar(lhs: IntTensor<Self>, rhs: Scalar) -> IntTensor<Self> {
371 unary_op!(lhs, int, |lhs| B::bitwise_and_scalar(lhs, rhs) => Int)
372 }
373
374 fn bitwise_or(lhs: IntTensor<Self>, rhs: IntTensor<Self>) -> IntTensor<Self> {
375 binary_op!((lhs, int), (rhs, int), |lhs, rhs| B::bitwise_or(lhs, rhs) => Int)
376 }
377
378 fn bitwise_or_scalar(lhs: IntTensor<Self>, rhs: Scalar) -> IntTensor<Self> {
379 unary_op!(lhs, int, |lhs| B::bitwise_or_scalar(lhs, rhs) => Int)
380 }
381
382 fn bitwise_xor(lhs: IntTensor<Self>, rhs: IntTensor<Self>) -> IntTensor<Self> {
383 binary_op!((lhs, int), (rhs, int), |lhs, rhs| B::bitwise_xor(lhs, rhs) => Int)
384 }
385
386 fn bitwise_xor_scalar(lhs: IntTensor<Self>, rhs: Scalar) -> IntTensor<Self> {
387 unary_op!(lhs, int, |lhs| B::bitwise_xor_scalar(lhs, rhs) => Int)
388 }
389
390 fn bitwise_not(tensor: IntTensor<Self>) -> IntTensor<Self> {
391 unary_op!(tensor, int, |tensor| B::bitwise_not(tensor) => Int)
392 }
393
394 fn bitwise_left_shift(lhs: IntTensor<Self>, rhs: IntTensor<Self>) -> IntTensor<Self> {
395 binary_op!((lhs, int), (rhs, int), |lhs, rhs| B::bitwise_left_shift(lhs, rhs) => Int)
396 }
397
398 fn bitwise_left_shift_scalar(lhs: IntTensor<Self>, rhs: Scalar) -> IntTensor<Self> {
399 unary_op!(lhs, int, |lhs| B::bitwise_left_shift_scalar(lhs, rhs) => Int)
400 }
401
402 fn bitwise_right_shift(lhs: IntTensor<Self>, rhs: IntTensor<Self>) -> IntTensor<Self> {
403 binary_op!((lhs, int), (rhs, int), |lhs, rhs| B::bitwise_right_shift(lhs, rhs) => Int)
404 }
405
406 fn bitwise_right_shift_scalar(lhs: IntTensor<Self>, rhs: Scalar) -> IntTensor<Self> {
407 unary_op!(lhs, int, |lhs| B::bitwise_right_shift_scalar(lhs, rhs) => Int)
408 }
409
410 fn int_cast(tensor: IntTensor<Self>, dtype: IntDType) -> IntTensor<Self> {
411 unary_op!(tensor, int, |tensor| B::int_cast(tensor, dtype) => Int)
412 }
413
414 fn int_unfold(
415 tensor: IntTensor<Self>,
416 dim: usize,
417 size: usize,
418 step: usize,
419 ) -> IntTensor<Self> {
420 unary_op!(tensor, int, |tensor| B::int_unfold(tensor, dim, size, step) => Int)
421 }
422
423 fn int_repeat_dim(tensor: IntTensor<Self>, dim: usize, times: usize) -> IntTensor<Self> {
424 unary_op!(tensor, int, |tensor| B::int_repeat_dim(tensor, dim, times) => Int)
425 }
426
427 fn int_cat(tensors: Vec<IntTensor<Self>>, dim: usize) -> IntTensor<Self> {
428 vec_op!(tensors, int, |tensors| B::int_cat(tensors, dim) => Int)
429 }
430
431 fn int_not_equal(
432 lhs: IntTensor<Self>,
433 rhs: IntTensor<Self>,
434 out_dtype: BoolDType,
435 ) -> BoolTensor<Self> {
436 binary_op!((lhs, int), (rhs, int), |lhs, rhs| B::int_not_equal(lhs, rhs, out_dtype) => Bool)
437 }
438
439 fn int_not_equal_elem(
440 lhs: IntTensor<Self>,
441 rhs: Scalar,
442 out_dtype: BoolDType,
443 ) -> BoolTensor<Self> {
444 unary_op!(lhs, int, |lhs| B::int_not_equal_elem(lhs, rhs, out_dtype) => Bool)
445 }
446
447 fn int_powi(lhs: IntTensor<Self>, rhs: IntTensor<Self>) -> IntTensor<Self> {
448 binary_op!((lhs, int), (rhs, int), |lhs, rhs| B::int_powi(lhs, rhs) => Int)
449 }
450
451 fn int_powi_scalar_impl(lhs: IntTensor<Self>, rhs: Scalar) -> IntTensor<Self> {
452 unary_op!(lhs, int, |lhs| B::int_powi_scalar_impl(lhs, rhs) => Int)
453 }
454
455 fn int_clamp_min(tensor: IntTensor<Self>, min: Scalar) -> IntTensor<Self> {
456 unary_op!(tensor, int, |tensor| B::int_clamp_min(tensor, min) => Int)
457 }
458
459 fn int_clamp_max(tensor: IntTensor<Self>, max: Scalar) -> IntTensor<Self> {
460 unary_op!(tensor, int, |tensor| B::int_clamp_max(tensor, max) => Int)
461 }
462
463 fn int_clamp(tensor: IntTensor<Self>, min: Scalar, max: Scalar) -> IntTensor<Self> {
464 unary_op!(tensor, int, |tensor| B::int_clamp(tensor, min, max) => Int)
465 }
466
467 fn int_neg(tensor: IntTensor<Self>) -> IntTensor<Self> {
468 unary_op!(tensor, int, |tensor| B::int_neg(tensor) => Int)
469 }
470
471 fn int_zeros(shape: Shape, device: &DispatchDevice, dtype: IntDType) -> IntTensor<Self> {
472 creation_op!(Int, device, |device| B::int_zeros(shape, device, dtype))
473 }
474
475 fn int_ones(shape: Shape, device: &DispatchDevice, dtype: IntDType) -> IntTensor<Self> {
476 creation_op!(Int, device, |device| B::int_ones(shape, device, dtype))
477 }
478
479 fn int_full(
480 shape: Shape,
481 fill_value: Scalar,
482 device: &DispatchDevice,
483 dtype: IntDType,
484 ) -> IntTensor<Self> {
485 creation_op!(Int, device, |device| B::int_full(
486 shape, fill_value, device, dtype
487 ))
488 }
489
490 fn int_mean(tensor: IntTensor<Self>) -> IntTensor<Self> {
491 unary_op!(tensor, int, |tensor| B::int_mean(tensor) => Int)
492 }
493
494 fn int_max(tensor: IntTensor<Self>) -> IntTensor<Self> {
495 unary_op!(tensor, int, |tensor| B::int_max(tensor) => Int)
496 }
497
498 fn int_max_dim(tensor: IntTensor<Self>, dim: usize) -> IntTensor<Self> {
499 unary_op!(tensor, int, |tensor| B::int_max_dim(tensor, dim) => Int)
500 }
501
502 fn int_max_dim_with_indices(
503 tensor: IntTensor<Self>,
504 dim: usize,
505 ) -> (IntTensor<Self>, IntTensor<Self>) {
506 multi_op!(
507 inputs[(tensor, int)],
508 outputs[(out, Int), (indices, Int)],
509 B::int_max_dim_with_indices(tensor, dim)
510 )
511 }
512
513 fn int_max_abs(tensor: IntTensor<Self>) -> IntTensor<Self> {
514 unary_op!(tensor, int, |tensor| B::int_max_abs(tensor) => Int)
515 }
516
517 fn int_max_abs_dim(tensor: IntTensor<Self>, dim: usize) -> IntTensor<Self> {
518 unary_op!(tensor, int, |tensor| B::int_max_abs_dim(tensor, dim) => Int)
519 }
520
521 fn int_min(tensor: IntTensor<Self>) -> IntTensor<Self> {
522 unary_op!(tensor, int, |tensor| B::int_min(tensor) => Int)
523 }
524
525 fn int_min_dim(tensor: IntTensor<Self>, dim: usize) -> IntTensor<Self> {
526 unary_op!(tensor, int, |tensor| B::int_min_dim(tensor, dim) => Int)
527 }
528
529 fn int_min_dim_with_indices(
530 tensor: IntTensor<Self>,
531 dim: usize,
532 ) -> (IntTensor<Self>, IntTensor<Self>) {
533 multi_op!(
534 inputs[(tensor, int)],
535 outputs[(out, Int), (indices, Int)],
536 B::int_min_dim_with_indices(tensor, dim)
537 )
538 }
539
540 fn int_transpose(tensor: IntTensor<Self>) -> IntTensor<Self> {
541 unary_op!(tensor, int, |tensor| B::int_transpose(tensor) => Int)
542 }
543
544 fn int_arange_step(
545 range: core::ops::Range<i64>,
546 step: usize,
547 device: &DispatchDevice,
548 dtype: IntDType,
549 ) -> IntTensor<Self> {
550 creation_op!(Int, device, |device| B::int_arange_step(
551 range, step, device, dtype
552 ))
553 }
554
555 fn int_arange(
556 range: core::ops::Range<i64>,
557 device: &DispatchDevice,
558 dtype: IntDType,
559 ) -> IntTensor<Self> {
560 creation_op!(Int, device, |device| B::int_arange(range, device, dtype))
561 }
562
563 fn int_any(tensor: IntTensor<Self>, out_dtype: BoolDType) -> BoolTensor<Self> {
564 unary_op!(tensor, int, |tensor| B::int_any(tensor, out_dtype) => Bool)
565 }
566
567 fn int_any_dim(tensor: IntTensor<Self>, dim: usize, out_dtype: BoolDType) -> BoolTensor<Self> {
568 unary_op!(tensor, int, |tensor| B::int_any_dim(tensor, dim, out_dtype) => Bool)
569 }
570
571 fn int_all(tensor: IntTensor<Self>, out_dtype: BoolDType) -> BoolTensor<Self> {
572 unary_op!(tensor, int, |tensor| B::int_all(tensor, out_dtype) => Bool)
573 }
574
575 fn int_all_dim(tensor: IntTensor<Self>, dim: usize, out_dtype: BoolDType) -> BoolTensor<Self> {
576 unary_op!(tensor, int, |tensor| B::int_all_dim(tensor, dim, out_dtype) => Bool)
577 }
578
579 fn int_sign(tensor: IntTensor<Self>) -> IntTensor<Self> {
580 unary_op!(tensor, int, |tensor| B::int_sign(tensor) => Int)
581 }
582
583 fn int_sort(tensor: IntTensor<Self>, dim: usize, descending: bool) -> IntTensor<Self> {
584 unary_op!(tensor, int, |tensor| B::int_sort(tensor, dim, descending) => Int)
585 }
586
587 fn int_sort_with_indices(
588 tensor: IntTensor<Self>,
589 dim: usize,
590 descending: bool,
591 ) -> (IntTensor<Self>, IntTensor<Self>) {
592 multi_op!(
593 inputs[(tensor, int)],
594 outputs[(out, Int), (indices, Int)],
595 B::int_sort_with_indices(tensor, dim, descending)
596 )
597 }
598
599 fn int_argsort(tensor: IntTensor<Self>, dim: usize, descending: bool) -> IntTensor<Self> {
600 unary_op!(tensor, int, |tensor| B::int_argsort(tensor, dim, descending) => Int)
601 }
602}