Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat : added nansum function for Pytorch frontend #23206

Merged
merged 11 commits into from
Sep 18, 2023
2 changes: 1 addition & 1 deletion .idea/ivy.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/runConfigurations/_template__of_py_test.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions ivy/functional/frontends/torch/reduction_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ def moveaxis(input, source, destination):
def nanmean(input, dim=None, keepdim=False, *, dtype=None, out=None):
return ivy.nanmean(input, axis=dim, keepdims=keepdim, dtype=dtype, out=out)

@numpy_to_torch_style_args
@to_ivy_arrays_and_back
def nansum(input, dim=None, keepdim=False, dtype=None, out=None):
return ivy.nansum(input, axis=dim, keepdims=keepdim, dtype=dtype, out=out)


@to_ivy_arrays_and_back
@with_supported_dtypes(
Expand Down
33 changes: 33 additions & 0 deletions ivy_tests/test_ivy/test_frontends/test_torch/test_reduction_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,39 @@ def test_torch_nanmean(
keepdim=keepdims,
)

@handle_frontend_test(
fn_tree="torch.nansum",
dtype_and_x=_statistical_dtype_values(
function="nansum",
min_value=-1e04,
max_value=1e04,
),
keepdims=st.booleans(),
)
def test_torch_nansum(
*,
dtype_and_x,
keepdims,
on_device,
fn_tree,
frontend,
test_flags,
backend_fw,
):
input_dtype, x, axis = dtype_and_x
helpers.test_frontend_function(
input_dtypes=input_dtype,
backend_to_test=backend_fw,
frontend=frontend,
test_flags=test_flags,
fn_tree=fn_tree,
on_device=on_device,
input=x[0],
dim=axis,
keepdim=keepdims,
juliagsy marked this conversation as resolved.
Show resolved Hide resolved
rtol=1e-02,
atol=1e-02,
)

# norm
@handle_frontend_test(
Expand Down
Loading