Skip to content

Conversation

jsallay
Copy link
Collaborator

@jsallay jsallay commented Jul 26, 2025

No description provided.

jsallay and others added 5 commits November 28, 2022 21:00
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]>
jsallay added 3 commits July 26, 2025 08:11
Signed-off-by: John Sallay <[email protected]>
Signed-off-by: John Sallay <[email protected]>
Signed-off-by: John Sallay <[email protected]>
@jsallay jsallay requested review from RalphSteinhagen and mormj July 26, 2025 14:05
RalphSteinhagen and others added 11 commits August 25, 2025 18:22
 * 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]>
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]>
@jsallay jsallay had a problem deploying to github-action-autobuild September 8, 2025 12:39 — with GitHub Actions Failure
@jsallay jsallay had a problem deploying to github-action-autobuild September 8, 2025 12:39 — with GitHub Actions Failure
@jsallay jsallay temporarily deployed to github-action-autobuild September 8, 2025 12:53 — with GitHub Actions Inactive
@jsallay jsallay temporarily deployed to github-action-autobuild September 8, 2025 12:53 — with GitHub Actions Inactive
Signed-off-by: John Sallay <[email protected]>
@jsallay jsallay had a problem deploying to github-action-autobuild September 8, 2025 12:56 — with GitHub Actions Failure
@jsallay jsallay had a problem deploying to github-action-autobuild September 8, 2025 12:56 — with GitHub Actions Failure
Signed-off-by: John Sallay <[email protected]>
@jsallay jsallay had a problem deploying to github-action-autobuild September 8, 2025 12:59 — with GitHub Actions Failure
@jsallay jsallay had a problem deploying to github-action-autobuild September 8, 2025 12:59 — with GitHub Actions Failure
Signed-off-by: John Sallay <[email protected]>
@jsallay jsallay had a problem deploying to github-action-autobuild September 8, 2025 13:02 — with GitHub Actions Failure
@jsallay jsallay had a problem deploying to github-action-autobuild September 8, 2025 13:02 — with GitHub Actions Failure
@jsallay jsallay had a problem deploying to github-action-autobuild September 8, 2025 23:17 — with GitHub Actions Failure
@jsallay jsallay had a problem deploying to github-action-autobuild September 8, 2025 23:17 — with GitHub Actions Failure
@jsallay jsallay had a problem deploying to github-action-autobuild September 8, 2025 23:28 — with GitHub Actions Failure
@jsallay jsallay had a problem deploying to github-action-autobuild September 8, 2025 23:28 — with GitHub Actions Failure
Signed-off-by: John Sallay <[email protected]>
@jsallay jsallay had a problem deploying to github-action-autobuild September 8, 2025 23:35 — with GitHub Actions Failure
@jsallay jsallay had a problem deploying to github-action-autobuild September 8, 2025 23:35 — with GitHub Actions Failure
Signed-off-by: John Sallay <[email protected]>
@jsallay jsallay had a problem deploying to github-action-autobuild September 8, 2025 23:38 — with GitHub Actions Failure
@jsallay jsallay had a problem deploying to github-action-autobuild September 8, 2025 23:38 — with GitHub Actions Failure
@jsallay jsallay had a problem deploying to github-action-autobuild September 8, 2025 23:55 — with GitHub Actions Failure
@jsallay jsallay had a problem deploying to github-action-autobuild September 8, 2025 23:55 — with GitHub Actions Failure
Signed-off-by: John Sallay <[email protected]>
@jsallay jsallay had a problem deploying to github-action-autobuild September 9, 2025 14:25 — with GitHub Actions Failure
@jsallay jsallay had a problem deploying to github-action-autobuild September 9, 2025 14:25 — with GitHub Actions Failure
@jsallay jsallay merged commit e314bfb into gnuradio:main Sep 9, 2025
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants