I want to create a torch::zeros
based on a dimension which comes from a std::vector<int> vec
. Apparently it is not possible to create a tensor by torch::zeros(vec)
, since it only accepts the rvalue of arrays like {a,b,c}
or c10::ArrayRef
. Since the length of my size vec
changes, I cannot use {a,b,c}
and I have to follow the second approach. Any idea how can I convert a std:vector
to c10::ArrayRef
?
I also tried passing an array by int* vec = &vec[0];
, still got type conversion error for the api.
Also, I tried to create an arrayRef
via auto dims = c10::ArrayRef<int64_t>(vec.size());
, but torch did not like its syntax.