What does it mean to compute "gradients" for nodes that have Int or bool types? Several choices:
- All gradients are zero -- may be mathematically correct (w.r.t. some assumptions I guess -- what is an infinitesimal change in integers?) but wasteful?
::backward() is disabled altogether and has_grad is always false -- this would require template specialization and maybe SFINAE. Another option is to omit SFINAE, so ::backward() still exists and is callable but it would throw at runtime.
::backward() works as if everything is floating and results become whatever they might be when casted back to ints -- this is the "no code change" case where I just instantiate the node with the scalar and assume everything works (some things will not work for sure). This is somewhat semantically similar to integer division of two ints, it's not mathematically correct w.r.t. real division, but it's somewhat approximately correct and somewhat reasonable.
What does it mean to compute "gradients" for nodes that have
Intorbooltypes? Several choices:::backward()is disabled altogether andhas_gradis always false -- this would require template specialization and maybe SFINAE. Another option is to omit SFINAE, so::backward()still exists and is callable but it would throw at runtime.::backward()works as if everything is floating and results become whatever they might be when casted back to ints -- this is the "no code change" case where I just instantiate the node with the scalar and assume everything works (some things will not work for sure). This is somewhat semantically similar to integer division of two ints, it's not mathematically correct w.r.t. real division, but it's somewhat approximately correct and somewhat reasonable.