MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / broadcast_shape

Method broadcast_shape

arm_compute/core/TensorShape.h:216–247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

214 */
215 template <typename... Shapes>
216 static TensorShape broadcast_shape(const Shapes &...shapes)
217 {
218 TensorShape bc_shape;
219
220 auto broadcast = [&bc_shape](const TensorShape &other)
221 {
222 if (bc_shape.num_dimensions() == 0)
223 {
224 bc_shape = other;
225 }
226 else if (other.num_dimensions() != 0)
227 {
228 for (size_t d = 0; d < TensorShape::num_max_dimensions; ++d)
229 {
230 const size_t dim_min = std::min(bc_shape[d], other[d]);
231 const size_t dim_max = std::max(bc_shape[d], other[d]);
232
233 if ((dim_min != 1) && (dim_min != dim_max))
234 {
235 bc_shape = TensorShape{0U};
236 break;
237 }
238
239 bc_shape.set(d, dim_max);
240 }
241 }
242 };
243
244 utility::for_each(broadcast, shapes...);
245
246 return bc_shape;
247 }
248
249 /** Set number of dimensions.
250 *

Callers

nothing calls this directly

Calls 3

for_eachFunction · 0.85
num_dimensionsMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected