All `make_partials_propagator` to return its input args as a tuple

Đang mở
#3,423 4 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ái cấu trúc
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Sôi nổi
Công nghệ
cpp
Lĩnh vực
backend

Hướng nghiên cứu

Start at the make_partials_propagator entry point and inspect the distributions' ref_type_t boilerplate. Trace how autodiff and non-autodiff arguments are handled, then define the tuple-returning behavior so local references reuse the moved memory. Done means the affected distributions use this interface without unnecessary copies.

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

Mô tả

code cleanup distributions performance

When a user calls something like normal_lpdf(std::move(y), std::move(mu), std::move(sigma)) nothing really happens with the moved memory. But we could actually move those objects into the partials_propagator so that the partials_propagator does not have to make a hard copy of the inputs. A nice piece would be if make_partials_propagator returned a tuple of the partials propagator and references to the moved memory so that the functions would reuse that local memory.

auto [partials_prop, y_ref, mu_ref, sigma_ref] = make_partials_propagator(
  std::move(y), std::move(mu), std::move(sigma));

For autodiff types the inputs would be moved into the partials propagator and then references to the object would be the return. For non-autodiff types the object would just be passed back

This would replace a lot of the ref_type_t boilerplate inside of the distributions since the values would then sit inside of the partials propagator.

This would be useful inside of the stanc compiler. We could have an optimization pass which looks at the last use of each vector/array in the log_prob function and applies std::move to the object at that point.

Ngôn ngữ chính
C++
Star
845
Fork
225
Merge trung bình
4 ngày 21 giờ
Pull request đã merge (30 ngày)
13

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

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 stan-dev/math

Tất cả issue của stan-dev/math

Issue tương tự

Thêm issue về C++

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.