MCPcopy Create free account
hub / github.com/MegEngine/MegCC / isContiguous

Function isContiguous

compiler/lib/Dialect/Kernel/IR/KernelDialect.cpp:19–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17namespace mlir {
18namespace Kernel {
19bool isContiguous(MemRefType memref) {
20 int64_t offset;
21 llvm::SmallVector<int64_t> stride;
22 if (failed(getStridesAndOffset(memref, stride, offset))) {
23 return false;
24 }
25
26 auto shape = memref.getShape();
27
28 if (stride.size() != shape.size())
29 return false;
30
31 int64_t cur = 1;
32 for (int i = stride.size() - 1; i >= 0; --i) {
33 auto dim = shape[i];
34 if (dim > 1 && cur != stride[i]) {
35 return false;
36 }
37 cur *= shape[i];
38 }
39 return true;
40}
41} // namespace Kernel
42} // namespace mlir
43

Callers 1

tryMemoryForwardFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected