Anonymous function creation is slow, and almost always necessary

Đang mở
#873 9 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
julia
Lĩnh vực
backend

Hướng nghiên cứu

Start by reading the ForwardDiff method signatures that accept functions and initial values; the issue does not name specific files or tests. Check how DifferentialEquations handles call-site parameters, then determine the scope and compatibility implications of adding a similar option. Done means ForwardDiff can accept parameters at the call site without relying on a closure that captures changing state.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Suppose I have a function f(x::Vector, p::SomeData), which I want to compute the Jacobian of. A common way to do this is

p = generate_some_data()
jac = ForwardDiff(x -> f(x, p), x0)

which has very bad performance on every call because we are instantiating a new anonymous function every time, which triggers compilation. A more clever way of doing this is

partially_applied_f = x -> f(x, p)
#repeat the lines below as much as needed
p = generate_some_data()
jac = ForwardDiff(partially_applied_f, x0)

which introduces a weird invisible dependency of the calls of partially_applied_f on the current state of p. Would it be feasible to update method signatures in this package to accept parameters at the call site? Such that the following code is valid:

p = generate_some_data()
jac = ForwardDiff(f, x0, parameter = p)

DifferentialEquations already do something similar with their method calls. This would remove a lot of overhead and imprevisibility in my use cases.

Ngôn ngữ chính
Julia
Star
1k
Fork
165
Merge trung bình
8 ngày 22 giờ
Pull request đã merge (30 ngày)
3

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của JuliaDiff/ForwardDiff.jl

Tất cả issue của JuliaDiff/ForwardDiff.jl

Issue tương tự

Thêm issue về Julia

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.