Is it possible to detach the recurrent connections of a torch.nn.RNN when calling forward on it?
I could do this with a torch.nn.RNNCell, like this:
rnn = nn.RNNCell(x, h)
input = torch.randn(l, b, x)
hx = torch.randn(b, h)
output = list()
for i in range(l):
    hx = rnn(input[i], hx).detach()
    output.append(hx)

Is there a way to do this without having to explicitly iterate over the sequence? I anticipate that doing it with an RNNCell will make the forward pass much slower.
I could also do it with torch.nn.RNN, but would still have to iterate over the sequence.
Thanks!
(Not sure if this is best for the autograd topic, I guess it could probably fall under NLP as well).