Proposal: Tagging API#815
Conversation
Apparently that approach is completely unsound: #748 (comment) |
|
Yes, that particular PR was unsound, but there are more options for tags defined at runtime, if someone wants to give it a try (one of the alternatives in #807 was via objectid) |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #815 +/- ##
==========================================
- Coverage 90.74% 90.25% -0.49%
==========================================
Files 11 11
Lines 1070 1078 +8
==========================================
+ Hits 971 973 +2
- Misses 99 105 +6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
tests are finally passing (except for |
|
I think the motivation for this change is missing and its design is unclear without clearly designed alternative tagging systems. Without such it's also not clear to me whether this would solve any actual problems and whether eg combinations of different tagging systems would create new problems. |
The main motivation for this PR is to allow experimenting with alternative tag designs. #748 is closed and #807 is stalled in its current form. For a proof of concept, i made an alternative tagging system, based on #807 (comment) along with a closure workaround That tag system in particular takes the tradeoff of a more cumbersome function definition in exchange of faster compile times; while the package itself does not have tests, the branch is used as AD provider for Clapeyron.jl, where we use up to 4th order nested duals for some functions.
On the interaction between two tagging systems, and in particular, the interaction of a external tagging system and the current (the extension code is broken at the moment if you want to load it as a standalone package, but the rest should work) |
This PR proposes a Tagging API. the main objective is to provide external ForwardDiff users a way to control tag generation and comparison. The API is composed of:
AbstractTag{F,V}: Abstract type for all tags following the Tagging API.maketag(f::F,::Type{V}): generates an instance of a tag, given an instance of a functionfand a element typeVwill generate a tag that follows the tag API.Some invariants:
fand a element typeV.Vshould be a number (not enforced at theAbstractTaglevel, i don't know if any package does something weird here)f::F, wherefshould behave according to the context it was usedNote that the invariants above do not imply that
maketagtype(f::F,::Type{V}) == MyTag{F,V}. For example,Fcould have additional information about closed-over variables that we want to move over toV.One application for this API is to create a
StaticTagtype that does comparisons via inspecting the fields of the closures (like what's proposed in #807), or for aHashedTagtype (like what was tried in #748). More importantly, experimenting with new tag types can be done in external packages, instead of PRs toForwardDiff.Closes #813
Any comments are really appreciated.