The probably most efficient way to do so should be
assert not torch.isnan(myTensor).any()

as there is no view included (since it isn’t necessary here) , no dimension has to be inferred, and calling any()  on a ByteTensor should be quite efficient itself.