|
8 | 8 | clip as _aliases_clip,
|
9 | 9 | unstack as _aliases_unstack,
|
10 | 10 | cumulative_sum as _aliases_cumulative_sum,
|
| 11 | + cumulative_prod as _aliases_cumulative_prod, |
11 | 12 | )
|
12 | 13 | from .._internal import get_xp
|
13 | 14 |
|
@@ -505,6 +506,20 @@ def nonzero(x: array, /, **kwargs) -> Tuple[array, ...]:
|
505 | 506 | raise ValueError("nonzero() does not support zero-dimensional arrays")
|
506 | 507 | return torch.nonzero(x, as_tuple=True, **kwargs)
|
507 | 508 |
|
| 509 | + |
| 510 | +# torch uses `dim` instead of `axis` |
| 511 | +def diff( |
| 512 | + x: array, |
| 513 | + /, |
| 514 | + *, |
| 515 | + axis: int = -1, |
| 516 | + n: int = 1, |
| 517 | + prepend: Optional[array] = None, |
| 518 | + append: Optional[array] = None, |
| 519 | +) -> array: |
| 520 | + return torch.diff(x, dim=axis, n=n, prepend=prepend, append=append) |
| 521 | + |
| 522 | + |
508 | 523 | # torch uses `dim` instead of `axis`
|
509 | 524 | def count_nonzero(
|
510 | 525 | x: array,
|
@@ -765,7 +780,7 @@ def sign(x: array, /) -> array:
|
765 | 780 | 'permute_dims', 'bitwise_invert', 'newaxis', 'conj', 'add',
|
766 | 781 | 'atan2', 'bitwise_and', 'bitwise_left_shift', 'bitwise_or',
|
767 | 782 | 'bitwise_right_shift', 'bitwise_xor', 'copysign', 'count_nonzero',
|
768 |
| - 'divide', |
| 783 | + 'diff', 'divide', |
769 | 784 | 'equal', 'floor_divide', 'greater', 'greater_equal', 'hypot',
|
770 | 785 | 'less', 'less_equal', 'logaddexp', 'maximum', 'minimum',
|
771 | 786 | 'multiply', 'not_equal', 'pow', 'remainder', 'subtract', 'max',
|
|
0 commit comments