Skip to content

Commit ad5c58d

Browse files
committed
getMRType: fix llvm strides must not be zero error
1 parent 9c9b55b commit ad5c58d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/jit/mlir.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,12 @@ ::mlir::Value DepManager::getDependent(::mlir::OpBuilder &builder,
266266
static ::mlir::MemRefType getMRType(size_t ndims, intptr_t offset,
267267
intptr_t *sizes, intptr_t *strides,
268268
::mlir::Type elType) {
269+
// sanitize strides
270+
for (size_t i = 0; i < ndims; i++) {
271+
if (strides[i] == 0) {
272+
strides[i] = 1;
273+
}
274+
}
269275
auto layout = ::mlir::StridedLayoutAttr::get(elType.getContext(), offset,
270276
{strides, ndims});
271277
return ::mlir::MemRefType::get({sizes, ndims}, elType, layout);

0 commit comments

Comments
 (0)