As you said, the problem with this approach is the possible non-contiguity of the tensor representation in memory. You can test it with the is-contiguous tensor member function. If your vector is non-contiguous, you can use the strides member function to get for each tensor dimension  the required number of “jumps” between each element of the tensor.
The safest way to achieve constructing a new tensor from the data_ptr of another, would in my opinion be :
auto new_tensor = torch::from_blob(input.data_ptr(), input.sizes(), input.strides(), torch::TensorOptions(torch::kFloat));