-
#include "tensorstore/strided_layout.h" -
absl::Status
tensorstore::ValidateShapeBroadcast(span<const Index> source_shape,
span<const Index> target_shape); Validates that
source_shapecan be broadcast totarget_shape.A
source_shapecan be broadcast to atarget_shapeif, starting from the trailing (highest index) dimensions, the size insource_shapeis either1or equal to the size intarget_shape. Any additional leading dimensions ofsource_shapethat don’t correspond to a dimension oftarget_shapemust be1. There are no restrictions on additional leading dimensions oftarget_shapethat don’t correspond to a dimension ofsource_shape.For example:
[VALID] source_shape: 5 target_shape: 4, 5
[VALID] source_shape: 4, 1 target_shape: 4, 5
[VALID] source_shape: 1, 1, 5 target_shape: 4, 5
[INVALID] source_shape: 2, 5 target_shape: 4, 5
[INVALID] source_shape: 2, 5 target_shape: 5