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

Separating uses of CoDual into distinct types #275

Open
willtebbutt opened this issue Sep 28, 2024 · 0 comments
Open

Separating uses of CoDual into distinct types #275

willtebbutt opened this issue Sep 28, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@willtebbutt
Copy link
Member

Currently CoDual is used for two purposes:

  1. to pair a primal and its fdata, and
  2. to pair a primal and its tangent.

Having two uses for the same type, only distinguishable by the context, is not good design. It was laziness on my part when I introduced fdata / rdata.

A better design would be to have two distinct types: PrimalFDataPair and PrimalTangentPair. These will be abbreviated to PFPair and PTPair respectively (otheriwse the code is going to become a lot more verbose).

Introducing this distinction will also substantially reduce the chances of bugs in interface code (value_and_gradient!!, DifferentiationInterface.jl's wrappers, etc) -- currently it's very straightforward to accidentally make a CoDual containing a primal + tangent, when you ought to have produce a CoDual containing a primal + fdata.

There are a couple of functions which will need to change -- for example zero_fcodual and zero_codual will become zero_primal_fdata_pair and zero_primal_tangent_pair. More verbose names are acceptable for these, as they do not appear in literally every rrule!! signature. There are probably some more that will appear during refactoring.

@willtebbutt willtebbutt added the enhancement New feature or request label Sep 28, 2024
@willtebbutt willtebbutt changed the title Renaming CoDual and separate used Separating uses of CoDual into distinct types Sep 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant