-
Notifications
You must be signed in to change notification settings - Fork 5
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
beignet.root_scalar #26
base: main
Are you sure you want to change the base?
Conversation
Questions we should answer before merging:
|
Comparing with scipy maybe this should be renamed to |
x0 = torch.zeros([0]) | ||
|
||
for iteration in range(maxiter): | ||
b = x0 - torch.linalg.solve(torch.func.jacfwd(func)(x0), func(x0)) |
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.
another reason to separate root
and root_scalar
would be to have an implementation that avoids doing a full linear solve for arrays of scalar problems where the jacobian is diagonal.
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.
Yep
output = () | ||
|
||
for g, b2 in zip(grad_outputs, b, strict=True): | ||
output = (*output, -g * b2 / a) |
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.
why is this style preferred? I don't think the original expression with the generator introduces any mutation right?
No description provided.