FloatTracker.jl icon indicating copy to clipboard operation
FloatTracker.jl copied to clipboard

Improve TrackedFloat-wrapping functions

Open ashton314 opened this issue 2 years ago • 3 comments

Per discussion on RXInfer.jl#116 it would be nice to have some functions to make it easier to wrap inputs in the TrackedFloat type.

ashton314 avatar May 24 '23 17:05 ashton314

Concretely:

  1. track(x) to traverse the array x and replace all floats with TFs. Use TrackedFloat64 as the default but allow changes.
  2. @track foo(...) to replace all Float-like types in the function signature with TF

Is 2 needed? I'm thinking no, because TF is a subtype of the matching floats and the type alone doesn't do any converting. (foo(4.2) would be an error).

bennn avatar May 24 '23 19:05 bennn

I think it'd be neat for 2 if we could hijack the original function so if it gets called with non-TrackedFloats, we wrap it and then call again.

ashton314 avatar May 24 '23 20:05 ashton314

Yes, that'd be great! Just like a Python decorator.

bennn avatar May 25 '23 18:05 bennn