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

Migrate #[autodiff] and #[rustc_autodiff] to the new attribute parser. #137774

Open
ZuseZ4 opened this issue Feb 28, 2025 · 2 comments
Open

Migrate #[autodiff] and #[rustc_autodiff] to the new attribute parser. #137774

ZuseZ4 opened this issue Feb 28, 2025 · 2 comments
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools C-cleanup Category: PRs that clean code up or issues documenting cleanup. F-autodiff `#![feature(autodiff)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ZuseZ4
Copy link
Member

ZuseZ4 commented Feb 28, 2025

Location

I think the author wants to add info to the rustc dev guide.

Summary

Hi @jdonszelmann,
first of all, thanks for the attribute refactor work and congrats on landing your big pr!
I recently introduced an #[autodiff] macro which can be applied on top of a function, and generates a second function. Both of the function then automatically receive a #[rustc_autodiff] attribute.
On of the two rustc_autodiff attributes, as well as the original autodiff macro take user arguments, so there is some duplicated parsing and verification. I'd like to move over to the new infra, and since a few people offered to help with autodiff, I thought this might be a nice opportunity to introduce them to it.
For reference, this was the original autodiff frontend PR: #129458

As a dummy example:

#[autodiff(df, Reverse, Duplicated, Duplicated)]
fn f(x: &f32, y: &mut f32) { *y  *= *x; }

would expand to:

#[rustc_autodiff]
fn f(x: &f32, y: &mut f32) { *y  *= *x; }
#[rustc_autodiff(Reverse, Duplicated, Duplicated)]
fn df(x: &f32, dx: &f32, y: &mut f32, dy: &mut f32) { // dummy code }

I think you haven't yet completed your plan to write a migration guide for the rustc-dev-guide, but do you have a migration PR that you can recommend to us as a blueprint to see how this could be done? Also, I don't know too much about your rework. Do you think the migration is going to end up as one big PR, or is it possible to split the work up?

@ZuseZ4 ZuseZ4 added the A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools label Feb 28, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 28, 2025
@jdonszelmann
Copy link
Contributor

Yes, see #137687 for now. I'm also available for questions on zulip

@jdonszelmann
Copy link
Contributor

jdonszelmann commented Feb 28, 2025

Though you shouldn't have to deal with the limited pre-ast lowering parsing

@jieyouxu jieyouxu added C-cleanup Category: PRs that clean code up or issues documenting cleanup. A-attributes Area: Attributes (`#[…]`, `#![…]`) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-discussion Category: Discussion or questions that doesn't represent real issues. F-autodiff `#![feature(autodiff)]` and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. C-discussion Category: Discussion or questions that doesn't represent real issues. labels Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools C-cleanup Category: PRs that clean code up or issues documenting cleanup. F-autodiff `#![feature(autodiff)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants