Tullio.jl
Tullio.jl copied to clipboard
Way to Disable Gradient Calculations "By Default"
My code won't require gradient calculations. Is there a way to disable gradient calculations for a large block of code, or to set the gradient calculations to be off unless I specifically request them?
Yes, if you write @tullio grad=false with no expression to calculate, this should update a global setting, which will apply to all subsequent macro calls. (It isn't per-module or anything, perhaps a little fragile?)
Yes, if you write
@tullio grad=falsewith no expression to calculate, this should update a global setting, which will apply to all subsequent macro calls. (It isn't per-module or anything, perhaps a little fragile?)
Hmm -- yeah, if the setting is 100% global and not limited to a module or function, I'll make sure to avoid using that, since it could cause other people's code to break otherwise.
It got written mostly as a way to run the same tests with different settings for gradients / threads / LoopVectorization etc. I agree it's not exactly an enterprise-grade mechanism, but sometimes handy for scripts etc. when you are in control. Or wish to temporarily disable something to debug.
Note that the gradient computation is just that, at macro expansion time, it generates a second set of functions by symbolically differentiating the right hand side of the given expression. These functions will never be called unless you take a derivative, never even compiled. That's why the default of always doing this makes some sense.