title: Create a torch::Tensor from C/C++ array without using "from_blob(...)..."
body: <p>Using the C++ libtorch frontend for <a href="https://pytorch.org/" rel="nofollow noreferrer"><code>Pytorch</code></a></p>
  <p>I want to create a  <code>torch::Tensor</code> from a C++ <code>double[]</code> array.  Comming from a legacy C/C++ API.
  I could not find a simple documentation about the subject not in <a href="https://pytorch.org/cppdocs/frontend.html" rel="nofollow noreferrer">docs</a> nor in the forums.</p>
  <p>Something like:</p>
  <pre><code>double array[5] = {1, 2, 3, 4, 5};   // or double *array;
  auto tharray = torch::Tensor(array, 5, torch::Device(torch::kCUDA));
  </code></pre>
  <p>The only thing I found is to use <code>torch::from_blob</code> but then I would have to <code>clone()</code> and use <code>to(device)</code> if I wanted to use it with CUDA.</p>
  <pre><code>double array[] = { 1, 2, 3, 4, 5};. // or double *array;
  auto options = torch::TensorOptions().dtype(torch::kFloat64);
  torch::Tensor tharray = torch::from_blob(array, {5}, options);
  </code></pre>
  <p>Is there any cleaner way of doing so?</p>