I need to make sure that a given Parameter tensor from a Module is kept sorted.
This tensor is updated by the optimizer at each step, but is there an elegant way to have some “callback” function called whenever it is modified, so that I may sort it when necessary ?
This is not so easy, because that tensor is a Parameter, which means I cannot just change its values, apparently.
Furthermore, I would like this behaviour of that member from my module to be “built-in”: I don’t want a user having to manually sort it each time he-she calls an optimizer step !
is there some more way to track that a class member for a module has been changed ?