@@ -2352,52 +2352,13 @@ static LogicalResult produceSliceErrorMsg(SliceVerificationResult result,
2352
2352
}
2353
2353
}
2354
2354
2355
- // / Verify that the offsets/sizes/strides-style access into the given tensor
2356
- // / is in-bounds. Only static information is verified.
2357
- static LogicalResult verifyInBoundsSlice (Operation *op,
2358
- RankedTensorType tensorType,
2359
- ArrayRef<int64_t > staticOffsets,
2360
- ArrayRef<int64_t > staticSizes,
2361
- ArrayRef<int64_t > staticStrides) {
2362
- for (int64_t i = 0 , e = tensorType.getRank (); i < e; ++i) {
2363
- // Nothing to verify for dynamic source dims.
2364
- if (tensorType.isDynamicDim (i))
2365
- continue ;
2366
- // Nothing to verify if the offset is dynamic.
2367
- if (ShapedType::isDynamic (staticOffsets[i]))
2368
- continue ;
2369
- if (staticOffsets[i] >= tensorType.getDimSize (i))
2370
- return op->emitOpError (" offset " )
2371
- << i << " is out-of-bounds: " << staticOffsets[i]
2372
- << " >= " << tensorType.getDimSize (i);
2373
- if (ShapedType::isDynamic (staticSizes[i]) ||
2374
- ShapedType::isDynamic (staticStrides[i]))
2375
- continue ;
2376
- int64_t lastPos =
2377
- staticOffsets[i] + (staticSizes[i] - 1 ) * staticStrides[i];
2378
- if (lastPos >= tensorType.getDimSize (i))
2379
- return op->emitOpError (" slice along dimension " )
2380
- << i << " runs out-of-bounds: " << lastPos
2381
- << " >= " << tensorType.getDimSize (i);
2382
- }
2383
- return success ();
2384
- }
2385
-
2386
2355
// / Verifier for ExtractSliceOp.
2387
2356
LogicalResult ExtractSliceOp::verify () {
2388
- RankedTensorType sourceType = getSourceType ();
2389
-
2390
2357
// Verify result type against inferred type.
2391
2358
RankedTensorType expectedType = ExtractSliceOp::inferResultType (
2392
- sourceType , getMixedOffsets (), getMixedSizes (), getMixedStrides ());
2359
+ getSourceType () , getMixedOffsets (), getMixedSizes (), getMixedStrides ());
2393
2360
SliceVerificationResult result = isRankReducedType (expectedType, getType ());
2394
- if (result != SliceVerificationResult::Success)
2395
- return produceSliceErrorMsg (result, *this , expectedType);
2396
-
2397
- // Verify that offsets, sizes, strides do not run out-of-bounds with respect
2398
- // to the source tensor.
2399
- return verifyInBoundsSlice (getOperation (), sourceType, getStaticOffsets (),
2400
- getStaticSizes (), getStaticStrides ());
2361
+ return produceSliceErrorMsg (result, *this , expectedType);
2401
2362
}
2402
2363
2403
2364
llvm::SmallBitVector ExtractSliceOp::getDroppedDims () {
@@ -2768,18 +2729,11 @@ static SliceVerificationResult verifyInsertSliceOp(
2768
2729
2769
2730
// / Verifier for InsertSliceOp.
2770
2731
LogicalResult InsertSliceOp::verify () {
2771
- // Verify result type against inferred type.
2772
2732
RankedTensorType expectedType;
2773
2733
SliceVerificationResult result =
2774
2734
verifyInsertSliceOp (getSourceType (), getType (), getStaticOffsets (),
2775
2735
getStaticSizes (), getStaticStrides (), &expectedType);
2776
- if (result != SliceVerificationResult::Success)
2777
- return produceSliceErrorMsg (result, *this , expectedType);
2778
-
2779
- // Verify that offsets, sizes, strides do not run out-of-bounds with respect
2780
- // to the source tensor.
2781
- return verifyInBoundsSlice (getOperation (), getDestType (), getStaticOffsets (),
2782
- getStaticSizes (), getStaticStrides ());
2736
+ return produceSliceErrorMsg (result, *this , expectedType);
2783
2737
}
2784
2738
2785
2739
// / If we have two consecutive InsertSliceOp writing to the same slice, we
@@ -3793,18 +3747,11 @@ LogicalResult ParallelInsertSliceOp::verify() {
3793
3747
return this ->emitError (" expected ParallelCombiningOpInterface parent, got:" )
3794
3748
<< *(getOperation ()->getParentOp ());
3795
3749
3796
- // Verify result type against inferred type.
3797
3750
RankedTensorType expectedType;
3798
3751
SliceVerificationResult result =
3799
3752
verifyInsertSliceOp (getSourceType (), getDestType (), getStaticOffsets (),
3800
3753
getStaticSizes (), getStaticStrides (), &expectedType);
3801
- if (result != SliceVerificationResult::Success)
3802
- return produceSliceErrorMsg (result, *this , expectedType);
3803
-
3804
- // Verify that offsets, sizes, strides do not run out-of-bounds with respect
3805
- // to the source tensor.
3806
- return verifyInBoundsSlice (getOperation (), getDestType (), getStaticOffsets (),
3807
- getStaticSizes (), getStaticStrides ());
3754
+ return produceSliceErrorMsg (result, *this , expectedType);
3808
3755
}
3809
3756
3810
3757
void ParallelInsertSliceOp::getCanonicalizationPatterns (
0 commit comments