Skip to content

Commit

Permalink
add more functions to test
Browse files Browse the repository at this point in the history
  • Loading branch information
Aarsh2001 committed Nov 5, 2023
1 parent 728db54 commit a108e75
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test_scripts/sample_torch_source_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -3032,3 +3032,27 @@ def nansum(
"""
dtype = ivy.as_native_dtype(dtype)
return torch.nansum(x, dim=axis, keepdim=keepdims, dtype=dtype)


def diff(
x: Union[torch.Tensor, list, tuple],
/,
*,
n: int = 1,
axis: int = -1,
prepend: Optional[Union[torch.Tensor, int, float, list, tuple]] = None,
append: Optional[Union[torch.Tensor, int, float, list, tuple]] = None,
out: Optional[torch.Tensor] = None,
) -> torch.Tensor:
x = x if isinstance(x, torch.Tensor) else torch.tensor(x)
prepend = (
prepend
if isinstance(prepend, torch.Tensor) or prepend is None
else torch.tensor(prepend)
)
append = (
append
if isinstance(append, torch.Tensor) or append is None
else torch.tensor(append)
)
return torch.diff(x, n=n, dim=axis, prepend=prepend, append=append)

0 comments on commit a108e75

Please sign in to comment.