|
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 |
|
@@ -499,6 +500,20 @@ def nonzero(x: array, /, **kwargs) -> Tuple[array, ...]: |
499 | 500 | raise ValueError("nonzero() does not support zero-dimensional arrays") |
500 | 501 | return torch.nonzero(x, as_tuple=True, **kwargs) |
501 | 502 |
|
| 503 | + |
| 504 | +# torch uses `dim` instead of `axis` |
| 505 | +def diff( |
| 506 | + x: array, |
| 507 | + /, |
| 508 | + *, |
| 509 | + axis: int = -1, |
| 510 | + n: int = 1, |
| 511 | + prepend: Optional[array] = None, |
| 512 | + append: Optional[array] = None, |
| 513 | +) -> array: |
| 514 | + return torch.diff(x, dim=axis, n=n, prepend=prepend, append=append) |
| 515 | + |
| 516 | + |
502 | 517 | # torch uses `dim` instead of `axis` |
503 | 518 | def count_nonzero( |
504 | 519 | x: array, |
@@ -748,7 +763,7 @@ def sign(x: array, /) -> array: |
748 | 763 | 'permute_dims', 'bitwise_invert', 'newaxis', 'conj', 'add', |
749 | 764 | 'atan2', 'bitwise_and', 'bitwise_left_shift', 'bitwise_or', |
750 | 765 | 'bitwise_right_shift', 'bitwise_xor', 'copysign', 'count_nonzero', |
751 | | - 'divide', |
| 766 | + 'diff', 'divide', |
752 | 767 | 'equal', 'floor_divide', 'greater', 'greater_equal', 'hypot', |
753 | 768 | 'less', 'less_equal', 'logaddexp', 'maximum', 'minimum', |
754 | 769 | 'multiply', 'not_equal', 'pow', 'remainder', 'subtract', 'max', |
|
0 commit comments