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

Function remove_scalar_axis

src/shape_transform_descriptor.cpp:1179–1201  ·  view source on GitHub ↗

If this is scalar, then remove all axes

Source from the content-addressed store, hash-verified

1177
1178// If this is scalar, then remove all axes
1179static void remove_scalar_axis(std::vector<dimension>& dimensions)
1180{
1181 dimension::sub* s = nullptr;
1182 for(auto& d : dimensions)
1183 {
1184 auto has_axis = [](const dimension::sub& x) { return not x.origin_axis().empty(); };
1185 auto it = std::find_if(d.subdimensions.begin(), d.subdimensions.end(), has_axis);
1186 if(it == d.subdimensions.end())
1187 continue;
1188 if(s != nullptr)
1189 return;
1190 if(std::count_if(std::next(it), d.subdimensions.end(), has_axis) > 0)
1191 return;
1192 s = &*it;
1193 }
1194 if(s != nullptr)
1195 {
1196 if(s->has_hidden_axis())
1197 s->hidden_axis.clear();
1198 if(s->len == 1)
1199 s->axis.clear();
1200 }
1201}
1202
1203static void collapse_1_dims(std::vector<dimension>& dimensions)
1204{

Callers 1

simplifyMethod · 0.85

Calls 6

find_ifFunction · 0.50
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
has_hidden_axisMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected