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

Function CheckContiguousTensor

dali/python/backend_impl.cc:216–232  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

214
215template<typename TStrides, typename TShape>
216void 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
234template<typename TStrides, typename TShape>
235void CheckContiguousTensor(const TStrides &strides, const TShape &shape, size_t element_size) {

Callers 4

FillTensorFromDlPackFunction · 0.85
FillTensorFromCudaArrayFunction · 0.85
ExposeTensorFunction · 0.85
ExposeTensorListCPUFunction · 0.85

Calls 2

make_stringFunction · 0.50
sizeFunction · 0.50

Tested by

no test coverage detected