Skip to content

For isclose(), rtol parameter should be explained before atol parameter in orderΒ #139563

@hyperkai

Description

@hyperkai

πŸ“š The doc issue

The doc of isclose() shows the parameters in order as shown below:

torch.isclose(input, other, rtol=1e-05, atol=1e-08, equal_nan=False) β†’ Tensor

And, the formula is explained as shown below:

|input - other| <= atol + rtol x |other|

But rtol parameter is explained after atol parameter as shown below:

Parameters

  • input (Tensor) – first tensor to compare
  • other (Tensor) – second tensor to compare
  • atol (float, optional) – absolute tolerance. Default: 1e-08
  • rtol (float, optional) – relative tolerance. Default: 1e-05 <- Here
  • equal_nan (bool, optional) – if True, then two NaN s will be considered equal. Default: False

Suggest a potential alternative/fix

So, But rtol parameter should be explained before atol parameter in order as shown below:

Parameters

  • input (Tensor) – first tensor to compare
  • other (Tensor) – second tensor to compare
  • rtol (float, optional) – relative tolerance. Default: 1e-05 <- Here
  • atol (float, optional) – absolute tolerance. Default: 1e-08
  • equal_nan (bool, optional) – if True, then two NaN s will be considered equal. Default: False

In addition, the formula is better to be as shown below so that we can easily understand it:

|input - other| <= rtol x |other| + atol

cc @svekars @brycebortree @sekyondaMeta

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: docsRelated to our documentation, both in docs/ and docblockstriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions