Closed awf closed 2 years ago
e.g. does this mean that you have to fix the value of
generate_lm
? If you want to compare the behavoiur ofgenerate_lm=False
withgenerate_lm=True
, you have to write a second copy of the function?
A decorator can also be called directly on a function, so you can write
def fun(..):
...
fun_lm = knossos.register(fun, generate_lm=True)
fun_nolm = knossos.register(fun, generate_lm=False)
Before:
The user needs to find a point at which to explicitly call knossos compilation, and must switch from use of the original function to the compiled version.
This was fine for experimentation, but this PR moves toward a smoother user experience, and is a prelude to vmap
After:
Functions are decorated with
@knossos.register
, and compilation can be explicit, or delayed to the first call.Endows f with the following behaviours
The implementation delays compilation until the first call, or when "f.compile()" is explicitly called.