Repository navigation
Commit 30bc8ea
committed
Use one aggregate_impl for reducers with and without keep_dims
xreducer_stepper::aggregate_impl had two overloads. The one used
without keep_dims walks the reduced axes, m_axes[0] to m_axes.back().
The keep_dims one walked every dimension of the expression, looked each
one up in m_axes with std::find, and recursed through the dimensions
that are not reduced without doing anything there.
Both do the same steps on the underlying stepper: keep_dims only
changes the shape of the result, which the stepper does not use here.
The extra size != 0 test of the keep_dims overload is also redundant,
since aggregate() returns the initial value for empty expressions
before calling aggregate_impl. The keep_dims overload is removed.
GCC 13 at -O3 inlined that recursion and warned about
m_e.shape()[dim] for dim == dimension() (-Warray-bounds), a path that
the axis validation in the constructor rules out. The warning goes away
with the overload.
The new test compares lazy keep_dims sums with immediate ones for
every set of axes of a 4-D array, in row and column major order and
with an initial value.1 parent 57f3d07 commit 30bc8ea
2 files changed
Lines changed: 37 additions & 46 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1123 | 1123 | | |
1124 | 1124 | | |
1125 | 1125 | | |
1126 | | - | |
1127 | | - | |
| 1126 | + | |
1128 | 1127 | | |
1129 | 1128 | | |
1130 | 1129 | | |
| |||
1789 | 1788 | | |
1790 | 1789 | | |
1791 | 1790 | | |
1792 | | - | |
| 1791 | + | |
1793 | 1792 | | |
1794 | 1793 | | |
1795 | 1794 | | |
| |||
1798 | 1797 | | |
1799 | 1798 | | |
1800 | 1799 | | |
| 1800 | + | |
| 1801 | + | |
| 1802 | + | |
1801 | 1803 | | |
1802 | | - | |
| 1804 | + | |
1803 | 1805 | | |
1804 | 1806 | | |
1805 | 1807 | | |
1806 | 1808 | | |
1807 | 1809 | | |
1808 | 1810 | | |
1809 | 1811 | | |
1810 | | - | |
| 1812 | + | |
1811 | 1813 | | |
1812 | 1814 | | |
1813 | 1815 | | |
1814 | | - | |
| 1816 | + | |
1815 | 1817 | | |
1816 | 1818 | | |
1817 | 1819 | | |
| |||
1827 | 1829 | | |
1828 | 1830 | | |
1829 | 1831 | | |
1830 | | - | |
1831 | | - | |
1832 | | - | |
1833 | | - | |
1834 | | - | |
1835 | | - | |
1836 | | - | |
1837 | | - | |
1838 | | - | |
1839 | | - | |
1840 | | - | |
1841 | | - | |
1842 | | - | |
1843 | | - | |
1844 | | - | |
1845 | | - | |
1846 | | - | |
1847 | | - | |
1848 | | - | |
1849 | | - | |
1850 | | - | |
1851 | | - | |
1852 | | - | |
1853 | | - | |
1854 | | - | |
1855 | | - | |
1856 | | - | |
1857 | | - | |
1858 | | - | |
1859 | | - | |
1860 | | - | |
1861 | | - | |
1862 | | - | |
1863 | | - | |
1864 | | - | |
1865 | | - | |
1866 | | - | |
1867 | | - | |
1868 | | - | |
1869 | | - | |
1870 | 1832 | | |
1871 | 1833 | | |
1872 | 1834 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1017 | 1017 | | |
1018 | 1018 | | |
1019 | 1019 | | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
1020 | 1049 | | |
1021 | 1050 | | |
1022 | 1051 | | |
| |||
0 commit comments