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

Custom rule for a function that returns an int + arrays #2191

Open
ebchin opened this issue Dec 7, 2024 · 0 comments
Open

Custom rule for a function that returns an int + arrays #2191

ebchin opened this issue Dec 7, 2024 · 0 comments

Comments

@ebchin
Copy link

ebchin commented Dec 7, 2024

I have a function that takes in some arrays of data and their sizes, processes that data, then returns a couple of arrays and their length (the size of the arrays returned are not known at compile time). I'd like to write a custom rule for the forward mode derivative of this function, but I haven't been able to figure out the syntax when the derivative is called inside another function.

I've tried using the return value to return the size of the arrays, but this caused a crash in clang 15 (see https://fwd.gymni.ch/Kca0sM for a simplified example).

I've also passed in the array size int as a pointer. This works when calling __enzyme_fwddiff() directly on the function, but when I call __enzyme_fwddiff() on another function that then calls this function, the custom rule is ignored (see a simplified example at https://fwd.gymni.ch/snIxLG).

I’ve found a few workarounds to get it working for now (switch the int for a double or initialize with magic numbers before calling the function), but I’d really appreciate some help finding a more natural way to do this.

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

No branches or pull requests

1 participant