-
-
Notifications
You must be signed in to change notification settings - Fork 237
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
Support for views, spans, iterators? #415
Comments
Hi, and thanks for the nice feedback and the interesting suggestion. Using |
True; but you could enable it conditionally if the compiler has this built-in. There are also third-party implementations of span for pre C++-20 compilers. Spans also meet requirements for contiguous iterators, so it might be best to template it and be agnostic to the exact implementation - just assuming we have a non-owning view on the input which we can run over and read, and possibly also a view on the output we can increment and write to. |
Copying the input data from a span into a vector should usually not be significant regarding speed or memory usage, since in the prediction step of most models, much more is happening. With such a small gain as the potential win, I'm not sure if it's worth the complexity. Are you interested in proposing an implementation in a PR? |
I'm pretty short on time right now, but if I end up looking into it as part of the current project, then definitely happy to get something committed. |
Hi,
Thanks for this! C++ is making NNs a little bit tolerable. If I could train with this in lieu of python at all, life would be much better!!
It seems that
tensor
/tensors
only have constructors for working directly with vectors of data. Would it be possible to support some other contiguous views, such as iterators, std::span, or maybe something from the ranges library, etc.?I'm currently iterating over a long time series of data, and feeding in data one sequence at a time, to an LSTM-based model. It'd be nice if I could provide some non-owning reference to the start of the current page, and then the same for where frugally-deep can place the outputs, as currently I am copying into a shorter vector, running inference, and copying the output. I assume a copy of about 512 values is negligible compared to everything else that will be going on, but it'd still be nice to have. I assume a span would be the lowest-overhead way to achieve this.
Are there any technical reasons why this wouldn't be possible?
Thanks
The text was updated successfully, but these errors were encountered: