[Mlir-commits] [mlir] [mlir][tosa] Add pass to assign static input shape to TOSA functions (PR #171156)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Dec 8 08:59:57 PST 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- mlir/lib/Dialect/Tosa/Transforms/TosaInputShape.cpp mlir/include/mlir/Dialect/Tosa/Transforms/Passes.h --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/mlir/lib/Dialect/Tosa/Transforms/TosaInputShape.cpp b/mlir/lib/Dialect/Tosa/Transforms/TosaInputShape.cpp
index ae7701892..1665f33f0 100644
--- a/mlir/lib/Dialect/Tosa/Transforms/TosaInputShape.cpp
+++ b/mlir/lib/Dialect/Tosa/Transforms/TosaInputShape.cpp
@@ -12,9 +12,9 @@
//
//===----------------------------------------------------------------------===//
-#include "mlir/Dialect/Tosa/Transforms/Passes.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/Tosa/IR/TosaOps.h"
+#include "mlir/Dialect/Tosa/Transforms/Passes.h"
#include "mlir/Pass/Pass.h"
namespace mlir {
@@ -80,9 +80,10 @@ FailureOr<IdxAndShape> parseInputShape(Location loc, StringRef input) {
// For example:
// "args=arg0:5x10,arg8:3x9" => {{{0, {5, 10}}, {8, {3, 9}}}, ""}
// "args=arg0:" => {{}, "error message"}
-FailureOr<SmallVector<IdxAndShape>> parseInputShapes(Location loc, const std::vector<std::string>& args) {
+FailureOr<SmallVector<IdxAndShape>>
+parseInputShapes(Location loc, const std::vector<std::string> &args) {
SmallVector<IdxAndShape> inputShapes;
- for (const std::string& arg : args) {
+ for (const std::string &arg : args) {
const auto maybeInputShape = parseInputShape(loc, arg);
if (failed(maybeInputShape))
return failure();
@@ -109,14 +110,13 @@ public:
func::FuncOp func = getOperation();
const auto getUpdatedTensorType =
- [&](size_t argIdx,
- ArrayRef<Type> argTypes, ArrayRef<int64_t> requestedShape) -> FailureOr<Type> {
+ [&](size_t argIdx, ArrayRef<Type> argTypes,
+ ArrayRef<int64_t> requestedShape) -> FailureOr<Type> {
const size_t numInputs = argTypes.size();
if (argIdx >= numInputs)
return func.emitError()
<< "provided arg index " << argIdx
- << " is larger than number of inputs "
- << numInputs << ".";
+ << " is larger than number of inputs " << numInputs << ".";
auto tensorType = dyn_cast<TensorType>(argTypes[argIdx]);
if (!tensorType)
@@ -126,8 +126,9 @@ public:
const ArrayRef<int64_t> originalShape = tensorType.getShape();
if (failed(verifyCompatibleShape(originalShape, requestedShape)))
return func.emitError()
- << "arg" << argIdx << " has incompatible shape with requested input shape ("
- << requestedShape << "), got " << tensorType;
+ << "arg" << argIdx
+ << " has incompatible shape with requested input shape ("
+ << requestedShape << "), got " << tensorType;
return tensorType.cloneWith(requestedShape, tensorType.getElementType());
};
@@ -169,9 +170,8 @@ public:
auto types = oldFunctionType.getResults();
newResults.assign(types.begin(), types.end());
}
- const FunctionType newFunctionType = oldFunctionType.clone(
- newInputs,
- newResults);
+ const FunctionType newFunctionType =
+ oldFunctionType.clone(newInputs, newResults);
func.setFunctionType(newFunctionType);
}
};
``````````
</details>
https://github.com/llvm/llvm-project/pull/171156
More information about the Mlir-commits
mailing list