MCPcopy Create free account
hub / github.com/astra-toolbox/astra-toolbox / isContiguous

Function isContiguous

python/astra/src/dlpack.cpp:89–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87}
88
89static bool isContiguous(DLTensor *tensor)
90{
91 if (!tensor->strides)
92 return true;
93
94 // Ignore singleton dimensions as they don't affect contiguity and tensor producers
95 // may optionally set their strides to 1
96 std::vector<int64_t> non_singleton_dims, non_singleton_strides;
97 getNonSingletonDims(tensor, non_singleton_dims, non_singleton_strides);
98
99 if (non_singleton_dims.size() < 2)
100 return true;
101
102 int64_t accumulator = 1;
103 for (int i = non_singleton_dims.size() - 1; i >= 0; --i) {
104 if (non_singleton_strides[i] != accumulator)
105 return false;
106 accumulator *= non_singleton_dims[i];
107 }
108 return true;
109}
110
111
112template<size_t D>

Callers 1

checkDLTensorFunction · 0.85

Calls 1

getNonSingletonDimsFunction · 0.85

Tested by

no test coverage detected