EnzymeAD / rust

A rust fork to work towards Enzyme integration
https://www.rust-lang.org
Other
67 stars 9 forks source link

Macro Design #32

Closed ZuseZ4 closed 8 months ago

ZuseZ4 commented 1 year ago

Let's collect some opinions on our current macro design to see if there is some common design that people would rather use than our current options:

1) It's fine that we disagree, but to summarize my point (which may well be misguided):

ZuseZ4 commented 1 year ago

As per zulip discussion we will remove the Return activity in cases where a function returns (), since we anyhow only accept const there and it might confuse users to have to annotate a not existing return.

OwenTrokeBillard commented 9 months ago

I peeked at the unreleased Rust Enzyme book and took notice of the macro syntax.

The current syntax is:

#[autodiff(df, Reverse, Active, Active, Active)]
fn f(x: f32, y: f32) -> f32 {
  x * x + 3.0 * y
}

Have you considered putting the activity declarations next to the arguments? That way it is clear which declarations are associated with which arguments. Something like:

#[autodiff(df, Reverse, Active)]
fn f(#[active] x: f32, #[active] y: f32) -> f32 {
  x * x + 3.0 * y
}

On another note, the book looks great so far. Excellent work as usual.

jedbrown commented 9 months ago

That is in fact supported and I prefer it. I believe for technical reasons, we can't/don't support those inline attributes on the return type.

jedbrown commented 9 months ago

And a word of warning, there are a few syntax bugs in the book currently. I'll fix them (using mdbook test) as soon as the new rebase is ready.

ZuseZ4 commented 9 months ago

I am mostly without internet till end of year, I'll answer in more details in the first days of January. The inline syntax is supported, unless you apply multiple autodiff macros to the same function.