New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Tensor::unroll() work with iterators. #12692
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine by me, but I would prefer if you didn't move the make_array_view()
functions that related to tensors -- these need to be deprecated anyway, so they might as well stay where they currently are.
Returning an array isn't going to work - MSVC cannot handle Instead I implemented a new version of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you still missing the ArrayView
constructor for tensors with rank>1?
Do you mean rank > 0? That was already there - I added the rank = 0 version. I don't need it any more for this PR so I think I will drop the commit anyway. |
OK with me. The naming is not important. /rebuild |
The CI check failed with an internal compiler error. I suspect it has nothing to do with your patch, but just to be on the safe side, could you rebase and push to start the check again? |
This makes the code applicable for more linear data structures than just Vector.
Alternative to #12684 and #12685. Conflicts with #12685 and #12691.If we want to get rid of
make_array_view(Tensor)
then we should offer a different way to convert theTensor
into a contiguous array.This PR adds a new functionThis PR addsTensor::to_array()
that does exactly that so that we do not need to do it manually whenever the need arises.Tensor::unroll(begin, end)
which populates some output structure with tensor values.A related change is thatTensor
has a constructor which takes anArrayView
as an argument, but we can only forward-declareArrayView
in that file due to the opposite-order dependency inarray_view.h
(inmake_array_view(Tensor &)
). I addressed that by moving themake_array_view()
functions into the other headers.