[Mlir-commits] [mlir] [mlir][tosa] Change the start and size of slice to tosa shape type (PR #124209)

Georgios Pinitas llvmlistbot at llvm.org
Wed Jan 29 13:00:21 PST 2025


================
@@ -891,8 +891,18 @@ LogicalResult tosa::SliceOp::inferReturnTypeComponents(
     MLIRContext *context, ::std::optional<Location> location,
     SliceOp::Adaptor adaptor,
     SmallVectorImpl<ShapedTypeComponents> &inferredReturnShapes) {
-  auto start = adaptor.getStart();
-  auto size = adaptor.getSize();
+
+  Type inputType = getElementTypeOrSelf(adaptor.getInput1().getType());
+  SmallVector<int64_t> start;
+  SmallVector<int64_t> size;
+
+  if (!tosa::getConstShapeValue(adaptor.getStart().getDefiningOp(), start) ||
----------------
GeorgeARM wrote:

> If we change the return type to std::optional<SmallVector<int64_t>, there will be extra code to check if the function is working or not. So we won't save too much lines of code here.

Isn't that what you do already by defining the variable and then calling the function with a reference to it to fill and then check if that failed?
Eitherway, you can leave as is for now I presume.

https://github.com/llvm/llvm-project/pull/124209


More information about the Mlir-commits mailing list