MCPcopy Create free account
hub / github.com/ROCm/AMDMIGraphX / common_axes_map_from_src

Method common_axes_map_from_src

src/shape_transform_descriptor.cpp:1827–1862  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1825}
1826
1827std::vector<std::vector<std::size_t>> shape_transform_descriptor::common_axes_map_from_src() const
1828{
1829 std::vector<std::vector<std::size_t>> result;
1830 auto subs = get_all_subdimensions(dimensions);
1831 std::map<std::size_t, std::vector<const dimension::sub*>> axes_map;
1832 for(const auto& s : subs)
1833 {
1834 if(not s.origin_axis().empty())
1835 axes_map[s.origin_axis().front()].push_back(&s);
1836 }
1837 for(auto&& p : axes_map)
1838 {
1839 std::sort(p.second.begin(), p.second.end(), by(std::less<>{}, [](const dimension::sub* s) {
1840 return s->axis;
1841 }));
1842 }
1843 if(axes_map.empty() and dimensions.size() == 1)
1844 {
1845 transform(range(rank), std::back_inserter(result), [](std::size_t i) {
1846 return std::vector<std::size_t>{i};
1847 });
1848 return result;
1849 }
1850 assert(not axes_map.empty());
1851 auto max_axis = std::prev(axes_map.end())->first;
1852 result.resize(max_axis + 1);
1853 for(auto&& p : axes_map)
1854 {
1855 assert(p.first < result.size());
1856 std::transform(p.second.begin(),
1857 p.second.end(),
1858 std::back_inserter(result[p.first]),
1859 [&](const dimension::sub* s) { return s - subs.data(); });
1860 }
1861 return result;
1862}
1863std::vector<std::vector<std::size_t>> shape_transform_descriptor::common_axes_map_from_dst() const
1864{
1865 std::vector<std::vector<std::size_t>> result;

Callers 3

TEST_CASEFunction · 0.80
applyMethod · 0.80
applyMethod · 0.80

Calls 13

get_all_subdimensionsFunction · 0.85
frontMethod · 0.80
resizeMethod · 0.80
sortFunction · 0.50
byFunction · 0.50
transformFunction · 0.50
rangeFunction · 0.50
emptyMethod · 0.45
push_backMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected