| 87 | } |
| 88 | |
| 89 | static 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 | |
| 112 | template<size_t D> |
no test coverage detected