[Mlir-commits] [mlir] TosaToLinalg: Allow to skip the TOSA validation pass (PR #91742)
Matthias Gehre
llvmlistbot at llvm.org
Fri May 10 06:43:08 PDT 2024
https://github.com/mgehre-amd updated https://github.com/llvm/llvm-project/pull/91742
>From d60cdbe4ce539764ecd7785179f6ee15e150eac1 Mon Sep 17 00:00:00 2001
From: Matthias Gehre <matthias.gehre at amd.com>
Date: Mon, 6 May 2024 15:08:17 +0200
Subject: [PATCH] TosaToLinalg: Allow to skip TOSA validation
---
.../mlir/Conversion/TosaToLinalg/TosaToLinalg.h | 5 +++--
.../Conversion/TosaToLinalg/TosaToLinalgPass.cpp | 14 ++++++++------
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/mlir/include/mlir/Conversion/TosaToLinalg/TosaToLinalg.h b/mlir/include/mlir/Conversion/TosaToLinalg/TosaToLinalg.h
index 5fd77c8a0211a..67965e34d8a3d 100644
--- a/mlir/include/mlir/Conversion/TosaToLinalg/TosaToLinalg.h
+++ b/mlir/include/mlir/Conversion/TosaToLinalg/TosaToLinalg.h
@@ -38,8 +38,9 @@ void addTosaToLinalgPasses(
const TosaToLinalgNamedOptions &tosaToLinalgNamedOptions =
TosaToLinalgNamedOptions(),
// Note: Default to 'none' level unless otherwise specified.
- tosa::TosaValidationOptions const &validationOptions = {
- tosa::TosaProfileEnum::Undefined, false, tosa::TosaLevelEnum::None});
+ std::optional<tosa::TosaValidationOptions> validationOptions =
+ tosa::TosaValidationOptions{tosa::TosaProfileEnum::Undefined, false,
+ tosa::TosaLevelEnum::None});
/// Populates TOSA to linalg pipelines
/// Currently, this includes only the "tosa-to-linalg-pipeline".
diff --git a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgPass.cpp b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgPass.cpp
index ad7f6cf84e5ed..8904e3253922c 100644
--- a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgPass.cpp
+++ b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgPass.cpp
@@ -78,7 +78,7 @@ std::unique_ptr<Pass> mlir::tosa::createTosaToLinalg() {
void mlir::tosa::addTosaToLinalgPasses(
OpPassManager &pm, const TosaToLinalgOptions &options,
const TosaToLinalgNamedOptions &tosaToLinalgNamedOptions,
- tosa::TosaValidationOptions const &validationOptions) {
+ std::optional<tosa::TosaValidationOptions> validationOptions) {
// Optional decompositions are designed to benefit linalg.
if (!options.disableTosaDecompositions)
pm.addNestedPass<func::FuncOp>(tosa::createTosaOptionalDecompositions());
@@ -93,7 +93,8 @@ void mlir::tosa::addTosaToLinalgPasses(
pm.addNestedPass<func::FuncOp>(tosa::createTosaLayerwiseConstantFoldPass(
{options.aggressiveReduceConstant}));
pm.addNestedPass<func::FuncOp>(tosa::createTosaMakeBroadcastablePass());
- pm.addPass(tosa::createTosaValidation(validationOptions));
+ if (validationOptions)
+ pm.addPass(tosa::createTosaValidation(*validationOptions));
pm.addNestedPass<func::FuncOp>(tosa::createTosaToLinalg());
}
@@ -110,11 +111,12 @@ void mlir::tosa::registerTosaToLinalgPipelines() {
[](OpPassManager &pm) {
TosaToLinalgOptions tosaToLinalgOptions;
TosaToLinalgNamedOptions tosaToLinalgNamedOptions;
+ TosaValidationOptions validationOptions;
+ validationOptions.profile = tosa::TosaProfileEnum::BaseInference;
+ validationOptions.StrictOperationSpecAlignment = true;
+ validationOptions.level = tosa::TosaLevelEnum::EightK;
tosa::addTosaToLinalgPasses(pm, tosaToLinalgOptions,
tosaToLinalgNamedOptions,
- /* validationOptions = */
- {tosa::TosaProfileEnum::BaseInference,
- /* StrictOperationSpecAlignment = */ true,
- tosa::TosaLevelEnum::EightK});
+ validationOptions);
});
}
More information about the Mlir-commits
mailing list