Skip to content

Determine semantics of "grad"/"backward" for integral scalar types #29

Description

@oir

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Design question

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions