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

Function collapse_1_dims

src/shape_transform_descriptor.cpp:1203–1231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1201}
1202
1203static void collapse_1_dims(std::vector<dimension>& dimensions)
1204{
1205 // Find a dimension that ends with a subdimension of 1 with a single axis,
1206 // and is followed by subdimension in the next dimension of 1 that has a
1207 // split axis. It will remove the trailing subdimension and update the
1208 // leading subdimension to use the axis from the trailing subdimension.
1209 adjacent_for_each(dimensions.begin(), dimensions.end(), [&](dimension& d1, dimension& d2) {
1210 if(d1.subdimensions.size() < 2)
1211 return;
1212 if(d2.subdimensions.empty())
1213 return;
1214 if(d2.len() != 1)
1215 return;
1216 const auto& sub1 = d1.subdimensions.back();
1217 auto& sub2 = d2.subdimensions.front();
1218 if(sub1.axis.size() != 1)
1219 return;
1220 if(sub2.axis.size() < 2)
1221 return;
1222 if(sub1.len != 1)
1223 return;
1224 if(sub2.len != 1)
1225 return;
1226 sub2.axis = sub1.axis;
1227 d1.subdimensions.pop_back();
1228 });
1229
1230 renumber_axes(dimensions);
1231}
1232
1233static void insert_empty_1s(std::vector<dimension>& dimensions, std::size_t rank)
1234{

Callers 1

simplifyMethod · 0.85

Calls 9

adjacent_for_eachFunction · 0.85
renumber_axesFunction · 0.85
lenMethod · 0.80
backMethod · 0.80
frontMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected