* @brief Checks whether the tensors in the list are packed sequentially, without gaps. * * The function checks if the data pointer to a next sample immediately follows the last * element of the previous sample. There's no constraint on the shapes of the samples, however. * To determine whether the tensor list can be reduced to a tensor, see @ref is_tensor. */
| 349 | * To determine whether the tensor list can be reduced to a tensor, see @ref is_tensor. |
| 350 | */ |
| 351 | bool is_contiguous() const { |
| 352 | if (num_samples() < 2) |
| 353 | return true; |
| 354 | auto *ptr = data[0]; |
| 355 | for (int i = 1; i < num_samples(); i++) { |
| 356 | auto *next = ptr + volume(tensor_shape_span(i - 1)); |
| 357 | if (data[i] != next) |
| 358 | return false; |
| 359 | ptr = next; |
| 360 | } |
| 361 | return true; |
| 362 | } |
| 363 | |
| 364 | /** |
| 365 | * @brief Checks whether the tensor list can be viewed as a tensor, with samples |