Well, if the indices are “small numbers”, you could make a caching tensor.
But if your code is parallelized and you need to compute some indices anyways, the speed gains might be limited and it’ll be a lot of bookkeeping to get this right.
Best regards
Thomas