-
Notifications
You must be signed in to change notification settings - Fork 14
Switch vector to Tensor class #116
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some aspects of flatbuffers are really slow (like construction) and we weren't really using flatbuffers in the way that they were intended anyway. This is a complete rewrite of the PMTs using std::variants. The code is much simpler and the performance is better (and in some cases an order of magnitude better). The code now requires c++20 as well. Signed-off-by: John Sallay <[email protected]>
Signed-off-by: Josh Morman <[email protected]> Signed-off-by: John Sallay <[email protected]>
Signed-off-by: Josh Morman <[email protected]> Signed-off-by: John Sallay <[email protected]>
Signed-off-by: John Sallay <[email protected]>
Signed-off-by: John Sallay <[email protected]>
Signed-off-by: John Sallay <[email protected]>
Signed-off-by: John Sallay <[email protected]>
Signed-off-by: John Sallay <[email protected]>
Signed-off-by: John Sallay <[email protected]>
Signed-off-by: John Sallay <[email protected]>
Signed-off-by: John Sallay <[email protected]>
* switch to C++23 (README, meson cpp_std=c++23; default werror=false). * Tensor<T> expansion: * PMR-backed storage for extents and data; optional MR in ctors/ops. * disambiguation for std::size_t ranges via tags: extents_from / data_from. * ctors: extents+data ranges, init-lists, count+value, iterator pairs, std::vector/std::pmr::vector; CTAD guides. * safe size computation with overflow detection; zero-extent dims → total size 0. * row-major indexing helpers: unchecked operator[](...) (variadic), checked at(...) (variadic/span), index_of(...), bounds_check(...). * std::vector-like API: capacity/reserve/shrink_to_fit/clear/push_back/emplace_back/pop_back/front/back/assign/fill/swap. * conversions and comparisons with std::vector/std::pmr::vector; <=> implemented. * shape ops: resize(...), resize_dim(dim, n), reshape(...); strides() (row-major). * std::mdspan if available (TENSOR_HAVE_MDSPAN), otherwise a lightweight view (data/extents/strides). * minor code/warning clean-ups Note: * drops Tensor1d tag; use data_from for 1-D construction (or pass a vector), and extents_from to force shape. * push_back on multi-dim tensors flattens to 1-D by design. Signed-off-by: rstein <[email protected]>
... static-storage specialisation, PMR clean-ups, test expansion * Make `Tensor<ElementType, Ex...>` constexpr/consteval friendly: * Static extents: zero-overhead layout using `std::array<T, product(Ex...)>` and a zero-sized `no_extents_t`. * Dynamic / semi-static: PMR-backed `std::pmr::vector` for extents/data; allocator propagated across ctors/ops. * Add `rank()`/`size()` `consteval` for static tensors; `extent<idx>()` `consteval`; `stride()`/`strides()` helpers. * API polish / changes: * Unify indexing and access: `operator[](...)/at(...)` now support static and dynamic paths; `index_of(...)` constexpr. * Iterators/pointers use `std::to_address`; add `pointer` typedefs and `container_data()` helpers. * Rename `view()` → `to_mdspan()` (and matching lightweight View); drop `extentsSpan()`, provide `extents()` (span for dynamic, `std::array` for static). * Add `fill()` `constexpr`; guard mutating ops with `requires (!_all_static)` (`clear/reshape/resize_dim`). * Add static factory `identity()` (square, static tensors). * Equality now templated across `OtherT, OtherEx...` with structural checks. * CTAD guides for flat and nested init-lists, and `std::array`. * Construction & conversion: * Rich set of ctors: extents range, data range, (extents,data), init-lists (flat/2D/3D), count+value, iterator pair, `std::vector`/`std::pmr::vector`. * Cross-type/cross-shape conversion ctors and assignments with dimension validation and allocator preservation. * Move from `pmr::vector` handles allocator mismatch via copy-move fallback. * Tests: large suite uplift to exercise constexpr/static behaviour and error paths: * Static constexpr construction, size/rank/extents `static_assert`s; memory-layout checks. * Conversion/assignment (static↔dynamic, cross-type), self/chained assignment, PMR propagation. * Boundary/edge cases: high-rank, single-element, zero extents, indexing/stride corners, allocator failure, overflow detection. * Nested init-lists (2D/3D), iterator category checks. * Replace `view()` with `to_mdspan()` in tests; add small constexpr `det` for 2×2/3×3; use `<print>` for diagnostics. Notes: * Behavioural changes: `view()` renamed to `to_mdspan()`, `extentsSpan()` removed; some mutators unavailable for static tensors. * ABI: fully static tensors are exactly the size of their element storage; dynamic/semi-static carry PMR state. Signed-off-by: rstein <[email protected]>
[PATCH] expanded Tensor<T>
Signed-off-by: John Sallay <[email protected]>
Signed-off-by: John Sallay <[email protected]>
Signed-off-by: John Sallay <[email protected]>
Signed-off-by: John Sallay <[email protected]>
Signed-off-by: John Sallay <[email protected]>
Signed-off-by: John Sallay <[email protected]>
Signed-off-by: John Sallay <[email protected]>
Signed-off-by: John Sallay <[email protected]>
Signed-off-by: John Sallay <[email protected]>
Signed-off-by: John Sallay <[email protected]>
Signed-off-by: John Sallay <[email protected]>
Signed-off-by: John Sallay <[email protected]>
Signed-off-by: John Sallay <[email protected]>
Signed-off-by: John Sallay <[email protected]>
Signed-off-by: John Sallay <[email protected]>
Signed-off-by: John Sallay <[email protected]>
Signed-off-by: John Sallay <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.