| 214 | |
| 215 | template<typename TStrides, typename TShape> |
| 216 | void CheckContiguousTensor(const TStrides &strides, int num_strides, |
| 217 | const TShape &shape, int num_extents, size_t element_size) { |
| 218 | DALI_ENFORCE(num_strides == num_extents, |
| 219 | "There should be exactly as many strides as there are extents in array shape."); |
| 220 | for (int i = 0; i < num_extents; i++) |
| 221 | if (shape[i] == 0) |
| 222 | return; // The volume is 0, the strides will never be used to compute an actual address |
| 223 | |
| 224 | int64_t stride_from_shape = element_size; |
| 225 | for (int i = num_strides - 1; i >= 0; i--) { |
| 226 | DALI_ENFORCE(shape[i] == 1 || // ignore unit extents - the stride won't be used anyway |
| 227 | strides[i] == stride_from_shape, |
| 228 | make_string("Strided data not supported. Dimension ", i, " has stride ", strides[i], |
| 229 | " whereas densely packed data of this shape would have a stride ", stride_from_shape)); |
| 230 | stride_from_shape *= shape[i]; |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | template<typename TStrides, typename TShape> |
| 235 | void CheckContiguousTensor(const TStrides &strides, const TShape &shape, size_t element_size) { |
no test coverage detected