From 1a0b3fd28eb72558662e191a24d9767a679c8c16 Mon Sep 17 00:00:00 2001 From: Scott Todd Date: Tue, 8 Aug 2023 08:07:57 -0700 Subject: [PATCH] Add error message for InlineExecutables with unsupported variants. (#14593) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes https://github.com/openxla/iree/issues/14587 (cc @dcaballe ). `--iree-execution-model=inline-static` only works with `--iree-hal-target-backends=vmvx-inline`. It was crashing when other backends were used, so this adds a check and error log. Sample logs: ``` D:\dev\projects\iree (inline-error-message) λ ..\iree-build\tools\iree-compile.exe -iree-input-type=stablehlo --iree-hal-target-backends=llvm-cpu --iree-hal-target-backends=llvm-cpu --iree-llvmcpu-target-triple=x86_64-unknown-linux-gnu --iree-execution-model=inline-static ./tests/e2e/stablehlo_ops/add.mlir -o ../iree-tmp/add.vmfb ./tests/e2e/stablehlo_ops/add.mlir:0:0: error: InlineStatic execution model is not compatible with hal target 'llvm-cpu' ./tests/e2e/stablehlo_ops/add.mlir:0:0: note: see current operation: "builtin.module"() ({ ... ``` --- compiler/src/iree/compiler/API/Internal/Embed.cpp | 13 +++++++++++++ .../HAL/Inline/Transforms/InlineExecutables.cpp | 3 +++ 2 files changed, 16 insertions(+) diff --git a/compiler/src/iree/compiler/API/Internal/Embed.cpp b/compiler/src/iree/compiler/API/Internal/Embed.cpp index 20f29796e098..044cd6933fee 100644 --- a/compiler/src/iree/compiler/API/Internal/Embed.cpp +++ b/compiler/src/iree/compiler/API/Internal/Embed.cpp @@ -728,6 +728,19 @@ bool Invocation::runPipeline(enum iree_compiler_pipeline_t pipeline) { return false; } + // InlineStatic (currently) only supports the `vmvx-inline` backend. + if (session.schedulingOptions.executionModel == + SchedulingOptions::ExecutionModel::InlineStatic) { + for (auto target : session.halTargetOptions.targets) { + if (target != "vmvx-inline") { + parsedModule->emitError() << "InlineStatic execution model is not " + "compatible with hal target '" + << target << "'"; + return false; + } + } + } + buildIREEVMTransformPassPipeline( session.targetRegistry, session.bindingOptions, session.inputOptions, session.preprocessingOptions, session.highLevelOptimizationOptions, diff --git a/compiler/src/iree/compiler/Modules/HAL/Inline/Transforms/InlineExecutables.cpp b/compiler/src/iree/compiler/Modules/HAL/Inline/Transforms/InlineExecutables.cpp index f8c65fa685a4..27880e0c45e5 100644 --- a/compiler/src/iree/compiler/Modules/HAL/Inline/Transforms/InlineExecutables.cpp +++ b/compiler/src/iree/compiler/Modules/HAL/Inline/Transforms/InlineExecutables.cpp @@ -132,6 +132,9 @@ class InlineExecutablesPass // Build the dispatch function by calling the target function in a loop. auto bodyFuncOp = innerSymbolTable.lookup(exportOp.getName()); + if (!bodyFuncOp) { + return exportOp.emitOpError("missing body function"); + } if (bodyFuncOp.isPublic()) { if (failed(rewriteWorkgroupSignature(layoutAttr, totalBindingCount, bodyFuncOp))) {