Ideally lineSelect would automatically round float values to their proper discrete indices and would be differentiable.
My plan is to use this method to implement a differentiable 3D renderer in pytorch.

The nearest insight I found on the forum is this but it does not really show out to ‘select’ from a buffer. Indexing a variable with a variable

wrt p0 is a non-differentiable operation, but you can use reinforcement learning, by using the reward(…) function on stochastic variables. so you will first get float indices, and you will stochastically sample from them over a multinomial or something, and you will give this sampled node a reward to propagate gradients back. see pytorch/examples or read on REINFORCE algorithm