Stop =torch.Tensor()[0] from segfaulting

Move precondition checks up to prevent element access from set-faulting.