If this is scalar, then remove all axes
| 1177 | |
| 1178 | // If this is scalar, then remove all axes |
| 1179 | static 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 | |
| 1203 | static void collapse_1_dims(std::vector<dimension>& dimensions) |
| 1204 | { |