I think it makes sense not to try and catch all the CUDA-side errors, but would it be possible to institute a check in the index_select function itself (similar to the fixes for the recent slicing issues 17, maybe) that ensure that users don’t try to grab an index that’s not in the array? I.e. if X.size()=[5,5,5] and you call X.index_select(2,5) (or more egregiously X.index_select(2,7)) it raises an error.
Or is the tensor.index_select function just something that’s hard-baked into CUDA that PyTorch doesn’t actually wrap? I might be misunderstanding how it’s put together.