-
Notifications
You must be signed in to change notification settings - Fork 10
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
fix: missing neg in rsqrt derivative #233
Conversation
The corresponding test needs to be updated: Enzyme-JAX/test/lit_tests/diffrules/stablehlo/rsqrt.mlir Lines 19 to 29 in 4e28cbc
|
@@ -1107,7 +1107,7 @@ def : HLOInactiveOp<"RngBitGeneratorOp">; | |||
def : HLODerivative<"RsqrtOp", (Op $x), | |||
[ | |||
// (Select (FCmpUEQ $x, (ConstantFP<"0"> $x)), (ConstantFP<"0"> $x), (FDiv (DiffeRet), (FMul (ConstantFP<"2"> $x), (Call<(SameFunc), [ReadNone,NoUnwind]> $x)))) | |||
(Div (DiffeRet), (Mul (HLOConstantFP<"2"> $x), (Mul $x, (Sqrt $x)))) | |||
(Neg (Div (DiffeRet), (Mul (HLOConstantFP<"2"> $x), (Mul $x, (Sqrt $x))))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor but can you put the neg on the mul and not on the div? This will enable better constant propagation (since often times differrt will be 1 or 0 or a phi thereof so then it simplifies nicely)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also actually why not just make the constant 2 into -2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also only changes one AD mode, presumably you’ll need to change the 2 to be a -2 in the line above as well
547f9b8
to
c592ee0
Compare
No description provided.