Skip to content

Repeted evaluation of fx0 when computing forward differences for gradients #202

Closed

Description

@junyuan-chen

For f that maps a vector of length N to a scalar, I am expecting f to be evaluated for only N+1 times with fdtype == Val(:forward). What actually happens is that the same fx0 = f(x) is evaluated for N times as iterating across all elements of the input vector. Hence, f is called 2N times!

See the line below that should be pulled out of the loop:

fx0 = f(x)

Activity

  1. added a commit that references this issue on Aug 16, 2025
    1f15677
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

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