File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
lib/Dialect/Bufferization/IR
test/Dialect/Bufferization Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -314,7 +314,11 @@ struct ReplaceStaticShapeDims : OpRewritePattern<AllocTensorOp> {
314
314
Value value = op.getDynamicSizes ()[dynValCounter++];
315
315
APInt intVal;
316
316
if (matchPattern (value, m_ConstantInt (&intVal))) {
317
- newShape[i] = intVal.getSExtValue ();
317
+ int64_t dim = intVal.getSExtValue ();
318
+ if (dim >= 0 )
319
+ newShape[i] = intVal.getSExtValue ();
320
+ else
321
+ newDynamicSizes.push_back (value);
318
322
} else {
319
323
newDynamicSizes.push_back (value);
320
324
}
Original file line number Diff line number Diff line change @@ -351,3 +351,16 @@ func.func @dealloc_base_memref_extract_of_alloc(%arg0: memref<2xi32>) {
351
351
// CHECK-SAME:([[ARG0:%.+]]: memref<2xi32>)
352
352
// CHECK-NOT: memref.alloc(
353
353
// CHECK: bufferization.dealloc ([[ARG0]] : memref<2xi32>) if (%true
354
+
355
+ // -----
356
+
357
+ // CHECK-LABEL: func @negative_input
358
+ func.func @negative_input () -> tensor <?x?x?xf16 > {
359
+ %idx27 = index.constant 27
360
+ %idx -3 = index .constant -3 // negative integer?
361
+ %c10 = arith.constant 10 : index
362
+ // CHECK: bufferization.alloc_tensor
363
+ // CHECK-SAME: tensor<10x?x27xf16>
364
+ %11 = bufferization.alloc_tensor (%c10 , %idx -3 , %idx27 ) : tensor <?x?x?xf16 >
365
+ return %11 : tensor <?x?x?xf16 >
366
+ }
You can’t perform that action at this time.
0 commit comments