Remove iree-translate. (#9143)
* Remove iree-translate.
* All of the functionality has been superceded by iree-compile. A few
remaining features were added in this PR to normalize.
* I suspect that the right way forward there is to create more of an API
around iree-compile (it has a little one now) in order to customize it
(i.e. extending dialect registration, etc). Can look at that in a
followup.
Progress on #9144
diff --git a/build_tools/cmake/iree_hal_cts_test_suite.cmake b/build_tools/cmake/iree_hal_cts_test_suite.cmake
index 1056b99..8c89438 100644
--- a/build_tools/cmake/iree_hal_cts_test_suite.cmake
+++ b/build_tools/cmake/iree_hal_cts_test_suite.cmake
@@ -20,7 +20,7 @@
# DRIVER_REGISTRATION_HDR: The C #include path for `DRIVER_REGISTRATION_FN`.
# DRIVER_REGISTRATION_FN: The C function which registers `DRIVER_NAME`.
# COMPILER_TARGET_BACKEND: Optional target backend name to pass to the
-# `-iree-hal-target-backends` option of `iree-translate` to use for
+# `-iree-hal-target-backends` option of `iree-compile` to use for
# executable generation. If this is omitted, or the associated compiler
# target is not enabled, tests which use executables will be disabled.
# EXECUTABLE_FORMAT: Executable format identifier. Will be interpreted
@@ -91,7 +91,7 @@
set(_EXECUTABLES_TESTDATA_NAME "${_RULE_COMPILER_TARGET_BACKEND}_executables")
set(_TRANSLATE_FLAGS
- "--iree-mlir-to-hal-executable"
+ "--compile-mode=hal-executable"
"--iree-hal-target-backends=${_RULE_COMPILER_TARGET_BACKEND}"
)
if(ANDROID)
@@ -105,7 +105,7 @@
set(_EMBED_DATA_SOURCES "")
foreach(_FILE_NAME ${IREE_ALL_CTS_EXECUTABLE_SOURCES})
# Note: this is an abuse of naming. We are not building a bytecode
- # module, but this CMake rule already wraps iree-translate.
+ # module, but this CMake rule already wraps iree-compile
# We should add a new function like `iree_hal_executable()`.
iree_bytecode_module(
NAME
@@ -117,7 +117,7 @@
FLAGS
${_TRANSLATE_FLAGS}
TRANSLATE_TOOL
- "iree-translate"
+ "iree-compile"
PUBLIC
TESTONLY
)
diff --git a/compiler/src/iree/compiler/API/BUILD b/compiler/src/iree/compiler/API/BUILD
index 0279ae0..a052745 100644
--- a/compiler/src/iree/compiler/API/BUILD
+++ b/compiler/src/iree/compiler/API/BUILD
@@ -77,7 +77,7 @@
"//compiler/src/iree/compiler/Tools:init_llvmir_translations",
"//compiler/src/iree/compiler/Tools:init_passes_and_dialects",
"//compiler/src/iree/compiler/Tools:init_targets",
- "//compiler/src/iree/compiler/Tools:iree_translate_lib",
+ "//compiler/src/iree/compiler/Tools:iree_compile_lib",
"//compiler/src/iree/compiler/Utils",
"@llvm-project//lld:COFF",
"@llvm-project//lld:Common",
diff --git a/compiler/src/iree/compiler/API/CMakeLists.txt b/compiler/src/iree/compiler/API/CMakeLists.txt
index 6b0678c..08d5b71 100644
--- a/compiler/src/iree/compiler/API/CMakeLists.txt
+++ b/compiler/src/iree/compiler/API/CMakeLists.txt
@@ -59,7 +59,7 @@
iree::compiler::Tools::init_targets
# Tools.
- iree::compiler::Tools::iree_translate_lib
+ iree::compiler::Tools::iree_compile_lib
${_OPTIONAL_LINK_LIBS}
)
diff --git a/compiler/src/iree/compiler/API/Tools.cpp b/compiler/src/iree/compiler/API/Tools.cpp
index bd29349..1c533ed 100644
--- a/compiler/src/iree/compiler/API/Tools.cpp
+++ b/compiler/src/iree/compiler/API/Tools.cpp
@@ -6,7 +6,7 @@
#include "iree/compiler/API/Tools.h"
-#include "iree/compiler/Tools/iree_translate_lib.h"
+#include "iree/compiler/Tools/iree_compile_lib.h"
int ireeCompilerRunMain(int argc, char **argv) {
return mlir::iree_compiler::runIreecMain(argc, argv);
diff --git a/compiler/src/iree/compiler/Dialect/VM/Target/Bytecode/test/BUILD b/compiler/src/iree/compiler/Dialect/VM/Target/Bytecode/test/BUILD
index 09ae599..474159f 100644
--- a/compiler/src/iree/compiler/Dialect/VM/Target/Bytecode/test/BUILD
+++ b/compiler/src/iree/compiler/Dialect/VM/Target/Bytecode/test/BUILD
@@ -25,7 +25,7 @@
),
cfg = "//compiler:lit.cfg.py",
tools = [
- "//tools:iree-translate",
+ "//tools:iree-compile",
"@llvm-project//llvm:FileCheck",
],
)
diff --git a/compiler/src/iree/compiler/Dialect/VM/Target/Bytecode/test/CMakeLists.txt b/compiler/src/iree/compiler/Dialect/VM/Target/Bytecode/test/CMakeLists.txt
index c34074c..0fc8070 100644
--- a/compiler/src/iree/compiler/Dialect/VM/Target/Bytecode/test/CMakeLists.txt
+++ b/compiler/src/iree/compiler/Dialect/VM/Target/Bytecode/test/CMakeLists.txt
@@ -19,7 +19,7 @@
"reflection_attrs.mlir"
TOOLS
FileCheck
- iree-translate
+ iree-compile
)
### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
diff --git a/compiler/src/iree/compiler/Dialect/VM/Target/Bytecode/test/constant_encoding.mlir b/compiler/src/iree/compiler/Dialect/VM/Target/Bytecode/test/constant_encoding.mlir
index c931f4e..e12e574 100644
--- a/compiler/src/iree/compiler/Dialect/VM/Target/Bytecode/test/constant_encoding.mlir
+++ b/compiler/src/iree/compiler/Dialect/VM/Target/Bytecode/test/constant_encoding.mlir
@@ -1,4 +1,5 @@
-// RUN: iree-translate --split-input-file --iree-vm-ir-to-bytecode-module --iree-vm-bytecode-module-output-format=flatbuffer-text %s | FileCheck %s
+// RUN: iree-compile --split-input-file --compile-mode=vm \
+// RUN: --iree-vm-bytecode-module-output-format=flatbuffer-text %s | FileCheck %s
// CHECK: "name": "constants"
vm.module @constants {
diff --git a/compiler/src/iree/compiler/Dialect/VM/Target/Bytecode/test/module_encoding_smoke.mlir b/compiler/src/iree/compiler/Dialect/VM/Target/Bytecode/test/module_encoding_smoke.mlir
index 287c1ef..7cbdc65 100644
--- a/compiler/src/iree/compiler/Dialect/VM/Target/Bytecode/test/module_encoding_smoke.mlir
+++ b/compiler/src/iree/compiler/Dialect/VM/Target/Bytecode/test/module_encoding_smoke.mlir
@@ -1,4 +1,5 @@
-// RUN: iree-translate --split-input-file --iree-vm-ir-to-bytecode-module --iree-vm-bytecode-module-output-format=flatbuffer-text %s | FileCheck %s
+// RUN: iree-compile --split-input-file --compile-mode=vm \
+// RUN: --iree-vm-bytecode-module-output-format=flatbuffer-text %s | FileCheck %s
// CHECK: "name": "simple_module"
vm.module @simple_module {
diff --git a/compiler/src/iree/compiler/Dialect/VM/Target/Bytecode/test/reflection_attrs.mlir b/compiler/src/iree/compiler/Dialect/VM/Target/Bytecode/test/reflection_attrs.mlir
index 26ee2aa..db573df 100644
--- a/compiler/src/iree/compiler/Dialect/VM/Target/Bytecode/test/reflection_attrs.mlir
+++ b/compiler/src/iree/compiler/Dialect/VM/Target/Bytecode/test/reflection_attrs.mlir
@@ -1,4 +1,5 @@
-// RUN: iree-translate --split-input-file --iree-vm-ir-to-bytecode-module --iree-vm-bytecode-module-output-format=flatbuffer-text %s | FileCheck %s
+// RUN: iree-compile --split-input-file --compile-mode=vm \
+// RUN: --iree-vm-bytecode-module-output-format=flatbuffer-text %s | FileCheck %s
// CHECK-LABEL: simple_module
vm.module @simple_module {
diff --git a/compiler/src/iree/compiler/Dialect/VM/Target/C/test/CMakeLists.txt b/compiler/src/iree/compiler/Dialect/VM/Target/C/test/CMakeLists.txt
index 887db5c..0b078a1 100644
--- a/compiler/src/iree/compiler/Dialect/VM/Target/C/test/CMakeLists.txt
+++ b/compiler/src/iree/compiler/Dialect/VM/Target/C/test/CMakeLists.txt
@@ -14,5 +14,5 @@
"${_GLOB_X_MLIR}"
TOOLS
FileCheck
- iree-translate
+ iree-compile
)
diff --git a/compiler/src/iree/compiler/Dialect/VM/Target/C/test/add.mlir b/compiler/src/iree/compiler/Dialect/VM/Target/C/test/add.mlir
index 5c5d7b8..d70a583 100644
--- a/compiler/src/iree/compiler/Dialect/VM/Target/C/test/add.mlir
+++ b/compiler/src/iree/compiler/Dialect/VM/Target/C/test/add.mlir
@@ -1,4 +1,4 @@
-// RUN: iree-translate --iree-vm-ir-to-c-module %s | FileCheck %s
+// RUN: iree-compile --compile-mode=vm --output-format=vm-c %s | FileCheck %s
// CHECK: #include "iree/vm/ops.h"
vm.module @add_module {
diff --git a/compiler/src/iree/compiler/Dialect/VM/Target/C/test/calling_convention.mlir b/compiler/src/iree/compiler/Dialect/VM/Target/C/test/calling_convention.mlir
index b456e0d..54881da 100644
--- a/compiler/src/iree/compiler/Dialect/VM/Target/C/test/calling_convention.mlir
+++ b/compiler/src/iree/compiler/Dialect/VM/Target/C/test/calling_convention.mlir
@@ -1,4 +1,4 @@
-// RUN: iree-translate --iree-vm-ir-to-c-module %s | FileCheck %s
+// RUN: iree-compile --compile-mode=vm --output-format=vm-c %s | FileCheck %s
// CHECK: #include "iree/vm/ops.h"
vm.module @calling_convention_test {
diff --git a/compiler/src/iree/compiler/Dialect/VM/Target/C/test/constant_ops.mlir b/compiler/src/iree/compiler/Dialect/VM/Target/C/test/constant_ops.mlir
index 9fe1b90..f79cf0c 100644
--- a/compiler/src/iree/compiler/Dialect/VM/Target/C/test/constant_ops.mlir
+++ b/compiler/src/iree/compiler/Dialect/VM/Target/C/test/constant_ops.mlir
@@ -1,4 +1,4 @@
-// RUN: iree-translate --split-input-file --iree-vm-ir-to-c-module --iree-vm-c-module-optimize=false %s | FileCheck %s
+// RUN: iree-compile --split-input-file --compile-mode=vm --output-format=vm-c --iree-vm-c-module-optimize=false %s | FileCheck %s
vm.module @rodata_ops {
// Check the generated arrays
diff --git a/compiler/src/iree/compiler/Dialect/VM/Target/C/test/control_flow.mlir b/compiler/src/iree/compiler/Dialect/VM/Target/C/test/control_flow.mlir
index 5f5e26b..3e76198 100644
--- a/compiler/src/iree/compiler/Dialect/VM/Target/C/test/control_flow.mlir
+++ b/compiler/src/iree/compiler/Dialect/VM/Target/C/test/control_flow.mlir
@@ -1,4 +1,4 @@
-// RUN: iree-translate --iree-vm-ir-to-c-module --iree-vm-c-module-optimize=false %s | FileCheck %s
+// RUN: iree-compile --compile-mode=vm --output-format=vm-c --iree-vm-c-module-optimize=false %s | FileCheck %s
vm.module @control_flow_module {
vm.func @control_flow_test(%a: i32, %cond: i32) -> i32 {
diff --git a/compiler/src/iree/compiler/Dialect/VM/Target/C/test/empty_module.mlir b/compiler/src/iree/compiler/Dialect/VM/Target/C/test/empty_module.mlir
index b180429..30b0078 100644
--- a/compiler/src/iree/compiler/Dialect/VM/Target/C/test/empty_module.mlir
+++ b/compiler/src/iree/compiler/Dialect/VM/Target/C/test/empty_module.mlir
@@ -1,4 +1,4 @@
-// RUN: iree-translate --iree-vm-ir-to-c-module %s | FileCheck %s
+// RUN: iree-compile --compile-mode=vm --output-format=vm-c %s | FileCheck %s
// CHECK: #include "iree/vm/ops.h"
vm.module @empty_module {
diff --git a/compiler/src/iree/compiler/Dialect/VM/Target/C/test/global_ops.mlir b/compiler/src/iree/compiler/Dialect/VM/Target/C/test/global_ops.mlir
index c84c006..ddb731d 100644
--- a/compiler/src/iree/compiler/Dialect/VM/Target/C/test/global_ops.mlir
+++ b/compiler/src/iree/compiler/Dialect/VM/Target/C/test/global_ops.mlir
@@ -1,4 +1,4 @@
-// RUN: iree-translate --iree-vm-ir-to-c-module --iree-vm-c-module-optimize=false %s | FileCheck %s
+// RUN: iree-compile --compile-mode=vm --output-format=vm-c --iree-vm-c-module-optimize=false %s | FileCheck %s
vm.module @global_ops {
// check the generated state struct
diff --git a/compiler/src/iree/compiler/Pipelines/Pipelines.cpp b/compiler/src/iree/compiler/Pipelines/Pipelines.cpp
index 001ea3b..9e70cc0 100644
--- a/compiler/src/iree/compiler/Pipelines/Pipelines.cpp
+++ b/compiler/src/iree/compiler/Pipelines/Pipelines.cpp
@@ -103,5 +103,29 @@
passManager.addPass(IREE::Util::createDropCompilerHintsPass());
}
+void buildDefaultIREEVMTransformPassPipeline(OpPassManager &passManager) {
+ // Note that the production compiler will provide hooks here that enable
+ // additional, whole-program related features, whereas this pipeline will
+ // only use the defaults. In practice, this means that things like const
+ // jitting are not supported by this pipeline.
+ static IREEVMPipelineHooks defaultHooks;
+
+ buildIREEVMTransformPassPipeline(
+ BindingOptions::FromFlags::get(), InputDialectOptions::FromFlags::get(),
+ HighLevelOptimizationOptions::FromFlags::get(),
+ SchedulingOptions::FromFlags::get(),
+ IREE::HAL::TargetOptions::FromFlags::get(),
+ IREE::VM::TargetOptions::FromFlags::get(), defaultHooks, passManager);
+}
+
+void registerIREEVMTransformPassPipeline() {
+ PassPipelineRegistration<> transformPassPipeline(
+ "iree-transformation-pipeline",
+ "Runs the full IREE input to VM transformation pipeline",
+ [](OpPassManager &passManager) {
+ buildDefaultIREEVMTransformPassPipeline(passManager);
+ });
+}
+
} // namespace iree_compiler
} // namespace mlir
diff --git a/compiler/src/iree/compiler/Pipelines/Pipelines.h b/compiler/src/iree/compiler/Pipelines/Pipelines.h
index b958286..1cc9c4b 100644
--- a/compiler/src/iree/compiler/Pipelines/Pipelines.h
+++ b/compiler/src/iree/compiler/Pipelines/Pipelines.h
@@ -38,6 +38,12 @@
IREE::VM::TargetOptions targetOptions, IREEVMPipelineHooks &hooks,
OpPassManager &passManager);
+// Builds the above with options initialized from flags.
+void buildDefaultIREEVMTransformPassPipeline(OpPassManager &passManager);
+
+// Registration hooks.
+void registerIREEVMTransformPassPipeline();
+
} // namespace iree_compiler
} // namespace mlir
diff --git a/compiler/src/iree/compiler/Tools/BUILD b/compiler/src/iree/compiler/Tools/BUILD
index 0f442f9..75f22ff 100644
--- a/compiler/src/iree/compiler/Tools/BUILD
+++ b/compiler/src/iree/compiler/Tools/BUILD
@@ -33,6 +33,7 @@
"//compiler/src/iree/compiler/Dialect/Util/IR",
"//compiler/src/iree/compiler/Dialect/Util/Transforms",
"//compiler/src/iree/compiler/Dialect/VM/Analysis",
+ "//compiler/src/iree/compiler/Dialect/VM/Conversion/VMToEmitC",
"//compiler/src/iree/compiler/Dialect/VM/IR",
"//compiler/src/iree/compiler/Dialect/VM/Transforms",
"//compiler/src/iree/compiler/Dialect/Vulkan/IR",
@@ -40,8 +41,7 @@
"//compiler/src/iree/compiler/InputConversion/MHLO",
"//compiler/src/iree/compiler/InputConversion/TMTensor",
"//compiler/src/iree/compiler/InputConversion/TOSA",
- "//compiler/src/iree/compiler/Translation:HALExecutable",
- "//compiler/src/iree/compiler/Translation:IREEVM",
+ "//compiler/src/iree/compiler/Pipelines",
"//llvm-external-projects/iree-dialects:IREEInputDialect",
"//llvm-external-projects/iree-dialects:IREELinalgExtDialect",
"//llvm-external-projects/iree-dialects:IREELinalgExtPasses",
@@ -143,18 +143,6 @@
)
cc_library(
- name = "init_translations",
- hdrs = [
- "init_translations.h",
- ],
- deps = [
- "//compiler/src/iree/compiler/Translation:HALExecutable",
- "//compiler/src/iree/compiler/Translation:IREEVM",
- "@llvm-project//mlir:SPIRVTranslateRegistration",
- ],
-)
-
-cc_library(
name = "init_xla_dialects",
hdrs = [
"init_xla_dialects.h",
@@ -188,29 +176,24 @@
)
cc_library(
- name = "iree_translate_lib",
+ name = "iree_compile_lib",
srcs = [
"iree_compile_lib.cc",
- "iree_translate_lib.cc",
],
- hdrs = ["iree_translate_lib.h"],
+ hdrs = ["iree_compile_lib.h"],
deps = [
":init_llvmir_translations",
":init_passes_and_dialects",
":init_targets",
- ":init_translations",
"//compiler/src/iree/compiler/Codegen",
"//compiler/src/iree/compiler/ConstEval",
"//compiler/src/iree/compiler/Dialect/VM/Target:init_targets",
"//compiler/src/iree/compiler/Dialect/VM/Target/Bytecode",
"//compiler/src/iree/compiler/Dialect/VM/Target/C",
"//compiler/src/iree/compiler/Pipelines",
- "//compiler/src/iree/compiler/Translation:HALExecutable",
- "//compiler/src/iree/compiler/Translation:IREEVM",
"//compiler/src/iree/compiler/Utils",
"@llvm-project//llvm:Support",
"@llvm-project//mlir:IR",
- "@llvm-project//mlir:LLVMToLLVMIRTranslation",
"@llvm-project//mlir:Parser",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:SCFTransforms",
diff --git a/compiler/src/iree/compiler/Tools/CMakeLists.txt b/compiler/src/iree/compiler/Tools/CMakeLists.txt
index d0fff99..2ef4996 100644
--- a/compiler/src/iree/compiler/Tools/CMakeLists.txt
+++ b/compiler/src/iree/compiler/Tools/CMakeLists.txt
@@ -69,6 +69,7 @@
iree::compiler::Dialect::Util::IR
iree::compiler::Dialect::Util::Transforms
iree::compiler::Dialect::VM::Analysis
+ iree::compiler::Dialect::VM::Conversion::VMToEmitC
iree::compiler::Dialect::VM::IR
iree::compiler::Dialect::VM::Transforms
iree::compiler::Dialect::Vulkan::IR
@@ -77,8 +78,7 @@
iree::compiler::InputConversion::TMTensor
iree::compiler::InputConversion::TOSA
iree::compiler::ConstEval
- iree::compiler::Translation::HALExecutable
- iree::compiler::Translation::IREEVM
+ iree::compiler::Pipelines
PUBLIC
)
@@ -207,28 +207,15 @@
iree_cc_library(
NAME
- init_translations
+ iree_compile_lib
HDRS
- "init_translations.h"
- DEPS
- iree::compiler::Translation::HALExecutable
- iree::compiler::Translation::IREEVM
- MLIRSPIRVTranslateRegistration
-)
-
-iree_cc_library(
- NAME
- iree_translate_lib
- HDRS
- "iree_translate_lib.h"
+ "iree_compile_lib.h"
SRCS
"iree_compile_lib.cc"
- "iree_translate_lib.cc"
DEPS
::init_llvmir_translations
::init_passes_and_dialects
::init_targets
- ::init_translations
LLVMSupport
MLIRIR
MLIRSCFTransforms
@@ -236,15 +223,12 @@
MLIRPass
MLIRSupport
MLIRTargetLLVMIRExport
- MLIRTranslateLib
iree::compiler::Codegen::Codegen
iree::compiler::ConstEval
iree::compiler::Dialect::VM::Target::Bytecode
iree::compiler::Dialect::VM::Target::init_targets
iree::compiler::Dialect::VM::Target::C
iree::compiler::Pipelines
- iree::compiler::Translation::HALExecutable
- iree::compiler::Translation::IREEVM
iree::compiler::Utils
PUBLIC
)
diff --git a/compiler/src/iree/compiler/Tools/init_iree_passes.h b/compiler/src/iree/compiler/Tools/init_iree_passes.h
index f0cef6d..53e9f09 100644
--- a/compiler/src/iree/compiler/Tools/init_iree_passes.h
+++ b/compiler/src/iree/compiler/Tools/init_iree_passes.h
@@ -31,7 +31,10 @@
#include "iree/compiler/InputConversion/TMTensor/Passes.h"
#endif
#include "iree/compiler/InputConversion/TOSA/Passes.h"
-#include "iree/compiler/Translation/IREEVM.h"
+#include "iree/compiler/Pipelines/Pipelines.h"
+
+// TODO: Remove these once rolled up into explicit registration.
+#include "iree/compiler/Dialect/VM/Conversion/VMToEmitC/ConvertVMToEmitC.h"
namespace mlir {
namespace iree_compiler {
@@ -62,6 +65,12 @@
IREE::VM::registerVMTestPasses();
IREE::VMVX::registerVMVXPasses();
registerIREEVMTransformPassPipeline();
+
+ // We have some dangling passes that don't use explicit
+ // registration and that we need to force instantiation
+ // of in order to register.
+ // TODO: Eliminate these.
+ IREE::VM::createConvertVMToEmitCPass();
}
} // namespace iree_compiler
} // namespace mlir
diff --git a/compiler/src/iree/compiler/Tools/init_translations.h b/compiler/src/iree/compiler/Tools/init_translations.h
deleted file mode 100644
index 6354df6..0000000
--- a/compiler/src/iree/compiler/Tools/init_translations.h
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright 2020 The IREE Authors
-//
-// Licensed under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-// This file defines a helper to trigger the registration of all translations
-// in and out of MLIR to the system.
-//
-// Based on MLIR's InitAllTranslations but without translations we don't care
-// about.
-//
-// Note that this performs registration of named translations for the use of
-// iree-translate. This is different from "LLVM IR Translations", which are
-// registered on a context and provide hooks for populating LLVM IR for
-// certain dialects. See init_llvmir_translations.h.
-
-#ifndef IREE_COMPILER_TOOLS_INIT_TRANSLATIONS_H_
-#define IREE_COMPILER_TOOLS_INIT_TRANSLATIONS_H_
-
-#include "iree/compiler/Translation/HALExecutable.h"
-#include "iree/compiler/Translation/IREEVM.h"
-
-namespace mlir {
-
-void registerToSPIRVTranslation();
-
-// This function should be called before creating any MLIRContext if one
-// expects all the possible translations to be made available to the context
-// automatically.
-inline void registerMlirTranslations() {
- static bool init_once = []() {
- registerToSPIRVTranslation();
- return true;
- }();
- (void)init_once;
-}
-
-namespace iree_compiler {
-
-// This function should be called before creating any MLIRContext if one
-// expects all the possible translations to be made available to the context
-// automatically.
-inline void registerIreeTranslations() {
- static bool init_once = []() {
- registerHALExecutableTranslation();
- registerIREEVMTranslation();
- return true;
- }();
- (void)init_once;
-}
-
-} // namespace iree_compiler
-} // namespace mlir
-
-#endif // IREE_COMPILER_TOOLS_INIT_TRANSLATIONS_H_
diff --git a/compiler/src/iree/compiler/Tools/iree_compile_lib.cc b/compiler/src/iree/compiler/Tools/iree_compile_lib.cc
index 33c3fd5..5ac37ac 100644
--- a/compiler/src/iree/compiler/Tools/iree_compile_lib.cc
+++ b/compiler/src/iree/compiler/Tools/iree_compile_lib.cc
@@ -4,6 +4,8 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#include "iree/compiler/Tools/iree_compile_lib.h"
+
#include <functional>
#include <memory>
#include <string>
@@ -16,7 +18,6 @@
#include "iree/compiler/Tools/init_llvmir_translations.h"
#include "iree/compiler/Tools/init_passes.h"
#include "iree/compiler/Tools/init_targets.h"
-#include "iree/compiler/Tools/iree_translate_lib.h"
#include "iree/compiler/Utils/PassUtils.h"
#include "iree/compiler/Utils/TracingUtils.h"
#include "llvm/ADT/StringRef.h"
@@ -55,6 +56,20 @@
vm_asm,
vm_bytecode,
vm_c,
+ // Non-user exposed output format for use with --compile-mode=hal-executable.
+ hal_executable,
+};
+
+enum class CompileMode {
+ // IREE's full compilation pipeline.
+ std,
+ // Compile from VM IR (currently this does nothing but may do more in the
+ // future).
+ vm,
+ // Translates an MLIR module containing a single hal.executable into a
+ // target-specific binary form (such as an ELF file or a flatbuffer containing
+ // a SPIR-V blob).
+ hal_executable,
};
IREEVMPipelineHooks &getHooks() {
@@ -128,6 +143,18 @@
clEnumValN(OutputFormat::vm_asm, "vm-asm", "IREE VM MLIR Assembly")),
llvm::cl::init(OutputFormat::none), llvm::cl::cat(mainOptions));
+ llvm::cl::opt<CompileMode> compileMode(
+ "compile-mode", llvm::cl::desc("IREE compilation mode"),
+ llvm::cl::values(
+ clEnumValN(CompileMode::std, "std", "Standard compilation"),
+ clEnumValN(CompileMode::vm, "vm", "Compile from VM IR"),
+ clEnumValN(
+ CompileMode::hal_executable, "hal-executable",
+ "Compile an MLIR module containing a single hal.executable into "
+ "a target-specific binary form (such as an ELF file or a "
+ "flatbuffer containing a SPIR-V blob)")),
+ llvm::cl::init(CompileMode::std), llvm::cl::cat(mainOptions));
+
llvm::cl::opt<bool> legacyTranslateToCModule(
"iree-mlir-to-vm-c-module",
llvm::cl::desc("Alias for --output-format=c-module (deprecated)"),
@@ -208,12 +235,43 @@
mlir::applyPassManagerCLOptions(passManager);
mlir::applyDefaultTimingPassManagerCLOptions(passManager);
passManager.addInstrumentation(std::make_unique<PassTracing>());
- buildIREEVMTransformPassPipeline(bindingOptions, inputOptions,
- highLevelOptimizationOptions,
- schedulingOptions, halTargetOptions,
- vmTargetOptions, getHooks(), passManager);
+
+ switch (compileMode) {
+ case CompileMode::std:
+ buildIREEVMTransformPassPipeline(
+ bindingOptions, inputOptions, highLevelOptimizationOptions,
+ schedulingOptions, halTargetOptions, vmTargetOptions, getHooks(),
+ passManager);
+
+ break;
+ case CompileMode::vm:
+ break;
+ case CompileMode::hal_executable: {
+ // Override the output format.
+ outputFormat = OutputFormat::hal_executable;
+ auto executableOps =
+ llvm::to_vector<4>(module->getOps<IREE::HAL::ExecutableOp>());
+ auto sourceOps =
+ llvm::to_vector<4>(module->getOps<IREE::HAL::ExecutableSourceOp>());
+ size_t usableOpCount = executableOps.size() + sourceOps.size();
+ if (usableOpCount != 1) {
+ return module->emitError()
+ << "HAL executable translation requires "
+ "exactly 1 top level hal.executable/hal.executable.source "
+ "op";
+ }
+ auto executableOptions = IREE::HAL::TargetOptions::FromFlags::get();
+ IREE::HAL::buildHALTransformPassPipeline(passManager,
+ executableOptions);
+ break;
+ }
+ default:
+ llvm::errs() << "INTERNAL ERROR: unknown compile mode\n";
+ return failure();
+ }
+
if (failed(passManager.run(module.get()))) {
- llvm::errs() << "compilation from source to vm failed\n";
+ llvm::errs() << "compilation failed\n";
return failure();
}
@@ -230,6 +288,23 @@
return mlir::iree_compiler::IREE::VM::translateModuleToC(
module.get(), cTargetOptions, os);
#endif
+ case OutputFormat::hal_executable: {
+ // Extract the serialized binary representation from the executable.
+ auto executableOp =
+ *(module->getOps<IREE::HAL::ExecutableOp>().begin());
+ auto binaryOps = llvm::to_vector<4>(
+ executableOp.getOps<IREE::HAL::ExecutableBinaryOp>());
+ if (binaryOps.size() != 1) {
+ return executableOp.emitError() << "executable translation failed to "
+ "produce exactly 1 binary for "
+ "the input executable";
+ }
+ auto binaryOp = binaryOps.front();
+ auto rawData = binaryOp.data().getRawData();
+ os.write(rawData.data(), rawData.size());
+ return success();
+ break;
+ }
default:
llvm::errs() << "INTERNAL ERROR: Unknown output format\n";
return failure();
diff --git a/compiler/src/iree/compiler/Tools/iree_compile_lib.h b/compiler/src/iree/compiler/Tools/iree_compile_lib.h
new file mode 100644
index 0000000..396b802
--- /dev/null
+++ b/compiler/src/iree/compiler/Tools/iree_compile_lib.h
@@ -0,0 +1,18 @@
+// Copyright 2021 The IREE Authors
+//
+// Licensed under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+#ifndef IREE_COMPILER_TOOLS_IREE_COMPILE_LIB_H
+#define IREE_COMPILER_TOOLS_IREE_COMPILE_LIB_H
+
+namespace mlir {
+namespace iree_compiler {
+
+int runIreecMain(int argc, char **argv);
+
+} // namespace iree_compiler
+} // namespace mlir
+
+#endif // IREE_COMPILER_TOOLS_IREE_COMPILE_LIB_H
\ No newline at end of file
diff --git a/compiler/src/iree/compiler/Tools/iree_translate_lib.cc b/compiler/src/iree/compiler/Tools/iree_translate_lib.cc
deleted file mode 100644
index da552ed..0000000
--- a/compiler/src/iree/compiler/Tools/iree_translate_lib.cc
+++ /dev/null
@@ -1,135 +0,0 @@
-// Copyright 2021 The IREE Authors
-//
-// Licensed under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-#include "iree/compiler/Tools/iree_translate_lib.h"
-
-#include <functional>
-#include <memory>
-#include <string>
-#include <type_traits>
-
-#include "iree/compiler/Dialect/VM/Target/init_targets.h"
-#include "iree/compiler/Tools/init_dialects.h"
-#include "iree/compiler/Tools/init_llvmir_translations.h"
-#include "iree/compiler/Tools/init_passes.h"
-#include "iree/compiler/Tools/init_targets.h"
-#include "iree/compiler/Tools/init_translations.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/CommandLine.h"
-#include "llvm/Support/InitLLVM.h"
-#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/SMLoc.h"
-#include "llvm/Support/SourceMgr.h"
-#include "llvm/Support/ToolOutputFile.h"
-#include "llvm/Support/raw_ostream.h"
-#include "mlir/IR/AsmState.h"
-#include "mlir/IR/Diagnostics.h"
-#include "mlir/IR/Dialect.h"
-#include "mlir/IR/MLIRContext.h"
-#include "mlir/Pass/PassManager.h"
-#include "mlir/Support/FileUtilities.h"
-#include "mlir/Support/LogicalResult.h"
-#include "mlir/Support/Timing.h"
-#include "mlir/Support/ToolUtilities.h"
-#include "mlir/Tools/mlir-translate/Translation.h"
-
-// TODO: Once we are switched to runIreecMain, this can be slimmed down
-// substantially, since it will just be about testing actual translations.
-int mlir::iree_compiler::runIreeTranslateMain(int argc, char **argv) {
- llvm::InitLLVM y(argc, argv);
-
- // Global/static registrations.
- mlir::iree_compiler::registerHALTargetBackends();
- mlir::iree_compiler::registerVMTargets();
- mlir::registerMlirTranslations();
- mlir::iree_compiler::registerIreeTranslations();
- mlir::iree_compiler::registerAllPasses();
-
- // MLIRContext registration and hooks.
- mlir::DialectRegistry registry;
- mlir::iree_compiler::registerAllDialects(registry);
- mlir::iree_compiler::registerLLVMIRTranslations(registry);
-
- // Make sure command line options are registered.
- (void)mlir::iree_compiler::IREE::HAL::TargetOptions::FromFlags::get();
-
- // Register MLIRContext command-line options like
- // -mlir-print-op-on-diagnostic.
- mlir::registerMLIRContextCLOptions();
- // Register assembly printer command-line options like
- // -mlir-print-op-generic.
- mlir::registerAsmPrinterCLOptions();
- // Register pass manager command-line options like -mlir-print-ir-*.
- mlir::registerPassManagerCLOptions();
- mlir::registerDefaultTimingManagerCLOptions();
-
- // General command line flags.
- llvm::cl::opt<std::string> inputFilename(llvm::cl::Positional,
- llvm::cl::desc("<input file>"),
- llvm::cl::init("-"));
-
- llvm::cl::opt<std::string> outputFilename(
- "o", llvm::cl::desc("Output filename"), llvm::cl::value_desc("filename"),
- llvm::cl::init("-"));
-
- llvm::cl::opt<bool> splitInputFile(
- "split-input-file",
- llvm::cl::desc("Split the input file into pieces and "
- "process each chunk independently"),
- llvm::cl::init(false));
-
- // Add flags for all the registered translations.
- llvm::cl::opt<const mlir::TranslateFunction *, false, mlir::TranslationParser>
- translationRequested("", llvm::cl::desc("Translation to perform"),
- llvm::cl::Optional);
-
- llvm::cl::ParseCommandLineOptions(argc, argv, "IREE translation driver\n");
-
- std::string errorMessage;
- auto input = mlir::openInputFile(inputFilename, &errorMessage);
- if (!input) {
- llvm::errs() << errorMessage << "\n";
- return 1;
- }
-
- auto output = mlir::openOutputFile(outputFilename, &errorMessage);
- if (!output) {
- llvm::errs() << errorMessage << "\n";
- return 1;
- }
-
- // The value is required in processBuffer but if Required option is set on
- // flag above then there is an error reported per possible translation rather
- // than single one, so check explicitly instead.
- if (!translationRequested) {
- llvm::errs()
- << "Translation to perform option: must be specified at least once!\n";
- return 1;
- }
-
- /// Processes the memory buffer with a new MLIRContext.
- auto processBuffer = [&](std::unique_ptr<llvm::MemoryBuffer> ownedBuffer,
- llvm::raw_ostream &os) {
- mlir::MLIRContext context;
- context.allowUnregisteredDialects();
- context.appendDialectRegistry(registry);
- llvm::SourceMgr sourceMgr;
- sourceMgr.AddNewSourceBuffer(std::move(ownedBuffer), llvm::SMLoc());
- mlir::SourceMgrDiagnosticHandler diagHandler(sourceMgr, &context);
- return (*translationRequested)(sourceMgr, os, &context);
- };
-
- if (splitInputFile) {
- if (failed(mlir::splitAndProcessBuffer(std::move(input), processBuffer,
- output->os())))
- return 1;
- } else {
- if (failed(processBuffer(std::move(input), output->os()))) return 1;
- }
-
- output->keep();
- return 0;
-}
diff --git a/compiler/src/iree/compiler/Tools/iree_translate_lib.h b/compiler/src/iree/compiler/Tools/iree_translate_lib.h
deleted file mode 100644
index 225c3b5..0000000
--- a/compiler/src/iree/compiler/Tools/iree_translate_lib.h
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2021 The IREE Authors
-//
-// Licensed under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-#ifndef IREE_COMPILER_TOOLS_IREE_TRANSLATE_LIB_H
-#define IREE_COMPILER_TOOLS_IREE_TRANSLATE_LIB_H
-
-namespace mlir {
-namespace iree_compiler {
-
-int runIreeTranslateMain(int argc, char **argv);
-
-// NOTE: We are transitioning from the main compiler being based on
-// the MLIR translation library (i.e. iree-translate) to a dedicated tool
-// called iree-compile. When this is done, the above should go away and this
-// file should be renamed to iree_compile_lib.h.
-int runIreecMain(int argc, char **argv);
-
-} // namespace iree_compiler
-} // namespace mlir
-
-#endif // IREE_COMPILER_TOOLS_IREE_TRANSLATE_LIB_H
diff --git a/compiler/src/iree/compiler/Translation/BUILD b/compiler/src/iree/compiler/Translation/BUILD
deleted file mode 100644
index d664e0b..0000000
--- a/compiler/src/iree/compiler/Translation/BUILD
+++ /dev/null
@@ -1,46 +0,0 @@
-# Copyright 2019 The IREE Authors
-#
-# Licensed under the Apache License v2.0 with LLVM Exceptions.
-# See https://llvm.org/LICENSE.txt for license information.
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-load("//build_tools/bazel:build_defs.oss.bzl", "iree_compiler_cc_library")
-
-package(
- default_visibility = ["//visibility:public"],
- features = ["layering_check"],
- licenses = ["notice"], # Apache 2.0
-)
-
-iree_compiler_cc_library(
- name = "HALExecutable",
- srcs = ["HALExecutable.cpp"],
- hdrs = ["HALExecutable.h"],
- deps = [
- "//compiler/src/iree/compiler/Dialect/HAL/Target",
- "//compiler/src/iree/compiler/Dialect/HAL/Transforms",
- "//compiler/src/iree/compiler/Utils",
- "@llvm-project//llvm:Support",
- "@llvm-project//mlir:IR",
- "@llvm-project//mlir:Pass",
- "@llvm-project//mlir:Support",
- "@llvm-project//mlir:Translation",
- ],
-)
-
-iree_compiler_cc_library(
- name = "IREEVM",
- srcs = ["IREEVM.cpp"],
- hdrs = ["IREEVM.h"],
- deps = [
- "//compiler/src/iree/compiler/ConstEval",
- "//compiler/src/iree/compiler/Dialect/Flow/IR",
- "//compiler/src/iree/compiler/Dialect/HAL/Target",
- "//compiler/src/iree/compiler/Dialect/VM/Target/C",
- "//compiler/src/iree/compiler/Pipelines",
- "//compiler/src/iree/compiler/Pipelines:Options",
- "//compiler/src/iree/compiler/Utils",
- "@llvm-project//mlir:Pass",
- "@llvm-project//mlir:Translation",
- ],
-)
diff --git a/compiler/src/iree/compiler/Translation/CMakeLists.txt b/compiler/src/iree/compiler/Translation/CMakeLists.txt
deleted file mode 100644
index 7fd0e64..0000000
--- a/compiler/src/iree/compiler/Translation/CMakeLists.txt
+++ /dev/null
@@ -1,52 +0,0 @@
-################################################################################
-# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from #
-# compiler/src/iree/compiler/Translation/BUILD #
-# #
-# Use iree_cmake_extra_content from iree/build_defs.oss.bzl to add arbitrary #
-# CMake-only content. #
-# #
-# To disable autogeneration for this file entirely, delete this header. #
-################################################################################
-
-iree_add_all_subdirs()
-
-iree_cc_library(
- NAME
- HALExecutable
- HDRS
- "HALExecutable.h"
- SRCS
- "HALExecutable.cpp"
- DEPS
- LLVMSupport
- MLIRIR
- MLIRPass
- MLIRSupport
- MLIRTranslateLib
- iree::compiler::Dialect::HAL::Target
- iree::compiler::Dialect::HAL::Transforms
- iree::compiler::Utils
- PUBLIC
-)
-
-iree_cc_library(
- NAME
- IREEVM
- HDRS
- "IREEVM.h"
- SRCS
- "IREEVM.cpp"
- DEPS
- MLIRPass
- MLIRTranslateLib
- iree::compiler::ConstEval
- iree::compiler::Dialect::Flow::IR
- iree::compiler::Dialect::HAL::Target
- iree::compiler::Dialect::VM::Target::C
- iree::compiler::Pipelines
- iree::compiler::Pipelines::Options
- iree::compiler::Utils
- PUBLIC
-)
-
-### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
diff --git a/compiler/src/iree/compiler/Translation/HALExecutable.cpp b/compiler/src/iree/compiler/Translation/HALExecutable.cpp
deleted file mode 100644
index ef8ecaa..0000000
--- a/compiler/src/iree/compiler/Translation/HALExecutable.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright 2021 The IREE Authors
-//
-// Licensed under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-#include "iree/compiler/Translation/HALExecutable.h"
-
-#include "iree/compiler/Dialect/HAL/Transforms/Passes.h"
-#include "iree/compiler/Utils/TracingUtils.h"
-#include "mlir/IR/BuiltinOps.h"
-#include "mlir/Pass/PassManager.h"
-#include "mlir/Tools/mlir-translate/Translation.h"
-
-namespace mlir {
-namespace iree_compiler {
-
-// Converts from a module containing a hal.executable into the serialized form.
-static LogicalResult translateFromMLIRToHALExecutable(
- mlir::ModuleOp moduleOp, IREE::HAL::TargetOptions executableOptions) {
- auto executableOps =
- llvm::to_vector<4>(moduleOp.getOps<IREE::HAL::ExecutableOp>());
- auto sourceOps =
- llvm::to_vector<4>(moduleOp.getOps<IREE::HAL::ExecutableSourceOp>());
- size_t usableOpCount = executableOps.size() + sourceOps.size();
- if (usableOpCount != 1) {
- return moduleOp.emitError()
- << "HAL executable translation requires "
- "exactly 1 top level hal.executable/hal.executable.source op";
- }
-
- PassManager passManager(moduleOp.getContext());
- mlir::applyPassManagerCLOptions(passManager);
- mlir::applyDefaultTimingPassManagerCLOptions(passManager);
- passManager.addInstrumentation(std::make_unique<PassTracing>());
-
- IREE::HAL::buildHALTransformPassPipeline(passManager, executableOptions);
-
- if (failed(passManager.run(moduleOp))) {
- return moduleOp.emitError() << "conversion from source -> HAL failed";
- }
- return success();
-}
-
-// Translates an MLIR module containing a single hal.executable into a
-// target-specific binary form (such as an ELF file or a FlatBuffer containing
-// a SPIR-V blob).
-//
-// Exposed via the --iree-mlir-to-hal-executable translation.
-static LogicalResult translateFromMLIRToHALExecutableWithFlags(
- mlir::ModuleOp moduleOp, llvm::raw_ostream &output) {
- mlir::registerPassManagerCLOptions();
-
- // Convert into the final target-specific module definition and serialize it.
- auto executableOptions = IREE::HAL::TargetOptions::FromFlags::get();
- auto result = translateFromMLIRToHALExecutable(moduleOp, executableOptions);
- if (failed(result)) {
- return result;
- }
-
- // Extract the serialized binary representation from the executable.
- auto executableOp = *moduleOp.getOps<IREE::HAL::ExecutableOp>().begin();
- auto binaryOps =
- llvm::to_vector<4>(executableOp.getOps<IREE::HAL::ExecutableBinaryOp>());
- if (binaryOps.size() != 1) {
- return executableOp.emitError()
- << "executable translation failed to produce exactly 1 binary for "
- "the input executable";
- }
- auto binaryOp = binaryOps.front();
- auto rawData = binaryOp.data().getRawData();
- output.write(rawData.data(), rawData.size());
- return success();
-}
-
-void registerHALExecutableTranslation() {
- TranslateFromMLIRRegistration toHALExecutableWithFlags(
- "iree-mlir-to-hal-executable", translateFromMLIRToHALExecutableWithFlags);
-}
-
-} // namespace iree_compiler
-} // namespace mlir
diff --git a/compiler/src/iree/compiler/Translation/HALExecutable.h b/compiler/src/iree/compiler/Translation/HALExecutable.h
deleted file mode 100644
index 3ecb21d..0000000
--- a/compiler/src/iree/compiler/Translation/HALExecutable.h
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2021 The IREE Authors
-//
-// Licensed under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-#ifndef IREE_COMPILER_TRANSLATION_HALEXECUTABLE_H_
-#define IREE_COMPILER_TRANSLATION_HALEXECUTABLE_H_
-
-#include "iree/compiler/Dialect/HAL/Target/TargetRegistry.h"
-#include "llvm/Support/raw_ostream.h"
-#include "mlir/IR/BuiltinOps.h"
-#include "mlir/Pass/PassManager.h"
-#include "mlir/Support/LogicalResult.h"
-
-namespace mlir {
-namespace iree_compiler {
-
-void registerHALExecutableTranslation();
-
-} // namespace iree_compiler
-} // namespace mlir
-
-#endif // IREE_COMPILER_TRANSLATION_HALEXECUTABLE_H_
diff --git a/compiler/src/iree/compiler/Translation/IREEVM.cpp b/compiler/src/iree/compiler/Translation/IREEVM.cpp
deleted file mode 100644
index b31abd8..0000000
--- a/compiler/src/iree/compiler/Translation/IREEVM.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-// Copyright 2019 The IREE Authors
-//
-// Licensed under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-#include "iree/compiler/Translation/IREEVM.h"
-
-#include "iree/compiler/ConstEval/Passes.h"
-#include "iree/compiler/Pipelines/Pipelines.h"
-#include "iree/compiler/Utils/PassUtils.h"
-#include "iree/compiler/Utils/TracingUtils.h"
-#include "mlir/Pass/PassManager.h"
-#include "mlir/Tools/mlir-translate/Translation.h"
-
-#ifdef IREE_HAVE_EMITC_DIALECT
-#include "iree/compiler/Dialect/VM/Target/C/CModuleTarget.h"
-#include "iree/compiler/Dialect/VM/Target/C/TranslationFlags.h"
-#endif // IREE_HAVE_EMITC_DIALECT
-
-namespace mlir {
-namespace iree_compiler {
-
-namespace {
-
-IREEVMPipelineHooks &getHooks() {
- static IREEVMPipelineHooks hooks = {
- // buildConstEvalPassPipelineCallback =
- [](OpPassManager &pm) { pm.addPass(ConstEval::createJitGlobalsPass()); }};
- return hooks;
-}
-
-} // namespace
-
-void buildDefaultIREEVMTransformPassPipeline(OpPassManager &passManager) {
- buildIREEVMTransformPassPipeline(
- BindingOptions::FromFlags::get(), InputDialectOptions::FromFlags::get(),
- HighLevelOptimizationOptions::FromFlags::get(),
- SchedulingOptions::FromFlags::get(),
- IREE::HAL::TargetOptions::FromFlags::get(),
- IREE::VM::TargetOptions::FromFlags::get(), getHooks(), passManager);
-}
-
-void registerIREEVMTransformPassPipeline() {
- PassPipelineRegistration<> transformPassPipeline(
- "iree-transformation-pipeline",
- "Runs the full IREE input to VM transformation pipeline",
- [](OpPassManager &passManager) {
- buildDefaultIREEVMTransformPassPipeline(passManager);
- });
-}
-
-// Converts from our source to a vm.module in canonical form.
-// After this completes we have a non-bytecode-specific vm.module that we
-// could lower to other forms (LLVM IR, C, etc).
-static LogicalResult translateFromMLIRToVM(
- ModuleOp moduleOp, BindingOptions bindingOptions,
- InputDialectOptions inputOptions,
- HighLevelOptimizationOptions highLevelOptimizationOptions,
- SchedulingOptions schedulingOptions,
- IREE::HAL::TargetOptions executableOptions,
- IREE::VM::TargetOptions targetOptions) {
- PassManager passManager(moduleOp.getContext());
- mlir::applyPassManagerCLOptions(passManager);
- mlir::applyDefaultTimingPassManagerCLOptions(passManager);
- passManager.addInstrumentation(std::make_unique<PassTracing>());
- buildIREEVMTransformPassPipeline(bindingOptions, inputOptions,
- highLevelOptimizationOptions,
- schedulingOptions, executableOptions,
- targetOptions, getHooks(), passManager);
- if (failed(passManager.run(moduleOp))) {
- llvm::errs() << "compilation from source to vm failed\n";
- return failure();
- }
- return success();
-}
-
-// Translates an MLIR module containing a set of supported IREE input dialects
-// to an IREE VM bytecode module for loading at runtime.
-//
-// See iree/schemas/bytecode_module_def.fbs for the description of the
-// serialized module format.
-//
-// Exposed via the --iree-mlir-to-vm-bytecode-module translation.
-static LogicalResult translateFromMLIRToVMBytecodeModuleWithFlags(
- ModuleOp moduleOp, llvm::raw_ostream &output) {
- mlir::registerPassManagerCLOptions();
- auto bindingOptions = BindingOptions::FromFlags::get();
- auto inputOptions = InputDialectOptions::FromFlags::get();
- auto highLevelOptimizationOptions =
- HighLevelOptimizationOptions::FromFlags::get();
- auto schedulingOptions = SchedulingOptions::FromFlags::get();
- auto halTargetOptions = IREE::HAL::TargetOptions::FromFlags::get();
- auto vmTargetOptions = IREE::VM::TargetOptions::FromFlags::get();
- auto bytecodeTargetOptions =
- IREE::VM::BytecodeTargetOptions::FromFlags::get();
- auto result = translateFromMLIRToVM(
- moduleOp, bindingOptions, inputOptions, highLevelOptimizationOptions,
- schedulingOptions, halTargetOptions, vmTargetOptions);
- if (failed(result)) {
- return result;
- }
- return translateModuleToBytecode(moduleOp, bytecodeTargetOptions, output);
-}
-
-#ifdef IREE_HAVE_EMITC_DIALECT
-// Translates an MLIR module containing a set of supported IREE input dialects
-// to an IREE VM C module.
-//
-// Exposed via the --iree-mlir-to-vm-c-module translation.
-static LogicalResult translateFromMLIRToVMCModuleWithFlags(
- ModuleOp moduleOp, llvm::raw_ostream &output) {
- mlir::registerPassManagerCLOptions();
- auto bindingOptions = BindingOptions::FromFlags::get();
- auto inputOptions = InputDialectOptions::FromFlags::get();
- auto highLevelOptimizationOptions =
- HighLevelOptimizationOptions::FromFlags::get();
- auto schedulingOptions = SchedulingOptions::FromFlags::get();
- auto halTargetOptions = IREE::HAL::TargetOptions::FromFlags::get();
- auto vmTargetOptions = IREE::VM::TargetOptions::FromFlags::get();
- auto cTargetOptions = IREE::VM::getCTargetOptionsFromFlags();
- auto result = translateFromMLIRToVM(
- moduleOp, bindingOptions, inputOptions, highLevelOptimizationOptions,
- schedulingOptions, halTargetOptions, vmTargetOptions);
- if (failed(result)) {
- return result;
- }
- // Serialize to c code.
- return mlir::iree_compiler::IREE::VM::translateModuleToC(
- moduleOp, cTargetOptions, output);
-}
-#endif // IREE_HAVE_EMITC_DIALECT
-
-void registerIREEVMTranslationFlags() {
- BindingOptions::FromFlags::get();
- InputDialectOptions::FromFlags::get();
- HighLevelOptimizationOptions::FromFlags::get();
- IREE::HAL::TargetOptions::FromFlags::get();
- IREE::VM::TargetOptions::FromFlags::get();
- IREE::VM::BytecodeTargetOptions::FromFlags::get();
- SchedulingOptions::FromFlags::get();
-}
-
-void registerIREEVMTranslation() {
- registerIREEVMTranslationFlags();
- TranslateFromMLIRRegistration toVMBytecodeModuleWithFlags(
- "iree-mlir-to-vm-bytecode-module",
- translateFromMLIRToVMBytecodeModuleWithFlags);
-
-#ifdef IREE_HAVE_EMITC_DIALECT
- TranslateFromMLIRRegistration toVMCModuleWithFlags(
- "iree-mlir-to-vm-c-module", translateFromMLIRToVMCModuleWithFlags);
-#endif // IREE_HAVE_EMITC_DIALECT
-}
-
-} // namespace iree_compiler
-} // namespace mlir
diff --git a/compiler/src/iree/compiler/Translation/IREEVM.h b/compiler/src/iree/compiler/Translation/IREEVM.h
deleted file mode 100644
index ab19f05..0000000
--- a/compiler/src/iree/compiler/Translation/IREEVM.h
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2019 The IREE Authors
-//
-// Licensed under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-#ifndef IREE_COMPILER_TRANSLATION_IREEVM_H_
-#define IREE_COMPILER_TRANSLATION_IREEVM_H_
-
-#include "iree/compiler/Dialect/HAL/Target/TargetRegistry.h"
-#include "iree/compiler/Dialect/VM/Conversion/TargetOptions.h"
-#include "iree/compiler/Dialect/VM/Target/Bytecode/BytecodeModuleTarget.h"
-#include "iree/compiler/Pipelines/Options.h"
-#include "iree/compiler/Utils/OptionUtils.h"
-#include "llvm/Support/raw_ostream.h"
-#include "mlir/IR/BuiltinOps.h"
-#include "mlir/Pass/PassManager.h"
-#include "mlir/Support/LogicalResult.h"
-
-namespace mlir {
-namespace iree_compiler {
-
-// Builds the translation pipeline with defaults.
-void buildDefaultIREEVMTransformPassPipeline(OpPassManager &passManager);
-
-// Registration hooks.
-void registerIREEVMTransformPassPipeline();
-void registerIREEVMTranslation();
-void registerIREEVMTranslationFlags();
-
-} // namespace iree_compiler
-} // namespace mlir
-
-#endif // IREE_COMPILER_TRANSLATION_IREEVM_H_
diff --git a/docs/developers/developing_iree/developer_overview.md b/docs/developers/developing_iree/developer_overview.md
index a59e52b..e221433 100644
--- a/docs/developers/developing_iree/developer_overview.md
+++ b/docs/developers/developing_iree/developer_overview.md
@@ -127,23 +127,6 @@
-o /tmp/simple_abs_vmvx.vmfb
```
-# iree-translate
-
-This is the IREE equivalent of MLIR's translation tool, which is used for
-testing translations between supported formats. It is used by various unit
-tests which are testing these features in isolation (outside of the main
-compiler driver).
-
-See
-[mlir-translate](https://github.com/llvm/llvm-project/tree/master/mlir/tools/mlir-translate),
-see "translation" in
-[MLIR's Glossary](https://mlir.llvm.org/getting_started/Glossary/#translation)
-for more information.
-
-Custom translations may also be layered on top of `iree-translate`, see
-[samples/custom_modules/dialect](https://github.com/google/iree/blob/main/samples/custom_modules/dialect)
-for a sample.
-
### iree-run-module
The `iree-run-module` program takes an already translated IREE module as input
diff --git a/runtime/src/iree/hal/cts/CMakeLists.txt b/runtime/src/iree/hal/cts/CMakeLists.txt
index 0216567..19976ec 100644
--- a/runtime/src/iree/hal/cts/CMakeLists.txt
+++ b/runtime/src/iree/hal/cts/CMakeLists.txt
@@ -20,7 +20,7 @@
PARENT_SCOPE
)
-# These tests use executables produced by the iree-translate compiler tool.
+# These tests use executables produced by the iree-compile compiler tool.
# If the compiler is disabled or a HAL driver implementation is not yet
# connected to a functional compiler target, these tests can be skipped.
set(IREE_EXECUTABLE_CTS_TESTS
diff --git a/runtime/src/iree/vm/BUILD b/runtime/src/iree/vm/BUILD
index 9fade44..680980e 100644
--- a/runtime/src/iree/vm/BUILD
+++ b/runtime/src/iree/vm/BUILD
@@ -271,8 +271,8 @@
testonly = True,
src = "bytecode_module_benchmark.mlir",
c_identifier = "iree_vm_bytecode_module_benchmark_module",
- flags = ["--iree-vm-ir-to-bytecode-module"],
- translate_tool = "//tools:iree-translate",
+ flags = ["--compile-mode=vm"],
+ translate_tool = "//tools:iree-compile",
)
cc_binary_benchmark(
@@ -291,8 +291,8 @@
testonly = True,
src = "bytecode_module_size_benchmark.mlir",
c_identifier = "iree_vm_bytecode_module_size_benchmark_module",
- flags = ["--iree-vm-ir-to-bytecode-module"],
- translate_tool = "//tools:iree-translate",
+ flags = ["--compile-mode=vm"],
+ translate_tool = "//tools:iree-compile",
)
iree_cmake_extra_content(
diff --git a/runtime/src/iree/vm/CMakeLists.txt b/runtime/src/iree/vm/CMakeLists.txt
index a0f57c1..28e9f97 100644
--- a/runtime/src/iree/vm/CMakeLists.txt
+++ b/runtime/src/iree/vm/CMakeLists.txt
@@ -235,9 +235,9 @@
C_IDENTIFIER
"iree_vm_bytecode_module_benchmark_module"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
FLAGS
- "--iree-vm-ir-to-bytecode-module"
+ "--compile-mode=vm"
TESTONLY
PUBLIC
)
@@ -263,9 +263,9 @@
C_IDENTIFIER
"iree_vm_bytecode_module_size_benchmark_module"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
FLAGS
- "--iree-vm-ir-to-bytecode-module"
+ "--compile-mode=vm"
TESTONLY
PUBLIC
)
diff --git a/runtime/src/iree/vm/test/BUILD b/runtime/src/iree/vm/test/BUILD
index c0e3029..349bdad 100644
--- a/runtime/src/iree/vm/test/BUILD
+++ b/runtime/src/iree/vm/test/BUILD
@@ -59,167 +59,215 @@
iree_bytecode_module(
name = "arithmetic_ops",
src = "arithmetic_ops.mlir",
- flags = ["--iree-vm-ir-to-bytecode-module"],
- translate_tool = "//tools:iree-translate",
+ flags = [
+ "--compile-mode=vm",
+ ],
+ translate_tool = "//tools:iree-compile",
)
iree_bytecode_module(
name = "arithmetic_ops_f32",
src = "arithmetic_ops_f32.mlir",
- flags = ["--iree-vm-ir-to-bytecode-module"],
- translate_tool = "//tools:iree-translate",
+ flags = [
+ "--compile-mode=vm",
+ ],
+ translate_tool = "//tools:iree-compile",
)
iree_bytecode_module(
name = "arithmetic_ops_i64",
src = "arithmetic_ops_i64.mlir",
- flags = ["--iree-vm-ir-to-bytecode-module"],
- translate_tool = "//tools:iree-translate",
+ flags = [
+ "--compile-mode=vm",
+ ],
+ translate_tool = "//tools:iree-compile",
)
iree_bytecode_module(
name = "assignment_ops",
src = "assignment_ops.mlir",
- flags = ["--iree-vm-ir-to-bytecode-module"],
- translate_tool = "//tools:iree-translate",
+ flags = [
+ "--compile-mode=vm",
+ ],
+ translate_tool = "//tools:iree-compile",
)
iree_bytecode_module(
name = "assignment_ops_f32",
src = "assignment_ops_f32.mlir",
- flags = ["--iree-vm-ir-to-bytecode-module"],
- translate_tool = "//tools:iree-translate",
+ flags = [
+ "--compile-mode=vm",
+ ],
+ translate_tool = "//tools:iree-compile",
)
iree_bytecode_module(
name = "assignment_ops_i64",
src = "assignment_ops_i64.mlir",
- flags = ["--iree-vm-ir-to-bytecode-module"],
- translate_tool = "//tools:iree-translate",
+ flags = [
+ "--compile-mode=vm",
+ ],
+ translate_tool = "//tools:iree-compile",
)
iree_bytecode_module(
name = "buffer_ops",
src = "buffer_ops.mlir",
- flags = ["--iree-vm-ir-to-bytecode-module"],
- translate_tool = "//tools:iree-translate",
+ flags = [
+ "--compile-mode=vm",
+ ],
+ translate_tool = "//tools:iree-compile",
)
iree_bytecode_module(
name = "call_ops",
src = "call_ops.mlir",
- flags = ["--iree-vm-ir-to-bytecode-module"],
- translate_tool = "//tools:iree-translate",
+ flags = [
+ "--compile-mode=vm",
+ ],
+ translate_tool = "//tools:iree-compile",
)
iree_bytecode_module(
name = "comparison_ops",
src = "comparison_ops.mlir",
- flags = ["--iree-vm-ir-to-bytecode-module"],
- translate_tool = "//tools:iree-translate",
+ flags = [
+ "--compile-mode=vm",
+ ],
+ translate_tool = "//tools:iree-compile",
)
iree_bytecode_module(
name = "comparison_ops_f32",
src = "comparison_ops_f32.mlir",
- flags = ["--iree-vm-ir-to-bytecode-module"],
- translate_tool = "//tools:iree-translate",
+ flags = [
+ "--compile-mode=vm",
+ ],
+ translate_tool = "//tools:iree-compile",
)
iree_bytecode_module(
name = "comparison_ops_i64",
src = "comparison_ops_i64.mlir",
- flags = ["--iree-vm-ir-to-bytecode-module"],
- translate_tool = "//tools:iree-translate",
+ flags = [
+ "--compile-mode=vm",
+ ],
+ translate_tool = "//tools:iree-compile",
)
iree_bytecode_module(
name = "control_flow_ops",
src = "control_flow_ops.mlir",
- flags = ["--iree-vm-ir-to-bytecode-module"],
- translate_tool = "//tools:iree-translate",
+ flags = [
+ "--compile-mode=vm",
+ ],
+ translate_tool = "//tools:iree-compile",
)
iree_bytecode_module(
name = "conversion_ops",
src = "conversion_ops.mlir",
- flags = ["--iree-vm-ir-to-bytecode-module"],
- translate_tool = "//tools:iree-translate",
+ flags = [
+ "--compile-mode=vm",
+ ],
+ translate_tool = "//tools:iree-compile",
)
iree_bytecode_module(
name = "conversion_ops_f32",
src = "conversion_ops_f32.mlir",
- flags = ["--iree-vm-ir-to-bytecode-module"],
- translate_tool = "//tools:iree-translate",
+ flags = [
+ "--compile-mode=vm",
+ ],
+ translate_tool = "//tools:iree-compile",
)
iree_bytecode_module(
name = "conversion_ops_i64",
src = "conversion_ops_i64.mlir",
- flags = ["--iree-vm-ir-to-bytecode-module"],
- translate_tool = "//tools:iree-translate",
+ flags = [
+ "--compile-mode=vm",
+ ],
+ translate_tool = "//tools:iree-compile",
)
iree_bytecode_module(
name = "global_ops",
src = "global_ops.mlir",
- flags = ["--iree-vm-ir-to-bytecode-module"],
- translate_tool = "//tools:iree-translate",
+ flags = [
+ "--compile-mode=vm",
+ ],
+ translate_tool = "//tools:iree-compile",
)
iree_bytecode_module(
name = "global_ops_f32",
src = "global_ops_f32.mlir",
- flags = ["--iree-vm-ir-to-bytecode-module"],
- translate_tool = "//tools:iree-translate",
+ flags = [
+ "--compile-mode=vm",
+ ],
+ translate_tool = "//tools:iree-compile",
)
iree_bytecode_module(
name = "global_ops_i64",
src = "global_ops_i64.mlir",
- flags = ["--iree-vm-ir-to-bytecode-module"],
- translate_tool = "//tools:iree-translate",
+ flags = [
+ "--compile-mode=vm",
+ ],
+ translate_tool = "//tools:iree-compile",
)
iree_bytecode_module(
name = "list_ops",
src = "list_ops.mlir",
- flags = ["--iree-vm-ir-to-bytecode-module"],
- translate_tool = "//tools:iree-translate",
+ flags = [
+ "--compile-mode=vm",
+ ],
+ translate_tool = "//tools:iree-compile",
)
iree_bytecode_module(
name = "list_ops_i64",
src = "list_ops_i64.mlir",
- flags = ["--iree-vm-ir-to-bytecode-module"],
- translate_tool = "//tools:iree-translate",
+ flags = [
+ "--compile-mode=vm",
+ ],
+ translate_tool = "//tools:iree-compile",
)
iree_bytecode_module(
name = "list_variant_ops",
src = "list_variant_ops.mlir",
- flags = ["--iree-vm-ir-to-bytecode-module"],
- translate_tool = "//tools:iree-translate",
+ flags = [
+ "--compile-mode=vm",
+ ],
+ translate_tool = "//tools:iree-compile",
)
iree_bytecode_module(
name = "ref_ops",
src = "ref_ops.mlir",
- flags = ["--iree-vm-ir-to-bytecode-module"],
- translate_tool = "//tools:iree-translate",
+ flags = [
+ "--compile-mode=vm",
+ ],
+ translate_tool = "//tools:iree-compile",
)
iree_bytecode_module(
name = "shift_ops",
src = "shift_ops.mlir",
- flags = ["--iree-vm-ir-to-bytecode-module"],
- translate_tool = "//tools:iree-translate",
+ flags = [
+ "--compile-mode=vm",
+ ],
+ translate_tool = "//tools:iree-compile",
)
iree_bytecode_module(
name = "shift_ops_i64",
src = "shift_ops_i64.mlir",
- flags = ["--iree-vm-ir-to-bytecode-module"],
- translate_tool = "//tools:iree-translate",
+ flags = [
+ "--compile-mode=vm",
+ ],
+ translate_tool = "//tools:iree-compile",
)
diff --git a/runtime/src/iree/vm/test/CMakeLists.txt b/runtime/src/iree/vm/test/CMakeLists.txt
index be720a9..059311b 100644
--- a/runtime/src/iree/vm/test/CMakeLists.txt
+++ b/runtime/src/iree/vm/test/CMakeLists.txt
@@ -56,9 +56,9 @@
SRC
"arithmetic_ops.mlir"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
FLAGS
- "--iree-vm-ir-to-bytecode-module"
+ "--compile-mode=vm"
PUBLIC
)
@@ -68,9 +68,9 @@
SRC
"arithmetic_ops_f32.mlir"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
FLAGS
- "--iree-vm-ir-to-bytecode-module"
+ "--compile-mode=vm"
PUBLIC
)
@@ -80,9 +80,9 @@
SRC
"arithmetic_ops_i64.mlir"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
FLAGS
- "--iree-vm-ir-to-bytecode-module"
+ "--compile-mode=vm"
PUBLIC
)
@@ -92,9 +92,9 @@
SRC
"assignment_ops.mlir"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
FLAGS
- "--iree-vm-ir-to-bytecode-module"
+ "--compile-mode=vm"
PUBLIC
)
@@ -104,9 +104,9 @@
SRC
"assignment_ops_f32.mlir"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
FLAGS
- "--iree-vm-ir-to-bytecode-module"
+ "--compile-mode=vm"
PUBLIC
)
@@ -116,9 +116,9 @@
SRC
"assignment_ops_i64.mlir"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
FLAGS
- "--iree-vm-ir-to-bytecode-module"
+ "--compile-mode=vm"
PUBLIC
)
@@ -128,9 +128,9 @@
SRC
"buffer_ops.mlir"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
FLAGS
- "--iree-vm-ir-to-bytecode-module"
+ "--compile-mode=vm"
PUBLIC
)
@@ -140,9 +140,9 @@
SRC
"call_ops.mlir"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
FLAGS
- "--iree-vm-ir-to-bytecode-module"
+ "--compile-mode=vm"
PUBLIC
)
@@ -152,9 +152,9 @@
SRC
"comparison_ops.mlir"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
FLAGS
- "--iree-vm-ir-to-bytecode-module"
+ "--compile-mode=vm"
PUBLIC
)
@@ -164,9 +164,9 @@
SRC
"comparison_ops_f32.mlir"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
FLAGS
- "--iree-vm-ir-to-bytecode-module"
+ "--compile-mode=vm"
PUBLIC
)
@@ -176,9 +176,9 @@
SRC
"comparison_ops_i64.mlir"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
FLAGS
- "--iree-vm-ir-to-bytecode-module"
+ "--compile-mode=vm"
PUBLIC
)
@@ -188,9 +188,9 @@
SRC
"control_flow_ops.mlir"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
FLAGS
- "--iree-vm-ir-to-bytecode-module"
+ "--compile-mode=vm"
PUBLIC
)
@@ -200,9 +200,9 @@
SRC
"conversion_ops.mlir"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
FLAGS
- "--iree-vm-ir-to-bytecode-module"
+ "--compile-mode=vm"
PUBLIC
)
@@ -212,9 +212,9 @@
SRC
"conversion_ops_f32.mlir"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
FLAGS
- "--iree-vm-ir-to-bytecode-module"
+ "--compile-mode=vm"
PUBLIC
)
@@ -224,9 +224,9 @@
SRC
"conversion_ops_i64.mlir"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
FLAGS
- "--iree-vm-ir-to-bytecode-module"
+ "--compile-mode=vm"
PUBLIC
)
@@ -236,9 +236,9 @@
SRC
"global_ops.mlir"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
FLAGS
- "--iree-vm-ir-to-bytecode-module"
+ "--compile-mode=vm"
PUBLIC
)
@@ -248,9 +248,9 @@
SRC
"global_ops_f32.mlir"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
FLAGS
- "--iree-vm-ir-to-bytecode-module"
+ "--compile-mode=vm"
PUBLIC
)
@@ -260,9 +260,9 @@
SRC
"global_ops_i64.mlir"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
FLAGS
- "--iree-vm-ir-to-bytecode-module"
+ "--compile-mode=vm"
PUBLIC
)
@@ -272,9 +272,9 @@
SRC
"list_ops.mlir"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
FLAGS
- "--iree-vm-ir-to-bytecode-module"
+ "--compile-mode=vm"
PUBLIC
)
@@ -284,9 +284,9 @@
SRC
"list_ops_i64.mlir"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
FLAGS
- "--iree-vm-ir-to-bytecode-module"
+ "--compile-mode=vm"
PUBLIC
)
@@ -296,9 +296,9 @@
SRC
"list_variant_ops.mlir"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
FLAGS
- "--iree-vm-ir-to-bytecode-module"
+ "--compile-mode=vm"
PUBLIC
)
@@ -308,9 +308,9 @@
SRC
"ref_ops.mlir"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
FLAGS
- "--iree-vm-ir-to-bytecode-module"
+ "--compile-mode=vm"
PUBLIC
)
@@ -320,9 +320,9 @@
SRC
"shift_ops.mlir"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
FLAGS
- "--iree-vm-ir-to-bytecode-module"
+ "--compile-mode=vm"
PUBLIC
)
@@ -332,9 +332,9 @@
SRC
"shift_ops_i64.mlir"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
FLAGS
- "--iree-vm-ir-to-bytecode-module"
+ "--compile-mode=vm"
PUBLIC
)
diff --git a/runtime/src/iree/vm/test/emitc/CMakeLists.txt b/runtime/src/iree/vm/test/emitc/CMakeLists.txt
index c4ef95f..3d617fb 100644
--- a/runtime/src/iree/vm/test/emitc/CMakeLists.txt
+++ b/runtime/src/iree/vm/test/emitc/CMakeLists.txt
@@ -52,9 +52,10 @@
H_FILE_OUTPUT
"arithmetic_ops.h"
FLAGS
- "--iree-vm-ir-to-c-module"
+ "--compile-mode=vm"
+ "--output-format=vm-c"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
)
iree_c_module(
@@ -65,9 +66,10 @@
H_FILE_OUTPUT
"arithmetic_ops_f32.h"
FLAGS
- "--iree-vm-ir-to-c-module"
+ "--compile-mode=vm"
+ "--output-format=vm-c"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
)
iree_c_module(
@@ -78,9 +80,10 @@
H_FILE_OUTPUT
"arithmetic_ops_i64.h"
FLAGS
- "--iree-vm-ir-to-c-module"
+ "--compile-mode=vm"
+ "--output-format=vm-c"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
)
iree_c_module(
@@ -91,9 +94,10 @@
H_FILE_OUTPUT
"assignment_ops.h"
FLAGS
- "--iree-vm-ir-to-c-module"
+ "--compile-mode=vm"
+ "--output-format=vm-c"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
)
iree_c_module(
@@ -104,9 +108,10 @@
H_FILE_OUTPUT
"assignment_ops_f32.h"
FLAGS
- "--iree-vm-ir-to-c-module"
+ "--compile-mode=vm"
+ "--output-format=vm-c"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
)
iree_c_module(
@@ -117,9 +122,10 @@
H_FILE_OUTPUT
"assignment_ops_i64.h"
FLAGS
- "--iree-vm-ir-to-c-module"
- TRANSLATE_TOOL
- iree-translate
+ "--compile-mode=vm"
+ "--output-format=vm-c"
+ TRANSLATE_TOOL
+ iree-compile
)
iree_c_module(
@@ -130,9 +136,10 @@
H_FILE_OUTPUT
"buffer_ops.h"
FLAGS
- "--iree-vm-ir-to-c-module"
+ "--compile-mode=vm"
+ "--output-format=vm-c"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
)
iree_c_module(
@@ -143,9 +150,10 @@
H_FILE_OUTPUT
"call_ops.h"
FLAGS
- "--iree-vm-ir-to-c-module"
+ "--compile-mode=vm"
+ "--output-format=vm-c"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
)
iree_c_module(
@@ -156,9 +164,10 @@
H_FILE_OUTPUT
"comparison_ops.h"
FLAGS
- "--iree-vm-ir-to-c-module"
- TRANSLATE_TOOL
- iree-translate
+ "--compile-mode=vm"
+ "--output-format=vm-c"
+ TRANSLATE_TOOL
+ iree-compile
)
iree_c_module(
@@ -169,9 +178,10 @@
H_FILE_OUTPUT
"comparison_ops_f32.h"
FLAGS
- "--iree-vm-ir-to-c-module"
+ "--compile-mode=vm"
+ "--output-format=vm-c"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
)
iree_c_module(
@@ -182,9 +192,10 @@
H_FILE_OUTPUT
"comparison_ops_i64.h"
FLAGS
- "--iree-vm-ir-to-c-module"
+ "--compile-mode=vm"
+ "--output-format=vm-c"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
)
iree_c_module(
@@ -195,9 +206,10 @@
H_FILE_OUTPUT
"control_flow_ops.h"
FLAGS
- "--iree-vm-ir-to-c-module"
+ "--compile-mode=vm"
+ "--output-format=vm-c"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
)
iree_c_module(
@@ -208,9 +220,10 @@
H_FILE_OUTPUT
"conversion_ops.h"
FLAGS
- "--iree-vm-ir-to-c-module"
+ "--compile-mode=vm"
+ "--output-format=vm-c"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
)
iree_c_module(
@@ -221,9 +234,10 @@
H_FILE_OUTPUT
"conversion_ops_f32.h"
FLAGS
- "--iree-vm-ir-to-c-module"
+ "--compile-mode=vm"
+ "--output-format=vm-c"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
)
iree_c_module(
@@ -234,9 +248,10 @@
H_FILE_OUTPUT
"conversion_ops_i64.h"
FLAGS
- "--iree-vm-ir-to-c-module"
+ "--compile-mode=vm"
+ "--output-format=vm-c"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
)
iree_c_module(
@@ -247,9 +262,10 @@
H_FILE_OUTPUT
"global_ops.h"
FLAGS
- "--iree-vm-ir-to-c-module"
+ "--compile-mode=vm"
+ "--output-format=vm-c"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
)
iree_c_module(
@@ -260,9 +276,10 @@
H_FILE_OUTPUT
"global_ops_f32.h"
FLAGS
- "--iree-vm-ir-to-c-module"
+ "--compile-mode=vm"
+ "--output-format=vm-c"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
)
iree_c_module(
@@ -273,9 +290,10 @@
H_FILE_OUTPUT
"global_ops_i64.h"
FLAGS
- "--iree-vm-ir-to-c-module"
+ "--compile-mode=vm"
+ "--output-format=vm-c"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
)
iree_c_module(
@@ -286,9 +304,10 @@
H_FILE_OUTPUT
"list_ops.h"
FLAGS
- "--iree-vm-ir-to-c-module"
+ "--compile-mode=vm"
+ "--output-format=vm-c"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
)
iree_c_module(
@@ -299,9 +318,10 @@
H_FILE_OUTPUT
"list_variant_ops.h"
FLAGS
- "--iree-vm-ir-to-c-module"
+ "--compile-mode=vm"
+ "--output-format=vm-c"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
)
iree_c_module(
@@ -312,9 +332,10 @@
H_FILE_OUTPUT
"ref_ops.h"
FLAGS
- "--iree-vm-ir-to-c-module"
+ "--compile-mode=vm"
+ "--output-format=vm-c"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
)
iree_c_module(
@@ -325,9 +346,10 @@
H_FILE_OUTPUT
"shift_ops.h"
FLAGS
- "--iree-vm-ir-to-c-module"
+ "--compile-mode=vm"
+ "--output-format=vm-c"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
)
iree_c_module(
@@ -338,9 +360,10 @@
H_FILE_OUTPUT
"shift_ops_i64.h"
FLAGS
- "--iree-vm-ir-to-c-module"
+ "--compile-mode=vm"
+ "--output-format=vm-c"
TRANSLATE_TOOL
- iree-translate
+ iree-compile
)
endif()
diff --git a/samples/custom_modules/BUILD b/samples/custom_modules/BUILD
deleted file mode 100644
index 303c910..0000000
--- a/samples/custom_modules/BUILD
+++ /dev/null
@@ -1,67 +0,0 @@
-# Copyright 2019 The IREE Authors
-#
-# Licensed under the Apache License v2.0 with LLVM Exceptions.
-# See https://llvm.org/LICENSE.txt for license information.
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-load("//build_tools/bazel:build_defs.oss.bzl", "iree_cmake_extra_content")
-load("//build_tools/bazel:iree_bytecode_module.bzl", "iree_bytecode_module")
-
-package(
- default_visibility = ["//visibility:public"],
- features = ["layering_check"],
- licenses = ["notice"], # Apache 2.0
-)
-
-cc_library(
- name = "module",
- srcs = ["module.cc"],
- hdrs = ["module.h"],
- deps = [
- "//runtime/src/iree/base",
- "//runtime/src/iree/base:cc",
- "//runtime/src/iree/hal",
- "//runtime/src/iree/modules/hal",
- "//runtime/src/iree/vm",
- "//runtime/src/iree/vm:cc",
- ],
-)
-
-iree_cmake_extra_content(
- content = """
-if(NOT IREE_TARGET_BACKEND_VMVX OR
- NOT IREE_HAL_DRIVER_VMVX)
- return()
-endif()
-""",
-)
-
-iree_bytecode_module(
- name = "custom_modules_test_module",
- src = "custom_modules_test.mlir",
- c_identifier = "iree_samples_custom_modules_test_module",
- flags = [
- "--iree-mlir-to-vm-bytecode-module",
- "--iree-hal-target-backends=vmvx",
- ],
- translate_tool = "//samples/custom_modules/dialect:custom-translate",
-)
-
-cc_test(
- name = "custom_modules_test",
- srcs = ["custom_modules_test.cc"],
- deps = [
- ":custom_modules_test_module_c",
- ":module",
- "//runtime/src/iree/base",
- "//runtime/src/iree/base:logging",
- "//runtime/src/iree/hal",
- "//runtime/src/iree/hal/vmvx/registration",
- "//runtime/src/iree/modules/hal",
- "//runtime/src/iree/testing:gtest",
- "//runtime/src/iree/testing:gtest_main",
- "//runtime/src/iree/vm",
- "//runtime/src/iree/vm:bytecode_module",
- "//runtime/src/iree/vm:cc",
- ],
-)
diff --git a/samples/custom_modules/CMakeLists.txt b/samples/custom_modules/CMakeLists.txt
deleted file mode 100644
index 0153895..0000000
--- a/samples/custom_modules/CMakeLists.txt
+++ /dev/null
@@ -1,70 +0,0 @@
-################################################################################
-# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from #
-# samples/custom_modules/BUILD #
-# #
-# Use iree_cmake_extra_content from iree/build_defs.oss.bzl to add arbitrary #
-# CMake-only content. #
-# #
-# To disable autogeneration for this file entirely, delete this header. #
-################################################################################
-
-if(NOT IREE_TARGET_BACKEND_VMVX OR
- NOT IREE_HAL_DRIVER_VMVX)
- return()
-endif()
-
-iree_add_all_subdirs()
-
-iree_cc_library(
- NAME
- module
- HDRS
- "module.h"
- SRCS
- "module.cc"
- DEPS
- iree::base
- iree::base::cc
- iree::hal
- iree::modules::hal
- iree::vm
- iree::vm::cc
- PUBLIC
-)
-
-iree_bytecode_module(
- NAME
- custom_modules_test_module
- SRC
- "custom_modules_test.mlir"
- C_IDENTIFIER
- "iree_samples_custom_modules_test_module"
- TRANSLATE_TOOL
- iree_samples_custom_modules_dialect_custom-translate
- FLAGS
- "--iree-mlir-to-vm-bytecode-module"
- "--iree-hal-target-backends=vmvx"
- PUBLIC
-)
-
-iree_cc_test(
- NAME
- custom_modules_test
- SRCS
- "custom_modules_test.cc"
- DEPS
- ::custom_modules_test_module_c
- ::module
- iree::base
- iree::base::logging
- iree::hal
- iree::hal::vmvx::registration
- iree::modules::hal
- iree::testing::gtest
- iree::testing::gtest_main
- iree::vm
- iree::vm::bytecode_module
- iree::vm::cc
-)
-
-### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
diff --git a/samples/custom_modules/custom_modules_test.cc b/samples/custom_modules/custom_modules_test.cc
deleted file mode 100644
index b93c4ba..0000000
--- a/samples/custom_modules/custom_modules_test.cc
+++ /dev/null
@@ -1,229 +0,0 @@
-// Copyright 2019 The IREE Authors
-//
-// Licensed under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-// Tests that our bytecode module can call through into our native module.
-
-#include "iree/base/api.h"
-#include "iree/hal/api.h"
-#include "iree/hal/vmvx/registration/driver_module.h"
-#include "iree/modules/hal/module.h"
-#include "iree/testing/gtest.h"
-#include "iree/testing/status_matchers.h"
-#include "iree/vm/api.h"
-#include "iree/vm/bytecode_module.h"
-#include "iree/vm/ref_cc.h"
-#include "samples/custom_modules/custom_modules_test_module_c.h"
-#include "samples/custom_modules/module.h"
-
-namespace {
-
-class CustomModulesTest : public ::testing::Test {
- protected:
- static void SetUpTestSuite() {
- IREE_CHECK_OK(iree_hal_vmvx_driver_module_register(
- iree_hal_driver_registry_default()));
- }
-
- virtual void SetUp() {
- IREE_CHECK_OK(iree_vm_instance_create(iree_allocator_system(), &instance_));
-
- // TODO(benvanik): move to instance-based registration.
- IREE_CHECK_OK(iree_hal_module_register_types());
- // TODO(benvanik): make a 'don't care' helper method.
- iree_hal_driver_t* hal_driver = nullptr;
- IREE_CHECK_OK(iree_hal_driver_registry_try_create_by_name(
- iree_hal_driver_registry_default(), iree_make_cstring_view("vmvx"),
- iree_allocator_system(), &hal_driver));
- iree_hal_device_t* hal_device = nullptr;
- IREE_CHECK_OK(iree_hal_driver_create_default_device(
- hal_driver, iree_allocator_system(), &hal_device));
- IREE_CHECK_OK(iree_hal_module_create(hal_device, iree_allocator_system(),
- &hal_module_));
- hal_allocator_ = iree_hal_device_allocator(hal_device);
- iree_hal_device_release(hal_device);
- iree_hal_driver_release(hal_driver);
-
- IREE_CHECK_OK(iree_custom_native_module_register_types());
- IREE_CHECK_OK(iree_custom_native_module_create(
- iree_allocator_system(), hal_allocator_, &native_module_));
-
- const auto* module_file_toc =
- iree_samples_custom_modules_test_module_create();
- IREE_CHECK_OK(iree_vm_bytecode_module_create(
- iree_const_byte_span_t{
- reinterpret_cast<const uint8_t*>(module_file_toc->data),
- module_file_toc->size},
- iree_allocator_null(), iree_allocator_system(), &bytecode_module_));
-
- std::vector<iree_vm_module_t*> modules = {hal_module_, native_module_,
- bytecode_module_};
- IREE_CHECK_OK(iree_vm_context_create_with_modules(
- instance_, IREE_VM_CONTEXT_FLAG_NONE, modules.data(), modules.size(),
- iree_allocator_system(), &context_));
- }
-
- virtual void TearDown() {
- iree_vm_module_release(hal_module_);
- iree_vm_module_release(native_module_);
- iree_vm_module_release(bytecode_module_);
- iree_vm_context_release(context_);
- iree_vm_instance_release(instance_);
- }
-
- iree_vm_function_t LookupFunction(const char* function_name) {
- iree_vm_function_t function;
- IREE_CHECK_OK(bytecode_module_->lookup_function(
- bytecode_module_->self, IREE_VM_FUNCTION_LINKAGE_EXPORT,
- iree_make_cstring_view(function_name), &function));
- return function;
- }
-
- iree_vm_instance_t* instance_ = nullptr;
- iree_vm_context_t* context_ = nullptr;
- iree_vm_module_t* bytecode_module_ = nullptr;
- iree_vm_module_t* native_module_ = nullptr;
- iree_vm_module_t* hal_module_ = nullptr;
- iree_hal_allocator_t* hal_allocator_ = nullptr;
-};
-
-TEST_F(CustomModulesTest, ReverseAndPrint) {
- // Allocate one of our custom message types to pass in.
- iree_custom_message_t* input_message = nullptr;
- IREE_ASSERT_OK(
- iree_custom_message_wrap(iree_make_cstring_view("hello world!"),
- iree_allocator_system(), &input_message));
- iree_vm_value_t count = iree_vm_value_make_i32(5);
-
- // Pass in the message and number of times to print it.
- // TODO(benvanik): make a macro/magic.
- iree::vm::ref<iree_vm_list_t> inputs;
- IREE_ASSERT_OK(iree_vm_list_create(/*element_type=*/nullptr, 2,
- iree_allocator_system(), &inputs));
- iree_vm_ref_t input_message_ref = iree_custom_message_move_ref(input_message);
- IREE_ASSERT_OK(iree_vm_list_push_ref_move(inputs.get(), &input_message_ref));
- IREE_ASSERT_OK(iree_vm_list_push_value(inputs.get(), &count));
-
- // Prepare outputs list to accept the results from the invocation.
- iree::vm::ref<iree_vm_list_t> outputs;
- IREE_ASSERT_OK(iree_vm_list_create(/*element_type=*/nullptr, 1,
- iree_allocator_system(), &outputs));
-
- // Synchronously invoke the function.
- IREE_ASSERT_OK(iree_vm_invoke(context_, LookupFunction("reverseAndPrint"),
- IREE_VM_INVOCATION_FLAG_NONE,
- /*policy=*/nullptr, inputs.get(), outputs.get(),
- iree_allocator_system()));
-
- // Read back the message that we reversed inside of the module.
- iree_custom_message_t* reversed_message =
- (iree_custom_message_t*)iree_vm_list_get_ref_deref(
- outputs.get(), 0, iree_custom_message_get_descriptor());
- ASSERT_NE(nullptr, reversed_message);
- char result_buffer[256];
- IREE_ASSERT_OK(iree_custom_message_read_value(reversed_message, result_buffer,
- IREE_ARRAYSIZE(result_buffer)));
- EXPECT_STREQ("!dlrow olleh", result_buffer);
-}
-
-TEST_F(CustomModulesTest, PrintTensor) {
- // Allocate the buffer we'll be printing.
- static iree_hal_dim_t kShape[] = {2, 4};
- static const float kBufferContents[2 * 4] = {0.0f, 1.0f, 2.0f, 3.0f,
- 4.0f, 5.0f, 6.0f, 7.0f};
- iree_hal_buffer_params_t params = {0};
- params.type =
- IREE_HAL_MEMORY_TYPE_HOST_LOCAL | IREE_HAL_MEMORY_TYPE_DEVICE_VISIBLE;
- params.usage = IREE_HAL_BUFFER_USAGE_DISPATCH |
- IREE_HAL_BUFFER_USAGE_TRANSFER | IREE_HAL_BUFFER_USAGE_MAPPING;
- iree_hal_buffer_view_t* buffer_view = nullptr;
- IREE_ASSERT_OK(iree_hal_buffer_view_allocate_buffer(
- hal_allocator_, kShape, IREE_ARRAYSIZE(kShape),
- IREE_HAL_ELEMENT_TYPE_FLOAT_32, IREE_HAL_ENCODING_TYPE_DENSE_ROW_MAJOR,
- params,
- iree_make_const_byte_span(kBufferContents, sizeof(kBufferContents)),
- &buffer_view));
-
- // Pass in the tensor as an expanded HAL buffer.
- iree::vm::ref<iree_vm_list_t> inputs;
- IREE_ASSERT_OK(iree_vm_list_create(/*element_type=*/nullptr, 1,
- iree_allocator_system(), &inputs));
- iree_vm_ref_t input_buffer_view_ref =
- iree_hal_buffer_view_move_ref(buffer_view);
- IREE_ASSERT_OK(
- iree_vm_list_push_ref_move(inputs.get(), &input_buffer_view_ref));
-
- // Prepare outputs list to accept the results from the invocation.
- iree::vm::ref<iree_vm_list_t> outputs;
- IREE_ASSERT_OK(iree_vm_list_create(/*element_type=*/nullptr, 1,
- iree_allocator_system(), &outputs));
-
- // Synchronously invoke the function.
- IREE_ASSERT_OK(iree_vm_invoke(context_, LookupFunction("printTensor"),
- IREE_VM_INVOCATION_FLAG_NONE,
- /*policy=*/nullptr, inputs.get(), outputs.get(),
- iree_allocator_system()));
-
- // Read back the message that we printed inside of the module.
- iree_custom_message_t* printed_message =
- (iree_custom_message_t*)iree_vm_list_get_ref_deref(
- outputs.get(), 0, iree_custom_message_get_descriptor());
- ASSERT_NE(nullptr, printed_message);
- char result_buffer[256];
- IREE_ASSERT_OK(iree_custom_message_read_value(printed_message, result_buffer,
- IREE_ARRAYSIZE(result_buffer)));
- EXPECT_STREQ("2x4xf32=[0 1 2 3][4 5 6 7]", result_buffer);
-}
-
-TEST_F(CustomModulesTest, RoundTripTensor) {
- // Allocate the buffer we'll be printing/parsing.
- static iree_hal_dim_t kShape[] = {2, 4};
- static const float kBufferContents[2 * 4] = {0.0f, 1.0f, 2.0f, 3.0f,
- 4.0f, 5.0f, 6.0f, 7.0f};
- iree_hal_buffer_params_t params = {0};
- params.type =
- IREE_HAL_MEMORY_TYPE_HOST_LOCAL | IREE_HAL_MEMORY_TYPE_DEVICE_VISIBLE;
- params.usage = IREE_HAL_BUFFER_USAGE_DISPATCH |
- IREE_HAL_BUFFER_USAGE_TRANSFER | IREE_HAL_BUFFER_USAGE_MAPPING;
- iree_hal_buffer_view_t* buffer_view = nullptr;
- IREE_ASSERT_OK(iree_hal_buffer_view_allocate_buffer(
- hal_allocator_, kShape, IREE_ARRAYSIZE(kShape),
- IREE_HAL_ELEMENT_TYPE_FLOAT_32, IREE_HAL_ENCODING_TYPE_DENSE_ROW_MAJOR,
- params,
- iree_make_const_byte_span(kBufferContents, sizeof(kBufferContents)),
- &buffer_view));
-
- // Pass in the tensor as an expanded HAL buffer.
- iree::vm::ref<iree_vm_list_t> inputs;
- IREE_ASSERT_OK(iree_vm_list_create(/*element_type=*/nullptr, 1,
- iree_allocator_system(), &inputs));
- iree_vm_ref_t input_buffer_view_ref =
- iree_hal_buffer_view_move_ref(buffer_view);
- IREE_ASSERT_OK(
- iree_vm_list_push_ref_move(inputs.get(), &input_buffer_view_ref));
-
- // Prepare outputs list to accept the results from the invocation.
- iree::vm::ref<iree_vm_list_t> outputs;
- IREE_ASSERT_OK(iree_vm_list_create(/*element_type=*/nullptr, 1,
- iree_allocator_system(), &outputs));
-
- // Synchronously invoke the function.
- IREE_ASSERT_OK(iree_vm_invoke(context_, LookupFunction("roundTripTensor"),
- IREE_VM_INVOCATION_FLAG_NONE,
- /*policy=*/nullptr, inputs.get(), outputs.get(),
- iree_allocator_system()));
-
- // Read back the message that's been moved around.
- iree_custom_message_t* printed_message =
- (iree_custom_message_t*)iree_vm_list_get_ref_deref(
- outputs.get(), 0, iree_custom_message_get_descriptor());
- ASSERT_NE(nullptr, printed_message);
- char result_buffer[256];
- IREE_ASSERT_OK(iree_custom_message_read_value(printed_message, result_buffer,
- IREE_ARRAYSIZE(result_buffer)));
- EXPECT_STREQ("2x4xf32=[0 1 2 3][4 5 6 7]", result_buffer);
-}
-
-} // namespace
diff --git a/samples/custom_modules/custom_modules_test.mlir b/samples/custom_modules/custom_modules_test.mlir
deleted file mode 100644
index 1c07259..0000000
--- a/samples/custom_modules/custom_modules_test.mlir
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright 2019 The IREE Authors
-//
-// Licensed under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-// Prints the %message provided reversed %count times using the native
-// implementation of the "custom.print" op.
-//
-// See custom_modules/dialect/custom_ops.td for the op definitions and
-// custom_modules/dialect/custom.imports.mlir for the import definitions.
-func.func @reverseAndPrint(%message : !custom.message, %count : i32) -> !custom.message
- attributes { iree.module.export, iree.abi.none } {
- %c1 = arith.constant 1 : i32
- %0 = "custom.get_unique_message"() : () -> !custom.message
- "custom.print"(%0, %c1) : (!custom.message, i32) -> ()
- %1 = call @reverse(%message) : (!custom.message) -> !custom.message
- "custom.print"(%1, %count) : (!custom.message, i32) -> ()
- return %1 : !custom.message
-}
-
-// Reverses a message. Just an example to show intra-module calls.
-func.func @reverse(%message : !custom.message) -> !custom.message {
- %0 = "custom.reverse"(%message) : (!custom.message) -> !custom.message
- return %0 : !custom.message
-}
-
-// Prints the provided tensor to by first converting it to a message.
-func.func @printTensor(%tensor : tensor<2x4xf32>) -> !custom.message
- attributes { iree.module.export, iree.abi.none } {
- %0 = "custom.tensor_to_message"(%tensor) : (tensor<2x4xf32>) -> !custom.message
- %c1 = arith.constant 1 : i32
- "custom.print"(%0, %c1) : (!custom.message, i32) -> ()
- return %0 : !custom.message
-}
-
-// Round-trips a tensor through a message.
-func.func @roundTripTensor(%tensor : tensor<2x4xf32>) -> !custom.message
- attributes { iree.module.export, iree.abi.none } {
- %0 = "custom.tensor_to_message"(%tensor) : (tensor<2x4xf32>) -> !custom.message
- %1 = "custom.message_to_tensor"(%0) : (!custom.message) -> tensor<2x4xf32>
- %2 = "custom.tensor_to_message"(%1) : (tensor<2x4xf32>) -> !custom.message
- %c1 = arith.constant 1 : i32
- "custom.print"(%2, %c1) : (!custom.message, i32) -> ()
- return %0 : !custom.message
-}
diff --git a/samples/custom_modules/dialect/BUILD b/samples/custom_modules/dialect/BUILD
deleted file mode 100644
index 8b071d0..0000000
--- a/samples/custom_modules/dialect/BUILD
+++ /dev/null
@@ -1,129 +0,0 @@
-# Copyright 2019 The IREE Authors
-#
-# Licensed under the Apache License v2.0 with LLVM Exceptions.
-# See https://llvm.org/LICENSE.txt for license information.
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-load("//build_tools/embed_data:build_defs.bzl", "c_embed_data")
-load("@llvm-project//mlir:tblgen.bzl", "td_library")
-load("//build_tools/bazel:enforce_glob.bzl", "enforce_glob")
-load("//build_tools/bazel:iree_tablegen.bzl", "iree_gentbl_cc_library")
-
-package(
- default_visibility = ["//visibility:public"],
- features = ["layering_check"],
- licenses = ["notice"], # Apache 2.0
-)
-
-td_library(
- name = "td_files",
- srcs = enforce_glob(
- ["custom_ops.td"],
- include = ["*.td"],
- ),
- deps = [
- "//compiler/src/iree/compiler/Dialect/HAL/IR:td_files",
- "//compiler/src/iree/compiler/Dialect/Util/IR:td_files",
- "@llvm-project//mlir:StdOpsTdFiles",
- ],
-)
-
-cc_library(
- name = "dialect",
- srcs = [
- "conversion_patterns.cc",
- "custom_dialect.cc",
- "custom_ops.cc.inc",
- ],
- hdrs = [
- "conversion_patterns.h",
- "custom_dialect.h",
- "custom_ops.h.inc",
- ],
- deps = [
- ":custom_imports",
- ":custom_ops_gen",
- "//compiler/src/iree/compiler/Dialect/HAL/Conversion",
- "//compiler/src/iree/compiler/Dialect/HAL/IR",
- "//compiler/src/iree/compiler/Dialect/Util/IR",
- "//compiler/src/iree/compiler/Dialect/VM/Conversion",
- "@llvm-project//llvm:Support",
- "@llvm-project//mlir:IR",
- "@llvm-project//mlir:Parser",
- "@llvm-project//mlir:Pass",
- "@llvm-project//mlir:SideEffects",
- "@llvm-project//mlir:Transforms",
- ],
-)
-
-iree_gentbl_cc_library(
- name = "custom_ops_gen",
- tbl_outs = [
- (
- ["--gen-op-decls"],
- "custom_ops.h.inc",
- ),
- (
- ["--gen-op-defs"],
- "custom_ops.cc.inc",
- ),
- ],
- tblgen = "@llvm-project//mlir:mlir-tblgen",
- td_file = "custom_ops.td",
- deps = [":td_files"],
-)
-
-c_embed_data(
- name = "custom_imports",
- srcs = ["custom.imports.mlir"],
- c_file_output = "custom.imports.c",
- flatten = True,
- h_file_output = "custom.imports.h",
- identifier = "iree_custom_imports",
-)
-
-cc_library(
- name = "init_dialect",
- hdrs = ["init_dialect.h"],
- deps = [
- ":dialect",
- "@llvm-project//mlir:IR",
- ],
-)
-
-cc_binary(
- name = "custom-opt",
- srcs = ["custom-opt-main.cc"],
- deps = [
- ":init_dialect",
- "//compiler/src/iree/compiler/Tools:init_passes_and_dialects",
- "//compiler/src/iree/compiler/Tools:init_targets",
- "@llvm-project//llvm:Support",
- "@llvm-project//mlir:IR",
- "@llvm-project//mlir:MlirOptLib",
- "@llvm-project//mlir:Support",
- ],
-)
-
-cc_binary(
- name = "custom-translate",
- srcs = ["custom-translate-main.cc"],
- deps = [
- ":init_dialect",
- "//compiler/src/iree/compiler/Dialect/VM/Target:init_targets",
- "//compiler/src/iree/compiler/Dialect/VM/Target/Bytecode",
- "//compiler/src/iree/compiler/Tools:init_compiler_modules",
- "//compiler/src/iree/compiler/Tools:init_iree_passes_and_dialects",
- "//compiler/src/iree/compiler/Tools:init_mlir_passes_and_dialects",
- "//compiler/src/iree/compiler/Tools:init_targets",
- "//compiler/src/iree/compiler/Tools:init_translations",
- "//compiler/src/iree/compiler/Tools:init_xla_dialects",
- "//compiler/src/iree/compiler/Translation:IREEVM",
- "@llvm-project//llvm:Support",
- "@llvm-project//mlir:IR",
- "@llvm-project//mlir:Pass",
- "@llvm-project//mlir:SCFTransforms",
- "@llvm-project//mlir:Support",
- "@llvm-project//mlir:Translation",
- ],
-)
diff --git a/samples/custom_modules/dialect/CMakeLists.txt b/samples/custom_modules/dialect/CMakeLists.txt
deleted file mode 100644
index 08d1474..0000000
--- a/samples/custom_modules/dialect/CMakeLists.txt
+++ /dev/null
@@ -1,115 +0,0 @@
-################################################################################
-# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from #
-# samples/custom_modules/dialect/BUILD #
-# #
-# Use iree_cmake_extra_content from iree/build_defs.oss.bzl to add arbitrary #
-# CMake-only content. #
-# #
-# To disable autogeneration for this file entirely, delete this header. #
-################################################################################
-
-iree_add_all_subdirs()
-
-iree_cc_library(
- NAME
- dialect
- HDRS
- "conversion_patterns.h"
- "custom_dialect.h"
- "custom_ops.h.inc"
- SRCS
- "conversion_patterns.cc"
- "custom_dialect.cc"
- "custom_ops.cc.inc"
- DEPS
- ::custom_imports
- ::custom_ops_gen
- LLVMSupport
- MLIRIR
- MLIRParser
- MLIRPass
- MLIRSideEffectInterfaces
- MLIRTransforms
- iree::compiler::Dialect::HAL::Conversion
- iree::compiler::Dialect::HAL::IR
- iree::compiler::Dialect::Util::IR
- iree::compiler::Dialect::VM::Conversion
- PUBLIC
-)
-
-iree_tablegen_library(
- NAME
- custom_ops_gen
- TD_FILE
- "custom_ops.td"
- OUTS
- --gen-op-decls custom_ops.h.inc
- --gen-op-defs custom_ops.cc.inc
-)
-
-iree_c_embed_data(
- NAME
- custom_imports
- SRCS
- "custom.imports.mlir"
- C_FILE_OUTPUT
- "custom.imports.c"
- H_FILE_OUTPUT
- "custom.imports.h"
- IDENTIFIER
- "iree_custom_imports"
- FLATTEN
- PUBLIC
-)
-
-iree_cc_library(
- NAME
- init_dialect
- HDRS
- "init_dialect.h"
- DEPS
- ::dialect
- MLIRIR
- PUBLIC
-)
-
-iree_cc_binary(
- NAME
- custom-opt
- SRCS
- "custom-opt-main.cc"
- DEPS
- ::init_dialect
- LLVMSupport
- MLIRIR
- MLIROptLib
- MLIRSupport
- iree::compiler::Tools::init_passes_and_dialects
- iree::compiler::Tools::init_targets
-)
-
-iree_cc_binary(
- NAME
- custom-translate
- SRCS
- "custom-translate-main.cc"
- DEPS
- ::init_dialect
- LLVMSupport
- MLIRIR
- MLIRPass
- MLIRSCFTransforms
- MLIRSupport
- MLIRTranslateLib
- iree::compiler::Dialect::VM::Target::Bytecode
- iree::compiler::Dialect::VM::Target::init_targets
- iree::compiler::Tools::init_compiler_modules
- iree::compiler::Tools::init_iree_passes_and_dialects
- iree::compiler::Tools::init_mlir_passes_and_dialects
- iree::compiler::Tools::init_targets
- iree::compiler::Tools::init_translations
- iree::compiler::Tools::init_xla_dialects
- iree::compiler::Translation::IREEVM
-)
-
-### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
diff --git a/samples/custom_modules/dialect/conversion_patterns.cc b/samples/custom_modules/dialect/conversion_patterns.cc
deleted file mode 100644
index 6aeeacd..0000000
--- a/samples/custom_modules/dialect/conversion_patterns.cc
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright 2019 The IREE Authors
-//
-// Licensed under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-#include "samples/custom_modules/dialect/conversion_patterns.h"
-
-#include "iree/compiler/Dialect/HAL/Conversion/ConversionTarget.h"
-#include "iree/compiler/Dialect/VM/Conversion/ImportUtils.h"
-#include "samples/custom_modules/dialect/custom_dialect.h"
-
-namespace mlir {
-namespace iree_compiler {
-namespace IREE {
-namespace Custom {
-
-void populateCustomToHALPatterns(MLIRContext *context,
- RewritePatternSet &patterns,
- TypeConverter &typeConverter) {
- // We can use the HAL conversion handler for this tensor->buffer conversion
- // as we just want the simple form. If we wanted to perform additional
- // verification or have a specific use case (such as a place where only the
- // buffer is required and the shape is not) we could add our own.
- patterns.insert<HALOpConversion<TensorToMessageOp, BufferToMessageOp>>(
- context, typeConverter);
- patterns.insert<HALOpConversion<MessageToTensorOp, MessageToBufferOp>>(
- context, typeConverter);
-}
-
-void populateCustomToVMPatterns(MLIRContext *context,
- SymbolTable &importSymbols,
- RewritePatternSet &patterns,
- TypeConverter &typeConverter) {
- // We can use the VM conversion handler for all of these as they are simple
- // 1:1 mappings. More complex mappings can provide their own conversions
- // (such as the HAL dialect does).
- patterns.insert<VMImportOpConversion<IREE::Custom::BufferToMessageOp>>(
- context, importSymbols, typeConverter, "custom.buffer_to_message");
- patterns.insert<VMImportOpConversion<IREE::Custom::MessageToBufferOp>>(
- context, importSymbols, typeConverter, "custom.message_to_buffer");
- patterns.insert<VMImportOpConversion<IREE::Custom::PrintOp>>(
- context, importSymbols, typeConverter, "custom.print");
- patterns.insert<VMImportOpConversion<IREE::Custom::ReverseOp>>(
- context, importSymbols, typeConverter, "custom.reverse");
- patterns.insert<VMImportOpConversion<IREE::Custom::GetUniqueMessageOp>>(
- context, importSymbols, typeConverter, "custom.get_unique_message");
-}
-
-} // namespace Custom
-} // namespace IREE
-} // namespace iree_compiler
-} // namespace mlir
diff --git a/samples/custom_modules/dialect/conversion_patterns.h b/samples/custom_modules/dialect/conversion_patterns.h
deleted file mode 100644
index f265c2c..0000000
--- a/samples/custom_modules/dialect/conversion_patterns.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2019 The IREE Authors
-//
-// Licensed under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-#ifndef IREE_SAMPLES_CUSTOM_MODULES_DIALECT_CONVERSION_PATTERNS_H_
-#define IREE_SAMPLES_CUSTOM_MODULES_DIALECT_CONVERSION_PATTERNS_H_
-
-#include "mlir/Pass/Pass.h"
-#include "mlir/Transforms/DialectConversion.h"
-
-namespace mlir {
-namespace iree_compiler {
-namespace IREE {
-namespace Custom {
-
-// Populates conversion patterns from the tensor-based custom dialect ops to the
-// HAL buffer-based ones.
-void populateCustomToHALPatterns(MLIRContext *context,
- RewritePatternSet &patterns,
- TypeConverter &typeConverter);
-
-// Populates conversion patterns from the custom dialect to the VM dialect.
-void populateCustomToVMPatterns(MLIRContext *context,
- SymbolTable &importSymbols,
- RewritePatternSet &patterns,
- TypeConverter &typeConverter);
-
-} // namespace Custom
-} // namespace IREE
-} // namespace iree_compiler
-} // namespace mlir
-
-#endif // IREE_SAMPLES_CUSTOM_MODULES_DIALECT_CONVERSION_PATTERNS_H_
diff --git a/samples/custom_modules/dialect/custom-opt-main.cc b/samples/custom_modules/dialect/custom-opt-main.cc
deleted file mode 100644
index a0be0fb..0000000
--- a/samples/custom_modules/dialect/custom-opt-main.cc
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2020 The IREE Authors
-//
-// Licensed under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-// Main entry function for custom-opt.
-// Based on the iree-opt main entry function (iree-opt-main.cc).
-//
-// We need this entry function because we want to register the custom
-// dialect, which is missing in IREE's opt main entry function.
-
-#include "iree/compiler/Tools/init_dialects.h"
-#include "iree/compiler/Tools/init_passes.h"
-#include "iree/compiler/Tools/init_targets.h"
-#include "llvm/Support/InitLLVM.h"
-#include "mlir/IR/Dialect.h"
-#include "mlir/Tools/mlir-opt/MlirOptMain.h"
-#include "samples/custom_modules/dialect/init_dialect.h"
-
-int main(int argc, char **argv) {
- llvm::InitLLVM y(argc, argv);
-
- mlir::DialectRegistry registry;
- mlir::iree_compiler::registerAllDialects(registry);
- mlir::iree_compiler::registerCustomDialect(registry);
-
- mlir::iree_compiler::registerAllPasses();
- mlir::iree_compiler::registerHALTargetBackends();
-
- if (failed(MlirOptMain(argc, argv, "IREE-TF modular optimizer driver\n",
- registry,
- /*preloadDialectsInContext=*/false))) {
- return 1;
- }
- return 0;
-}
diff --git a/samples/custom_modules/dialect/custom-translate-main.cc b/samples/custom_modules/dialect/custom-translate-main.cc
deleted file mode 100644
index ec152fe..0000000
--- a/samples/custom_modules/dialect/custom-translate-main.cc
+++ /dev/null
@@ -1,116 +0,0 @@
-// Copyright 2020 The IREE Authors
-//
-// Licensed under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-// Custom translation main entry function.
-// Based on the iree-compile main entry function (iree-compile-main.cc).
-//
-// We need this entry function because we want to register the custom
-// dialect, which is missing in IREE's translation main entry function.
-
-#include "iree/compiler/Dialect/VM/Target/init_targets.h"
-#include "iree/compiler/Tools/init_compiler_modules.h"
-#include "iree/compiler/Tools/init_iree_dialects.h"
-#include "iree/compiler/Tools/init_mlir_dialects.h"
-#include "iree/compiler/Tools/init_targets.h"
-#include "iree/compiler/Tools/init_translations.h"
-#include "iree/compiler/Tools/init_xla_dialects.h"
-#include "llvm/Support/InitLLVM.h"
-#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/SourceMgr.h"
-#include "llvm/Support/ToolOutputFile.h"
-#include "mlir/IR/AsmState.h"
-#include "mlir/IR/Diagnostics.h"
-#include "mlir/IR/MLIRContext.h"
-#include "mlir/Pass/PassManager.h"
-#include "mlir/Support/FileUtilities.h"
-#include "mlir/Support/LogicalResult.h"
-#include "mlir/Support/ToolUtilities.h"
-#include "mlir/Tools/mlir-translate/Translation.h"
-#include "samples/custom_modules/dialect/init_dialect.h"
-
-static llvm::cl::opt<std::string> inputFilename(llvm::cl::Positional,
- llvm::cl::desc("<input file>"),
- llvm::cl::init("-"));
-
-static llvm::cl::opt<std::string> outputFilename(
- "o", llvm::cl::desc("Output filename"), llvm::cl::value_desc("filename"),
- llvm::cl::init("-"));
-
-static llvm::cl::opt<bool> splitInputFile(
- "split-input-file",
- llvm::cl::desc("Split the input file into pieces and "
- "process each chunk independently"),
- llvm::cl::init(false));
-
-int main(int argc, char **argv) {
- llvm::InitLLVM y(argc, argv);
-
- mlir::DialectRegistry registry;
-
- mlir::registerMlirDialects(registry);
- mlir::registerXLADialects(registry);
- mlir::iree_compiler::registerIreeDialects(registry);
- // Register the custom dialect
- mlir::iree_compiler::registerCustomDialect(registry);
- mlir::iree_compiler::registerIreeCompilerModuleDialects(registry);
- mlir::iree_compiler::registerHALTargetBackends();
- mlir::iree_compiler::registerVMTargets();
- mlir::registerMlirTranslations();
- mlir::iree_compiler::registerIreeTranslations();
- // Make sure command line options are registered.
- (void)mlir::iree_compiler::IREE::HAL::TargetOptions::FromFlags::get();
-
- // Register MLIRContext command-line options like
- // -mlir-print-op-on-diagnostic.
- mlir::registerMLIRContextCLOptions();
- // Register assembly printer command-line options like
- // -mlir-print-op-generic.
- mlir::registerAsmPrinterCLOptions();
- // Register pass manager command-line options like -mlir-print-ir-*.
- mlir::registerPassManagerCLOptions();
-
- // Add flags for all the registered translations.
- llvm::cl::opt<const mlir::TranslateFunction *, false, mlir::TranslationParser>
- translationRequested("", llvm::cl::desc("Translation to perform"),
- llvm::cl::Required);
-
- llvm::cl::ParseCommandLineOptions(argc, argv, "IREE translation driver\n");
-
- std::string errorMessage;
- auto input = mlir::openInputFile(inputFilename, &errorMessage);
- if (!input) {
- llvm::errs() << errorMessage << "\n";
- return 1;
- }
-
- auto output = mlir::openOutputFile(outputFilename, &errorMessage);
- if (!output) {
- llvm::errs() << errorMessage << "\n";
- return 1;
- }
-
- /// Processes the memory buffer with a new MLIRContext.
- auto processBuffer = [&](std::unique_ptr<llvm::MemoryBuffer> ownedBuffer,
- llvm::raw_ostream &os) {
- mlir::MLIRContext context;
- context.appendDialectRegistry(registry);
- llvm::SourceMgr sourceMgr;
- sourceMgr.AddNewSourceBuffer(std::move(ownedBuffer), llvm::SMLoc());
- mlir::SourceMgrDiagnosticHandler diagHandler(sourceMgr, &context);
- return (*translationRequested)(sourceMgr, os, &context);
- };
-
- if (splitInputFile) {
- if (failed(mlir::splitAndProcessBuffer(std::move(input), processBuffer,
- output->os())))
- return 1;
- } else {
- if (failed(processBuffer(std::move(input), output->os()))) return 1;
- }
-
- output->keep();
- return 0;
-}
diff --git a/samples/custom_modules/dialect/custom.imports.mlir b/samples/custom_modules/dialect/custom.imports.mlir
deleted file mode 100644
index 76463b7..0000000
--- a/samples/custom_modules/dialect/custom.imports.mlir
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2019 The IREE Authors
-//
-// Licensed under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-// Describes a custom module implemented in native code.
-// The imports are used for mapping higher-level IR types to the VM ABI and for
-// attaching additional attributes for compiler optimization.
-//
-// Each import defined here has a matching function exported from the native
-// module (custom_modules/native_module.cc). In most cases an op in the source
-// dialect will map directly to an import here, though it's possible for
-// versioning and overrides to cause M:N mappings.
-vm.module @custom {
-
-// Formats the tensor using the IREE buffer printer to have a shape/type and
-// the contents as a string.
-vm.import @buffer_to_message(
- %buffer_view : !vm.ref<!hal.buffer_view>
-) -> !vm.ref<!custom.message>
-attributes {nosideeffects}
-
-// Parses the message containing a IREE buffer parser-formatted tensor.
-vm.import @message_to_buffer(
- %message : !vm.ref<!custom.message>
-) -> !vm.ref<!hal.buffer_view>
-attributes {nosideeffects}
-
-// Prints the %message provided %count times.
-// Maps to the IREE::Custom::PrintOp.
-vm.import @print(
- %message : !vm.ref<!custom.message>,
- %count : i32
-)
-
-// Returns the message with its characters reversed.
-// Maps to the IREE::Custom::ReverseOp.
-vm.import @reverse(
- %message : !vm.ref<!custom.message>
-) -> !vm.ref<!custom.message>
-attributes {nosideeffects}
-
-// Returns a per-context unique message.
-// Maps to the IREE::Custom::GetUniqueMessageOp.
-vm.import @get_unique_message() -> !vm.ref<!custom.message>
-attributes {nosideeffects}
-
-} // vm.module
diff --git a/samples/custom_modules/dialect/custom_dialect.cc b/samples/custom_modules/dialect/custom_dialect.cc
deleted file mode 100644
index f2f7058..0000000
--- a/samples/custom_modules/dialect/custom_dialect.cc
+++ /dev/null
@@ -1,104 +0,0 @@
-// Copyright 2019 The IREE Authors
-//
-// Licensed under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-#include "samples/custom_modules/dialect/custom_dialect.h"
-
-#include "iree/compiler/Dialect/HAL/Conversion/ConversionDialectInterface.h"
-#include "iree/compiler/Dialect/VM/Conversion/ConversionDialectInterface.h"
-#include "llvm/ADT/StringSwitch.h"
-#include "mlir/IR/DialectImplementation.h"
-#include "mlir/IR/SymbolTable.h"
-#include "mlir/Parser/Parser.h"
-#include "mlir/Transforms/DialectConversion.h"
-#include "samples/custom_modules/dialect/conversion_patterns.h"
-#include "samples/custom_modules/dialect/custom.imports.h"
-
-namespace mlir {
-namespace iree_compiler {
-namespace IREE {
-namespace Custom {
-
-namespace {
-
-// Exposes conversion patterns that transition tensors to buffers during the
-// Flow->HAL dialect lowering. This is only required if the dialect has ops that
-// use tensor types.
-class CustomToHALConversionInterface : public HALConversionDialectInterface {
- public:
- using HALConversionDialectInterface::HALConversionDialectInterface;
-
- void setupConversionTarget(ConversionTarget &target,
- RewritePatternSet &patterns,
- TypeConverter &typeConverter) const override {
- populateCustomToHALPatterns(getDialect()->getContext(), patterns,
- typeConverter);
- }
-};
-
-// Exposes the import module and conversion patterns used to convert custom
-// ops to their vm.import counterparts.
-class CustomToVMConversionInterface : public VMConversionDialectInterface {
- public:
- using VMConversionDialectInterface::VMConversionDialectInterface;
-
- OwningOpRef<mlir::ModuleOp> parseVMImportModule() const override {
- return mlir::parseSourceString<mlir::ModuleOp>(
- StringRef(iree_custom_imports_create()->data,
- iree_custom_imports_create()->size),
- getDialect()->getContext());
- }
-
- void populateVMConversionPatterns(
- SymbolTable &importSymbols, RewritePatternSet &patterns,
- TypeConverter &typeConverter) const override {
- populateCustomToVMPatterns(getDialect()->getContext(), importSymbols,
- patterns, typeConverter);
- }
-};
-
-} // namespace
-
-CustomDialect::CustomDialect(MLIRContext *context)
- : Dialect(getDialectNamespace(), context, TypeID::get<CustomDialect>()) {
- addInterfaces<CustomToHALConversionInterface,
- CustomToVMConversionInterface>();
-
- addTypes<MessageType>();
-
-#define GET_OP_LIST
- addOperations<
-#include "samples/custom_modules/dialect/custom_ops.cc.inc"
- >();
-}
-
-Type CustomDialect::parseType(DialectAsmParser &parser) const {
- StringRef typeName;
- if (failed(parser.parseKeyword(&typeName))) return {};
- auto type = llvm::StringSwitch<Type>(typeName)
- .Case("message", MessageType::get(getContext()))
- .Default(nullptr);
- if (!type) {
- parser.emitError(parser.getCurrentLocation())
- << "unknown type: " << typeName;
- }
- return type;
-}
-
-void CustomDialect::printType(Type type, DialectAsmPrinter &p) const {
- if (type.isa<MessageType>()) {
- p << "message";
- } else {
- assert(false && "unknown type");
- }
-}
-
-} // namespace Custom
-} // namespace IREE
-} // namespace iree_compiler
-} // namespace mlir
-
-#define GET_OP_CLASSES
-#include "samples/custom_modules/dialect/custom_ops.cc.inc"
diff --git a/samples/custom_modules/dialect/custom_dialect.h b/samples/custom_modules/dialect/custom_dialect.h
deleted file mode 100644
index 7134e93..0000000
--- a/samples/custom_modules/dialect/custom_dialect.h
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright 2019 The IREE Authors
-//
-// Licensed under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-#ifndef IREE_SAMPLES_CUSTOM_MODULES_DIALECT_CUSTOM_DIALECT_H_
-#define IREE_SAMPLES_CUSTOM_MODULES_DIALECT_CUSTOM_DIALECT_H_
-
-#include "iree/compiler/Dialect/HAL/IR/HALTypes.h"
-#include "iree/compiler/Dialect/Util/IR/UtilTypes.h"
-#include "mlir/IR/Dialect.h"
-#include "mlir/IR/OpDefinition.h"
-#include "mlir/Interfaces/SideEffectInterfaces.h"
-
-namespace mlir {
-namespace iree_compiler {
-namespace IREE {
-namespace Custom {
-
-class CustomDialect : public Dialect {
- public:
- explicit CustomDialect(MLIRContext *context);
- static StringRef getDialectNamespace() { return "custom"; }
-
- Type parseType(DialectAsmParser &parser) const override;
- void printType(Type type, DialectAsmPrinter &p) const override;
-};
-
-class MessageType : public Type::TypeBase<MessageType, Type, TypeStorage> {
- public:
- using Base::Base;
-};
-
-} // namespace Custom
-} // namespace IREE
-} // namespace iree_compiler
-} // namespace mlir
-
-#define GET_OP_CLASSES
-#include "samples/custom_modules/dialect/custom_ops.h.inc"
-
-#endif // IREE_SAMPLES_CUSTOM_MODULES_DIALECT_CUSTOM_DIALECT_H_
diff --git a/samples/custom_modules/dialect/custom_ops.td b/samples/custom_modules/dialect/custom_ops.td
deleted file mode 100644
index 1b633e3..0000000
--- a/samples/custom_modules/dialect/custom_ops.td
+++ /dev/null
@@ -1,149 +0,0 @@
-// Copyright 2019 The IREE Authors
-//
-// Licensed under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-#ifndef IREE_SAMPLES_CUSTOM_MODULES_DIALECT_CUSTOM_OPS
-#define IREE_SAMPLES_CUSTOM_MODULES_DIALECT_CUSTOM_OPS
-
-include "iree/compiler/Dialect/HAL/IR/HALBase.td"
-include "iree/compiler/Dialect/Util/IR/UtilBase.td"
-include "mlir/Interfaces/SideEffectInterfaces.td"
-
-def CUSTOM_Dialect : Dialect {
- let name = "custom";
- let cppNamespace = "::mlir::iree_compiler::IREE::Custom";
-
- let summary = [{
- A custom dialect demonstrating custom ops and implementations.
- }];
- let description = [{
- The ops in this dialect are lowered to vm.imports as described in the
- `custom_modules/dialect/custom.imports.mlir` file and the implementations
- are provided by the `custom_modules/native_module.cc` file.
- }];
-}
-
-def CUSTOM_Message : DialectType<
- CUSTOM_Dialect,
- CPred<"$_self.isa<IREE::Custom::MessageType>()">,
- "message"> {
- let description = [{
- A string message that can be printed. These types will be reference counted
- at runtime and must derive from iree_vm_ref_t but otherwise can be whatever
- the dialect wants.
- }];
-}
-
-def CUSTOM_TensorToMessageOp : Op<CUSTOM_Dialect, "tensor_to_message"> {
- let summary = [{formats tensor contents as a message}];
- let description = [{
- Formats the tensor using the IREE buffer printer to have a shape/type and
- the contents as a string.
-
- This demonstrates handling tensor->buffer conversion through the HAL layer.
- This op (tensor_to_message) is only used prior to translation and instances
- of it will be converted to the lower-level HAL-based buffer_to_message op.
- }];
-
- let arguments = (ins
- AnyTensor:$operand
- );
- let results = (outs
- CUSTOM_Message:$result
- );
-}
-
-def CUSTOM_BufferToMessageOp : Op<CUSTOM_Dialect, "buffer_to_message"> {
- let summary = [{formats buffer contents as a message}];
- let description = [{
- Formats the tensor using the IREE buffer printer to have a shape/type and
- the contents as a string.
- }];
-
- let arguments = (ins
- HAL_BufferView:$buffer_view
- );
- let results = (outs
- CUSTOM_Message:$result
- );
-}
-
-def CUSTOM_MessageToTensorOp : Op<CUSTOM_Dialect, "message_to_tensor"> {
- let summary = [{parses message contents as a tensor}];
- let description = [{
- Parses the message containing a IREE buffer parser-formatted tensor.
- }];
-
- let arguments = (ins
- CUSTOM_Message:$message
- );
- let results = (outs
- AnyTensor:$result
- );
-}
-
-def CUSTOM_MessageToBufferOp : Op<CUSTOM_Dialect, "message_to_buffer"> {
- let summary = [{parses message contents as a buffer}];
- let description = [{
- Parses the message containing a IREE buffer parser-formatted tensor.
- }];
-
- let arguments = (ins
- CUSTOM_Message:$message
- );
- let results = (outs
- HAL_BufferView:$result
- );
-}
-
-def CUSTOM_PrintOp : Op<CUSTOM_Dialect, "print"> {
- let summary = [{prints a message zero or more times}];
- let description = [{
- Prints the input message zero or more times with a newline inbetween.
-
- This demonstrates passing arguments from the application (the original
- message).
- }];
-
- let arguments = (ins
- CUSTOM_Message:$message,
- I32:$count
- );
-}
-
-def CUSTOM_ReverseOp : Op<CUSTOM_Dialect, "reverse", [NoSideEffect]> {
- let summary = [{reverses the characters in the given the message}];
- let description = [{
- Reverses the message characters and returns the new value.
-
- This demonstrates allocating new values from within the op implementation
- (the reversed result). Note that this op (as well as the vm.import) are
- marked with NoSideEffect/nosideeffect to enable additional compiler
- optimization.
- }];
-
- let arguments = (ins
- CUSTOM_Message:$operand
- );
- let results = (outs
- CUSTOM_Message:$result
- );
-}
-
-def CUSTOM_GetUniqueMessageOp : Op<CUSTOM_Dialect, "get_unique_message", [NoSideEffect]> {
- let summary = [{returns a per-context unique message}];
- let description = [{
- Returns a unique message allocated per context using the module.
-
- This demonstrates context-specific global storage. Mutation methods could
- exist that update the global storage as desired.
- }];
-
- let results = (outs
- CUSTOM_Message:$result
- );
-}
-
-#endif // IREE_SAMPLES_CUSTOM_MODULES_DIALECT_CUSTOM_OPS
diff --git a/samples/custom_modules/dialect/init_dialect.h b/samples/custom_modules/dialect/init_dialect.h
deleted file mode 100644
index 117233b..0000000
--- a/samples/custom_modules/dialect/init_dialect.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2020 The IREE Authors
-//
-// Licensed under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-// This files defines a helper to trigger the registration of the custom
-// dialect to the system.
-//
-// Imported from the iree-template-cpp project.
-
-#ifndef IREE_SAMPLES_CUSTOM_MODULES_DIALECT_INIT_DIALECT_H_
-#define IREE_SAMPLES_CUSTOM_MODULES_DIALECT_INIT_DIALECT_H_
-
-#include "mlir/IR/Dialect.h"
-#include "samples/custom_modules/dialect/custom_dialect.h"
-
-namespace mlir {
-namespace iree_compiler {
-
-// Add custom dialect to the provided registry.
-inline void registerCustomDialect(DialectRegistry ®istry) {
- registry.insert<IREE::Custom::CustomDialect>();
-}
-
-} // namespace iree_compiler
-} // namespace mlir
-
-#endif // IREE_SAMPLES_CUSTOM_MODULES_DIALECT_INIT_DIALECT_H_
diff --git a/samples/custom_modules/dialect/test/BUILD b/samples/custom_modules/dialect/test/BUILD
deleted file mode 100644
index 336503d..0000000
--- a/samples/custom_modules/dialect/test/BUILD
+++ /dev/null
@@ -1,30 +0,0 @@
-# Copyright 2019 The IREE Authors
-#
-# Licensed under the Apache License v2.0 with LLVM Exceptions.
-# See https://llvm.org/LICENSE.txt for license information.
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-load("//build_tools/bazel:iree_lit_test.bzl", "iree_lit_test_suite")
-load("//build_tools/bazel:enforce_glob.bzl", "enforce_glob")
-
-package(
- default_visibility = ["//visibility:public"],
- features = ["layering_check"],
- licenses = ["notice"], # Apache 2.0
-)
-
-iree_lit_test_suite(
- name = "lit",
- srcs = enforce_glob(
- [
- "conversion.mlir",
- "custom_ops.mlir",
- ],
- include = ["*.mlir"],
- ),
- cfg = "//samples:lit.cfg.py",
- tools = [
- "//samples/custom_modules/dialect:custom-opt",
- "@llvm-project//llvm:FileCheck",
- ],
-)
diff --git a/samples/custom_modules/dialect/test/CMakeLists.txt b/samples/custom_modules/dialect/test/CMakeLists.txt
deleted file mode 100644
index aa240b4..0000000
--- a/samples/custom_modules/dialect/test/CMakeLists.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-################################################################################
-# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from #
-# samples/custom_modules/dialect/test/BUILD #
-# #
-# Use iree_cmake_extra_content from iree/build_defs.oss.bzl to add arbitrary #
-# CMake-only content. #
-# #
-# To disable autogeneration for this file entirely, delete this header. #
-################################################################################
-
-iree_add_all_subdirs()
-
-iree_lit_test_suite(
- NAME
- lit
- SRCS
- "conversion.mlir"
- "custom_ops.mlir"
- TOOLS
- FileCheck
- iree::samples::custom_modules::dialect::custom-opt
-)
-
-### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
diff --git a/samples/custom_modules/dialect/test/conversion.mlir b/samples/custom_modules/dialect/test/conversion.mlir
deleted file mode 100644
index 19a9238..0000000
--- a/samples/custom_modules/dialect/test/conversion.mlir
+++ /dev/null
@@ -1,116 +0,0 @@
-// Copyright 2019 The IREE Authors
-//
-// Licensed under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-// Tests the (automatic) conversion from the custom dialect to the VM dialect.
-// Depending on whether any manual conversion is performed this may get complex,
-// such as when versioning imports or performing optimizations.
-
-// RUN: custom-opt %s --iree-hal-conversion --iree-vm-conversion --split-input-file | FileCheck %s
-
-// CHECK-LABEL: @tensorToMessage
-func.func @tensorToMessage(%tensor : tensor<2x4xf32>) {
- // CHECK-NEXT: %[[MSG:.+]] = vm.call @custom.buffer_to_message(%arg0) {nosideeffects} : (!vm.ref<!hal.buffer_view>) -> !vm.ref<!custom.message>
- %0 = "custom.tensor_to_message"(%tensor) : (tensor<2x4xf32>) -> !custom.message
- %c1 = arith.constant 1 : i32
- // CHECK: vm.call @custom.print(%[[MSG]]
- "custom.print"(%0, %c1) : (!custom.message, i32) -> ()
- return
-}
-
-// -----
-
-// CHECK-LABEL: @dynamicTensorToMessage
-func.func @dynamicTensorToMessage(%arg0 : tensor<?x?xf32>) {
- // CHECK: %[[MSG:.+]] = vm.call @custom.buffer_to_message(%arg0) {nosideeffects} : (!vm.ref<!hal.buffer_view>) -> !vm.ref<!custom.message>
- %0 = "custom.tensor_to_message"(%arg0) : (tensor<?x?xf32>) -> !custom.message
- %c1 = arith.constant 1 : i32
- // CHECK: vm.call @custom.print(%[[MSG]]
- "custom.print"(%0, %c1) : (!custom.message, i32) -> ()
- return
-}
-
-// -----
-
-// CHECK-LABEL: @dynamicTensorToMessage2
-func.func @dynamicTensorToMessage2(%arg0 : tensor<?x?xf32>) {
- // CHECK: %[[MSG:.+]] = vm.call @custom.buffer_to_message(%arg0) {nosideeffects} : (!vm.ref<!hal.buffer_view>) -> !vm.ref<!custom.message>
- %0 = "custom.tensor_to_message"(%arg0) : (tensor<?x?xf32>) -> !custom.message
- %c1 = arith.constant 1 : i32
- // CHECK: vm.call @custom.print(%[[MSG]]
- "custom.print"(%0, %c1) : (!custom.message, i32) -> ()
- return
-}
-
-// -----
-
-// CHECK-LABEL: @messageToTensor
-func.func @messageToTensor(%arg0 : !custom.message) -> tensor<2x4xf32> {
- // CHECK: %[[VIEW:.+]] = vm.call @custom.message_to_buffer(%arg0) {nosideeffects} : (!vm.ref<!custom.message>) -> !vm.ref<!hal.buffer_view>
- %0 = "custom.message_to_tensor"(%arg0) : (!custom.message) -> tensor<2x4xf32>
- // CHECK: vm.return %[[VIEW]]
- return %0 : tensor<2x4xf32>
-}
-
-// -----
-
-// CHECK-LABEL: @messageToTensorReturnDim
-func.func @messageToTensorReturnDim(%arg0 : !custom.message) -> index {
- %0 = "custom.message_to_tensor"(%arg0) : (!custom.message) -> tensor<?x4xf32>
- %c0 = arith.constant 0 : index
- %1 = tensor.dim %0, %c0 : tensor<?x4xf32>
- // CHECK: %[[VIEW:.+]] = vm.call @custom.message_to_buffer(%arg0) {nosideeffects} : (!vm.ref<!custom.message>) -> !vm.ref<!hal.buffer_view>
- // CHECK: %{{.+}} = vm.const.i32.zero
- // CHECK: %[[ZERO:.+]] = vm.const.i32.zero
- // CHECK: %[[DIM64:.+]] = vm.call @hal.buffer_view.dim(%[[VIEW]], %[[ZERO]])
- // CHECK: %[[DIM32:.+]] = vm.trunc.i64.i32 %[[DIM64]]
- // CHECK: vm.return %[[DIM32]]
- return %1 : index
-}
-
-// -----
-
-// CHECK-LABEL: @messageToTensorReturnRank
-func.func @messageToTensorReturnRank(%arg0 : !custom.message) -> index {
- %0 = "custom.message_to_tensor"(%arg0) : (!custom.message) -> tensor<*xf32>
- %1 = tensor.rank %0 : tensor<*xf32>
- // CHECK-DAG: %[[VIEW:.+]] = vm.call @custom.message_to_buffer(%arg0) {nosideeffects} : (!vm.ref<!custom.message>) -> !vm.ref<!hal.buffer_view>
- // CHECK-DAG: %[[RANK:.+]] = vm.call @hal.buffer_view.rank(%[[VIEW]])
- // CHECK: vm.return %[[RANK]]
- return %1 : index
-}
-
-// -----
-
-// CHECK-LABEL: @printOp
-func.func @printOp(%arg0 : !custom.message) {
- %c1_i32 = arith.constant 1 : i32
- // CHECK: vm.call @custom.print(%arg0, %c1) : (!vm.ref<!custom.message>, i32) -> ()
- "custom.print"(%arg0, %c1_i32) : (!custom.message, i32) -> ()
- return
-}
-
-// CHECK: vm.import @custom.print
-
-// -----
-
-// CHECK-LABEL: @reverseOp
-func.func @reverseOp(%arg0 : !custom.message) -> !custom.message {
- // CHECK: %ref = vm.call @custom.reverse(%arg0) {nosideeffects} : (!vm.ref<!custom.message>) -> !vm.ref<!custom.message>
- %0 = "custom.reverse"(%arg0) : (!custom.message) -> !custom.message
- return %0 : !custom.message
-}
-
-// CHECK: vm.import @custom.reverse
-
-// -----
-
-// CHECK: vm.import @custom.get_unique_message
-// CHECK-LABEL: @getUniqueMessageOp
-func.func @getUniqueMessageOp() -> !custom.message {
- // CHECK: %ref = vm.call @custom.get_unique_message() {nosideeffects} : () -> !vm.ref<!custom.message>
- %0 = "custom.get_unique_message"() : () -> !custom.message
- return %0 : !custom.message
-}
diff --git a/samples/custom_modules/dialect/test/custom_ops.mlir b/samples/custom_modules/dialect/test/custom_ops.mlir
deleted file mode 100644
index b602a99..0000000
--- a/samples/custom_modules/dialect/test/custom_ops.mlir
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2019 The IREE Authors
-//
-// Licensed under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-// Tests the printing/parsing of the custom dialect ops.
-// This doesn't have much meaning here as we don't define any custom printers or
-// parsers but does serve as a reference for the op usage.
-
-// RUN: custom-opt --split-input-file %s | custom-opt --split-input-file | FileCheck %s
-
-// CHECK-LABEL: @printOp
-func.func @printOp(%arg0 : !custom.message) {
- %c1_i32 = arith.constant 1 : i32
- // CHECK: "custom.print"(%arg0, %c1_i32) : (!custom.message, i32) -> ()
- "custom.print"(%arg0, %c1_i32) : (!custom.message, i32) -> ()
- return
-}
-
-// -----
-
-// CHECK-LABEL: @reverseOp
-func.func @reverseOp(%arg0 : !custom.message) -> !custom.message {
- // CHECK: %0 = "custom.reverse"(%arg0) : (!custom.message) -> !custom.message
- %0 = "custom.reverse"(%arg0) : (!custom.message) -> !custom.message
- return %0 : !custom.message
-}
-
-// -----
-
-// CHECK-LABEL: @getUniqueMessageOp
-func.func @getUniqueMessageOp() -> !custom.message {
- // CHECK: %0 = "custom.get_unique_message"() : () -> !custom.message
- %0 = "custom.get_unique_message"() : () -> !custom.message
- return %0 : !custom.message
-}
diff --git a/samples/custom_modules/module.cc b/samples/custom_modules/module.cc
deleted file mode 100644
index a05ac27..0000000
--- a/samples/custom_modules/module.cc
+++ /dev/null
@@ -1,298 +0,0 @@
-// Copyright 2019 The IREE Authors
-//
-// Licensed under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-#include "samples/custom_modules/module.h"
-
-#include <atomic>
-#include <cstdint>
-#include <cstdio>
-#include <cstring>
-#include <memory>
-#include <string>
-#include <type_traits>
-#include <utility>
-
-#include "iree/base/api.h"
-#include "iree/base/status_cc.h"
-#include "iree/hal/api.h"
-#include "iree/modules/hal/module.h"
-#include "iree/vm/native_module_cc.h"
-#include "iree/vm/ref_cc.h"
-
-//===----------------------------------------------------------------------===//
-// !custom.message type
-//===----------------------------------------------------------------------===//
-
-// Runtime type descriptor for the !custom.message describing how to manage it
-// and destroy it. The type ID is allocated at runtime and does not need to
-// match the compiler ID.
-static iree_vm_ref_type_descriptor_t iree_custom_message_descriptor = {0};
-
-// The "message" type we use to store string messages to print.
-// This could be arbitrarily complex or simply wrap another user-defined type.
-// The descriptor that is registered at startup defines how to manage the
-// lifetime of the type (such as which destruction function is called, if any).
-// See ref.h for more information and additional utilities.
-typedef struct iree_custom_message_t {
- // Ideally first; used to track the reference count of the object.
- iree_vm_ref_object_t ref_object;
- // Allocator the message was created from.
- // Ideally pools and nested allocators would be used to avoid needing to store
- // the allocator with every object.
- iree_allocator_t allocator;
- // String message value.
- iree_string_view_t value;
-} iree_custom_message_t;
-
-IREE_VM_DEFINE_TYPE_ADAPTERS(iree_custom_message, iree_custom_message_t);
-
-iree_status_t iree_custom_message_create(iree_string_view_t value,
- iree_allocator_t allocator,
- iree_custom_message_t** out_message) {
- IREE_ASSERT_ARGUMENT(out_message);
- // Note that we allocate the message and the string value together.
- iree_custom_message_t* message = NULL;
- IREE_RETURN_IF_ERROR(iree_allocator_malloc(
- allocator, sizeof(*message) + value.size, (void**)&message));
- message->ref_object.counter = IREE_ATOMIC_VAR_INIT(1);
- message->allocator = allocator;
- message->value.data = ((const char*)message) + sizeof(iree_custom_message_t);
- message->value.size = value.size;
- memcpy((void*)message->value.data, value.data, message->value.size);
- *out_message = message;
- return iree_ok_status();
-}
-
-iree_status_t iree_custom_message_wrap(iree_string_view_t value,
- iree_allocator_t allocator,
- iree_custom_message_t** out_message) {
- IREE_ASSERT_ARGUMENT(out_message);
- iree_custom_message_t* message = NULL;
- IREE_RETURN_IF_ERROR(
- iree_allocator_malloc(allocator, sizeof(*message), (void**)&message));
- message->ref_object.counter = IREE_ATOMIC_VAR_INIT(1);
- message->allocator = allocator;
- message->value = value; // Unowned.
- *out_message = message;
- return iree_ok_status();
-}
-
-void iree_custom_message_destroy(void* ptr) {
- iree_custom_message_t* message = (iree_custom_message_t*)ptr;
- iree_allocator_free(message->allocator, ptr);
-}
-
-iree_status_t iree_custom_message_read_value(iree_custom_message_t* message,
- char* buffer,
- size_t buffer_capacity) {
- IREE_ASSERT_ARGUMENT(message);
- IREE_ASSERT_ARGUMENT(buffer);
- if (buffer_capacity < message->value.size + 1) {
- // Not an error; just a size query.
- return iree_status_from_code(IREE_STATUS_OUT_OF_RANGE);
- }
- memcpy(buffer, message->value.data, message->value.size);
- buffer[message->value.size] = 0;
- return iree_ok_status();
-}
-
-iree_status_t iree_custom_native_module_register_types() {
- if (iree_custom_message_descriptor.type) {
- return iree_ok_status(); // Already registered.
- }
- iree_custom_message_descriptor.type_name =
- iree_make_cstring_view("custom.message");
- iree_custom_message_descriptor.offsetof_counter =
- offsetof(iree_custom_message_t, ref_object.counter);
- iree_custom_message_descriptor.destroy = iree_custom_message_destroy;
- return iree_vm_ref_register_type(&iree_custom_message_descriptor);
-}
-
-//===----------------------------------------------------------------------===//
-// VM module interface implementation
-//===----------------------------------------------------------------------===//
-
-namespace iree {
-namespace samples {
-namespace {
-
-// Per-context module state.
-// This can contain "globals" and other arbitrary state.
-//
-// Thread-compatible; the runtime will not issue multiple calls at the same
-// time using the same state. If the implementation uses external threads then
-// it must synchronize itself.
-class CustomModuleState final {
- public:
- explicit CustomModuleState(iree_allocator_t host_allocator,
- vm::ref<iree_hal_allocator_t> device_allocator)
- : host_allocator_(host_allocator),
- device_allocator_(std::move(device_allocator)) {}
- ~CustomModuleState() = default;
-
- Status Initialize(int32_t unique_id) {
- // Allocate a unique ID to demonstrate per-context state.
- auto str_buffer = "ctx_" + std::to_string(unique_id);
- IREE_RETURN_IF_ERROR(
- iree_custom_message_create(iree_make_cstring_view(str_buffer.c_str()),
- host_allocator_, &unique_message_));
-
- return OkStatus();
- }
-
- // custom.buffer_to_message(%buffer_view) -> %result
- StatusOr<vm::ref<iree_custom_message_t>> BufferToMessage(
- vm::ref<iree_hal_buffer_view_t> buffer_view) {
- // Convert the buffer view to a [shape]x[type]=[contents] string.
- std::string string_value(4096, '\0');
- iree_status_t status;
- do {
- iree_host_size_t actual_length = 0;
- status = iree_hal_buffer_view_format(
- buffer_view.get(), /*max_element_count=*/1024,
- string_value.size() + 1, &string_value[0], &actual_length);
- string_value.resize(actual_length);
- } while (iree_status_is_out_of_range(status));
- IREE_RETURN_IF_ERROR(std::move(status));
-
- // Pack the string contents into a message.
- vm::ref<iree_custom_message_t> message;
- IREE_RETURN_IF_ERROR(iree_custom_message_create(
- iree_string_view_t{string_value.data(), string_value.size()},
- host_allocator_, &message));
- return std::move(message);
- }
-
- // custom.message_to_buffer(%message) -> %buffer_view
- StatusOr<vm::ref<iree_hal_buffer_view_t>> MessageToBuffer(
- vm::ref<iree_custom_message_t> message) {
- // Convert the [shape]x[type]=[contents] string to a buffer view.
- vm::ref<iree_hal_buffer_view_t> buffer_view;
- IREE_RETURN_IF_ERROR(
- iree_hal_buffer_view_parse(message->value, device_allocator_.get(),
- &buffer_view),
- "parsing value '%.*s'", (int)message->value.size, message->value.data);
- return std::move(buffer_view);
- }
-
- // custom.print(%message, %count)
- Status Print(vm::ref<iree_custom_message_t> message, int32_t count) {
- for (int i = 0; i < count; ++i) {
- fwrite(message->value.data, 1, message->value.size, stdout);
- fputc('\n', stdout);
- }
- fflush(stdout);
- return OkStatus();
- }
-
- // custom.reverse(%message) -> %result
- StatusOr<vm::ref<iree_custom_message_t>> Reverse(
- vm::ref<iree_custom_message_t> message) {
- vm::ref<iree_custom_message_t> reversed_message;
- IREE_RETURN_IF_ERROR(iree_custom_message_create(
- message->value, message->allocator, &reversed_message));
- char* str_ptr = const_cast<char*>(reversed_message->value.data);
- for (int low = 0, high = reversed_message->value.size - 1; low < high;
- ++low, --high) {
- char temp = str_ptr[low];
- str_ptr[low] = str_ptr[high];
- str_ptr[high] = temp;
- }
- return std::move(reversed_message);
- }
-
- // custom.get_unique_message() -> %result
- StatusOr<vm::ref<iree_custom_message_t>> GetUniqueMessage() {
- return vm::retain_ref(unique_message_);
- }
-
- private:
- // Allocator that the caller requested we use for any allocations we need to
- // perform during operation.
- iree_allocator_t host_allocator_ = iree_allocator_system();
-
- // HAL buffer allocator that uses host-local memory. This is just for this
- // test as we don't actually use a HAL device and don't have a real device
- // allocator to use.
- vm::ref<iree_hal_allocator_t> device_allocator_;
-
- // A unique message owned by the state and returned to the VM.
- // This demonstrates any arbitrary per-context state one may want to store.
- vm::ref<iree_custom_message_t> unique_message_;
-};
-
-// Function table mapping imported function names to their implementation.
-// The signature of the target function is expected to match that in the
-// custom.imports.mlir file.
-static const vm::NativeFunction<CustomModuleState> kCustomModuleFunctions[] = {
- vm::MakeNativeFunction("buffer_to_message",
- &CustomModuleState::BufferToMessage),
- vm::MakeNativeFunction("message_to_buffer",
- &CustomModuleState::MessageToBuffer),
- vm::MakeNativeFunction("print", &CustomModuleState::Print),
- vm::MakeNativeFunction("reverse", &CustomModuleState::Reverse),
- vm::MakeNativeFunction("get_unique_message",
- &CustomModuleState::GetUniqueMessage),
-};
-
-// The module instance that will be allocated and reused across contexts.
-// Any context-specific state must be stored in a state structure such as
-// CustomModuleState below.
-//
-// Assumed thread-safe (by construction here, as it's immutable), though if more
-// state is stored here it will need to be synchronized by the implementation.
-class CustomModule final : public vm::NativeModule<CustomModuleState> {
- public:
- using vm::NativeModule<CustomModuleState>::NativeModule;
-
- // Example of global initialization (shared across all contexts), such as
- // loading native libraries or creating shared pools.
- Status Initialize(iree_hal_allocator_t* device_allocator) {
- device_allocator_ = vm::retain_ref(device_allocator);
- next_unique_id_ = 0;
- return OkStatus();
- }
-
- // Creates per-context state when the module is added to a new context.
- // May be called from any thread.
- StatusOr<std::unique_ptr<CustomModuleState>> CreateState(
- iree_allocator_t host_allocator) override {
- auto state = std::make_unique<CustomModuleState>(
- host_allocator, vm::retain_ref(device_allocator_));
- IREE_RETURN_IF_ERROR(state->Initialize(next_unique_id_++));
- return state;
- }
-
- private:
- // Used for any HAL buffer allocations we need to make.
- vm::ref<iree_hal_allocator_t> device_allocator_;
-
- // The next ID to allocate for states that will be used to form the
- // per-context unique message. This shows state at the module level. Note that
- // this must be thread-safe.
- std::atomic<int32_t> next_unique_id_;
-};
-
-} // namespace
-
-// Note that while we are using C++ bindings internally we still expose the
-// module as a C instance. This hides the details of our implementation.
-extern "C" iree_status_t iree_custom_native_module_create(
- iree_allocator_t host_allocator, iree_hal_allocator_t* device_allocator,
- iree_vm_module_t** out_module) {
- IREE_ASSERT_ARGUMENT(out_module);
- *out_module = NULL;
- auto module = std::make_unique<CustomModule>(
- "custom", host_allocator,
- iree::span<const vm::NativeFunction<CustomModuleState>>(
- kCustomModuleFunctions));
- IREE_RETURN_IF_ERROR(module->Initialize(device_allocator));
- *out_module = module.release()->interface();
- return iree_ok_status();
-}
-
-} // namespace samples
-} // namespace iree
diff --git a/samples/custom_modules/module.h b/samples/custom_modules/module.h
deleted file mode 100644
index f3aa215..0000000
--- a/samples/custom_modules/module.h
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright 2019 The IREE Authors
-//
-// Licensed under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-#ifndef IREE_SAMPLES_CUSTOM_MODULES_MODULE_H_
-#define IREE_SAMPLES_CUSTOM_MODULES_MODULE_H_
-
-#include <stddef.h>
-#include <stdint.h>
-
-#include "iree/base/api.h"
-#include "iree/hal/api.h"
-#include "iree/vm/api.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif // __cplusplus
-
-typedef struct iree_custom_message_t iree_custom_message_t;
-
-// Creates a new !custom.message object with a copy of the given |value|.
-iree_status_t iree_custom_message_create(iree_string_view_t value,
- iree_allocator_t allocator,
- iree_custom_message_t** out_message);
-
-// Wraps an externally-owned |value| in a !custom.message object.
-iree_status_t iree_custom_message_wrap(iree_string_view_t value,
- iree_allocator_t allocator,
- iree_custom_message_t** out_message);
-
-// Copies the value of the !custom.message to the given output buffer and adds
-// a \0 terminator.
-iree_status_t iree_custom_message_read_value(iree_custom_message_t* message,
- char* buffer,
- size_t buffer_capacity);
-
-// Registers the custom types used by the module.
-// WARNING: not thread-safe; call at startup before using.
-iree_status_t iree_custom_native_module_register_types(void);
-
-// Creates a native custom module.
-// Modules may exist in multiple contexts and should be thread-safe and (mostly)
-// immutable. Use the per-context allocated state for retaining data.
-iree_status_t iree_custom_native_module_create(
- iree_allocator_t host_allocator, iree_hal_allocator_t* device_allocator,
- iree_vm_module_t** out_module);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif // __cplusplus
-
-IREE_VM_DECLARE_TYPE_ADAPTERS(iree_custom_message, iree_custom_message_t);
-
-#endif // IREE_SAMPLES_CUSTOM_MODULES_MODULE_H_
diff --git a/compiler/src/iree/compiler/Translation/test/BUILD b/tests/compiler_driver/BUILD
similarity index 91%
rename from compiler/src/iree/compiler/Translation/test/BUILD
rename to tests/compiler_driver/BUILD
index 51f6dd7..c4d5332 100644
--- a/compiler/src/iree/compiler/Translation/test/BUILD
+++ b/tests/compiler_driver/BUILD
@@ -25,10 +25,9 @@
],
include = ["*.mlir"],
),
- cfg = "//compiler:lit.cfg.py",
+ cfg = "//tests:lit.cfg.py",
tools = [
"//tools:iree-compile",
- "//tools:iree-translate",
"@llvm-project//llvm:FileCheck",
],
)
diff --git a/compiler/src/iree/compiler/Translation/test/CMakeLists.txt b/tests/compiler_driver/CMakeLists.txt
similarity index 91%
rename from compiler/src/iree/compiler/Translation/test/CMakeLists.txt
rename to tests/compiler_driver/CMakeLists.txt
index e0a58f3..04fa8d9 100644
--- a/compiler/src/iree/compiler/Translation/test/CMakeLists.txt
+++ b/tests/compiler_driver/CMakeLists.txt
@@ -1,6 +1,6 @@
################################################################################
# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from #
-# compiler/src/iree/compiler/Translation/test/BUILD #
+# tests/compiler_driver/BUILD #
# #
# Use iree_cmake_extra_content from iree/build_defs.oss.bzl to add arbitrary #
# CMake-only content. #
@@ -20,7 +20,6 @@
TOOLS
FileCheck
iree-compile
- iree-translate
)
### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
diff --git a/compiler/src/iree/compiler/Translation/test/hal_executable.mlir b/tests/compiler_driver/hal_executable.mlir
similarity index 94%
rename from compiler/src/iree/compiler/Translation/test/hal_executable.mlir
rename to tests/compiler_driver/hal_executable.mlir
index 25c463e..aa923f4 100644
--- a/compiler/src/iree/compiler/Translation/test/hal_executable.mlir
+++ b/tests/compiler_driver/hal_executable.mlir
@@ -1,4 +1,7 @@
-// RUN: iree-translate --split-input-file --mlir-print-ir-after=iree-hal-serialize-executables --iree-mlir-to-hal-executable --iree-hal-target-backends=vmvx %s --o=/dev/null 2>&1 | FileCheck %s
+// RUN: iree-compile --compile-mode=hal-executable \
+// RUN: --mlir-print-ir-after=iree-hal-serialize-executables \
+// RUN: --iree-hal-target-backends=vmvx %s \
+// RUN: --o=/dev/null 2>&1 | FileCheck %s
// Each entry point has a layout specification indicating the total number of
// push constants available and the descriptor sets and their bindings.
diff --git a/compiler/src/iree/compiler/Translation/test/smoketest.mlir b/tests/compiler_driver/smoketest.mlir
similarity index 85%
rename from compiler/src/iree/compiler/Translation/test/smoketest.mlir
rename to tests/compiler_driver/smoketest.mlir
index c19b42b..a4816f5 100644
--- a/compiler/src/iree/compiler/Translation/test/smoketest.mlir
+++ b/tests/compiler_driver/smoketest.mlir
@@ -1,4 +1,6 @@
-// RUN: iree-compile --split-input-file --iree-input-type=mhlo --iree-hal-target-backends=vmvx --iree-mlir-to-vm-bytecode-module --iree-vm-bytecode-module-output-format=flatbuffer-text %s | FileCheck %s
+// RUN: iree-compile --split-input-file --iree-input-type=mhlo \
+// RUN: --iree-hal-target-backends=vmvx --iree-mlir-to-vm-bytecode-module \
+// RUN: --iree-vm-bytecode-module-output-format=flatbuffer-text %s | FileCheck %s
// CHECK-LABEL: "name": "simple_module"
module @simple_module {
diff --git a/compiler/src/iree/compiler/Translation/test/streams.mlir b/tests/compiler_driver/streams.mlir
similarity index 97%
rename from compiler/src/iree/compiler/Translation/test/streams.mlir
rename to tests/compiler_driver/streams.mlir
index f5edc57..8fdc999 100644
--- a/compiler/src/iree/compiler/Translation/test/streams.mlir
+++ b/tests/compiler_driver/streams.mlir
@@ -1,4 +1,7 @@
-// RUN: iree-compile --split-input-file --iree-hal-target-backends=vmvx --iree-mlir-to-vm-bytecode-module --iree-vm-bytecode-module-output-format=flatbuffer-text %s --mlir-print-ir-after=iree-vm-ordinal-allocation 2>&1 | FileCheck %s
+// RUN: iree-compile --split-input-file --iree-hal-target-backends=vmvx \
+// RUN: --output-format=vm-bytecode \
+// RUN: --iree-vm-bytecode-module-output-format=flatbuffer-text %s \
+// RUN: --mlir-print-ir-after=iree-vm-ordinal-allocation 2>&1 | FileCheck %s
// This file has a few test programs that show how to mix `flow` dispatches into
// those created by the `linalg` dispatch region formation: the idea is to use
diff --git a/tools/BUILD b/tools/BUILD
index cdbf082..27757f5 100644
--- a/tools/BUILD
+++ b/tools/BUILD
@@ -129,9 +129,9 @@
"//compiler/src/iree/compiler/Dialect/HAL/Target",
"//compiler/src/iree/compiler/Dialect/VM/Target:init_targets",
"//compiler/src/iree/compiler/Dialect/VM/Target/Bytecode",
+ "//compiler/src/iree/compiler/Pipelines",
"//compiler/src/iree/compiler/Tools:init_passes_and_dialects",
"//compiler/src/iree/compiler/Tools:init_targets",
- "//compiler/src/iree/compiler/Translation:IREEVM",
"//runtime/src/iree/base",
"//runtime/src/iree/base:cc",
"//runtime/src/iree/base:logging",
@@ -229,19 +229,10 @@
)
cc_binary(
- name = "iree-translate",
- srcs = ["iree-translate-main.cc"],
- tags = ["hostonly"],
- deps = [
- "//compiler/src/iree/compiler/Tools:iree_translate_lib",
- ],
-)
-
-cc_binary(
name = "iree-compile",
srcs = ["iree-compile-main.cc"],
tags = ["hostonly"],
deps = [
- "//compiler/src/iree/compiler/Tools:iree_translate_lib",
+ "//compiler/src/iree/compiler/Tools:iree_compile_lib",
],
)
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index af4e5c5..e9645b4 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -187,23 +187,11 @@
iree_cc_binary(
NAME
- iree-translate
- SRCS
- "iree-translate-main.cc"
- DEPS
- iree::compiler::Tools::iree_translate_lib
- DATA
- ${IREE_LLD_TARGET}
- HOSTONLY
- )
-
- iree_cc_binary(
- NAME
iree-compile
SRCS
"iree-compile-main.cc"
DEPS
- iree::compiler::Tools::iree_translate_lib
+ iree::compiler::Tools::iree_compile_lib
DATA
${IREE_LLD_TARGET}
HOSTONLY
@@ -268,9 +256,9 @@
iree::compiler::Dialect::HAL::Target
iree::compiler::Dialect::VM::Target::Bytecode
iree::compiler::Dialect::VM::Target::init_targets
+ iree::compiler::Pipelines
iree::compiler::Tools::init_passes_and_dialects
iree::compiler::Tools::init_targets
- iree::compiler::Translation::IREEVM
iree::hal
iree::hal::drivers
iree::modules::hal
diff --git a/tools/iree-compile-main.cc b/tools/iree-compile-main.cc
index bc55d2b..8ee0605 100644
--- a/tools/iree-compile-main.cc
+++ b/tools/iree-compile-main.cc
@@ -4,7 +4,7 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#include "iree/compiler/Tools/iree_translate_lib.h"
+#include "iree/compiler/Tools/iree_compile_lib.h"
int main(int argc, char **argv) {
return mlir::iree_compiler::runIreecMain(argc, argv);
diff --git a/tools/iree-run-mlir-main.cc b/tools/iree-run-mlir-main.cc
index 87d9587..198f736 100644
--- a/tools/iree-run-mlir-main.cc
+++ b/tools/iree-run-mlir-main.cc
@@ -46,9 +46,9 @@
#include "iree/compiler/Dialect/HAL/Target/TargetBackend.h"
#include "iree/compiler/Dialect/VM/Target/Bytecode/BytecodeModuleTarget.h"
#include "iree/compiler/Dialect/VM/Target/init_targets.h"
+#include "iree/compiler/Pipelines/Pipelines.h"
#include "iree/compiler/Tools/init_dialects.h"
#include "iree/compiler/Tools/init_targets.h"
-#include "iree/compiler/Translation/IREEVM.h"
#include "iree/hal/api.h"
#include "iree/hal/drivers/init.h"
#include "iree/modules/hal/module.h"
@@ -519,10 +519,16 @@
mlir::iree_compiler::registerAllDialects(registry);
mlir::iree_compiler::registerHALTargetBackends();
mlir::iree_compiler::registerVMTargets();
- mlir::iree_compiler::registerIREEVMTranslationFlags();
mlir::registerLLVMDialectTranslation(registry);
// Make sure command line options are registered.
+ // Flag options structs (must resolve prior to CLI parsing).
+ (void)mlir::iree_compiler::BindingOptions::FromFlags::get();
+ (void)mlir::iree_compiler::InputDialectOptions::FromFlags::get();
+ (void)mlir::iree_compiler::HighLevelOptimizationOptions::FromFlags::get();
+ (void)mlir::iree_compiler::SchedulingOptions::FromFlags::get();
(void)mlir::iree_compiler::IREE::HAL::TargetOptions::FromFlags::get();
+ (void)mlir::iree_compiler::IREE::VM::TargetOptions::FromFlags::get();
+ (void)mlir::iree_compiler::IREE::VM::BytecodeTargetOptions::FromFlags::get();
// Register MLIRContext command-line options like
// -mlir-print-op-on-diagnostic.
diff --git a/tools/iree-translate-main.cc b/tools/iree-translate-main.cc
deleted file mode 100644
index 6473741..0000000
--- a/tools/iree-translate-main.cc
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright 2019 The IREE Authors
-//
-// Licensed under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-#include "iree/compiler/Tools/iree_translate_lib.h"
-
-int main(int argc, char **argv) {
- return mlir::iree_compiler::runIreeTranslateMain(argc, argv);
-}