Skip to content

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

Open
@ebchin

Description

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions