MCPcopy Create free account
hub / github.com/NVIDIA/DALI / is_contiguous

Method is_contiguous

include/dali/core/tensor_view.h:351–362  ·  view source on GitHub ↗

* @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. */

Source from the content-addressed store, hash-verified

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

Callers 2

TESTFunction · 0.80
RunFunction · 0.80

Calls 3

volumeFunction · 0.85
tensor_shape_spanFunction · 0.85
num_samplesFunction · 0.50

Tested by 1

TESTFunction · 0.64