Hi Hmmm!



 HmmmmML:

        self._delay = torch.nn.Parameter(torch.FloatTensor([offset]))
...
        self._write_ptr = int(self._delay.item())
...
            # Write
            self.circ_buffer[self._write_ptr] = x_i
            # Read (with linear interpolation)
            i0 = np.floor(self._read_ptr).astype(int)
            i1 = (i0 + 1) % self.N
            frac = self._read_ptr - np.floor(self._read_ptr)
            y[i] = self.circ_buffer[i0] + frac*(self.circ_buffer[i1]-self.circ_buffer[i0])



Although _delay is a Parameter and potentially trainable, at a technical
level, as soon as you call .item() on it you “break the computation graph,”
as the result of .item() is no longer a pytorch tensor and therefore no
longer participates in autograd.
At a more conceptual level, you then call python’s int() (on the result of
.item()).  int() is not (usefully) differentiable, so even if you performed
that logic using pytorch tensor operations, you would still not be able to
backpropagate gradients through that step in the computation.
I don’t understand your use case, so I don’t know whether this would
work, but, at least in terms of differentiability, you might try performing
an “interpolated write,” analogously to the interpolated read that you
have implemented.
Best.
K. Frank