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

[RFC] Add result accuracy to unary ops #2592

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Conversation

hanrach9
Copy link

@hanrach9 hanrach9 commented Oct 15, 2024

This is a proposal to add result_accuracy attribute to the following transcendental unary ops to StableHLO: exp, expm1, log, logp1, logistic, recp, sqrt, rsqrt, cbrt, sin, cos and tanh. Any feedback would be appreciated, thanks!

Proposal to add result_accuracy to the following transcendental unary ops: `exp`, `expm1`, `log`, `logp1`, `logistic` and `tanh`.
[RFC] Add result accuracy to transcendental unary ops
@hanrach9 hanrach9 marked this pull request as draft October 15, 2024 23:14
@hanrach9 hanrach9 marked this pull request as ready for review October 16, 2024 22:37
## Overview

This RFC proposes adding a new attribute `result_accuracy` to the following
transcendental unary ops: `exp`, `expm1`, `log`, `logp1`, `logistic` and `tanh`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason sqrt and rsqrt is not in the list?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it should be should be supported for sqrt, rsqrt, cos, sin and recp too. Will update the doc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is recp? I don't think we have an op for that

Copy link
Member

@ghpvnist ghpvnist Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI atan2 and tan are the two remaining transcendental ops not in this list (atan2 seems to be the only binary op)

Copy link
Author

@hanrach9 hanrach9 Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

recp is divide. So the complete list will be sin, cos, tan, divide, sqrt, rqrt, cbrt, exp, expm1, log, logp1, logistic and erf. Is erf supported?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would make divide the only binary op on this list.. which feels strange. Is this right that this proposal should be extended in scope to binary ops?

rfcs/20241015-result-accuracy.md Outdated Show resolved Hide resolved
@hanrach9 hanrach9 changed the title [RFC] Add result accuracy to transcendental unary ops [RFC] Add result accuracy to unary ops Oct 23, 2024
The inequality will be checked against the errors of each implementation and the
one that can satisfy the constraint will be returned. If multiple
implementations satisfy the inequality, the faster implementation will be used.
If none of the implementations can meet the requested tolerance, the compiler
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naive question - Does this mean it's a runtime check that's inserted by the compiler?

Or there's some upfront guarantee / check that's promised by underlying implementations? My interpretation of this sentence makes it sound like the compiler has to first run the operation, then check that the result accuracy was correct and return if error.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No runtime checks, the compiler will look check the request against its implementation errors at compile time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants